akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	int n;cin>>n;
	int a[n+1]={0},b[n+1]={0},c[n]={0};
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n-1;i++)cin>>c[i];
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=b[a[i]];
		if(a[i-1]+1==a[i])sum+=c[a[i-1]];
	}
	cout<<sum<<endl;
}

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

int main() {
	int n;
	cin>>n;
	long a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(n==1)
	cout<<"Yes";
	else {
	for(int i=n-1;i>0;i--)
	{
		int x = a[i-1]-a[i];
		if(x<=0)
		continue;
		else
		{
			if(x>1)
			{
				cout<<"No";
				return 0;
			}
			else 
			a[i-1]--;
		}
		
		
	}
	cout<<"Yes";}
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }
    

    ll ans = LINF;

    REP(check, 2){
        ll temp = 0;
        ll total = 0;
        REP(i, N){
            total += A[i];
            // cout << total << endl;
            if(i%2 == check){
                if(total > 0) continue;
                else{
                    temp += abs(total-1);
                    total = 1;
                }
            }
            else{
                if(total < 0) continue;
                else{
                    temp += abs(total+1);
                    total = -1;
                }
            }
        }
        // cout << "temp:" << temp << endl;
        ans = min(ans,temp);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  for (int i=1; i<=N; i++) {
    double num = i*1.08;
    int P;
    P = (int)num;
    if (P == N) {
      cout << i << endl;
      return 0;
    }
  } 
  cout << ":(" << endl;
}

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

int digitcheck(int i){
  int d = 0;
  while(i > 0){
    d += i % 10;
    i /= 10;
  }
  return d;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int buff = digitcheck(i);
    if(buff >= a && buff <= b){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#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 k , s;
  int x , y , z;
  int ans = 0;
  
  cin >> k >> s;
  
  rep(x,k+1){
  	rep(y,k+1){
      if(s-x-y < k+1 && -1 < s-x-y){
      	ans++;
      }
    	
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  string ans;
  REP(i, N){
    if(S[i] == '0') ans.push_back('0');
    if(S[i] == '1') ans.push_back('1');
    if(S[i] == 'B' && ans.size() != 0) ans.erase(ans.size()-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ans=[0]*d
for i in range(d):
  ans[i]=np.argmax(s[i]) + 1

for sd in ans:
	print(1)

Measured memory_bytes: 27580
import heapq

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)])

i = 0
q = []
ret = 0
for d in range(1, m + 1):
    while i < len(ab) and ab[i][0] <= d:
        heapq.heappush(q, -ab[i][1])
        i += 1
    if len(q) > 0:
        ret -= heapq.heappop(q)
print(ret)

Measured memory_bytes: 31964
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



Measured memory_bytes: 2756
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int f(int n){
	if( n % 2 == 0){
		return n / 2;
	}else{
		return (3*n) + 1;
	}
}

int main()
{
	ll D,N;
	cin>>D>>N;
	ll num;
	if( D == 0){
		num = 1;
	}else if( D == 1){
		num = 100;
	}else{
		num = 10000;
	}
	ll ans;
	if( N == 100){
		ans = num*101;
	}else{
		ans = num*N;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3148
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 200005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

ll n, m, father[NO], a[NO], b[NO], siz[NO], ans[NO], cnt;
//variable

ll getfather(ll o)
{
	if (father[o] == o)
		return o;
	return father[o] = getfather(father[o]);
}
void init()
{
	n = read(), m = read();
	for (int i = m; i >= 1; i--)
		a[i] = read(), b[i] = read();
	for (int i = 1; i <= n; i++)
		father[i] = i, siz[i] = 1;
	ans[0] = n * (n - 1) / 2;
}
//functions

int main()
{
	init();
	for (int i = 1; i <= m; i++)
	{
		int fa = getfather(a[i]), fb = getfather(b[i]);
		if (fa == fb)
		{
			ans[i] = ans[i - 1];
			continue;
		}
		ans[i] = ans[i - 1] - siz[fa] * siz[fb];
		siz[fb] += siz[fa];
		father[fa] = fb;
//		for (int i = 1; i <= n; i++)
//			cout << i << ':' << getfather(i) <<' '<< siz[getfather(i)] << endl;
//		cout << "ans ::   " << ans[i] << endl;
	}
	for (int i = m - 1; i >= 0; i--)
		cout << ans[i] << endl;
	return 0;
}
//main
/*
5 5
1 4
2 4
1 2
2 3
3 4


*/

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int n;
    cin >> n;
  
  for (int i=0;i<n;i++){
    cin >> s;
    if (s == "Y"){
      cout << "Four" << endl;
    break;
    }
    
  }
   if (s != "Y"){
     cout << "Three" << endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string S;
  cin >> S;
  int ans = INF;
  for (ll i = 0; i < S.size() - 2; ++i)
  {
    string num = "";
    num += S[i];
    num += S[i + 1];
    num += S[i + 2];
    // cout << num << endl;
    ans = min(ans, abs(753 - stoi(num)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a,const void *b){
  if(*(int*)a-*(int*)b > 0) return 1;
  return -1;
}

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N,K;
  scanf("%d%d",&N,&K);

  int h[N];
  for(int i = 0;i < N;i++) scanf("%d",&h[i]);

  qsort(h,N,sizeof(int),compare_int);

  int ans = 1e9;
  for(int i = 0;i < N-K+1;i++){
    ans = min(ans,h[i+K-1]-h[i]);
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 892
n, k = map(int, input().split())
a = tuple(map(int, input().split()))
ok = 10**9
ng = 0
while abs(ng-ok) > 1:
    mid = (ok + ng) // 2
    cnt = 0
    for i in a:
        cnt += (i+mid-1)//mid-1
    if cnt <= k:
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 104252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
typedef pair<int, bool> P;
int main()
{
    int N, M;
    scanf("%d%d", &N, &M);
    vector<bool> flag(N + 1);
    vector<int> e(M + 1);
    rep(i, M) scanf("%d", &e[i]);
    for (int i = M - 1; i >= 0; i--)
    {
        if (flag[e[i]])
            continue;
        flag[e[i]] = true;
        printf("%d\n", e[i]);
    }
    for (int i = 1; i <= N; i++)
    {
        if (!flag[i])
            printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
double round(double r)
{
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

int num[300000];

int main()
{
    ll sum=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>num[i];
    int m=num[0];
    for(int i=1;i<n;i++)
    {
        if(num[i]<m)
            sum+=m-num[i];
        else
            m=num[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 4380
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y: return
        else:
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x 
    
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
ans = [0]*N
uf = UnionFind(N)
 
for a, b in AB:
    uf.union(a-1, b-1)
for i in range(N):
    ans[i] = uf.size(i) - 1
for a, b in AB:
    ans[a-1] -= 1
    ans[b-1] -= 1
for c, d in CD:
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)

Measured memory_bytes: 62120
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(all(a));
  int u=a[2]*10+a[1]+a[0];
  cout << u << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a;
  cin>>a;
  
  for(int i=1;i<10;++i)
  {
    if(a/i<10 && a%i==0)
    {
cout<<"Yes";
      return 0;
  }
  }  
   cout<<"No";
    return 0;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        int ans = 0;

        for(int i=0; i<n; i++){
            int input = sc.nextInt();
            array[i] = input;
        }

        for(int i=0; i<n; i++){
            ans += search(array, 0, i);
        }


        System.out.println(ans);
    }
    public static int search(int[] array, int count, int index){
        if(array[index] % 2 != 0){
            return count;
        } else {
            array[index] /= 2;
            count++;
            return search(array, count, index);
        }
    }
}


Measured memory_bytes: 35244
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, c; cin>>a>>b>>c;
	cout<<min(c, b/a);
	return 0;
}


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

#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); i++)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>


using namespace std;

int main() {
	int h, w;
	cin >> h >> w;

	VS s(h);
	REP(i, h) {
		cin >> s[i];
	}

	VVI flg = VVI(h,VI(w));

	REP(y, h) {
		REP(x, w) {
			if (flg[y][x]) { 
				continue;
			}
			if (s[y][x] == '.') {
				continue; 
			}
			if (s[y][x] == '#') {
				if (y < h - 1) {
					if (s[y + 1][x] == '#') {
						flg[y + 1][x] = true;
						continue;
					}
				}
				if (x < w - 1) {
					if (s[y][x + 1] == '#') {
						flg[y][x + 1] = true;
						continue;
					}
				}
				if (y > 0) {
					if (s[y - 1][x] == '#') {
						continue;
					}
				}
				if (x > 0) {
					if (s[y][x - 1] == '#') {
						continue;
					}
				}
			}
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
N = int(input())
def yakusuu(a):
    b = 0
    if a % 2 == 1:
        for i in range(1,a+1):
            if a % i == 0:
                b += 1
        return b
    else:
        return 0
ans = 0
for i in range(1,N+1):
    if yakusuu(i) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    
    string s;
    cin >> s;
    
    li ans = 1;
    for (int i = 0; i < n - 1; ++i) {
        ans += s[i] != s[i + 1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String w = scan.next();
		String lw = w.toLowerCase();
		String sw[] = lw.split("");
		int i,m,t,ti;
		ti = 0;
		for(;;){
			String s = scan.next();
			String ls = s.toLowerCase();
			String ss[] = ls.split("");
			if(s.equals("END_OF_TEXT"))
				break;
				t = 0;
			for(m = 0; m < w.length(); m++){
				if(s.length() < w.length() || s.length() != w.length())
					break;
				if(ss[m].equals(sw[m]))
					t++;			
				}
				if(t == w.length())
					ti++;
			}
		System.out.println(ti);
		}
	}

		

	

Measured memory_bytes: 26328
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main (){
  string s, c;
  cin >> s;
  std::string v;
  
  int count = s.size() - 2;
  
  v = std::to_string(count);
   
  c = s[0] + v + s[s.size()-1];
  
  cout << c << endl;
}
  
  
    

Measured memory_bytes: 256
#!/usr/bin/env python3
#ARC93 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
lst = []
for _ in range(50):
    lst.append(['#']*100)
for _ in range(50):
    lst.append(['.']*100)
print(100,100)
cnt = 0
flg = True
if cnt != a-1:
    for i in range(25-1):
        for j in range(50):
            lst[2*i][2*j] = '.'
            cnt += 1
            if cnt == a-1:
                flg = False
                break
        if not flg:
            break
cnt = 0
flg = True
if cnt != b-1:
    for i in range(25+1,50)[::-1]:
        for j in range(50)[::-1]:
            lst[2*i+1][2*j+1] = '#'
            cnt += 1
            if cnt == b-1:
                flg = False
                break
        if not flg:
            break
for i in range(100):
    print(''.join(lst[i]))


Measured memory_bytes: 38384
N=int(input())

step = sum([90*100**i for i in range(len(str(N))//2)])
dance_floor = sum([9*100**i for i in range(len(str(N))//2)])

ans = len(str(N))%2 * (N-step)  +  -1*(len(str(N))%2-1) * dance_floor
print(ans)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int q;
    cin >> q;
    int a, x;
    set<int> s;
    while(q--){
        cin >> a >> x;
        if(a==0){
            s.insert(x);
            cout << s.size() << "\n";
        }else if(a==1){
            cout << s.count(x) << "\n";
        }else{
            s.erase(x);
        }
    }
    
    return 0;
}


Measured memory_bytes: 12460
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9;
const int mod = 1e9 + 7;

int n, m;

LL get(int x)
{
    LL ret = 1;
    FF(i, 2, x)
    {
        ret = (ret * i) % mod;
    }
    return ret;
}
int main()
{
#ifndef ONLINE_JUDGE
    //IN;
#endif

    SCC(n, m);
    if(n > m) swap(n, m);
    LL ans = 1;
    if(m - n == 1){
        ans = (ans * get(m)) % mod;
        ans = (ans * get(n)) % mod;
    }
    else if(n == m){
        ans = (ans * get(m)) % mod;
        ans = (ans * get(n)) % mod;
        ans = (ans * 2) % mod;
    }
    else
        ans = 0;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		long w = sc.nextInt();

		if (h == 1 || w == 1) {
			System.out.println(1);
		} else if (h * w % 2 == 0) {
			System.out.println(h * w / 2);
		} else {
			System.out.println(h * w / 2 + 1);
		}

		sc.close();
	}

}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, m;
  cin >> n >> m;
  vi p(m), a(m);
  rep(i, m) {
    string s;
    cin >> p[i] >> s;
    if (s == "AC") a[i] = 1;
  }
  dump(p, a);
  map<int, int> mp;
  ll wa = 0;
  rep(i, m) {
    if (mp[p[i]] == -1) continue;
    if (a[i]) {
      wa += mp[p[i]];
      mp[p[i]] = -1;
    } else {
      mp[p[i]]++;
    }
  }
  ll ac = 0;
  rep(i, n) if (mp[i + 1] == -1) ac++;
  cout << ac << " " << wa << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define test int t;cin>>t; while(t--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
int main()
{
string s,t;
cin>>s>>t;
int c=0;
for(int i=0;i<s.length();i++)
{
    if(s[i]!=t[i]){c++;}
}
cout<<c<<endl;

}



Measured memory_bytes: 3880
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for (int i = s.length() - 1 ; i > 0 ; i--) {
		int y = 0;
		for (int j = 0 ; j < i / 2 ; j++) {
			if (s[j] == s[j + i / 2]) y++;
		}
		if (y == i / 2 && i % 2 == 0) {
			cout << i;
			return 0;
		}
	}
}

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

int main()
{
  int n,m,i,display;
  vector<int> v(10);
  v[0] = 63;
  v[1] = 6;
  v[2] = 91;
  v[3] = 79;
  v[4] = 102;
  v[5] = 109;
  v[6] = 125;
  v[7] = 39;
  v[8] = 127;
  v[9] = 111;
  while(cin>>n,~n){
    display=0;
    while(n-->0){
      cin>>m;
      display^=v[m];
      for(i=1<<6;i>0;i=i>>1) cout<<((display&i)!=0);
      display=v[m];
      cout<<endl;
    }
  }
}

Measured memory_bytes: 0
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=900000+10;

const int mod=1e9+7;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int fac[N],ifac[N],pw[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
    for (re int i=pw[0]=1;i<=n;++i) pw[i]=3ll*pw[i-1]%mod;
}

inline int C(int n,int m) {
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main() { init(900000);
    int n=read(),m=read(),k=read(); if (m<k) swap(m,k);
    int ans=0,lst=1;
    for (re int i=0;i<=m+k;++i) {
        ans=(ans+1ll*C(n+i-1,n-1)*pw[m+k-i]%mod*lst)%mod;
        if (i<k) lst=2ll*lst%mod;
        else if (i<m) lst=(2ll*lst+mod-C(i,k))%mod;
        else lst=(2ll*lst+mod-C(i,k)+mod-C(i,i-m))%mod;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

const int md = int(1e9) + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1);

  for (int i = 1; i <= n; i++) {
    int num = i;
    for (int j = 2; j <= n; j++) {
      while (num % j == 0) {
        num /= j;
        cnt[j]++;
      }
    }
  }

  int res = 1;
  for (int i = 2; i <= n; i++) {
    res = mul(res, cnt[i] + 1);
  }
  cout << res << '\n';
  return 0;
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> p;
    p.push_back(a);
    p.push_back(b);
    p.push_back(c);

    sort(p.begin(), p.end(), greater<int>());

    cout << p.at(0)*10+p.at(1)+p.at(2) << endl;

    return 0;
}


Measured memory_bytes: 256
n, k  = map(int, input().split())

if n >= k:
    n = n%k
    n_abs = abs(n-k)
    if n <= n_abs:
        print(n)
    else:
        print(n_abs)
elif n < k and k < 2*n:
    n_abs = abs(n-k)
    if n <= n_abs:
        print(n)
    else:
        print(n_abs)
else:
    print(n)

#nに対して操作を行う。
#操作とは、nとkの差の絶対値をとること。
#この操作を２回行えば起こりうる事象を全て観測した事になる。
#ただしnとkの値が大きいので、商とか使う。


#Plan 
# n >= k   割り算でnを小さくしてからalgorithm1
# n < k n < k < 2n　の時と2n <= kの時でさらに分岐？ 後者はアウト。前者はalgorithm2

#algorithm1 →　割れないほど小さくなってから、nで絶対値とったらさらに小さくなるかどうか。この時nは2k未満である。差を作って小さい方を選ぶ。
#algorithm2 → algorithm1と同じっぽい。






Measured memory_bytes: 3060
H, W, A, B = list(map(int, input().split()))
A_limit = W//2
B_limit = H//2

if A_limit < A or B_limit < B:
    print("No")
    
else:
    A_li = ["1" if i < A else "0" for i in range(W)]
    not_A_li = ["0" if i < A else "1" for i in range(W)]

    for _ in range(H-B):
        print("".join(A_li))
    
    for _ in range(B):
        print("".join(not_A_li))

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll X; cin>>X;
	ll a=X/500; X%=500;
	ll b=X/5;
	cout<<1000*a+5*b<<"\n";
	return 0;
}

Measured memory_bytes: 256
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    loop {
        let line = getline();
        let vec: Vec<&str> = line.trim().split(' ').collect();
        let ll = vec[0].parse::<i32>().unwrap();
        let op = vec[1].chars().nth(0).unwrap();
        let rr = vec[2].parse::<i32>().unwrap();

        if op == '?' {
            break;
        } else {
            let result = match op {
                '+' => ll + rr,
                '-' => ll - rr,
                '*' => ll * rr,
                '/' => ll / rr,
                _ => 0,
            };
            println!("{}", result);
        }
    }
}



Measured memory_bytes: 5036
#include<stdio.h>
#include<string.h>
int main(void){
	int i,j,n;
	char gyo[1001];

	scanf("%s",gyo);
	n=strlen(gyo);
	for(i=0;i<n;i++){
		j=gyo[i];
		if(j=='A'||j=='B'||j=='C'){
			gyo[i]+=23;
		}else gyo[i]-=3;
	}
	for(i=0;i<n;i++){
		printf("%c",gyo[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
#include <iostream>

using namespace std;

int main() {
    char S[5];
    int count=0,i;
    cin >> S;
    for( i=0;i<=2;i++)
    {
        if(S[i] == 'A')
        {
           
            count++;
            
        }

    }

    if(count==3 || count==0)
    {
        cout <<  "No";
    }
    else {
        cout << "Yes";
    }
}

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

int main() {
	vector<bool> prime(100009, true);
    prime[0] = false; prime[1] = false;
    int i=1;
	while (i < 10009) {
		i++;
		if (!prime[i]) continue;
		for (int j = 2; j * i < 100009; ++j) {
			prime[j * i] = false;
		}
	}
  
  	vector<int> ans(100009,0);
	int sum = 0;
    for(int i=0;i<100009;i++){
        if(prime[i]&&prime[(i+1)/2]) sum++;
        ans[i]=sum;
    }
    
	//for (int i = 0; i < 100009; ++i) cout << i << ","<<ans[i]<<endl;

	int q; cin >> q;
	for (int i = 0; i < q; ++i) {
		int l, r; cin >> l >> r;
		cout << ans[r] - ans[l-1] << endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long  ll;
typedef unsigned long long int ull;
#define pb push_back
#define For(ii,aa,bb) for(ll ii = aa; ii < bb;ii++)
#define Rof(ii,aa,bb) for(ll ii = aa; ii >= bb;ii--)
#define st first 
#define nd second 
#define MP make_pair
#define MAX 1000000009
#define MOD 1000000007
#define all(v6) v6.begin(),v6.end()
#define IT iterator
#define ln "\n"
#define F(ii) ((abs(ii) + ii)/2)
#define N 500005
using namespace std;
ll n,k, m;
ll dp[N] = {0};
ll arr[N];
void solve(ll pl){
	dp[pl] = MAX;
	For(i, 1, k + 1){
		if (pl - i < 1){
			break;
		}
		dp[pl] = min(dp[pl], abs(arr[pl] - arr[pl - i]) + dp[pl - i]);
	}
	if (dp[pl] == MAX){
		dp[pl] = 0;
	}
	if (pl != n){
		solve(pl + 1);
	}
}
int main(){
	#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
	For(i, 1, n + 1){
		cin >> arr[i];
	}
	solve(1);
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 5120
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:30:51 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()

s = str(N)
flag = False
cnt = 1
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        cnt = 1
    if cnt >= 3:
        flag = True
        break

print("Yes" if flag else "No")

Measured memory_bytes: 3064
import numpy as np
n=int(input())
def f(n):
  num=int(np.sqrt(2*n))
  while True:
    if num*(num+1)//2 > n:
      return num-1
    num+=1
p=[]
p_tf=[1 for i in range(int(np.sqrt(n))+1)]
p_tf=np.array(p_tf)
for i in range(2,int(np.sqrt(n))+1):
  if p_tf[i] and n%i==0:
    p.append(i)
    p_tf[i::i]-=1
p2=p.copy()
for i in p2:
  num=n//i
  t=True
  for j in p2:
    if num%j==0:
      t=False
  if t:
    p.append(num)
if len(p)==0 and n!=1:
  p=[n]
ans=0
for i in p:
  j=1
  while True:
    if n%i==0:
      n//=i
      j+=1
    else:
      j-=1
      break
  ans+=f(j)
print(ans)

Measured memory_bytes: 42648
import copy
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I for i in range(self.sz * 2)]
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)

def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    from fractions import gcd
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()

Measured memory_bytes: 82340
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
    int X, N;
    cin >> X >> N;
    vector<int> n_list;
    bool XinN = false;
    
    if (N == 0) {
        cout << X << endl;
        return 0;
    }
    
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        if (n == X)
            XinN = true;
        n_list.push_back(n);
    }
    
    if (!XinN) {
        cout << X << endl;
        return 0;
    }
    
    bool not_founded = true;
    int inc_n_dec = 1;
    
    while (not_founded) {
        auto result1 = find(n_list.begin(),n_list.end(),X - inc_n_dec);
        if (result1 == n_list.end()) {
            cout << X - inc_n_dec << endl;
            return 0;
        } else {
            auto result2 = find(n_list.begin(),n_list.end(),X + inc_n_dec);
            if (result2 == n_list.end()){
                cout << X + inc_n_dec<<endl;
                return 0;
            }
        }
        inc_n_dec++;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll H, W;
        cin >> H >> W;
        vector<vector<string>> grid(H, vector<string>(W));
        rep(i, 0, H) rep(j, 0, W) cin >> grid[i][j];

        rep(i, 0, H) {
                rep(j, 0, W) {
                        string s = grid[i][j];
                        if (s == "snuke") {
                                cout << (char)('A' + j) << i+1 << endl;
                                return 0;
                        }
                }
        }
}


Measured memory_bytes: 3592
# ABC134C - Exception Handling
def main():
    N, *A = map(int, open(0))
    m1, m2 = sorted(A, reverse=1)[:2]
    ans = [m1 if i != m1 else m2 for i in A]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 27768
#include <cmath>
#include <iostream>

using namespace std;

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

    int left = 1, right = n;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;

        if (left < l) {
            left = l;
        }

        if (right > r) {
            right = r;
        }
    }

    cout << max(0, right - left + 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <string>
#include <stdlib.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mset(a, b) memset(a, b, sizeof(a))
#define LL long long
#define P pair<int, int>
const int MAX = 1e5 +5;
const int inf = 0x3f3f3f3f;
using namespace std;

int main()
{
    int n, L;
    cin >> n >> L;
    int tot = 0, d = inf;
    int ans ;
    for(int i = 0; i < n; i++){
        tot += i + L;
    }
    for(int i = 0; i < n; i++){
        int tmp = tot - (i+L);
        if(abs(tmp-tot) < d) {
            ans = tmp;
            d = abs(tmp-tot);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int N,M;
  long long sum=0;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int A;
    cin >> A;
    sum+=A;
  }
  if(sum>N){
    cout << -1 << endl;
  }
  else{
    cout << N-sum << endl;
  }
}
  
  

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	string s;
	cin >> s;
	if (s.back() == 's') {
		cout << s << "es";
	} else {
		cout << s << "s";
	}

	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3656
#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.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0, bob = 0;
  
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  cout << alice - bob << endl;
    
}

Measured memory_bytes: 3640
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> b(n-1);
    vector<lint> a(n, 0);
    REP(i, n-1){
        cin >> b[i];
    }
    for (int i=n-1; i>=0; i--){
        if(i == n-1){
            a[n-1] = b[n-2];
        }
        else if(i == 0){
            a[0] = b[0];
        }
        else {
            //debugpair(b.at(i-1), b.at(i));
            a[i] = min(b.at(i-1), b.at(i));
        }
    }
    lint ans = 0;
    REP(i, n){
        //debug(a[i]);
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string s;
  cin >> s;
  vector<ll> sum(2019,0);
  ull len = s.size();
  ll t1 = 0;
  ll piv = 1;
  rep_rev(i,len){
    t1 += piv * (s[i] - '0');
    t1 %= 2019;
    sum[t1]++;
    piv *= 10;
    piv %= 2019;
    //cout << t1 << endl;
  }



  t2 = 0;
  ll ans = 0;
  piv = 1;

  ans += sum[0];
  rep_rev(i,len){
    t2 += piv * (s[i] - '0');
    t2 %= 2019;
    sum[t2]--;
    ans += sum[t2];
    piv *= 10;
    piv %= 2019;
    //cout << t2 << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
      
        if(N%500 <= A){
          System.out.println("Yes");
        }else{
          System.out.println("No"); 
        }
	}
}


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

using namespace std;

int main() {
    string s;
    int q;
    cin >> s >> q;
    vector<int> t(q), f(q);
    vector<char> c(q);
    for (int i = 0; i < q; ++i) {
        cin >> t[i];
        if (t[i] == 2) {
            cin >> f[i] >> c[i];
        }
    }
    // input

    deque<char> ans(s.size());
    for (int i = 0; i < s.size(); ++i) ans[i] = s[i];
    bool rev = false;
    // preprocess

    for (int i = 0; i < q; ++i) {
        if (t[i] == 1) rev = !rev;
        else {
            if (f[i] == 1) {
                if (!rev) ans.push_front(c[i]);
                else ans.push_back(c[i]);
            }
            else {
                if (!rev) ans.push_back(c[i]);
                else ans.push_front(c[i]);
            }
        }
    }
    // solve

    if (!rev) for (int i = 0; i < ans.size(); ++i) cout << ans[i];
    else for (int i = ans.size() - 1; i > -1; --i) cout << ans[i];
    cout << endl;
}

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

bool isOK(vector<int> v) {
	for (int i = 0; i < 8; i++) {
		for (int j = i + 1; j < 8; j++) {
			if (abs(v[j] - v[i]) == j - i) {
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int k;
	cin >> k;
	vector<int> x(k), y(k);
	for (int i = 0; i < k; i++) {
		cin >> x[i] >> y[i];
	}
	vector<int> v = { 0, 1, 2, 3, 4, 5, 6, 7 };
	do {
		bool OK = true;
		for (int i = 0; i < k; i++) {
			if (v[x[i]] != y[i]) {
				OK = false;
			}
		}
		if (OK && isOK(v)) {
			break;
		}
	} while (next_permutation(v.begin(), v.end()));
	vector<string> res(8, "........");
	for (int i = 0; i < 8; i++) {
		res[i][v[i]] = 'Q';
	}
	for (int i = 0; i < 8; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main(){

  long long int n;
  cin>>n;

  long long int l, r;
  cin>>l>>r;

  for(int i=1; i<n; i++){
    long long int t, a;
    cin>>t>>a;
    long long int j=max((l-1+t)/t, (r-1+a)/a);
 //   while(j*t<l or j*a<r) j++;
    l=j*t;
    r=j*a;
  }

  cout<<l+r<<endl;
}


Measured memory_bytes: 3640
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let l = read_line();
    let s = l.trim();
    // println!("{}", s);
    if s=="Sunny" {
        print!("Cloudy");
    }else if s=="Cloudy" {
        print!("Rainy");
    } else {
        print!("Sunny");
    }
    
    
    
    
}   

Measured memory_bytes: 4352