akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<int> a(N+1);
    FOR(i, 1, N+1) cin >> a[i];

    vector<int> ans(N+1, 0);
    vector<int> num_balls(N+1, 0);
    for(int i = N; i >= 1; --i){
        ans[i] = (num_balls[i]+a[i]) % 2;
        if(ans[i] == 1){
            for(int j = 1; j*j <= i; ++j){
                if(i%j == 0){
                    ++num_balls[j];
                    if(j*j != i) ++num_balls[i/j];
                }
            }
        }
    }

    int M = accumulate(ans.begin(), ans.end(), 0);
    cout << M << endl;
    FOR(i, 1, N+1) if(ans[i] == 1) cout << i << " ";
    
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("modulo.in","r",stdin);
	//freopen("modulo.out","w",stdout);
	
	int n,tmp;
	int sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&tmp);
		sum+=tmp;
	}
	printf("%d",sum-n);
	
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> List = new ArrayList<>();
        int n = sc.nextInt();
        for(int i=0;i<n;i++) List.add(sc.nextInt());
        int max = -999999999;
        int min = List.get(0);
        for(int i=1;i<List.size();i++){
            max = Math.max(max,List.get(i)-min);
            min = Math.min(min,List.get(i));
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 106088
a, b = map(int, input().split())

A = []
A.append(['.']*(b+2))

for i in range(a):
    
    A.append(list('.'+input()+'.'))
A.append(['.']*(b+2))

ans = 0
for i in range(1, a+2):
    for j in range(1, b+2):
        if(A[i][j] == '#' and ans == 0):
            if(A[i][j-1] != "#" and A[i][j+1] != "#" and A[i-1][j] != "#" and A[i+1][j] != "#"):
                print('No')
                ans += 1
                break
if(ans == 0):
    print('Yes')

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(9);
    for (int i = 0; i < k; ++i) {
        char c;
        cin >> c;
        d[c - '0'] = 1;
    }

    int i = n;
    while (1) {
        int m = i;
        while (m > 0) {
            if (d[m % 10] == 1) {
                break;
            }
            m /= 10;
        }
        if (m == 0) {
            cout << i << '\n';
            return 0;
        }
        ++i;
    }
}

Measured memory_bytes: 256
n = int(input())

affilé = 0
ok = 0


for i in range(n):
  d1, d2 = [int(k) for k in input().split()]
  if d1 == d2:
    affilé += 1
  elif d1 != d2:
    affilé = 0
  

  if affilé == 3:
    ok = 1

if ok == 0:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 9236
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false),in.tie(0),cout.tie(0);
#define input freopen("input.in","right_interval",stdin);
#define output freopen("output.out","w",stdout);
#define e printf("\n");
#define all(it,v) for(it=(v).begin();it!=(v).end();it++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x);
#define pf(x) printf("%f",x);
#define pl(x) printf("%lld",x);
typedef vector<vector<ll> > mat;
const ll mx=100001;
const ll mod=1000000007;
const ll inf=0x3f3f3f3f;
//ifstream in("input.txt");
//ofstream out("output.txt");
void solve();
int main()
{
  int t=1;
//  si(t);
  rep(i,1,t)
  {
    solve();
    if(i!=t) e
  }
  return 0;
}
int dp[3001][3001];
void solve()
{
  int i,j,k,m,n;
  string a,b;
  cin>>a>>b;
  n=a.size(); m=b.size();
  rep(i,0,n)
  {
    rep(j,0,m)
    {
      if(!i || !j) dp[i][j]=0;
      else
      if(a[i-1] == b[j-1]) dp[i][j]=1+dp[i-1][j-1];
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
/*  rep(i,0,n)
  {
    rep(j,0,m)
    cout<<dp[i][j]<<" ";
    e
  }*/
  i=n;j=m;
  string c;
  while(i>0 && j>0)
  {
    if(a[i-1]== b[j-1])
    {
      c.push_back(a[i-1]);
      i--;
      j--;
    }  
    else
    if(dp[i-1][j]>dp[i][j-1])
    {
      i--;
    }
    else
      j--;
  }
  reverse(c.begin(),c.end());
  cout<<c;
}





























Measured memory_bytes: 35456
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    vector<int> d1(n), d2(n);
    rep(i, n) cin >> d1[i] >> d2[i];

    int ans=0;
    int cnt=0;

    rep(i,n) {
        if (d1[i] == d2[i]) cnt++;
        else cnt=0;
        
        if (cnt == 3) ans=1;
    }

    if (ans==0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

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

int main()
{
  long long X,K,D;
  cin >> X >> K >> D;
  if(X<0) X = -X;
  long long num;
  long long point = X;
  num = X/D;
  
  if(K-num <= 0) point = point-K*D;
  else
  {
    point = point-num*D;
    K=K-num;
    if(K%2 == 1) point = abs(point - D);
  }
  
  cout << point << endl;
  
  return 0;
}
  

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
#define nl '\n'
#define eb emplace_back
#define f(i,start,n) for(int i=start; i<=n; i++)
#define pi 3.1415926535
#define mod 1000000000+7
#define MAX 100000+1
#define t int t; cin >> t; while(t--)

int mark[200001];
int max_ = 0;

int main()
{
    FASTIO;
    //t
    {
        int n = 0; cin >> n;
        ull a[n]; ull ans = 1;
        for(int i=0; i<n; i++)
        {
            cin >> a[i];
            if(a[i]==0){
                cout << 0; return 0;
            }
        }
        for(int i=0; i<n; i++)
        {
            if(1000000000000000000/a[i]<ans){
                cout << "-1"; return 0;
            }
            ans *= a[i];
        }
        cout << ans;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  double ans = v.at(0);
  for(int i = 1; i < n; i++) {
    ans = (ans + v.at(i)) / 2;
  }
  cout << ans << endl;
}


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

int main() {
  int X, N;
  cin >> X >> N;
  int p[N];
  
  if ( N != 0 ) {
    for ( int i = 0; i < N; i++ ) {
      cin >> p[i];
    }
  }
  
  int min = 10000;
  int ans = 0;
  if ( N == 0 ) {
    cout << X << endl;
  } else {
    for ( int i = 0; i <= 101; i++ ) {
      for ( int j = 0; j < N; j++ ) {
        if ( i == p[j] ) {
          goto OUT;
        } 
      }
      if ( abs(X-i) < min ) {
            min = abs(X-i);
            ans = i;
      }
      OUT:
      ;
    }
  }
  
  if ( N != 0 ) {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>

int main(){
	char S[256];
    char T[256];
	int A;
	int B;
	int a;
	int b;
	char U[256];
    scanf("%s %s",S,T);
    scanf("%d %d",&A,&B);
    scanf("%s",U);
    if(strcmp(S,U)==0){
    	a=A-1;
    	b=B;
    }else{
    	a=A;
    	b=B-1;
    }
    printf("%d %d",a,b);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll h,w;
cin >> h >> w;
vector<string> s(h);
rep(i,h) cin >> s[i];
vector<vector<ll>> L(h,vector<ll> (w,0)),R(h,vector<ll> (w,0)),U(h,vector<ll> (w,0)),D(h,vector<ll> (w,0));
rep(i,h){
    rep(j,w){
        if(s[i][j] == '#') L[i][j] = 0;
        else{
            if(j == 0) L[i][j] = 1;
            else L[i][j] = L[i][j - 1] + 1;
        }
    }
}
rep(i,h){
    for(int j = w - 1; 0 <= j; j--){
        if(s[i][j] == '#') R[i][j] = 0;
        else{
            if(j == w - 1) R[i][j] = 1;
            else R[i][j] = R[i][j + 1] + 1;
        }

    }
}
rep(j,w){
    rep(i,h){
        if(s[i][j] == '#') U[i][j] = 0;
        else{
            if(i == 0) U[i][j] = 1;
            else U[i][j] = U[i - 1][j] + 1;
        }
    }
}
rep(j,w){
    for(int i = h - 1; 0 <= i; i--){
        if(s[i][j] == '#') D[i][j] = 0;
        else{
            if(i == h - 1) D[i][j] = 1;
            else D[i][j] = D[i + 1][j] + 1;
        }
    }
}
ll ans = 0;
rep(i,h){
    rep(j,w){
        ans = max(ans,R[i][j] + U[i][j] + L[i][j] + D[i][j] - 3);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 132828
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

double dp[3010][3010];


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    double p[3010];
    rep(i, N) cin >> p[i];
    dp[0][0] = 1.0;
    rep(i, N) {
        rep(j, N) {
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }
    double ans = 0.0;
    REP(i, (N + 1) / 2, N) ans += dp[N][i];
    /*
    rep(i, N + 1) {
        rep(j, N + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    printf("%.12f", ans);

    return 0;
}


Measured memory_bytes: 70784
s=list(map(int,input().split()))
a=s[0]
b=s[1]
c=s[2]
k=s[3]
aa=0
bb=0
cc=0

if k>=a:
    aa=a
    k=k-a;
    if k>=b:
        bb=b
        k=k-b
        cc=k
    else:
        bb=k
        k=0
else:
    aa=k
    k=0

print(aa-cc)


Measured memory_bytes: 9196
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] w=new int[s[0]+1];
		var hs=new Dictionary<int,int>();
		long ans=0;
		hs[0]=1;
		for(int i=1;i<=s[0];i++){
			w[i]=(w[i-1]+a[i-1])%s[1];
			if(hs.ContainsKey(w[i])){ans+=hs[w[i]];hs[w[i]]++;}
			else{hs[w[i]]=1;}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 20064
#include<stdio.h>
int main()
{
	char s[10];
	scanf("%s",s);
	if(s[0]!=s[1]){
		if(s[1]!=s[2]){
			if(s[2]!=s[0]){
				printf("Yes");
			}else{
				printf("No");
			}
		}else{
			printf("No");
		}
	}else{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main()
{
    char s[5];

    scanf("%s", s, 4);

    if (strcmp(s,"ABC")==0)
    {
        printf("ARC\n");
    }
    else
    {
        printf("ABC\n");
    }
    return 0;
}

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

const int INF = (int) 1e9;
typedef bitset<100> BitSet;
const int N = 1005;
string s;
int eval[N], start1[N], start2[N];
int n;
BitSet mask[100];
BitSet stw[10]; // startWith

void evaluate(int &ptr) {
    if (s[ptr] >= '0' && s[ptr] <= '9') {
        start1[ptr] = start2[ptr] = -1;
        int &x = eval[ptr] = 0;
        while (s[ptr] >= '0' && s[ptr] <= '9') {
            x = x * 10 + s[ptr] - '0';
            ++ptr;
        }
        return;
    }
    int optr = ptr;
    assert(s[++ptr] == '(');
    start1[optr] = ++ptr;
    evaluate(ptr);
    assert(s[ptr++] == ',');
    start2[optr] = ptr;
    evaluate(ptr);
    assert(s[ptr++] == ')');
    if (s[optr] == '_') {
        eval[optr] = min(eval[start1[optr]], eval[start2[optr]]);
    } else {
        eval[optr] = max(eval[start1[optr]], eval[start2[optr]]);
    }
}

int Fleast(int ptr, int v) {
    assert(v != 0);
    if (s[ptr] >= '0' && s[ptr] <= '9') {
        if (s[ptr] - '0' >= v) return ptr;
        return ptr + 1;
    }
    if (s[ptr] == '_') {
        return Fleast(start2[ptr], v);
    }
    if (s[ptr] == '^') {
        if (eval[start1[ptr]] >= v) return Fleast(start1[ptr], v); 
        return Fleast(start2[ptr], v);
    }
    assert(false);
}

int Fmost(int ptr, int v) {
    assert(v != 99);
    if (s[ptr] >= '0' && s[ptr] <= '9') {
        if (s[ptr] == '0') return ptr;
        if ((s[ptr] - '0') * 10 + 9 <= v) return ptr;
        return ptr + 1;
    }
    if (s[ptr] == '_') {
        if (eval[start1[ptr]] <= v) return Fmost(start1[ptr], v);
        return Fmost(start2[ptr], v);
    }
    if (s[ptr] == '^') {
        return Fmost(start2[ptr], v);
    }
    assert(false);
}

int F(int ptr) {
    if (s[ptr] >= '0' && s[ptr] <= '9') {
        if (s[ptr] == '0') return ptr;
        return ptr + 1;
    }
    if (s[ptr] == '_') {
        if (eval[start1[ptr]] == 0) return F(start1[ptr]);
        if (eval[start1[ptr]] > eval[start2[ptr]]) return F(start2[ptr]);
        return Fleast(start2[ptr], eval[start1[ptr]]);
    }
    if (s[ptr] == '^') {
        if (eval[start1[ptr]] == 99) return F(start1[ptr]);
        if (eval[start1[ptr]] < eval[start2[ptr]]) return F(start2[ptr]);
        return Fmost(start2[ptr], eval[start1[ptr]]);
    }
    assert(false);
}

/*int F(int ptr, BitSet big) {
    // TODO Neu hien nhien
    if (start1[ptr] == -1) {
        int x = s[ptr] - '0';
        if ((startWith[ptr] | big) == big) return ptr;
        return ptr + 1;
    }
    int res = F(start1[ptr], big);
    if (res == INF) {
    } else {
    }
}*/

void runTest() {
    cin >> s;
    n = s.size();
    { int ptr = 0; evaluate(ptr); assert(s[ptr] == '?'); }
    cout << eval[0] << ' ' << F(0) + 1 << '\n';
}

int main() {
#ifdef __DNK__
    assert(freopen("F.in", "r", stdin));
#endif
    ios::sync_with_stdio(false);
    int nt; cin >> nt;
    for (int i = 0; i < 100; ++i) {
        mask[i][i] = 1;
        int x = i;
        while (x >= 10) x /= 10;
        stw[x] |= mask[i];
    }
    for (int tc = 0; tc < nt; ++tc) {
        runTest();
    }
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())

div = make_divisors(N)
ans = 100

for d in div:
    a = d
    b = N // a
    ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)


Measured memory_bytes: 9104
#include "bits/stdc++.h"
using namespace std;

int my_re(int64_t x)
{
  if(x%26==0)
  {
    return 26;
  }
  else
  {
    return x%26;
  }
}

int main()
{
  int64_t n,p;
  cin>>n;
  p=n;
  vector<int64_t> a;
  while(p!=0)
  {
    a.push_back(my_re(p));
    p=(p-my_re(p))/26;
  }
  reverse(a.begin(),a.end());
  for(int i=0;i<a.size();i++)
  {
    a.at(i)+=96;
    cout<<(char)a.at(i);
  }
}

Measured memory_bytes: 3628
#include<iostream>
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) Rep(i,0,a)
using namespace std;
int main(){
	int tre[21][21],n,m,l,sum,x,y,re;
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	char c;
	while(cin>>n,n){
		sum=0;
		rep(i,21)
			rep(j,21)
				tre[i][j]=0;
		rep(i,n){
			cin>>x>>y;
			tre[y][x]=1;
		}
		cin>>m;
		x=10;
		y=10;
		rep(i,m){
			cin>>c>>l;
			if(c=='N')
			re=0;
			else if(c=='E')
			re=1;
			else if(c=='S')
			re=2;
			else if(c=='W')
			re=3;
			rep(j,l){
				x+=dx[re];
				y+=dy[re];
				if(tre[y][x]==1){
				tre[y][x]=0;
				sum++;
			}
			}
			
		}
		if(sum==n)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	
    double a,b,c=0;
    cin >> a;
  	for (int i = 1; i<=9; i++){
      b=a/i;
      if (b==1||b==2||b==3||b==4||b==5||b==6||b==7||b==8||b==9){
        cout << "Yes";
        c=1;
        break;}}
    if (c==0){cout << "No";}}
      

Measured memory_bytes: 3748
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans)


main()


Measured memory_bytes: 73672
#include <stdio.h>
int main(){
  long long int h, w;
  scanf("%lld%lld", &h , &w);
  if (h == 1 || w == 1) {
    puts("1");
    return 0;
  }
  long long int ans;
  if ((h * w) % 2 == 0) {
    ans = (h * w) / 2;
  } else {
      ans = (h * w + 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

void Solve(){
    int n, m;
    cin>>n>>m;
    vector<int> g[n];
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin>>v[i];
    while(m--){
        int u, v;
        cin>>u>>v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> vst(n);
    int res = 0;
    for(int i = 0; i < n; i++){
        if(vst[i]) continue;
        vst[i] = true;
        bool good = true;
        for(auto x: g[i]){
            if(v[x] >= v[i]) good = false;
            if(v[x] <= v[i]) vst[x] = true;
        }
        if(good) res++;
    }
    cout<<res<<endl;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    //cin>>T;
    while(T--){
        Solve();
    }
}

Measured memory_bytes: 8812
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

const ll MAX = (ll)1e14;

ll a[100009];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(n); ini(k);
	forn(i, 0, n) in(a[i]);
	ll ret = MAX;
	forn(i, 0, n-k+1) {
		ll p = a[i], q = a[i+k-1];
		//cout << p << ' ' << q << '\n';
		if (p < 0 && q < 0) ret = min(ret, max(abs(p), abs(q)));
		if (p >= 0 && q >= 0) ret = min(ret, max(p, q));
		else ret = min(ret, min(abs(p), abs(q))*2 + max(abs(p), abs(q)));
	}
	outn(ret);
	
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int n = c.length;
        int[] r = new int[n];
        int base = 1;
        r[n-1] = c[n-1] - '0';
        int mod = 2019;
        int[] rm = new int[mod];
        rm[0] = 1;
        rm[r[n-1]] = 1;
        for(int i=n-2; i>=0; i--) {
            base *= 10;
            base %= 2019;
            int num = c[i]-'0';
            r[i] = (r[i+1] + num * base) % mod;
            rm[r[i]]++;
        }

        long res = 0;
        for(int i=0; i<mod; i++) {
            res += (long)rm[i] * (rm[i]-1) / 2;
        }

        System.out.println(res);


    }



}

Measured memory_bytes: 41632
use std::io;
use std::cmp;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}



fn main() {
    let n = read_line().trim().parse::<usize>().expect("invalid");
    let xs:Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut ys = xs.clone();
    ys.sort();
    
    let m = ys[n/2];

    for i in 0..n {
        if xs[i] < m {
            println!("{}", m);
        } else {
            println!("{}", ys[n/2 -1]);
        }
    }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));
  for (int i = 0; i < s.length(); i++) {
    for (int j = 0; j < t.length(); j++) {
      dp[i + 1][j + 1] = max({dp[i][j + 1], dp[i + 1][j], dp[i][j] + (s[i] == t[j])});
    }
  }

  string ans = "";
  int p = t.length();
  for (int i = s.length() - 1; i >= 0; i--) {
    for (int j = p - 1; j >= 0; j--) {
      if (s[i] == t[j] and dp[i][j] + 1 == dp[i + 1][p]) {
        ans = s[i] + ans;
        p = j;
        break;
      }
    }
  }
  cout << ans << endl;
}


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

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

int main(){
	int n;
	string a,b;
	cin>>n;
	cin>>a>>b;
	for(int i=0;i<n;i++){
		cout<<a[i]<<b[i];
	}
	cout<<endl;
}

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

using namespace std;

int main() {
   char c;
   cin >> c;
   if(c == 'a' || c == 'i' || c == 'u'||c=='e'||c=='o'){
      cout<<"vowel";
   }else{
      cout<<"consonant";
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main () {
  int m, r, f;
  
  while (1) {
    cin >> m >> r >> f;
    if (m == -1 && r == -1 && f == -1) {
      break;
    } else if (m == -1 || r == -1 || m + r < 30) {
      cout << 'F';
    } else if (m + r >= 80) {
      cout << 'A';
    } else if (m + r >= 65) {
      cout << 'B';
    } else if (m + r >= 50) {
      cout << 'C';
    } else {
      if (f >= 50) {
	cout << 'C';
      } else {
	cout << 'D';
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main(){
  const int Nab= 26;
  int N;
  string str;
  cin >> N >> str;

  vector<set<int>> data(Nab);
  for(int i=0; i<N; i++){
    data.at(str.at(i)-'a').insert(i+1); // 1-indexed
  }

  int Q;
  cin >> Q;

  int query,buf1,buf2;
  char bufc;
  for(int i=0; i<Q; i++){
    cin >> query;
    if(query==1){
      cin >> buf1 >> bufc;
      for(int j=0; j<Nab; j++){
        data.at(j).erase(buf1);
      }
      data.at(bufc-'a').insert(buf1);
    }
    else{
      cin >> buf1 >> buf2;
      int ans= 0;
      for(int j=0; j<Nab; j++){
        auto itr1= data.at(j).lower_bound(buf1);
        auto itr2= data.at(j).upper_bound(buf2);
        if(distance(itr1,itr2) > 0){ ans++; }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24196
program Kstones;

const
  fi='kstone.inp';
  fo='kstone.out';

var
  a:array[1..100] of longint;
  f:array[0..100000] of 0..1;
  n,k: longint;

procedure nhap;
var i: longint;
begin

  readln(n,k);
  for i:=1 to n do read(a[i]);

end;

procedure xuli;
var i,j: longint;
begin

  fillchar(f,sizeof(f),0);

  for i:=1 to n do f[a[i]]:=1;

  for i:=1 to k do begin
    for j:=1 to n do begin
      if (i>a[j]) then begin
        if f[i-a[j]]=0 then f[i]:=1;
      end;
    end;
  end;

  if f[k]=0 then write('Second')
  else write('First');

end;

begin

  //assign(input,fi);     reset(input);
  //assign(output,fo);    rewrite(output);

  nhap;
  xuli;

  //close(input);         close(output);

end.


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;
typedef pair<int,int> P;
const int MAX_Q = 200005;
ll D[MAX_Q];
vector<tuple<ll,ll,ll> > event;
multiset<ll> X;

int main()
{
	int N,Q;
	cin >> N >> Q;
	rep(i,N)
	{
		ll s,t,x;
		cin >> s >> t >> x;
		event.push_back(make_tuple(s-x,1,x));
		event.push_back(make_tuple(t-x,-1,x));
	}
	sort(event.begin(), event.end());
	rep(i,Q)
	{
		cin >> D[i];
	}
	int idx = 0;
	rep(i,Q)
	{
		//cout << get<0>(event[idx]) << " " << get<1>(event[idx]) << " " << get<2>(event[idx]) << endl;
		while (idx < event.size() && get<0>(event[idx]) <= D[i])
		{
			if (get<1>(event[idx]) == 1)
			{
				X.insert(get<2>(event[idx]));
			}
			else
			{
				X.erase(X.find(get<2>(event[idx])));
			}
			idx++;
		}

		if (X.empty())
		{
			cout << "-1" << endl;
		}
		else
		{
			cout << *X.begin() << endl;
		}
	}
	return 0;
}

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

using namespace std;

const int N = 102, K = 100005;
int dp[K], a[N];
int n;

bool cal(int y) {
	if (y < a[0]) return 0;
	int &ret = dp[y];
	if (ret != -1) return ret;
	ret = 0;
	for (int i = 0; i < n; i++) {
		if (y - a[i] < 0) break;
		if (cal(y - a[i]) == 0) {
			ret = 1;
		}
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	int k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	printf(cal(k) ? "First" : "Second");
	return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char a;
    cin >> a;
    if (a <= 'Z')
        cout << 'A' << "\n";
    else
        cout << 'a' << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,K;
        cin>>N>>K;
        map<ll,ll> ma;
        for(ll i=0;i<K;i++)
        {
            ll a;
            cin>>a;
            for(ll j=0;j<a;j++)
            {
                ll b;
                cin>>b;
                ma[b]++;
            }
        }
        ll ans=0;
        for(ll i=1;i<=N;i++)
        {
            if(ma[i]==0)
                ans++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var a = Input().ToInt();
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			if(i % 2 == 0 && a[i]%2==1)
				wa++;
		}
		Console.WriteLine(wa);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27316
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, p = LI()
    def fact(x):
        res = 1
        for i in range(2, int(sqrt(x)) + 3):
            t = 0
            while x % i == 0:
                t += 1
                x //= i
            while t >= n:
                res *= i
                t -= n
        return res
    if n == 1:
        print(p)
        return
    print(fact(p))

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 h: integer;
 a: integer;
begin
 get(h);
 get(a);
 put((h+a-1)/a);
end hoge;

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

using namespace std;

int main() {
    int n;
    int a[100009];
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    a[n] = 1000000009;
    int past = 0;
    int p_c = 0;
    int res = 0;
    for(int i=0; i<=n; i++) {
        if(a[i]!=past) {
            if(p_c>=past) 
                res += p_c - past;
            else
                res += p_c;
            past = a[i];
            p_c = 0;
        }
        p_c++;
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a;
    cin>>b;
    
    if(a<b){
        cout<<"a < b";
    }else if(a>b){
        cout<<"a > b";
    }else{
        cout<<"a == b";
    }
    cout << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int n,x;
    while(cin>>n>>x)
    {
        
        if(n==0)break;
        int sum=0;
        rep(i,1,n+1)
        {
            rep(j,i+1,n+1)
            {
                rep(k,j+1,n+1)
                {
                    if(i+j+k==x)sum++;
                }
            }
        }
        cout<<sum<<endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

vector<bool> eratosthenes(int n) {
	vector<bool> is_prime(n + 1);
	rep(i, 0, n + 1) is_prime[i] = true;
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return is_prime;
}

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

	vector<bool> is_prime = eratosthenes(1e5);

	int d[100001];
	memset(d, 0, sizeof(d));
	rep(i, 1, 1e5 + 1) {
		if(i % 2 != 0) {
			if(is_prime[i] and is_prime[(i + 1) / 2]) d[i] = d[i - 1] + 1;
			else d[i] = d[i - 1];
		} else d[i] = d[i - 1];
	}

	int Q;
	cin >> Q;
	vector<int> rsl;
	rep(i, 0, Q) {
		int l, r;
		cin >> l >> r;
		if(l % 2 != 0) {
			if(is_prime[l] and is_prime[(l + 1) / 2]) rsl.push_back(d[r] - d[l] + 1);
			else rsl.push_back(d[r] - d[l]);
		} else rsl.push_back(d[r] - d[l]);
	}

	rep(i, 0, Q) cout << rsl[i] << endl;
}


Measured memory_bytes: 1528
/*
17D8101013F 森田　匡博
ALDS5_B.cpp 2019/10/24
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>
#define INFTY 999999999

long long int n, sum;

void merge(long long int *A, int left, int mid, int right) 
{
  int n1, n2;
  n1 = mid - left;
  n2 = right - mid;
  
  long long int L[n1+1], R[n2+1];
  for(int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for(int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  int s, t;
  s = 0; t = 0;
  for(int i = left; i < right; i++) {
    if(L[s] <= R[t]) {
      A[i] = L[s];
      s++;
    }
    else {
      A[i] = R[t];
      t++;
      sum += n1 - s;
    }
  }
}

void mergeSort(long long int A[], int left, int right) 
{
  if(left + 1 < right) {
    int mid = (int)((left + right) / 2);
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  long long int A[n];
  for(int i = 0; i < n; i++) {
    std::cin >> A[i];
  }
  sum = 0;
  mergeSort(A, 0, n);

  std::cout << sum << "\n";
}




Measured memory_bytes: 6216
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;
int main(){
	ll N; cin >> N;
	vector<ll> a(N); for(int i = 0; i < N; ++i) cin >> a[i];

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

	map<int, int> c;
	for(int i = 0; i < N; ++i){
		c[a[i]] += 1;
	}

	if(c.size() == 1) {
		if(c[0] > 0) { cout << "Yes" << endl; return 0; }
		else { cout << "No" << endl; return 0; }
	}

	if(a.size() % 3 != 0) { cout << "No" << endl; return 0; }
	if(c.size() > 3) { cout << "No" << endl; return 0; }

	vector<int> tmp;
	for(auto itr = c.begin(); itr != c.end(); ++itr){
		tmp.push_back(itr->first);
	}

	if(c.size() == 2){
		if(c[0] > 0 && c[0]*2 == c[tmp[1]]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else if(c.size() == 3) {
		if((tmp[0] ^ tmp[1]) == tmp[2]){
			if(c[tmp[0]] == c[tmp[1]] && c[tmp[1]] == c[tmp[2]])
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4480
import itertools

nums = [int(e) for e in input().split()]

list0 = []
A = []
A0 = list(range(0,nums[0]))
for i in range(0, nums[0]):
    val = [int(e) for e in input().split()]
    list0.append(val)
    for x in itertools.combinations(A0,i+1):
        A.append(list(x))

Z = [0]
for i in range(1,nums[1]+1):
    Z.append(nums[2])

X = []
for i in range(0,len(A)):
    Y = [0] * (nums[1]+1)
    for j in range(0,len(A[i])):
        Y = [x + y for (x, y) in zip(Y,list0[A[i][j]])]
    W = [x - y for (x, y) in zip(Y,Z)]
    if min(W) >= 0:
        X.append(Y[0])

if len(X) > 0:
    print(min(X))
else:
    print('-1')

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  ll ans=0;
  for(auto e:m){
    if(e.second%2) ans++;
  }
  cout<<ans<<endl;
}

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


int main(){
  int H,W;
  cin >> H >> W;
  
  char board[52][52];
  //範囲外の条件分岐がめんどくさいので上下左右に１マス余裕をもって入力しておく。
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++)cin >> board[i][j];
  }
  
  //問題文を言い換えると、上下左右どこにも隣接したマスがない部分があったらNoを出力ということになる
  for(int i = 1; i<= H; i++){
    for(int j = 1; j <= W; j++){
      if(board[i][j] == '#'){
        if(board[i-1][j] != '#' && board[i][j-1] != '#' && board[i][j+1] != '#' && board[i+1][j]!= '#' ){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define PB push_back
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int powmod(int n, int x, int mod){
  if (x == 0){
    return 1;
  } else {
    int tmp = powmod(n, x / 2, mod);
    tmp = (ll) tmp * tmp % mod;
    if (x % 2 == 1){tmp = (ll) tmp * n % mod;}
    return tmp;
  }
}

int invmod(int n, int p){
  assert(0 < n % p);
  return powmod(n, p - 2, p);
}

static const int MOD = 1000000007;

int main(){
  INT(n); VI(as, n);
  vector<int> ans;
  set<int> s;
  int dup = 1, dl = -1, dr = -1;
  map<int, vector<unsigned int>> mp;
  vector<unsigned int> fact, factinv;
  ull tmp;
  tmp = 1;
  REP(i, 1, n + 2){
    fact.PB(tmp);
    factinv.PB(invmod(tmp, MOD));
    tmp *= i;
    tmp %= MOD;
  }
  FOR(it, as){
    if (s.count(*it)){
      dup = *it;
    } else {
      s.insert(*it);
    }
  }
  REP(i, n + 1){
    if (as[i] == dup){
      if (dl < 0){
        dl = i;
      } else {
        dr = i;
      }
    }
  }
  auto cmod = [&](int n, int r)->unsigned int{
    if (n == 0 || r < 0 || n < r){return 0;}
    ull tmp = fact[n];
    tmp = tmp * factinv[n - r] % MOD;
    tmp = tmp * factinv[r] % MOD;
    return (unsigned int) tmp;
  };
  REP(i, 1, n + 2){
    if (i == 1){
      printf("%d\n", n);
    } else if (i == n + 1){
      printf("%d\n", 1);
    }  else {
      unsigned int cnt = cmod(n - 1, i);
      cnt %= MOD;
      cnt += cmod(n - 1, i - 2);
      cnt %= MOD;
      cnt += cmod(n - 1, i - 1);
      cnt %= MOD;
      cnt += cmod(n - 1, i - 1);
      cnt %= MOD;
      cnt += MOD - cmod(n + dl - dr, i - 1);
      cnt %= MOD;
      printf("%d\n", cnt);
    }
  }
  return 0;
}

Measured memory_bytes: 7028
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
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()))

n = I()
a = LI()
m = a[0]
ans = 0
for i in range(1, n):
    if a[i] <= m:
        ans += m - a[i]
    else:
        m = a[i]
print(ans)

Measured memory_bytes: 92212
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  int ans = 0;
  if (n < 10) {
    ans = r + 100 * ( 10 - n );
  } else {
    ans = r;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = gcd(a[0],a[1]);
		for(int i = 2; i < n; i++) {
			ans = gcd(ans,a[i]);
		}
		System.out.println(ans);
	 }
	 private static int gcd(int m, int n) {
		 if(m<n) return gcd(n,m);
		 if(n==0)return m;
		 return gcd(n,m%n);
	 }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for(int i = 0; i < N; ++i) cin >> V[i];
  long long ans = 0;
  for(int i = 0; i <= min(K,N); ++i){//取り出す回数の合計
    for(int j = 0; j <= i; ++j){//左から取り出す回数
      vector<int> tmp;
      for(int k = 0; k < j; ++k){
        tmp.push_back(V[k]);
      }
      for(int k = 0; k < i-j; ++k){
        tmp.push_back(V[N-1-k]);
      }
      long long s = 0;
      sort(tmp.begin(), tmp.end());
      for(int k = 0; k < K-i; ++k)
        if(k < (int)tmp.size() and tmp[k] > 0) s += tmp[k];
      for(int k = K-i; k < i; ++k){
        s += tmp[k];
      }
      ans = max(ans,s);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ; 
using namespace std;
ll dp[100006][13];
ll arr[100006];
void p()
{
    arr[0]=1LL;
    for(int i=1;i<1000006;i++) arr[i]= (arr[i-1]*10)% 13;
}
int main()
{
    string s;
    cin>>s;
    p();
    dp[0][0]=1;
    for(int i=1;i<13;i++) dp[0][i]=0;
    for(int i=1;i<=s.size();i++){
        int idx= s.size()-i;
        for(int k=0;k<13;k++){
            if(s[idx]=='?') {
                ll cnt=0;
                for(int j=0;j<10;j++){
                    
                    ll val= j*arr[i-1];
                    val%=13;
                    cnt+=dp[i-1][(k-val+13)%13];
                    cnt%=mod;
                }
                dp[i][k]=cnt;
                dp[i][k]%=mod;
            }
            else{
                int j=s[idx]-'0';
                ll val= j*arr[i-1]; val%=13;
                // cout<<val<<endl;
                dp[i][k]=dp[i-1][(k-val+13)%13];
                dp[i][k]%=mod;
            }
        }
    }
    // for(int i=0;i<=s.size();i++){
    //     for(int j=0;j<13;j++) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[s.size()][5]%mod<<endl;
    
    
    
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> res(0);
  while (N > 0)
  {
    res.push_back(N % K);
    N /= K;
  }
  cout << res.size() << endl;
}


Measured memory_bytes: 256
#Tenka1_C
N = int(input())
def solve(h, n):
    x = N * h * n
    y = 4 * h * n - N * (n + h)
    if y <= 0:
        return -1
    if x % y == 0:
        return x // y
    else:
        return -1
    
flg = False
for h in range(1, 3501):
    if flg: break
    for n in range(1, 3501):
        if flg: break
        if solve(h, n) != -1:
            print(h, n, solve(h, n))
            flg = True

Measured memory_bytes: 41196
N, M =  [int(_) for _ in input().split()]

inputList = [[int(_) for _ in input().split()] for _ in range(M)]
abList = sorted(inputList, key=lambda x:x[1])

bridge = 0
ans = 0

for ab in abList:
  if not ab[0] <= bridge < ab[1]: # 3 <=0 <   5 //  4 <= 4 < 6 //  2 <= 4 7 // 7 <= 4 < 9
    bridge = ab[1] -1             # 4           //  pass                    // bridge = 8
    ans += 1                      # 1           //  pass                    // +1

print(ans)

Measured memory_bytes: 23704
#include <iostream>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;
vector<int> ve[100001];
int pre[100001];


int find(int x)
{
    int r=x;
    while(r!=pre[r])
    {
        r=pre[r];
    }
    int p=x;
    while(p!=r)
    {
        int k=pre[p];
        pre[p]=r;
        p=k;
    }
    return r;
}

int main()
{

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        pre[i]=i;

    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        int x1=find(x);
        // printf("n\n");
        int y1=find(y);

        if(x1!=y1)
        {
            pre[x1]=y1;
        }

    }

   int cnt=0;

    for(int i=1;i<=n;i++)
    {
       if(pre[i]==i)
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}












Measured memory_bytes: 2944