akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 998244353

int x[100000];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, n)scanf("%d", &x[i]);
	int ret = 1e9;
	REP(i, n - k + 1) {
		if (x[i] < 0) {
			if (x[i + k - 1] < 0) ret = min(ret, -x[i]);
			else ret = min(ret, min(-2 * x[i] + x[i + k - 1], 2* x[i + k - 1] - x[i]));
		}
		else{
			ret = min(ret, x[i+k-1]);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int n,i,x[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",x[i]);
    if(i!=0){
      printf(" ");
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	char a, b, c, d;
	cin >> a >> b >> c >> d;

	int sol[3] = { 0, 0, 0 };
	for (int i = 0; i < 2; ++i) {
		sol[0] = i;
		for (int j = 0; j < 2; ++j) {
			sol[1] = j;
			for (int k = 0; k < 2; ++k) {
				sol[2] = k;

				int res = a - '0';
				if (sol[0] == 0) res += b - '0';
				else res -= b - '0';
				if (sol[1] == 0) res += c - '0';
				else res -= c - '0';
				if (sol[2] == 0) res += d - '0';
				else res -= d - '0';

				if (res == 7) {
					cout << a << (sol[0] == 0 ? '+' : '-') << b << (sol[1] == 0 ? '+' : '-') << c << (sol[2] == 0 ? '+' : '-') << d << "=7";
					
					//system("pause");
					return 0;
				}
			}
		}
	}
	
	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
    int b, r, g, c, s, t;
    while(cin >> b >> r >> g >> c >> s >> t, b||r||g||c||s||t){
        int result = 100 + b*5*15 + r*3*15 + (b+r)*15 + g*7 + c*2
            - (t-s-(5*b+3*r))*3 - (5*b+3*r)*2;
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  vector<int> rev(N);
  
  for (int i = 0; i < N; i++) {
    rev[A[i]-1]=i+1;
    }
  for (int i=0;i<N;i++){
    cout << rev[i] << endl;
  
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n;
	lint k; scanf("%d%lld",&n,&k);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	auto b=a;
	rep(i,n) b[i]*=-1;

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	lint lo=-INF,hi=INF;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;

		lint cnt=0;
		rep(i,n){
			if(a[i]==0){
				if(mi>=0) cnt+=n;
			}
			else if(a[i]>0){
				lint num;
				if(mi>=0) num=mi/a[i];
				else      num=-((-mi+a[i]-1)/a[i]);
				cnt+=upper_bound(a.begin(),a.end(),num)-a.begin();
			}
			else{
				lint num;
				if(mi>=0) num=mi/-a[i];
				else      num=-((-mi-a[i]-1)/-a[i]);
				cnt+=upper_bound(b.begin(),b.end(),num)-b.begin();
			}
			if(a[i]*a[i]<=mi) cnt--;
		}
		assert(cnt%2==0);
		cnt/=2;

		if(cnt>=k) hi=mi;
		else       lo=mi;
	}
	printf("%lld\n",lo+1);

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(2));
    for (int i = 0; i < n; ++i)
        cin >> a[i][0];
    for (int i = 0; i < n; ++i)
        cin >> a[i][1];
    int c = ~0u >> 1;
    for (int m = 0; m < (1 << n); ++m) {
        vector<int> b(n);
        iota(begin(b), end(b), 0);
        int t = 0;
        auto d = [&](int i) { return a[b[i]][m >> b[i] & 1]; };
        for (int i = 0; i < n; ++i) {
            int j = i;
            for (int k = i; k < n; ++k)
                if (d(k) < d(j) ||
                    (d(k) == d(j) && ((b[j] ^ i ^ m >> b[j]) & 1)))
                    j = k;
            if ((b[j] ^ i ^ m >> b[j]) & 1) {
                t = ~0u >> 1;
                break;
            }
            int e = b[j];
            for (int k = j; k != i; --k)
                ++t, b[k] = b[k - 1];
            b[i] = e;
        }
        c = min(c, t);
    }
    cout << (c == ~0u >> 1 ? -1 : c) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  vector<int> ab(2);
  rep(i,n){
    ab[i%2]+=a[i];
  }
  int ans=abs(ab[0]-ab[1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, T) = (input[0], input[1])
let t = readLine()!.characters.split(" ").map{Int(String($0))!}
print((1..<N).reduce(T){$0+min(t[$1]-t[$1-1], T)})

Measured memory_bytes: 12768
S = input()
D = {chr(i):0 for i in range(65, 65+26)}

f=0
for i in range(4):
  D[S[i]] += 1
  if D[S[i]] == 2:
    f +=1

if f ==2:
  print ("Yes")
else:
  print ("No")
      

Measured memory_bytes: 2940
N = int(input())
l = list(map(int, input().split()))
res = False
total = 0
while True:
    for i in l:
        if i % 2 != 0:
            res = True
    if res:
        break
    for i in range(len(l)):
        l[i] = l[i] / 2
    total += 1
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int collatz(int n){
    if(n%2==0)return n/2;
    else return 3*n+1;
}
int main(){
  int s;
  cin>>s;
  vector<bool> already(1001000,false);
  int count=1;
  already[s]=true;
  while(true){
    s=collatz(s);
    count++;
    if(already[s]){
      cout<<count<<endl;
      break;
    }
    else already[s]=true;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

int n, m, Q;
int t[501][501];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m >> Q;
  REP(i, n+1) REP(j, n+1) t[i][j] = 0;
  REP(i, m) {
    int l, r;
    cin >> l >> r;
    t[l][r]++;
  }

  FOR(i, 1, n+1) {
    int sum = 0;
    FOR(j, i, n+1) {
      sum += t[i][j];
      t[i][j] = sum;
    }
  }

  for(int i=n; i>0; i--) {
    int sum = 0;
    for(int j=i; j>0; j--) {
      sum += t[j][i];
      t[j][i] = sum;
    }
  }

  REP(i, Q) {
    int ans = 0;
    int p, q;
    cin >> p >> q;

    cout << t[p][q] << endl;
  }
}


Measured memory_bytes: 1920
#include <stdio.h>

int func2(int n) {
	int count = 0;
	int a, b, c;

	/* 4つの数の和では求まらないパターンの排除 */
	if(n < 37) {
		for(a = 0; a < 10; a++) {
			if(n - a < 0) break;/* この時点までに解が存在しないと分かったとき */

			for(b = 0; b < 10; b++) {
				if(n - (a + b)  < 0) break;/* この時点までに解が存在しないと分かったとき */

				for(c = 0; c < 10; c++) {
					/* dの値次第では解が見つかる場合 */
					if(n - (a + b + c) < 10 && n - (a + b + c) >= 0) {
						count++;
					}
				}
			}
		}
	}
	return count;
}

int main() {
	int n;

	while(scanf("%d", &n) != EOF) {
		printf("%d\n", func2(n));
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  string a,b; cin>>a>>b;
  cout<<b+a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
int digit(int);
using namespace std;

int main()
{
    int a, b;
    while (cin >> a >> b){
        cout << digit(a + b) <<endl;
    }
}

int digit(int n){
    if (n == 0) return 1;
    int i;
    for (i = 0; n > 0;i++){
        n = n / 10;
    }
    return i;
}

Measured memory_bytes: 1160
solve n = 
        let 
            (q, r) = quotRem n 11
            r' = 
                if (r >= 1) && (r <= 6)
                    then 1
                    else if (r >= 7) && (r <= 10)
                        then 2
                        else 0
        in
            2 * q + r'

main = do
    n <- readLn :: IO Int
    print $ solve n

Measured memory_bytes: 508
import heapq

n, m, s, t = map( int, input().split())

def dijkstra(graph, start):
    dist = [ 10**14 for _ in range(n)]
    dist[start] = 0
    q = [(0,start)]
    while q:
        l, v = heapq.heappop(q)
        if dist[v] < l:
            continue
        for u, d in graph[v].items():
            if dist[u] > l+d:
                dist[u] = l+d
                heapq.heappush(q, (dist[u], u))
    return dist

D_yen = [ dict() for _ in range(n)]
D_snuuk = [ dict() for _ in range(n)]
for _ in range(m):
    u, v, a, b = map( int, input().split())
    u, v = u-1, v-1
    D_yen[u][v] = D_yen[v][u] = a
    D_snuuk[u][v] = D_snuuk[v][u] = b

C_yen = dijkstra(D_yen, s-1)
C_snuuk = dijkstra(D_snuuk, t-1)
ans = 10**15
ANS = [ 0 for _ in range(n)]
for i in range(n):
    ans = min( ans, C_yen[n-1-i] + C_snuuk[n-1-i])
    ANS[n-1-i] = ans
for i in range(n):
    print(10**15 - ANS[i])

Measured memory_bytes: 92944
#include <bits/stdc++.h>
using namespace std;

#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

using vi = vector<int>;

void term() { cout << -1 << endl; exit(0); }

int main() {
string s, t; cin>>s>>t;
int n = s.length();
vi nxt[2*n];
s += s;
fr(i,0,2*n) {
if (i<2*n-1) nxt[i] = nxt[i+1], nxt[i][s[i+1]-'a'] = i+1;
else nxt[i] = vi(26,2*n);
}
int i = 0;
while (i < n && s[i] != t[0]) i++;
if (i == n) term();
long long ans = 0;
f(j,1,t.length()) {
i = nxt[i][t[j]-'a'];
if (i==2*n) term();
else if (i>=n) ans += n;
i %= n;
}
ans += i;
cout << ans+1 << endl;
return 0;
}

Measured memory_bytes: 27136
n = int(input())
a = list(map(int, input().split()))
r = [0]*n
ans = float('Inf')

for i in range(n):
  if i == 0:
    r[i] = a[i]
  else:
    r[i] = r[i-1] + a[i]
    
for i in range(n-1):
  ans = min(ans, abs((r[-1] - r[i]) - r[i]))

print(ans)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    string s;
    cin >> s;
    int a=0, b=0;

    rep(i, 3) {
        if (s[i] == 'A') a++;
        if (s[i] == 'B') b++;

    }


    if (a==0 or b==0) {
        cout << "No" <<endl;
    } else {
        cout << "Yes" <<endl;
    }


}



Measured memory_bytes: 256
import sys
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
L=[a,b,c,d,e]
for i in range(4):
  for j in range(i+1,5):
    if abs(L[i]-L[j])>k:
      print(":(")
      sys.exit()
print("Yay!")

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;

const int maxn=2e5+7,maxp=1e4+7;
int tmp,n,p,poww;
long long cnt[maxp],ans;
char s[maxn];

int main()
{
	cin>>n>>p;
	cnt[0]=1;
	poww=1;
	scanf("%s",s+1); 
	if(p==2||p==5) {
		for(int i=n;i>=1;--i) {
			if((s[i]-'0')%p==0) ans+=i;
		}
		printf("%lld",ans);
		return 0;
	}
	for(int i=n;i>=1;--i) {
		tmp=tmp+(s[i]-'0')*poww;
		tmp%=p;
		poww*=10;
		poww%=p;
		ans+=cnt[tmp];
		cnt[tmp]++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 512
def bipartite():
    color = {v: None for v in V}
    stack = [(V[0], 0)]
    parts = {0: [], 1:[]}
    while stack:
        v, c = stack.pop()
        if color[v] is not None: # consistent
            continue
        color[v] = c
        parts[c].append(v)
        for u in E[v]:
            if color[u] is None: # not visited yet
                stack.append((u, c^1)) # paint u with different color from v's one
            elif color[u] != c: # consistent
                continue
            else: # inconsistent
                return (None, None)
    return (parts[0], parts[1])
            
N, M = map(int, input().split())
V = range(1, N+1)
E = {v: [] for v in V}
for _ in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
p1, p2 = bipartite()
if p1 is None:
    print(N * (N-1) // 2 - M)
else:
    print(len(p1) * len(p2) - M)

Measured memory_bytes: 44852
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int b[n+1],w[n+1];
    for(int i = 0; i < n+1; i++){
        b[i] = 0;
        w[i] = 0;
    }
    for(int i = 1; i < n+1; i++){
        if(s[i-1] == '#'){
            b[i] = b[i-1] + 1;
        }else{
            b[i] = b[i-1];
        }
    }
    for(int i = n-1; i >= 0; i--){
        if(s[i] == '.'){
            w[i] = w[i+1] + 1;
        }else{
            w[i] = w[i+1];
        }
    }
    int ans = mod;
    for(int i = 0; i <= n; i++){
        int tmp = b[i] + w[i];
        ans = min(ans,tmp);
    }
    cout << ans;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

int n; map <LL, int> s;

int main(){
	int i, v; LL pf = 0, ans = 0;
	scanf("%d", &n);
	s[0] = 1;
	for(i = 1; i <= n; ++ i){
		scanf("%d", &v);
		ans += s[pf += v];
		++ s[pf];
	} printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
N, A, B = map(int, input().split())
S = input()

qual = {"A": 0, "B": 0}

for i in range(N):
    ans = False
    l = S[i]
    if qual["A"] + qual["B"] < A + B:
        if l == "a":
            ans = True
            qual["A"] += 1
        elif l == "b":
            if qual["B"] < B:
                ans = True
                qual["B"] += 1
    if ans:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9316
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
import math

ans_p = 0
defa = [_ for _ in range(1,n+1)]
for i,x in enumerate(p):
    index = defa.index(x)
    ans_p += math.factorial(n-i-1)*len(defa[:index])
    defa.remove(x)
    
ans_q = 0
defa = [_ for _ in range(1,n+1)]
for i,x in enumerate(q):
    index = defa.index(x)
    ans_q += math.factorial(n-i-1)*len(defa[:index])
    defa.remove(x)
    
print(abs(ans_p-ans_q))

Measured memory_bytes: 3188
n = int(input())
hap = []
for i in range(n):
    hap += [[int(i) for i in input().split()]]
dp =[[0,0,0] for i in range(n+1)]
for i in range(1,n+1):
    if i == 1:
        dp[1] = hap[0] 
    else:
        for j in range(3):
            dp[i][j] = max(dp[i-1][(j+1)%3]+hap[i-1][j],dp[i-1][(j+2)%3]+hap[i-1][j])
print(max(dp[n]))

Measured memory_bytes: 44084
h,n = map(int,input().split())
dg = 10**5

ba = []
for _ in [0]*n:
    a,b = map(int,input().split())
    if a >= h:
        a = h
    ba.append(b*dg + a)
ba.sort()

d = [10**9]*(h+1)
d[0] = 0

for i in range(1, h+1):
    for e in ba:
        a,b = e%dg, e//dg
        if i<=a:
            if d[i] > b:
                d[i] = b
        else:
            if d[i] > d[i-a]+b:
                d[i] = d[i-a]+b
print(d[-1])

Measured memory_bytes: 41772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans=0;
  rep(i,N/R+1) rep(j,(N-i*R)/G+1) if((N-R*i-j*G)%B==0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int W = 8;
const int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[] = {0, -1, -1, -1, 0, 1, 1, 1};
vector<string> board(W);

int Check(int x, int y, int d, char c)
{
    if (x < 0 || x >= W || y < 0 || y >= W)
        return -1;
    if (board[y][x] == '.')
        return -1;

    if (board[y][x] == c)
        return 0;
    else if (board[y][x] != c) {
        int res = Check(x + dx[d], y + dy[d], d, c);
        if (res == -1)
            return -1;
        else {
            return res + 1;
        }
    }
}

void Change(int x, int y, int d, char c)
{
    if (board[y][x] == c)
        return ;
    board[y][x] = c;
    Change(x + dx[d], y + dy[d], d, c);
}

bool Hand(char c)
{
    bool change = false;
    int num, x, y, mask;

    num = mask = 0;
    if (c == 'o') {
        for (int i = 0; i < W; ++i) {
            for (int j = 0; j < W; ++j) {
                int tmp_sum = 0, tmp = 0, tmp_mask = 0;
                if (board[i][j] == '.')
                    for (int d = 0; d < 8; ++d) {
                        tmp = Check(j + dx[d], i + dy[d], d, c);
                        if (tmp > 0) {
                            tmp_sum += tmp;
                            tmp_mask |= 1 << d;
                        }
                    }

                if (tmp_sum > num) {
                    num = tmp_sum;
                    mask = tmp_mask;
                    y = i;
                    x = j;
                }
            }
        }
    }
    else if (c == 'x') {
        for (int i = W - 1; i >= 0; --i) {
            for (int j = W - 1; j >= 0; --j) {
                int tmp_sum = 0, tmp = 0, tmp_mask = 0;
                if (board[i][j] == '.')
                    for (int d = 0; d < 8; ++d) {
                        tmp = Check(j + dx[d], i + dy[d], d, c);
                        if (tmp > 0) {
                            tmp_sum += tmp;
                            tmp_mask |= 1 << d;
                        }
                    }

                if (tmp_sum > num) {
                    num = tmp_sum;
                    mask = tmp_mask;
                    y = i;
                    x = j;
                }
            }
        }
    }

    if (num != 0) {
        change = true;
        board[y][x] = c;

        for (int d = 0; d < 8; ++d)
            if (mask >> d & 1)
                Change(x + dx[d], y + dy[d], d, c);
    }

    return change;
}

int main()
{
    // Input
    for (int i = 0; i < W; ++i)
        cin >> board[i];

    while (true) {
        bool change = false;
        change |= Hand('o');
        change |= Hand('x');

        if (!change)
            break;
    }

    // Output
    for (int i = 0; i < W; ++i)
        cout << board[i] << endl;

    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MAXN = 110;
const int INF = numeric_limits<int>::max();
int n, a[MAXN], ans = INF;
int sqr(int x) {
  return x * x;
}
int main() {
  cin >> n;
  for(reg int i = 1; i <= n; ++i)
    cin >> a[i];
  for(reg int i = 1; i <= 100; ++i) {
    int sum = 0;
    for(reg int j = 1; j <= n; ++j) {
      sum += sqr(a[j] - i);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main(){
    int n,chk,ans;
    scanf("%d",&n);
    vector<int> a(n);
    for(auto&e:a) scanf("%d",&e);
    for (int i=-100;i<101;i++) {
        chk=0;
        for (int j=0;j<n;j++) {
            chk+=abs(a[j]-i)*abs(a[j]-i);
        }
        if (i==-100) ans=chk;
        ans=min(ans,chk);
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  double R;
  cin>>R;
  cout<<setprecision(10);
  cout<<R*2*3.1415926535<<endl;
}



Measured memory_bytes: 3784
X,K,D = map(int, input().split())
X=abs(X)
if X>=K*D:
  print(X-K*D)
else:
  y=X//D
  z=K-y
  j=y*D
  if z%2==0:
    print(X-j)
  else:
    print(abs(X-j-D))


Measured memory_bytes: 61876
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    set<string> s;
    rep(i,N){
        cin>>S;
        s.insert(S);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 19164
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> P;

ll a[212345],b[212345];

int main(){
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(pow(2,k-50)>n){
        for(int i=0;i<n;i++){
            cout<<n<<" ";
        }
        return 0;
    }
    for(int i=0;i<k;i++){
        for(int m=0;m<n+1;m++){
            b[m]=0;
        }
        for(int m=0;m<n;m++){
            b[max((ll)0,m-a[m])]++;
            b[min(n-1,m+a[m])+1]--;
        }
        ll count=0;
        for(int m=0;m<n;m++){
            count+=b[m];
            a[m]=count;
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
    }

    return 0;
}


Measured memory_bytes: 7164
#include<iostream>
using namespace std;

struct Card { char suit, value; }; 

void bubble(struct Card a[], int n); //n -> how many cards
void selection(struct Card a[], int n);
void print(struct Card a[], int n);
bool isStable(struct Card a[], struct Card b[], int n); //equal or not

int main() {
  int n;
  cin >> n;
  
  Card c1[36], c2[36];
  for ( int i = 0; i < n; i++ ) {
      cin >> c1[i].suit >> c1[i].value;
  }
  for ( int i = 0; i < n; i++ ) c2[i] = c1[i];
  bubble(c1, n);
  selection(c2, n);
  print(c1, n);
  cout << "Stable" << endl; //bubble must be stable
  print(c2, n);
  if ( isStable(c1, c2, n) ) { //compare to bubble
      cout << "Stable" << endl;
  } else {
      cout << "Not stable" << endl;
  }
  return 0;
}

void bubble(struct Card a[], int n) { //c1
    //like bubble float up every step
    for ( int i = 0; i <= n - 1; i++ ) 
        for ( int j = n - 1; j >= i + 1; j-- ) //float up
            if ( a[j].value < a[j - 1].value ) { //a is not c1
                //decide j j-1 index first and up to for 
                Card tmp = a[j]; a[j] = a[j - 1]; a[j - 1] = tmp; 
            }
}

void selection(struct Card a[], int n) {
    int j;
    for ( int i = 0; i < n; i++ ) { //fixed
    int minj = i;
        for ( j = i; j < n; j++ ) 
            if ( a[j].value < a[minj].value ) minj = j;
        Card tmp = a[i]; a[i] = a[minj]; a[minj] = tmp; 
        //in the original order
    } 
}

void print(struct Card a[], int n) {
    for ( int i = 0; i < n; i++ ) {
        cout << a[i].suit << a[i].value;
        if ( i != n - 1 ) cout << " ";
    }
    cout << endl;
}

bool isStable(struct Card a[], struct Card b[], int n) {
    int c = 0;
    for ( int i = 0; i < n; i++ ) {
        if ( a[i].suit == b[i].suit && a[i].value == b[i].value ) c++;
    }
    if ( c == n ) return true;
    else return false;
}




Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)
multiset<ll> sm, lg;
int sz=0;
ll sm_sum=0, lg_sum=0;
ll med;
ll sum=0;
void fix() {
	while(sz(sm)<sz(lg)) {
		ll akt=*lg.begin();
		lg.erase(lg.begin());
		lg_sum-=akt;

		sm.insert(med);
		sm_sum+=med;		
		
		med=akt;
	}
	
	
	while(sz(sm)>sz(lg)) {
		ll akt=*prev(sm.end());
		sm.erase(prev(sm.end()));
		sm_sum-=akt;

		lg.insert(med);
		lg_sum+=med;		
		
		med=akt;
	}
	
	
}
void insert(ll x) {
	sz++;
	if(sz==1) med=x;
	else if(x<med) {
		sm.insert(x);
		sm_sum+=x;
	}else {
		lg.insert(x);
		lg_sum+=x;
	}
	fix();
}	
	
	

int main() {
	IO;
	int q;
	cin>>q;
	for(int i=0;i<q;++i) {
		int typ;
		cin>>typ;
		if(typ==1) {
			int a,b;
			cin>>a>>b;
			sum+=b;
			insert(a);
		}else {
			cout<<med<<" "<<sum+sz(sm)*med-sm_sum+lg_sum-sz(lg)*med<<"\n"; 
		}
		
	}
	return 0;
}


Measured memory_bytes: 12876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(s) s.begin(),s.end()

int main(void){
    int n;
    while(cin>>n, n){
        vector<string> s(n);
        int a[256] = {};
        bool not_zero[256] = {};
        rep(i,n){
            cin>>s[i];
            int k = s[i].size();
            if(k>1) not_zero[s[i][0]] = true;
            reverse(all(s[i]));
            rep(j,k){
                a[s[i][j]] += pow(10,j)*(i==n-1 ? -1 : 1);
            }
        }
        
        set<char> st;
        rep(i,n){
            for(char c:s[i]){
                st.insert(c);
            }
        }
        string char_list;
        for(char c : st){
            char_list += c;
        }

        char_list += string(10-(int)st.size(), '-');
        sort(all(char_list));
        int res = 0;

        int perm = 0;
        do{
            perm++;
            if(not_zero[char_list[0]]) continue;
            int sum = 0;
            rep(i,10) sum += i*a[char_list[i]];
            if(sum == 0) res++;
        }while(next_permutation(all(char_list)));
        cout<<res<<endl;
    }

    return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	int N, K; cin >> N >> K;
	int kind = 0;
	map <int, int> mp;
	vector <pair <int, int> > vec;
	rep( i, 0, N ){
		int input; cin >> input;
		if (mp.find( input ) == mp.end()){
			mp[ input ] = kind;
			vec.push_back( pair <int, int>{1, kind} );
			kind++;
		}
		else {
			vec[ mp[ input ] ].first++;
		}
	}
	if (kind - 1 < K){
		cout << 0 << endl;
		return 0;
	}
	sort_asc( vec );
	ll ans = 0LL;
	rep( i, 0, kind - K ){
		ans +=  vec[ i ].first;
	}
	cout <<  ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 410;
int n; ll s[maxn], f[maxn][maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", s + i), s[i] += s[i - 1];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; i + j <= n; j++) {
			int l = j, r = i + j; f[l][r] = 1ll << 60;
			for (int k = l; k < r; k++) {
				f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r]);
			}
			f[l][r] += s[r] - s[l - 1];
		}
	}
	printf("%lld", f[1][n]);
	return 0;
}

Measured memory_bytes: 1536
fun main(args: Array<String>) {
	val input = IntArray(5) { (readLine() ?: return).toInt() }
	val sort = input.map { it % 10 }.filter { it > 0 }.sorted()
	if (sort.size == 0) {
		println(input.sum())
		return
	}
	println(input.map { if (it % 10 == 0) it else (it / 10 + 1) * 10 }.sum() - 10 + sort[0])
}

Measured memory_bytes: 36252
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m,k;
char s[2050][2050];
void cp(int x,int y,int len){
    fo(i,0,len-1)
        fo(j,0,len-1)
            s[x+i][y+j] = s[i][j];
}
void gen(int x){
    int len=(1<<x);
    fo(i,0,len-1)
        fo(j,0,len-1)
            s[i][j] = '0';
    s[0][0]='1';
    fo(i,1,x-1){
        cp(0, 1<<i, (1<<i)-1);
        cp(1<<i, 1<<i, (1<<i)-1);
        cp(1<<i, 0, (1<<i)-1);
        s[(1<<i)-1][(1<<i)-1] = '1';
    }
}
int main(){
    cin>>n>>m;
    gen(max(n,m));
    n=1<<n;m=1<<m;
    fo(i,0,n-2){
        s[i][m-1]='\0';
        cout<<s[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
//dp[opbjects included][total wieght] = value
const int max_objects = 101;
const int max_weight = 1e5+1;
ll dp[max_objects][max_weight];
ll items;
ll total_weight;
int solve()
{
   for(int i=1;i<=items;i++)
   {
   	ll weight;ll value;
   	cin>>weight;cin>>value;
   	 for(int j=1;j<=total_weight;j++)
   	 {
   	 	if(j>=weight)
   	 	{
   	 		dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight]+value);
   	 	   // cout<<"i:"<<i<<"j:"<<j<<"\n";
   	 	}
   	   else
   	   	dp[i][j] = dp[i-1][j];
   	 }
   }

//cout<<dp[2][8]<<"\n";
//cout<<dp[2][3]<<"\n";
//cout<<dp[1][3]<<"\n";
//cout<<
cout<<dp[items][total_weight]<<"\n";
}

int main()
{
//#ifndef ONLINE_JUDGE
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
//#endif
cin>>items;
cin>>total_weight;
memset(dp,0,sizeof(dp));
solve();
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int n;
  cin >> n;

  set<string> strings;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    strings.insert(s);
  }

  cout << strings.size() << endl;

  return 0;
}


Measured memory_bytes: 19180
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
    A += V*T
    B += W*T
    if A >= B :
        print("YES")
    else:print("NO")
else:
    A -= V*T
    B -= W*T
    if A <= B:
        print("YES")
    else:print("NO")

Measured memory_bytes: 9212
#include<cstdio>
int main(void){
int n;
long long a[10000];
long long b[10000];
long long s=0;
long long t=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
}
for(int i=0;i<n;i++){
scanf("%lld",&b[i]);
s+=(b[i]-a[i]);
if(a[i]>b[i])t+=(a[i]-b[i]);
else if((b[i]-a[i])%2==1)t++;
}
if(s<t)printf("No\n");
else printf("Yes\n");
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define    endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  10000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



void solve(){
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	if(s=="ARC") cout<<"ABC";

}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1,f;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}

Measured memory_bytes: 3648
from sys import stdin
mod = 998244353
def solveAsPolynomial():
    import numpy as np
    N,S = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    ans = 0
    f = np.zeros(S+1,np.int64)#f[k] := ある多項式のx**kの係数
    for A in a:
        #f = (f+1)(1+x**A)として更新していく
        f[0] += 1#f+1
        f[A:] += f[:-A].copy()#f*(1+x**A)
        f %= mod
        ans += f[S]
        #x**S = X**(A_1+...+A_k)ゆえ、f[S]は知りたい組み合わせの数と等しい
        ans %= mod
    return ans
def main():
  ans = solveAsPolynomial()
  print(ans)
if __name__ =="__main__":
  main()


Measured memory_bytes: 13748
import sys
sys.setrecursionlimit(1000000)
def maxcost(li,n,i,strt,dp):
    if i==(n-1):
        return li[i][strt]
    mx=-sys.maxsize
    for l in range(3):
        if l!=strt:
            if dp[i+1][l]==-1:
                cost=maxcost(li,n,i+1,l,dp)
                dp[i+1][l]=cost
            else:
                cost=dp[i+1][l]
            mx=max(mx,cost+li[i][strt])
    return mx


n=int(input())
li=[]
for i in range(n):
    temp=[int(x) for x in input().split()]
    li.append(temp)
dp=[[-1 for j in range(3)] for i in range(n)]
print(max(maxcost(li,n,0,0,dp),maxcost(li,n,0,1,dp),maxcost(li,n,0,2,dp)))

Measured memory_bytes: 133848
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,x,y,a[100001],b[100001],f[100001],p[100001],bz[100001],o;
ll c[100001],dp[100001],sum[100001];
int hed[100001],too[200001],nxt[200001],tot;
void link(int x,int y)
{
	nxt[++tot]=hed[x];
	too[tot]=y;
	hed[x]=tot;
}
int find(int x)
{
	return f[x]=(x==f[x]?x:find(f[x]));
}
bool cmp(int x,int y)
{
	return c[x]<c[y];
}
int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%d %d",&a[i],&b[i]),c[i]=max(0,a[i]-b[i]),p[i]=f[i]=i,sum[i]=b[i];
	for (int i=1;i<=m;i++)scanf("%d %d",&x,&y),link(x,y),link(y,x);
	sort(p+1,p+1+n,cmp);
	for (int i=1;i<=n;i++)
	{
		vector<int> son;
		int u=p[i];
		bz[u]=1;
		for (int vv=hed[u];vv;vv=nxt[vv])
		{
			int v=too[vv];
			if (bz[v])
			{
				int x=find(u),y=find(v);
				if (x!=y)sum[u]+=sum[y],f[y]=u,son.push_back(y);
			}
		}
		dp[u]=c[u]+sum[u];
		for (int j=0;j<son.size();j++)o=son[j],dp[u]=min(dp[u],sum[u]-sum[o]+max(c[u],dp[o]));
	}
	printf("%lld\n",dp[find(1)]);
}

Measured memory_bytes: 10128
import java.util.*;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		int a=0,b=0,n=0;
		String num;
		while(sc.hasNext()){
			a=sc.nextInt();
			b=sc.nextInt();
			num=String.valueOf(a+b);	
			n=num.length();
			System.out.println(n);
		}
	}
}

Measured memory_bytes: 20432
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

k = sum(B)-sum(A)
cb = sum([a-b for b,a in zip(B,A) if b<a])
ca = sum([(b-a+1)//2 for b,a in zip(B,A) if b>a])
if ca<=k and cb<= k:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 10520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
ll a,b,c,d;
bool ab,ac,bc;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)ac=true;
	if(abs(a-b)<=d)ab=true;
	if(abs(b-c)<=d)bc=true;
	if(ac||(ab&&bc))pri("Yes");
	else pri("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rp(i, n) for (int i = 0; i < n; i++)
#define rpn(i, n) for (int i = 0; i <= n; i++)
#define p(s) cout << s << endl
#define pc(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//
/**
 * 配列の要素を表示します.(1 2 3 4 5)のような感じ.
 *
 * @param a 表示したい配列
 * @param n 配列の要素数
 */
void printArray(const int a[], int n) {
  rp(i, n) {
    if (i != 0) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  int a[n];
  rp(i, n) {
    cin >> a[i];
  }

  rp(i, n) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    printArray(a, n);
  }
}




Measured memory_bytes: 3124
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N), X(Q);
    rep(i, N) cin >> A[i];
    rep(i, Q) cin >> X[i];
    vector<ll> acc(N + 1, 0);
    rep(i, N) {
        acc[i + 1] += acc[i] + A[i];
    }
    A.insert(A.begin(), 0);
    rep(q, Q) {
        ll ans = 0;
        ll x = X[q];
        rep2(i, 1, N + 1) {
            ll cnt = upper_bound(acc.begin(), acc.end(), x + acc[i - 1]) - acc.begin();
            ans += cnt - i;
        }
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 5264
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <map>
typedef long long int ll;
using namespace std;
typedef pair<string,int> psi;

int main() {
	int N,M;
	cin >> N >> M;
	vector<int> v[10];
	map<psi,int> mp;
	for(int i=0;i<M;i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int tmp;
			cin >> tmp;
			v[tmp-1].push_back(i);
		}
	}
	vector<int> mm(M+1);
	for(int i=0;i<M;i++){
		scanf("%d",&mm[i]);
	}
	int cnt=0;
	for(int i=0;i<=((1ll<<N)-1);i++){
		vector<int> x(M+1);
		for(int j=0;j<N;j++)
		{
			if(i&(1<<j))
			{
				for(auto u:v[j]) x[u]++;
				
			}
		}
		int flag=1;
		for(int j=0;j<M;j++)
		{
			if(mm[j]%2!=x[j]%2)
			{
				flag=0;break;
			}
		}
		if(flag) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b, d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a / b;
  r = a % b;
  f = (double)a / (double)b;

  printf("%d %d %.5f\n", d, r, f);
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdbool.h>

#define MAX 100000

bool binary_search(int);

int A[MAX];
int n;

int main(void) {
  int q, k, i;

  scanf("%d", &n);
  for(i=0; i<n; ++i)
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i=0; i<q; ++i) {
    scanf("%d", &k);
    if(binary_search(k)) {
      printf("1\n");
    }else {
      printf("0\n");
    }
  }

  return 0;
}

bool binary_search(int key) {
  int mid, left = 0, right = n;

  while(left < right) {
    mid = (left+right)/2;
    if(A[mid] == key) {
      return true;
    } else if(A[mid] < key) {
      left = mid+1;
    } else {
      right = mid;
    }
  }

  return false;
}



Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  bool same(int x, int y) {
    x = find(x), y = find(y);
    return x == y;
  }
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main()
{
    // 整数の入力
    ll N,M,K;
    cin >> N >> M >> K;
    vector<set<ll>> blocks(N);
    vector<set<ll>> friends(N);
    map<ll,set<ll>> groups;
    UnionFind uf(N);
    for(int i = 0;i< M;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a,b);
        friends[a].insert(b);
        friends[b].insert(a);
    }

    for(int i = 0;i< K;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        blocks[a].insert(b);
        blocks[b].insert(a);
    }

    for(int i = 0;i < N;i++){
        groups[uf.find(i)].insert(i);
    }

    for(int i = 0;i < N;i++){
        ll count = groups[uf.find(i)].size();
        count--;//じぶん
        for(auto f:friends[i]){
            if(groups[uf.find(i)].find(f) != groups[uf.find(i)].end()){
                count--;
            }
        }

        for(auto b:blocks[i]){
            if(groups[uf.find(i)].find(b) != groups[uf.find(i)].end()){
                count--;
            }
        }
        if (i != 0){
            cout << " ";
        }
        cout << count;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 43008
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);

        int n = Integer.parseInt(String.format("%s%s", ab[0], ab[1]));
        for (int i = 1; i <= n / 2; i++) {
            if (i * i == n) {
                System.out.println("Yes");
                return;
            } else if (i * i > n) {
                break;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>
#include <map>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	map<string, int> S = {
		{"AC", 0},
		{"WA", 0},
		{"TLE", 0},
		{"RE", 0}
	};
	string str;
	rep(i, N) {
		cin >> str;
		S[str] += 1;
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", S["AC"], S["WA"], S["TLE"], S["RE"]);
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while( scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

  cout << pop() << endl;

  return 0;
}



Measured memory_bytes: 3244