solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
def main(): n1,b1 = map(int,input().split()) x = [int(i) for i in input().split()][::-1] n2, b2 = map(int, input().split()) y = [int(i) for i in input().split()][::-1] xan,yan = 0,0 for i , ii in enumerate(x): xan += ii*b1**i for i, ii in enumerate(y): yan += ii*b2** i if xan > yan: print(">") else: print("=" if yan == xan else "<") if __name__ == '__main__': main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long n, l, k; long long a1 = 0, a2 = 0; cin >> n >> l; for (int i = 0; i < n; i++) { cin >> k; if (k) a1 += k * pow(l, n - i - 1); } cin >> n >> l; for (int i = 0; i < n; i++) { cin >> k; if (k) a2 += k * pow(l, n - i - 1); } if (a1 > a2) cout << ">"; else if (a1 == a2) cout << "="; else if (a1 < a2) cout << "<"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, i, e, f, g, n, m, k, l, x, X, Y, A[11], B[11]; int main() { cin >> n >> x; for (i = 1; i <= n; i++) cin >> A[i]; f = 1; for (i = n; i >= 1; i--) { X += f * A[i]; f *= x; } cin >> n >> x; for (i = 1; i <= n; i++) cin >> B[i]; f = 1; for (i = n; i >= 1; i--) { Y += f * B[i]; f *= x; } if (X < Y) cout << "<"; else if (X > Y) cout << ">"; else cout << "="; }
7
CPP
#include <bits/stdc++.h> using namespace std; int n, m, bx, by; int N1[20], N2[20]; long long base[20]; int main() { while (~scanf("%d%d", &n, &bx)) { base[0] = 1; for (int i = 1; i <= n - 1; i++) { base[i] = base[i - 1] * bx; } long long ans1 = 0; for (int i = 0; i <= n - 1; i++) { int num; scanf("%d", &num); ans1 += num * base[n - 1 - i]; } scanf("%d", &m); scanf("%d", &by); base[0] = 1; for (int i = 1; i <= m - 1; i++) { base[i] = base[i - 1] * by; } long long ans2 = 0; for (int i = 0; i <= m - 1; i++) { int num; scanf("%d", &num); ans2 += num * base[m - 1 - i]; } if (ans1 == ans2) puts("="); else if (ans1 < ans2) puts("<"); else puts(">"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-12; double __t; void quit(); long long a, b; int n, bas; int main() { cin >> n >> bas; long long t = 1; for (int i = 0; i < (int)n - 1; i++) t *= bas; int t1; for (int i = 0; i < (int)n; i++) { cin >> t1; a += t * t1; t /= bas; } cin >> n >> bas; t = 1; for (int i = 0; i < (int)n - 1; i++) t *= bas; for (int i = 0; i < (int)n; i++) { cin >> t1; b += t * t1; t /= bas; } if (a == b) cout << "=\n"; else if (a > b) cout << ">\n"; else cout << "<\n"; quit(); } void quit() { exit(0); }
7
CPP
def make_num(lst, osn): result = 0 for elem in lst: result *= osn result += elem return result n, bx = [int(i) for i in input().split()] num1 = make_num(map(int, input().split()), bx) m, by = [int(i) for i in input().split()] num2 = make_num(map(int, input().split()), by) if num1 < num2: print('<') elif num1 == num2: print('=') else: print('>')
7
PYTHON3
def parser(): a = input().split(); base = int(a[1]); exponent = 0; out = 0; vct = input().split(); for i in reversed(vct): out += pow(base, exponent) * int(i); exponent += 1; return out; a = parser(); b = parser(); if (a == b): print ('=') else: if (a > b): print ('>') else: print ('<') # print (a) # print (b)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, bx, x; long long X = 0; cin >> n >> bx; for (int i = 1; i <= n; i++) { cin >> x; X += x * pow(bx, n - i); } int m, by, y; long long Y = 0; cin >> m >> by; for (int i = 1; i <= m; i++) { cin >> y; Y += y * pow(by, m - i); } if (X == Y) { cout << "="; return 0; } if (X > Y) { cout << ">"; return 0; } cout << "<"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; int n, m; long long x, y; long long res1 = 0; long long res2 = 0; cin >> n >> x; for (i = 0; i < n; i++) { long long tmp; cin >> tmp; res1 = res1 * x + tmp; } cin >> m >> y; for (i = 0; i < m; i++) { long long tmp; cin >> tmp; res2 = res2 * y + tmp; } if (res1 == res2) cout << "="; else if (res1 < res2) cout << "<"; else cout << ">"; cout << "\n"; return 0; }
7
CPP
def main(): X=0 Y=0 n, bx = [int(i) for i in input().split()] num = [int(i) for i in input().split()] for i in range(n): X+=num[n-i-1]*(bx**(i)) n2, by = [int(i) for i in input().split()] num2 = [int(i) for i in input().split()] for i in range(n2): Y+=num2[n2-i-1]*(by**(i)) if X>Y: print('>') elif X<Y: print('<') else: print('=') if __name__ == "__main__": main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long n, bx, num1 = 0; cin >> n >> bx; long long arr[n + 3]; for (long long i = 0; i < n; i++) { cin >> arr[i]; } for (long long i = n - 1, j = 1; i >= 0; i--, j *= bx) { if (i == n - 1) num1 += arr[i]; else num1 += arr[i] * j; } long long num2 = 0, m, by; cin >> m >> by; long long ar[m + 3]; for (long long i = 0; i < m; i++) { cin >> ar[i]; } for (long long i = m - 1, j = 1; i >= 0; i--, j *= by) { if (i == m - 1) num2 += ar[i]; else num2 += ar[i] * j; } if (num1 > num2) cout << '>' << endl; else if (num1 < num2) cout << '<' << endl; else cout << '=' << endl; return 0; }
7
CPP
n,bx=[int(i) for i in input().split()] x=input().split() s=0 for i in range(n): s=s+int(x[i])*(bx**(n-i-1)) m,by=[int(i) for i in input().split()] y=input().split() t=0 for i in range(m): t=t+int(y[i])*(by**(m-i-1)) if s<t: print('<') if s==t: print('=') if s>t: print('>')
7
PYTHON3
n, a = map(int, input().split()) s1 = input().split() s1 = [0]*(40 - n) + s1 m, b = map(int, input().split()) s2 = input().split() s2 = [0]*(40 - m) + s2 sum1 = 0 sum2 = 0 for i in range(40): sum1 += int(s1[i]) * a ** (40 - i - 1) sum2 += int(s2[i]) * b ** (40 - i - 1) if sum1 > sum2: print('>') elif sum2 == sum1: print('=') else: print('<') #print(sum1) #print(sum2)
7
PYTHON3
(n, b) = map(int, input().split()) x = list(map(int, input().split())) (m, c) = map(int, input().split()) y = list(map(int, input().split())) x = x[::-1] y = y[::-1] X = 0 Y = 0 for i in range(len(x)): X += x[i] * b ** i for i in range(len(y)): Y += y[i] * c ** i if (X == Y): print("=") elif (X < Y): print("<") else: print(">")
7
PYTHON3
x, bx = map(int, input().split()) a = list(map(int, input().split())) y, by = map(int, input().split()) b = list(map(int, input().split())) one = two = 0 power = 0 for i, x in enumerate(reversed(a)): one += x * bx**i for i, x in enumerate(reversed(b)): two += x * by**i if one < two: print("<") elif one == two: print("=") else: print(">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int d, dig1, i, base1; long long sum1 = 0; cin >> dig1 >> base1; vector<int> st; for (i = 0; i < dig1; i++) { cin >> d; st.push_back(d); } for (int j = i - 1, i = 0; j >= 0; j--, i++) { sum1 += st[j] * pow(base1, i); } vector<int> st2; int d1, dig2, base2; long long sum2 = 0; cin >> dig2 >> base2; for (i = 0; i < dig2; i++) { cin >> d1; st2.push_back(d1); } for (int j = i - 1, i = 0; j >= 0; j--, i++) { sum2 += st2[j] * pow(base2, i); } if (sum1 == sum2) cout << "=" << endl; else if (sum1 > sum2) cout << ">" << endl; else cout << "<" << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, x, y, bx, by, num1 = 0, num2 = 0; cin >> n >> bx; int a[n + 1]; for (int i = 0; i < n; i++) { cin >> a[i]; num1 = num1 * bx + a[i]; } cin >> m >> by; int b[m + 1]; for (int i = 0; i < m; i++) { cin >> b[i]; num2 = num2 * by + b[i]; } if (num1 == num2) cout << "="; else if (num1 > num2) cout << ">"; else cout << "<"; }
7
CPP
x = input().split(' ') n = int(x[0]) bx = int(x[1]) x = input().split(' ') y = input().split(' ') m = int(y[0]) by = int(y[1]) y = input().split(' ') t = 1 X = 0 while (n > 0): n -= 1 X += t * int(x[n]) t *= bx t = 1 Y = 0 while (m > 0): m -= 1 Y += t * int(y[m]) t *= by #print(X, Y) if (X == Y): print("=\n") elif (X < Y): print("<\n") else: print(">\n")
7
PYTHON3
#!/usr/bin/python3 n,bx = [int(x) for x in input().strip().split()] X = [int(x) for x in input().strip().split()] NX = 0 for idx,x in enumerate(X): NX *= bx NX += x m,by = [int(x) for x in input().strip().split()] Y = [int(x) for x in input().strip().split()] NY = 0 for idx,x in enumerate(Y): NY *= by NY += x if NX == NY:print('=') elif NX > NY:print('>') else:print('<')
7
PYTHON3
n , bx = map(int, input().split()) X , Y = 0 , 0 for x in list(map(int,input().split())): X = X * bx + x n , by = map(int, input().split()) for y in list(map(int,input().split())): Y = Y * by + y print([['<','>'][X>Y], '='][X==Y])
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long Pow(int a, int b) { long long ret = 1; while (b--) ret *= a; return ret; } long long Solve(stack<int>& vec, int x) { long long cnt = 0; int i = 0; while (!vec.empty()) { cnt += vec.top() * Pow(x, i); i++; vec.pop(); } return cnt; } int main() { int n, x, m, y, num; long long sum1, sum2; stack<int> vec; while (cin >> n >> x) { for (int i = 0; i < n; i++) { cin >> num; vec.push(num); } sum1 = Solve(vec, x); cin >> m >> y; for (int i = 0; i < m; i++) { cin >> num; vec.push(num); } sum2 = Solve(vec, y); if (sum1 == sum2) cout << "=" << endl; else if (sum1 < sum2) cout << "<" << endl; else cout << ">" << endl; } return 0; }
7
CPP
def digits_to_int(b, ds): i = 0 for d in ds: i = i*b + d return i def compare(bx, xd, by, yd): x = digits_to_int(bx, xd) y = digits_to_int(by, yd) return '<' if x < y else '>' if x > y else '=' if __name__ == '__main__': n, bx = map(int, input().split()) xd = tuple(map(int, input().split())) m, by = map(int, input().split()) yd = tuple(map(int, input().split())) print(compare(bx, xd, by, yd))
7
PYTHON3
#n = int(input()) n, bx = [int(i) for i in input().split(" ")] arr = [int(i) for i in input().split(" ")] ans1 = 0 pw = bx ** (n-1) for i in arr: ans1 += i*pw pw //= bx n, bx = [int(i) for i in input().split(" ")] arr = [int(i) for i in input().split(" ")] ans2 = 0 pw = bx ** (n-1) for i in arr: ans2 += i*pw pw //= bx if ans1 == ans2: print ("=") elif ans1 > ans2: print (">") else: print ("<")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; long long ba, bb; int na, nb; cin >> na; cin >> ba; a = 0; while (na--) { long long n; cin >> n; a *= ba; a += n; } cin >> nb; cin >> bb; b = 0; while (nb--) { long long n; cin >> n; b *= bb; b += n; } if (a == b) { puts("="); } else if (a > b) { puts(">"); } else { puts("<"); } return 0; }
7
CPP
import sys a, b = [int(x) for x in input().split()] base = b ** (a - 1) res1 = 0 arr = [int(x) for x in input().split()] for digit in arr: res1 += digit * base base //= b a, b = [int(x) for x in input().split()] base = b ** (a - 1) res2 = 0 arr = [int(x) for x in input().split()] for digit in arr: res2 += digit * base base //= b if res1 > res2: print('>') elif res1 < res2: print('<') else: print('=')
7
PYTHON3
I=lambda:map(int,input().split()[::-1]) def f(): b,_=I() r,x=0,1 for i in I(): r+=i*x x*=b return r a=f()-f() print("<"if a<0 else ">="[a==0]) # Made By Mostafa_Khaled
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long power(int b, int i) { if (i == 0) return 1; else return b * power(b, i - 1); } int main() { long long x, y, sum1 = 0, sum2 = 0; for (int m = 0; m < 2; m++) { cin >> x >> y; if (y > 1 && y <= 40 && x >= 1 && x < 11) { int arr[x]; for (int i = x - 1; i >= 0; i--) { cin >> arr[i]; if (m == 0) sum1 += arr[i] * power(y, i); else if (m == 1) sum2 += arr[i] * power(y, i); } } } if (y > 1 && y <= 40 && x >= 1 && x < 11) { if (sum1 < sum2) cout << "<" << endl; else if (sum1 > sum2) cout << ">" << endl; else cout << "=" << endl; sum1 = 0; sum2 = 0; } return 0; }
7
CPP
def mp(): return map(int,input().split()) def lt(): return list(map(int,input().split())) def pt(x): print(x) n,bx = mp() L = lt() m,by = mp() T = lt() c = 0 while L != []: c *= bx c += L.pop(0) b = 0 while T != []: b *= by b += T.pop(0) if c > b: print(">") elif c == b: print("=") else: print("<")
7
PYTHON3
vstup = input() seznam = [int(n) for n in vstup.split()] cislo = [int(n) for n in input().split()] zaklad = seznam[1] vstup2 = input() seznam2 = [int(n) for n in vstup2.split()] cislo2 = [int(n) for n in input().split()] zaklad2 = seznam2[1] def preved (cislo,zaklad): prvni = 0 for k in range(len(cislo)): rad = len(cislo) - k - 1 prvni2 = (zaklad**rad) * cislo[k] prvni += prvni2 return prvni x = preved(cislo,zaklad) y = preved(cislo2,zaklad2) if x > y: print(">") elif x < y: print("<") else: print("=")
7
PYTHON3
def fun(m, b, L): ret = 0 L.reverse() for i in range(m): ret += L[i] * (b ** i) return ret n, bx = map(int, input().split()) X = list(map(int, input().split())) xx = fun(n, bx, X) m, by = map(int, input().split()) Y = list(map(int, input().split())) yy = fun(m, by, Y) if xx > yy: print(">") elif xx < yy: print("<") else: print("=")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long pow(long long x, long long n) { if (n == 0) return 1; else if (n == 1) return x; else if (n % 2 == 0) return pow(x * x, n / 2); else return pow(x * x, n / 2) * x; } int main() { vector<long long> x, y; long long n, m, e, Ans1 = 0, Ans2 = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> e; Ans1 += e * pow(m, n - i - 1); } cin >> n >> m; for (int i = 0; i < n; i++) { cin >> e; Ans2 += e * pow(m, n - i - 1); } if (Ans1 < Ans2) cout << '<'; if (Ans1 > Ans2) cout << '>'; if (Ans1 == Ans2) cout << '='; return 0; }
7
CPP
def f(a, b, c) : ret = 0 mult = 1 for i in range (a - 1, -1, -1) : ret += int(c[i]) * mult mult = mult * b return ret a1 = input().split() c1 = input().split() a2 = input().split() c2 = input().split() #print (a1, c1) #print (a2, c2) x = f(int(a1[0]), int(a1[1]), c1) y = f(int(a2[0]), int(a2[1]), c2) if (y == x) : print("=") elif (x < y) : print ("<") else : print (">")
7
PYTHON3
a=int(input().split()[1]) b=input().split() c=int(input().split()[1]) d=input().split() power = 0 total = 0 for i in range(len(b)-1,-1,-1): total += int(b[i])*a**power power += 1 a=total power = 0 total = 0 for i in range(len(d)-1,-1,-1): total += int(d[i])*c**power power += 1 c=total if a==c: print('=') elif a>c: print('>') else: print('<')
7
PYTHON3
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2015 missingdays <missingdays@missingdays> # # Distributed under terms of the MIT license. """ """ n, b = list(map(int, input().split())) l1 = list(reversed(list(map(int, input().split())))) m, a = list(map(int, input().split())) l2 = list(reversed(list(map(int, input().split())))) x = 0 y = 0 for i in range(len(l1)): x += (l1[i]*pow(b, i)) for i in range(len(l2)): y += (l2[i]*pow(a, i)) if x < y: print("<") elif x == y: print("=") else: print(">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; const int INF = 1000000000; int N, M; long long int BX, BY; long long int X, Y; int main() { ios_base::sync_with_stdio(false); cin >> N >> BX; X = 0; long long int tmp; for (int i = 0; i < N; i++) { cin >> tmp; X = X * BX + tmp; } cin >> M >> BY; for (int i = 0; i < M; i++) { cin >> tmp; Y = Y * BY + tmp; } if (X < Y) cout << "<"; else if (X > Y) cout << ">"; else cout << "="; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; long long x; cin >> n >> x; long long a = 0, b = 0; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a = a * x + tmp; } cin >> n >> x; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; b = b * x + tmp; } if (a > b) cout << ">" << endl; else if (a < b) cout << "<" << endl; else cout << "=" << endl; }
7
CPP
n, bx = map(int, input().split()) X = list(map(int, input().split())) m, by = map(int, input().split()) Y = list(map(int, input().split())) vx = 0 factor = 1 for i in X[::-1]: vx += i * factor factor *= bx vy = 0 factor = 1 for i in Y[::-1]: vy += i * factor factor *= by if vy == vx: print('=') elif vx < vy: print('<') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> int main() { int n, m, x, y, c, i; long long a = 0, b = 0, cx = 1, cy = 1; scanf("%d%d", &n, &x); for (i = 1; i < n; i++) cx *= x; for (i = 0; i < n; i++) { scanf("%d", &c); a += cx * c; cx /= x; } scanf("%d%d", &m, &y); for (i = 1; i < m; i++) cy *= y; for (i = 0; i < m; i++) { scanf("%d", &c); b += cy * c; cy /= y; } if (a == b) putc('=', stdout); else if (a < b) putc('<', stdout); else putc('>', stdout); return 0; }
7
CPP
if __name__ == '__main__': n, bx = map(int, input().split()) xarr = list(map(int, input().split())) x = 0 for i in range(n): x += xarr[n - i - 1] * (bx ** i) n, bx = map(int, input().split()) yarr = list(map(int, input().split())) y = 0 for i in range(n): y += yarr[n - i - 1] * (bx ** i) print('=' if x == y else '<' if x < y else '>')
7
PYTHON3
xcount, xschis = map(int, input().split()) x = list(map(int, input().split())) x = x[::-1] sumx = 0 ycount, yschis = map(int, input().split()) y = list(map(int, input().split())) y = y[::-1] sumy = 0 s = "" for i in range(len(x)): sumx += pow(xschis, i) * x[i] for j in range(len(y)): sumy += pow(yschis, j) * y[j] if sumx > sumy: s = ">" elif sumx == sumy: s = "=" else: s = "<" print(s)
7
PYTHON3
import math xLen, xBase = map(int, input().split()) xStr = input() xArr = xStr.split() yLen, yBase = map(int, input().split()) yStr = input() yArr = yStr.split() def toDec(base, s): res = 0; for i in range(len(s)): res = res + int(s[len(s)-i-1])*math.pow(base, i) return round(res) x = toDec(xBase, xArr) y = toDec(yBase, yArr) if x > y: res = '>' elif x < y: res = '<' else: res = '=' print(res)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int N, bx, by; unsigned long long int nx = 0, ny = 0; int temp; cin >> N >> bx; while (N--) { cin >> temp; nx *= bx; nx += temp; } cin >> N >> by; while (N--) { cin >> temp; ny *= by; ny += temp; } if (nx > ny) cout << ">" << endl; if (nx == ny) cout << "=" << endl; if (nx < ny) cout << "<" << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long int b10(int n, int arr[], int base) { long long int answer = 0; long long int multiplier = 1; for (int i = 1; i <= n; i++) { answer += (arr[n - i] * multiplier); multiplier *= base; } return answer; } long long int input() { long long int n, b; cin >> n >> b; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; return b10(n, arr, b); } int main() { long long int A = input(); long long int B = input(); if (A > B) cout << ">"; else if (A < B) cout << "<"; else cout << "="; return 0; }
7
CPP
from itertools import count from operator import mul def ints(): return [int(x) for x in input().split()] def number(): (n, base), digits = ints(), ints() powers = (base ** i for i in range(n - 1, -1, -1)) return sum(d * p for d, p in zip(digits, powers)) X, Y = number(), number() print('>' if X > Y else '<' if X < Y else '=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, b, t; long long x = 0, y = 0, bp; int a[1000]; int main() { ios::sync_with_stdio(false); cin >> n >> b; bp = 1; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { x += bp * a[i]; bp *= b; } cin >> n >> b; bp = 1; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { y += bp * a[i]; bp *= b; } if (x < y) { cout << "<\n"; return 0; } if (x > y) { cout << ">\n"; return 0; } cout << "=\n"; return 0; }
7
CPP
def convertTo10(d, base, n): index = d - 1 result = 0 while index >= 0: pow = d - index - 1 result += n[index]*(base**pow) index -= 1 return result if __name__=="__main__": d1, b1 = input().split() d1, b1 = int(d1), int(b1) n1 = input().split() n1 = [ int(x) for x in n1 ] n110 = convertTo10(d1, b1, n1) d2, b2 = input().split() d2, b2 = int(d2), int(b2) n2 = input().split() n2 = [ int(x) for x in n2 ] n210 = convertTo10(d2, b2, n2) if n110 < n210: print('<') elif n110 > n210: print('>') else: print('=')
7
PYTHON3
a = list(map(int, input().split())) n = a[0] m = a[1] a = list(map(int, input().split())) for i in range(n): a[n-i-1] *= m**i x = 0 for i in range(n): x += a[i] x = int(x) a = list(map(int, input().split())) n = a[0] m = a[1] a = list(map(int, input().split())) for i in range(n): a[n-i-1] *= m**i y = 0 for i in range(n): y += a[i] if x<y: print("<") elif x>y: print(">") else: print("=")
7
PYTHON3
n,b1=map(int,input().split()) arr1=list(map(int,input().split())) m,b2=map(int,input().split()) arr2=list(map(int,input().split())) sum1=0 sum2=0 for i in arr1: sum1+= i* (b1**(n-1)) n-=1 for i in arr2: sum2+= i* (b2**(m-1)) m-=1 if (sum1==sum2): print("=") elif(sum1<sum2): print("<") else: print(">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n, m; long long x, y, t1, t2, z; scanf("%d", &n); scanf("%lld", &x); t1 = 0; for (int i = int(0); i <= int(n - 1); i++) { scanf("%lld", &z); t1 *= x; t1 += z; } scanf("%d", &m); scanf("%lld", &y); t2 = 0; for (int i = int(0); i <= int(m - 1); i++) { scanf("%lld", &z); t2 *= y; t2 += z; } if (t1 == t2) cout << "="; else if (t1 < t2) cout << "<"; else cout << ">"; return 0; }
7
CPP
n, bx = map(int, input().split()) X = list(map(int, input().split())) m, by = map(int, input().split()) Y = list(map(int, input().split())) resX, resY = 0, 0 for i in range(n): resX += X[-i - 1] * bx ** i for i in range(m): resY += Y[-i - 1] * by ** i if(resX < resY): print("<") elif(resX == resY): print("=") else: print(">")
7
PYTHON3
n, b1 = map(int, input().split()) num = [int(x) for x in input().split()] p = b1 ** (n - 1) x = 0 for i in range(n): numx = int(num[i]) x += numx * p p //= b1 m, b2 = map(int, input().split()) num = [int(x) for x in input().split()] p = b2 ** (m - 1) y = 0 for i in range(m): numy = int(num[i]) y += numy * p p //= b2 if x < y: print('<') elif x > y: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; string str; double EPS = 0.00001; bool contains(vector<double> &v, double val) { for (int i = 0; i < v.size(); i++) if (abs(val - v[i]) < EPS) return true; return false; } int count(string &s, char c) { int res = 0; for (int i = 0; i < s.length(); i++) if (s[i] == c) res++; return res; } struct point { int x, y; }; int e; bool align(point a1, point a2, point a3) { return (a2.x - a1.x) * (a3.y - a2.y) == (a3.x - a2.x) * (a2.y - a1.y); } int main() { int n, bx, m, by; cin >> n >> bx; vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i]; cin >> m >> by; vector<int> y(m); for (int i = 0; i < m; i++) cin >> y[i]; long long X = 0; for (int i = 0; i < n; i++) X += x[n - i - 1] * pow(bx, i); long long Y = 0; for (int i = 0; i < m; i++) Y += y[m - i - 1] * pow(by, i); if (X == Y) cout << '='; else if (X < Y) cout << '<'; else cout << '>'; cout << endl; return 0; }
7
CPP
a,b=map(int,input().split()) n1=list(map(int,input().split())) n=0 for c in n1:n=n*b+c x,y=map(int,input().split()) n2=list(map(int,input().split())) m=0 for c in n2:m=m*y+c if n==m:print('=') elif n<m:print('<') else:print('>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { double p, q, x, y, n, a, b, i, j, an = 0, ans = 0; cin >> n >> a; p = n; for (i = 1; i <= n; i++) { p--; cin >> x; an += x * pow(a, p); } cin >> n >> b; q = n; for (j = 1; j <= n; j++) { q--; cin >> y; ans += y * pow(b, q); } if (an > ans) { cout << ">" << endl; } else if (an < ans) { cout << "<" << endl; } else if (an == ans) { cout << "=" << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long power(long long X, int p) { long long re = 1; while (p) { if (p & 1) re *= X; X *= X; p >>= 1; } return re; } int main() { int n, x; scanf("%d %d", &n, &x); long long X = 0; for (int i = 0, a; i < n; i++) scanf("%d", &a), X += a * power(x, n - 1 - i); scanf("%d %d", &n, &x); long long Y = 0; for (int i = 0, a; i < n; i++) scanf("%d", &a), Y += power(x, n - i - 1) * a; if (X == Y) cout << "="; else if (X < Y) cout << "<"; else cout << ">"; }
7
CPP
#include <bits/stdc++.h> using namespace std; int n, m; long long a, b, t; int main(int argc, char* argv[]) { cin >> n >> m; a = 0; b = 0; for (int i = 0; i < n; i++) { cin >> t; a *= m; a += t; } cin >> n >> m; for (int i = 0; i < n; i++) { cin >> t; b *= m; b += t; } if (a == b) cout << "=" << endl; else if (a > b) cout << ">" << endl; else cout << "<" << endl; return 0; }
7
CPP
#include <bits/stdc++.h> long long p(int x, int y) { if (y == 0) { return 1; } return x * p(x, y - 1); } int main() { int i, n, x, m, y, input; long long a = 0, b = 0; scanf("%d%d", &n, &x); for (i = n - 1; i >= 0; --i) { scanf("%d", &input); a += input * p(x, i); } scanf("%d%d", &m, &y); for (i = m - 1; i >= 0; --i) { scanf("%d", &input); b += input * p(y, i); } if (a < b) { printf("<\n"); } else if (a > b) { printf(">\n"); } else { printf("=\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long int arx[105], ary[105], nx, bx, ny, by, sumx, sumy; int main() { scanf("%lld %lld", &nx, &bx); for (int i = 1; i <= nx; i++) { scanf("%lld", arx + i); } long long int t = 1; for (int i = 1; i <= nx; i++) { sumx += t * arx[nx - i + 1]; t *= bx; } scanf("%lld %lld", &ny, &by); for (int i = 1; i <= ny; i++) { scanf("%lld", ary + i); } t = 1; for (int i = 1; i <= ny; i++) { sumy += t * ary[ny - i + 1]; t *= by; } if (sumx == sumy) puts("="); else if (sumx > sumy) puts(">"); else puts("<"); }
7
CPP
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:600000000") using namespace std; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const int INF = (int)1e9; const long long INFLL = (long long)1e18; const double PI = acos(-1.0); template <typename T> T swop(T &a, T &b) { a ^= b; b ^= a; a ^= b; } template <typename T> T sqr(T x) { return x * x; } template <typename T> T GCD(T x, T y) { return y ? GCD<T>(y, x % y) : x; } template <typename T> T LCM(T x, T y) { return x / GCD<T>(x, y) * y; } const int N = (int)1e5 + 5; long long n, bx, by, a1 = 0, a2 = 0; int main() { ios::sync_with_stdio(false); cout.setf(ios ::fixed | ios ::showpoint); cout.precision(15); cin >> n >> bx; while (n--) { int x; cin >> x; a1 = a1 * bx + x; } cin >> n >> by; while (n--) { int x; cin >> x; a2 = a2 * by + x; } if (a2 > a1) cout << "<"; else if (a2 < a1) cout << ">"; else cout << "="; return 0; }
7
CPP
#!/usr/bin/python3 def make_num(lst, bx): res = 0 for elem in lst: res *= bx res += elem return res n, bx = map(int, input().split()) num1 = make_num(map(int, input().split()), bx) m, by = map(int, input().split()) num2 = make_num(map(int, input().split()), by) if num1 < num2: print('<') elif num1 == num2: print('=') else: print('>')
7
PYTHON3
X,x=map(int,input().split()) a=[int(i) for i in input().split()] a=a[::-1] h=0 for i in range(X): h+=a[i]*x**i Y,y=map(int,input().split()) b=[int(i) for i in input().split()] b=b[::-1] k=0 for i in range(Y): k+=b[i]*y**i if(h==k): print('=') elif(h<k): print('<') else: print('>')
7
PYTHON3
numbers = input().split() m, a = int(numbers[0]), int(numbers[1]) bx = list(map(int, input().split()))[::-1] numbers = input().split() n, b = int(numbers[0]), int(numbers[1]) by = list(map(int, input().split()))[::-1] p = 0 for x in range(m): p += bx[x] * (a ** x) q = 0 for x in range(n): q += by[x] * (b ** x) if p > q: print(">") elif p < q: print("<") else: print("=")
7
PYTHON3
def calc(base,arr): n=len(arr) ans=0 for i in range(0,n): ans=ans+(base**i)*arr[-1-i] return ans info=list(map(int,input().split())) sizex,basex=info[0],info[1] valx=list(map(int,input().split())) info=list(map(int,input().split())) sizey,basey=info[0],info[1] valy=list(map(int,input().split())) one =calc(basex,valx) two=calc(basey,valy) if one==two: print("=") elif one<two: print("<") elif one>two: print(">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long power(int b, int p) { long long i, m = 1; for (i = 1; i <= p; i++) m = m * b; return m; } int main() { long long x = 0, y = 0, bx, by, n, i, j, k, po, t; cin >> n >> bx; po = n - 1; for (i = 1; i <= n; i++) { scanf("%I64d", &t); x += power(bx, po) * t; po--; } cin >> n >> by; po = n - 1; for (i = 1; i <= n; i++) { scanf("%I64d", &t); y += power(by, po) * t; po--; } if (x > y) cout << ">"; else if (x < y) cout << "<"; else cout << "="; cout << '\n'; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long n, bx; cin >> n >> bx; long long a[n]; long long X = 0; long long Y = 0; for (int i = n - 1; i >= 0; i--) { cin >> a[i]; X = X + a[i] * pow(bx, i); } long long n1, by; cin >> n1 >> by; long long a1[n]; for (int i = n1 - 1; i >= 0; i--) { cin >> a1[i]; Y = Y + a1[i] * pow(by, i); } if (X == Y) { cout << "="; } else if (X < Y) { cout << "<"; } else { cout << ">"; } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, bx, m, by, num; long long sumX = 0, sumY = 0; cin >> n >> bx; for (int i = 0; i < n; i++) { cin >> num; sumX = sumX * bx + num; } cin >> m >> by; for (int i = 0; i < m; i++) { cin >> num; sumY = sumY * by + num; } if (sumX == sumY) cout << "=\n"; else if (sumX > sumY) cout << ">\n"; else cout << "<\n"; return 0; }
7
CPP
n, base = [int(i) for i in input().split()] nl = input().split() numa = 0 for c in nl: numa *= base numa += int(c) n, base = [int(i) for i in input().split()] nl = input().split() numb = 0 for c in nl: numb *= base numb += int(c) if numa == numb: print("=") elif numa > numb: print(">") else: print("<")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, bx, m, by; long long x = 0, y = 0; cin >> n >> bx; for (int i = 0; i < n; i++) { int k; cin >> k; x *= bx; x += k; } cin >> m >> by; for (int i = 0; i < m; i++) { int k; cin >> k; y *= by; y += k; } if (x < y) cout << "<"; else if (x > y) cout << ">"; else cout << "="; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long arr[22]; int main() { long long a, b, d; long long c, e, f, g, h; cin >> a; cin >> b; for (d = 0; d < a; d++) cin >> arr[d]; for (d = a - 1, e = 0, g = 1; d > -1; d--) { e += arr[d] * g; g *= b; } cin >> a; cin >> b; for (d = 0; d < a; d++) cin >> arr[d]; for (d = a - 1, f = 0, g = 1; d > -1; d--) { f += arr[d] * g; g *= b; } if (f == e) { printf("=\n"); } else if (f < e) { printf(">\n"); } else printf("<\n"); return 0; }
7
CPP
n,bx = input().split() n,bx = int(n),int(bx); d = input().split() x,pot = 0,1 d.reverse() for dd in d: x += int(dd)*pot pot *= bx; n,bx = input().split() n,bx = int(n),int(bx); d = input().split() y,pot = 0,1 d.reverse() for dd in d: y += int(dd)*pot pot *= bx; if x<y: print('<') elif x>y: print('>') else: print('=')
7
PYTHON3
x=0 n,k=map(int,input().split()) for i in map(int,input().split()): n-=1 x+=i*k**n y=0 n,k=map(int,input().split()) for i in map(int,input().split()): n-=1 y+=i*k**n print('=' if x==y else '<' if x < y else '>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int ar[1000], br[1000]; long long pow1(int a, int b) { long long sum = 1; for (int i = 0; i < b; i++) sum *= a; return sum; } int main() { long long x = 0, y = 0, a, b, c, d; cin >> a >> b; for (int i = 0; i < a; i++) cin >> ar[i]; int p = 0; for (int i = a - 1; i >= 0; i--) x += ar[i] * pow1(b, p++); cin >> c >> d; for (int i = 0; i < c; i++) cin >> br[i]; p = 0; for (int i = c - 1; i >= 0; i--) { y += br[i] * pow1(d, p++); } if (x == y) puts("="); if (x < y) puts("<"); if (x > y) puts(">"); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, b, z; long long x = 0, y = 0; scanf("%d %d", &n, &b); for (int i = 0; i < n; i++) { scanf("%d", &z); x = x * b + z; } scanf("%d %d", &n, &b); for (int i = 0; i < n; i++) { scanf("%d", &z); y = y * b + z; } if (x > y) printf(">"); else if (x < y) printf("<"); else printf("="); }
7
CPP
#include <bits/stdc++.h> using namespace std; const long long OO = 1e8; const long long OOL = 1e16; const long long MOD = 1e9 + 7; const double EPS = 1e-9; unsigned long long gcd(unsigned long long a, unsigned long long b) { return (b == 0 ? a : gcd(b, a % b)); } unsigned long long lcm(unsigned long long a, unsigned long long b) { return (a * (b / gcd(a, b))); } long long N, K; void printVec(vector<int> v2) { for (int i = 0; i < (int)v2.size(); ++i) cout << v2[i] << " "; cout << endl; } int main() { long long x = 0, y = 0; vector<int> v; int l, r; cin >> l >> r; char c; long long p = 0; for (int i = 0; i < l; i++) { cin >> N; v.push_back(N); } long long pw = 1; x += v[v.size() - 1]; for (int i = v.size() - 2; i >= 0; i--) { pw *= r; x += v[i] * pw; } v.clear(); cin >> l >> r; for (int i = 0; i < l; i++) { cin >> N; v.push_back(N); } pw = 1; y += v[v.size() - 1]; for (int i = v.size() - 2; i >= 0; i--) { pw *= r; y += v[i] * pw; } if (x == y) cout << "="; else if (x > y) cout << ">"; else cout << "<"; return 0; }
7
CPP
n, bx = list(map(int, input().split(" "))) X = list(map(int, input().split(" "))) m, by = list(map(int, input().split(" "))) Y = list(map(int, input().split(" "))) vx = 0 vy = 0 for i in range(n-1, -1, -1): vx+= X[n-i-1]*(bx**i) for i in range(m-1, -1, -1): vy+= Y[m-i-1]*(by**i) if(vx == vy): print("=") elif(vx> vy): print(">") else: print("<")
7
PYTHON3
import math a, b=map(int,input().split()) ls=[] ls=map(int,input().split()) ls=list(ls) number=0 B=1 for x in reversed(ls): number+= x*B B=B*b p, q= map(int,input().split()) lst = [] lst=map(int,input().split()) lst=list(lst) numberY=0 B=1 for x in reversed(lst): numberY+= x*B B=B*q if number>numberY: print('>') if number < numberY: print('<') if number == numberY: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long X; long long Y; int bx, by, nx, ny; cin >> nx >> bx; cin >> X; int temp; for (int i = 1; i < nx; i++) { cin >> temp; X = bx * X + temp; } cin >> ny >> by; cin >> Y; for (int i = 1; i < ny; i++) { cin >> temp; Y = by * Y + temp; } if (X < Y) { cout << "<" << endl; } else if (X > Y) { cout << ">" << endl; } else { cout << "=" << endl; } }
7
CPP
n, bx = map(int, input().split()) x = list(map(int, input().split())) m, by = map(int, input().split()) y = list(map(int, input().split())) r = 0 for i in x: r *= bx r += i R = 0 for i in y: R *= by R += i # print(r, R) if r == R: print('=') else: print(['>', '<'][r < R])
7
PYTHON3
from math import * from functools import * N, a = map(int, input().split()) A = reduce(lambda res, x : res * a + x, list(map(int, input().split())), 0) N, b = map(int, input().split()) B = reduce(lambda res, x : res * b + x, list(map(int, input().split())), 0) print([['>', '='][A == B], '<'][A < B])
7
PYTHON3
n,bx = map(int,input().split()) s = input().split() s = [int(x) for x in s] add1 = 0 for i in range(n): add1 += pow(bx, i)*s[-i-1] m,by = map(int,input().split()) t = input().split() t = [int(x) for x in t] add2 = 0 for i in range(m): add2 += pow(by, i)*t[-i-1] if add1==add2: print("=") elif add1>add2: print(">") else: print("<")
7
PYTHON3
n,x=map(int,input().split()) l=list(map(int,input().split())) m,y=map(int,input().split()) d=list(map(int,input().split())) l,d=l[::-1],d[::-1] c,ka=0,0 for i in range(n): c=c+pow(x,i)*l[i] for i in range(m): ka=ka+pow(y,i)*d[i] if(ka>c): print('<') elif(ka<c): print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; inline long long input() { long long n; cin >> n; return n; } long long pw(long long a, long long b) { return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2))); } const int MAXN = 1e6 + 10; const int MOD = 1e9 + 7; const int MOD2 = 998244353; const long long INF = 8e18; int v[44], v2[44]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n1, x, n2, y; long long ans1 = 0, ans2 = 0; cin >> n1 >> x; long long t = 1, t2 = 1; for (int i = n1 - 1; i >= 0; i--) { cin >> v[i]; } for (int i = 0; i < n1; i++) { ans1 += t * v[i]; t *= x; } cin >> n2 >> y; for (int i = n2 - 1; i >= 0; i--) { cin >> v2[i]; } for (int i = 0; i < n2; i++) { ans2 += t2 * v2[i]; t2 *= y; } if (ans1 == ans2) { cout << "="; } else if (ans1 > ans2) { cout << ">"; } else { cout << "<"; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long GetNo(vector<long long> s, long long n, long long d) { reverse(s.begin(), s.end()); long long ans = 0; for (long long i = 0; i < n; i++) ans += (s[i]) * pow(d, i); return ans; } int main() { long long n, x; cin >> n >> x; vector<long long> X(n); for (long long i = 0; i < n; i++) cin >> X[i]; long long a = GetNo(X, n, x); long long m, y; cin >> m >> y; vector<long long> Y(m); for (long long i = 0; i < m; i++) cin >> Y[i]; long long b = GetNo(Y, m, y); if (a == b) cout << "="; else if (a > b) cout << ">"; else cout << "<"; return 0; }
7
CPP
def getNum(x, base): ans = 0 for r in x: ans = (ans * base) + r return ans N, bx = map(int, input().strip().split()) x = [int(x) for x in input().strip().split()] M, by = map(int, input().strip().split()) y = [int(x) for x in input().strip().split()] xx = getNum(x, bx) yy = getNum(y, by) if(xx == yy): print("=") elif(xx < yy): print("<") else: print(">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long int n, bx, m, by, i, x = 0, y = 0; cin >> n >> bx; long long int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } cin >> m >> by; long long int b[m]; for (i = 0; i < m; i++) { cin >> b[i]; } for (i = 0; i < n; i++) { x += (a[i] * pow(bx, n - 1 - i)); } for (i = 0; i < m; i++) { y += (b[i] * pow(by, m - 1 - i)); } if (x < y) { cout << "<"; } else if (x == y) { cout << "="; } else { cout << ">"; } }
7
CPP
#Two Bases.py import os n, bx = map(int, input().split()) x = 0 lx = [] t = input() for i in t.split(): lx.append(int(i)) for i in range(0, n): x = x * bx + lx[i] # print(x) m, by = map(int, input().split()) y = 0 ly = [] t = input() for i in t.split(): ly.append(int(i)) for i in range(0, m): y = y * by + ly[i] # print(x) # print(y) if x > y: print(">") else: if x < y: print("<") else: print("=")
7
PYTHON3
n, b = map(int, input().split()) a = list(map(int, input().split())) x = 0 for i in range(n): x += a[i] * b ** (n - i - 1) n, b = map(int, input().split()) a = list(map(int, input().split())) y = 0 for i in range(n): y += a[i] * b ** (n - i - 1) if x == y: print('=') elif x < y: print('<') else: print('>')
7
PYTHON3
## necessary imports import sys input = sys.stdin.readline #from math import ceil, floor, factorial; # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp ## gcd function def gcd(a,b): if a == 0: return b return gcd(b%a, a) ## nCr function efficient using Binomial Cofficient def nCr(n, k): if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return int(res) ## upper bound function code -- such that e in a[:i] e < x; def upper_bound(a, x, lo=0): hi = len(a) while lo < hi: mid = (lo+hi)//2 if a[mid] < x: lo = mid+1 else: hi = mid return lo ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0 and n > 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0 and n > 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b # find function with path compression included (recursive) # def find(x, link): # if link[x] == x: # return x # link[x] = find(link[x], link); # return link[x]; # find function with path compression (ITERATIVE) def find(x, link): p = x; while( p != link[p]): p = link[p]; while( x != p): nex = link[x]; link[x] = p; x = nex; return p; # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e6 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# # spf = [0 for i in range(MAXN)] # spf_sieve() def factoriazation(x): ret = {}; while x != 1: ret[spf[x]] = ret.get(spf[x], 0) + 1; x = x//spf[x] return ret ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) ## taking integer array input def int_array(): return list(map(int, input().strip().split())) ## taking string array input def str_array(): return input().strip().split(); #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### # n = int(input()); # ans = ''; # while(n > 0): # n -= 1; # remainder = n % 26; # digit = chr(remainder + 97); # ans = digit + ans; # n = (n - remainder) // 26; # print(ans); nb, xb = int_array(); b = int_array(); na, xa = int_array(); a = int_array(); bval = aval = 0; for i in range(nb): x = (xb**i) * b[nb - i - 1]; bval += x; for i in range(na): x = (xa**i) * a[na - i - 1]; aval += x; if bval < aval: print('<'); elif bval > aval: print('>'); else: print('=');
7
PYTHON3
a, b = 0, 0 n, m = [int(x) for x in input().split()] for item in input().split(): a = a * m + int(item) n, m = [int(x) for x in input().split()] for item in input().split(): b = b * m + int(item) if a < b: print("<") elif a > b: print(">") else: print("=")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { auto get = []() { int n, b; cin >> n >> b; long long res = 0, cur = 1; vector<int> a(n); for (auto &ai : a) cin >> ai; while (n--) { res += cur * a.back(); a.pop_back(); cur *= b; } return res; }; long long x = get(), y = get(); if (x < y) cout << '<' << endl; if (x > y) cout << '>' << endl; if (x == y) cout << '=' << endl; return 0; }
7
CPP
x = [int(e) for e in input().split(" ")] x1 = [int(t) for t in input().split(" ")] y = [int(w) for w in input().split(" ")] y1 = [int(q) for q in input().split(" ")] indx1 = len(x1)-1 #último item da lista indy1 = len(y1)-1 #último item da lista basex = x[1] basey = y[1] lx = x[0] ly = y[0] somx = 0 somy = 0 k = 0 h = 0 while (lx > 0): somx += (x1[indx1]*(x[1]**k)) indx1 -= 1 k += 1 lx -= 1 while (ly > 0): somy += (y1[indy1]*(y[1]**h)) indy1 -= 1 h += 1 ly -= 1 if(somx == somy): print("=") elif (somx > somy): print(">") elif (somx < somy): print("<") else: pass
7
PYTHON3
inp = input().split() n = int(inp[0]) bx = int(inp[1]) X = input().split() for i in range(n): X[i] = int(X[i]) X = X[::-1] inp = input().split() m = int(inp[0]) by = int(inp[1]) Y = input().split() for i in range(m): Y[i] = int(Y[i]) Y = Y[::-1] sum_X = 0 base = 1 for n in X: sum_X += base*n base *= bx sum_Y = 0 base = 1 for n in Y: sum_Y += base*n base *= by if sum_X == sum_Y: print('=') elif sum_X < sum_Y: print('<') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> #pragma GCC optimize("Ofast", "inline", "-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,mmx") inline long long read() { long long s(0); bool w(1); char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } long long l, r, n, m, x, y, num; int main() { n = read(), x = read(); for (int i = 1; i <= n; i++) { num = read(); l = l * x + num; } scanf("%lld%lld", &m, &y); for (int i = 1; i <= m; i++) { num = read(); r = r * y + num; } puts(l == r ? "=" : (l > r ? ">" : "<")); }
7
CPP
import sys n,bx = map(int, input().split()) b = list(reversed(list(map(int, input().split())))) num = 0; base = 1; for i in range(n): num += b[i] * base base *= bx m,by = map(int, input().split()) ba = list(reversed(list(map(int, input().split())))) num2 = 0; base = 1; for i in range(m): num2 += ba[i] * base base *= by if num > num2: print(">") elif num < num2: print("<") else: print("=")
7
PYTHON3
import sys def getN(): n, base = map(int, sys.stdin.readline().split()) x = list(map(int, sys.stdin.readline().split())) b = 1 ans = 0 for xi in x[::-1]: ans += xi * b b *= base return ans X = getN() Y = getN() if X < Y: print('<') elif X > Y: print('>') else: print('=')
7
PYTHON3
def get(): a = [int(x) for x in input().split()] d = 0 for x in input().split(): d = d*a[1] + int(x) return d dg = get() dg2 = get() if (dg == dg2): print('=') elif (dg > dg2): print('>') else: print('<')
7
PYTHON3
def convert(digits, base): res = 0 digits.reverse() power = 1 for i in digits: res += i * power power *= base return res n, base_a = [int(x) for x in input().split()] digits_a = [int(x) for x in input().split()] a = convert(digits_a, base_a) n, base_a = [int(x) for x in input().split()] digits_a = [int(x) for x in input().split()] b = convert(digits_a, base_a) if a < b: print("<") elif a > b: print(">") else: print("=")
7
PYTHON3
first_number_base = [int(info) for info in input().split(' ')] first_number_digits = input().split(' ') second_number_base = [int(info) for info in input().split(' ')] second_number_digits = input().split(' ') if first_number_base[1] != 10: first_number = 0 counter = 0 for i in list(reversed(first_number_digits)): first_number += int(i) * first_number_base[1] ** counter counter += 1 else: first_number = int(''.join(first_number_digits)) if second_number_base[1] != 10: second_number = 0 counter = 0 for i in list(reversed(second_number_digits)): second_number += int(i) * second_number_base[1] ** counter counter += 1 else: second_number = int(''.join(second_number_digits)) if first_number < second_number: print('<') elif first_number > second_number: print('>') else: print('=')
7
PYTHON3
n, a=map(int, input().split()) X=[0]+[int(x) for x in input().split()] m, b=map(int, input().split()) Y=[0]+[int(x) for x in input().split()] num1, num2=0, 0 for x in range(1, len(X)): num1+=X[x]*pow(a, n-x) for y in range(1, len(Y)): num2+=Y[y]*pow(b, m-y) if num1<num2: print("<") elif num1>num2: print(">") else: print("=")
7
PYTHON3
Answer = [] for i in range(2): Temp = list(map(int, input().split())) Num = list(map(int, input().split()))[::-1] Answer.append(sum([Num[i] * Temp[1] ** i for i in range(Temp[0])])) print("=" if Answer[1] == Answer[0] else ("<" if Answer[0] < Answer[1] else ">")) # Show you deserve being the best to whom doesn't believe in you.
7
PYTHON3