akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 2e5+2;
const int MOD = 1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

int N,K;
int A[501];
int R[501];
int ans;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    int s = 0;
    for (int i = 0; i < N; i++) s += A[i];
    vector<int> factors;
    for (int i = 1; i*i <= s; i++) {
        if (s%i == 0) {
            factors.pb(i);
            if (i*i < s) factors.pb(s/i);
        }
    }

    int mx = *max_element(A,A+N);
    for (int x: factors) {
        for (int i = 0; i < N; i++) {
            R[i] = A[i]%x;
        }
        sort(R,R+N);

        int i;
        for (i = 0; i < N && !R[i]; i++);
        if (i == N) ans = max(ans, x);
        else {
            int j = N-1;
            int c = 0;
            int remain = K;
            while (i < j && remain) {
                int mn = min(R[i], x-R[j]);
                mn = min(mn, remain);
                remain -= mn;
                R[i] -= mn;
                if (R[i] == 0) i++;
                R[j] = (R[j]+mn) % x;
                if (R[j] == 0) j--;
            }

            if (i > j) ans = max(ans, x);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, N; cin >> A >> B >> N;
    ll ans = 1LL<<60;
    for(int i = 1; i <= N; i++)
    {
        if(B % i) continue;
        for(int j = 1; j <= N; j++) ans = min(ans, abs(A - B / i * j));
    }
    cout << ans << endl;
    return 0;
}




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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    
    if(a[0]>=1){
        if(n==0&&a[0]==1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    
    ll now=0,now2=1,now3=1,ans=n+1;
    bool flag=true;
    
    for(ll i=1;i<n+1;i++){
        ll nokori=a[i];
        if(i==n) nokori--;
        if(nokori==0) continue;
        while(nokori){
            if(now2!=0){
                if(nokori<=now2){
                    //cout << 'a';
                    now2=now2-nokori;
                    ans+=nokori*(i-now);
                    nokori=0;
                }else{
                    nokori=nokori-now2;
                    ans+=now2*(i-now);
                    now2=0;
                }
            }else{
                now++;
                if(now==i){
                    flag=false;
                    break;
                }
                now3=now3*2-a[now];
                now2=now3;
            }
        }
        if(now==i) break;
    }
    
    
    if(!flag) cout << "-1" << endl;
    else cout << ans << endl;
    
    return 0;
}











Measured memory_bytes: 4004
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 
int index = L[m][n]; 
char lcs[index+1]; 
lcs[index] = '\0'; 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout <<lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
	string X,Y;cin>>X>>Y;
int m = X.size(); 
int n = Y.size(); 
lcs(X, Y, m, n); 
return 0; 
} 


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int nums [n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            int a;
            cin>>a;
            nums[i][j] = a;
        }

    }
    int dp [n][3];
    dp[0][0] = nums[0][0];
    dp[0][1] = nums[0][1];
    dp[0][2] = nums[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            int max_happiness = 0;
            for(int k=0;k<3;k++){
                if(k==j){
                    continue;
                }
                max_happiness = max(max_happiness,dp[i-1][k]);
            }
            dp[i][j] = max_happiness + nums[i][j];
        }
    }
    int total_happiness = 0;
    for(int j=0;j<3;j++){
        total_happiness = max(total_happiness,dp[n-1][j]);
    }
    cout<<total_happiness;
    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cout<<nums[i][j]<<" ";
}
        cout<<""<<endl;
    }
    */
}


Measured memory_bytes: 5960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int>A(N+1);
  for(int i=1; i<N+1; i++){
    cin >> A.at(i);
  }
   vector<int>Ans(N+1);
  for(int i=1; i<N+1; i++){
    Ans.at(A.at(i))=i;
  }
  
  
  for(int i=1; i<N+1; i++){
    cout << Ans.at(i) << ' ' ;
  }
  
}


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

long long n, a, b, res;

int main(){
    cin >> n >> a >> b;
    if ((b-a)%2==0){
        res = (b-a)/2;
    } else {
        if (a-1<n-b) {
            res = a-1 + (b-a-1)/2 +1;
        } else {
            res = n-b + (b-a-1)/2 +1;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int a,b,c;
        cin >> a >> b >> c;
        int sum = max(max(a,b),c)*10;
                if(sum/10==a) sum+=b+c;
                if(sum/10==b) sum+=a+c;
                if(sum/10==c) sum+=a+b;
        cout << sum << endl;
}

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 k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int sumX = 0;
        int sumY = 0;
        if(k > n){
            for(int i = 0;i < n;i++){
                sumX = sumX + x;
            }
        }
        else{
            for(int i = 0;i < k;i++){
                sumX = sumX + x;
            }
            for(int j = k;j < n;j++){
                sumY = sumY + y;
            }
        }
        System.out.println(sumX+sumY);
    }
}


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

vector<string> ansv;
int n;

void dfs(string str, int cur){
    if(cur == n) {
        ansv.push_back(str);
        return;
    }
    cur++;
    char last = 'a';
    for(char c : str){
        last = max(last, c);
        dfs(str+c, cur);
    }
    last+=1;
    dfs(str+last, cur);
}
void dfs2(string s, char c) {
    if(s.length()==n) ansv.push_back(s);
    else{
        for(char cc = 'a'; cc<=c; cc++){
            dfs2(s+cc, (cc==c ? (char)(c+1) : c));
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    dfs2("", 'a');
    sort(ansv.begin(), ansv.end());
    for(auto a : ansv){
        cout << a <<endl;
    }

}

Measured memory_bytes: 7796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

const int N = 100010;
vector<vector<int>> graph(N, vector<int>());
vector<int> cnt(N);
vector<bool> white(N);
string s;

void dfs1(int n, int p) {
	for (int i : graph[n]) {
		if (i == p) continue;
		dfs1(i, n);
		if (white[i]) cnt[n]++;
	}
	if (cnt[n] || s[n] == 'W') white[n] = true;
}

vector<int> dis(N), check(N);

void dfs2(int n, int p, int d) {
	dis[n] = d;
	for (int i : graph[n]) {
		if (i == p) continue;
		dfs2(i, n, d + check[i]);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	cin >> s;
	int w = -1;
	rep(i, n) if (s[i] == 'W') w = i;
	if (w == -1) {
		cout << "0\n";
		return 0;
	}
	dfs1(w, -1);
	ll ans = 0;
	rep(i, n) {
		if (i == w && cnt[i]) cnt[i]--;
		if (s[i] == 'W' && cnt[i] % 2 == 0) cnt[i]++;
		else if (s[i] == 'B' && cnt[i] % 2 == 1) cnt[i]++;
		else if (cnt[i]) {
			check[i] = 1;  ans += 2;
		}
		ans += cnt[i];
	}
	dfs2(0, -1, check[0]);
	int tmp = -1, ver = -1;
	rep(i, n) if (chmax(tmp, dis[i])) ver = i;
	dfs2(ver, -1, check[ver]);
	int ma = 0;
	rep(i, n) chmax(ma, dis[i]);
	ans -= 2 * ma;
	cout << ans << '\n';
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
    
  if (N*A > B) {
    cout << B << endl;
  }
  else if (N*A <= B){
    cout << N*A << endl;
  }
  // ここにプログラムを追記
}

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

int main(){
	int N, i;
	double ans = 0;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		double x;
		string y;
		scanf("%lf", &x);
		cin >> y;
		if(y[0] == 'J'){
			ans += x;
		}
		else{
			ans += 380000 * x;
		}
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll digit(ll n){
	 ll ans = log10(n)+1;
	 return ans;
}
int main(){
	//mahakal(),fast;
	ll n ;
	cin>> n ;
	ll ans=0;
	for(ll i=1;i<=n ;i++){
		if(digit(i)&1)ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
const int inf = (int) 1e9;

int h, w, sy, sx, gy, gx;
string in[100];
set<pair<vi, int> > s;

int p[200], sz[200], size[200], dist[200][200];
int root(int x){ return x == p[x] ? x : (p[x] = root(p[x])); }

int main(){
	
	while(cin >> w >> h, w){
		rep(i, h){
			cin >> in[i];
			rep(j, w){
				if(in[i][j] == 'S') sy = i, sx = j;
				if(in[i][j] == 'G') gy = i, gx = j;
			}
		}
		
		rep(i, 200) p[i] = i, sz[i] = 1;
		rep(i, 200) rep(j, 200) dist[i][j] = inf;
		rep(i, h) rep(j, w) if(in[i][j] != '#'){
			rep(d, 4){
				int y = i + dy[d], x = j + dx[d];
				if(y < 0 || y >= h || x < 0 || x >= w) continue;
				if(in[y][x] != '#'){
					dist[i * w + j][y * w + x] = 1;
				}
			}
		}
		rep(k, 200) rep(i, 200) rep(j, 200)
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		
		rep(i, h) rep(j, w) if(in[i][j] == 'X'){
			rep(d, 4){
				int y = i + dy[d], x = j + dx[d];
				if(y < 0 || y >= h || x < 0 || x >= w) continue;
				if(in[y][x] == 'X'){
					int a = root(y * w + x), b = root(i * w + j);
					if(a != b) p[b] = a, sz[a] += sz[b];
				}
			}
		}
		map<int, int> of;
		rep(i, h) rep(j, w) if(in[i][j] == 'X'){
			of[root(i * w + j)] = 0;
		}
		int k = 0;
		each(i, of){
			i->second = k++;
			size[i->second] = sz[i->first];
		}
		
		vi v(k);
		s.clear();
		priority_queue<pair<pi, pair<vi, int> > > q;
		
		q.push(mp(mp(-dist[gy * w + gx][sy * w + sx], 0), mp(v, sy * w + sx)));
		
		while(!q.empty()){
			int y = q.top().second.second / w, x = q.top().second.second % w;
			int c = q.top().first.second;
			v = q.top().second.first;
			q.pop();
			
			if(s.count(mp(v, y * w + x))) continue;
			s.insert(mp(v, y * w + x));
			
			if(in[y][x] == 'G'){
				cout << -c << endl;
				break;
			}
			
			rep(d, 4){
				int ny = y + dy[d], nx = x + dx[d];
				if(ny < 0 || ny >= h || nx < 0 || nx >= w || in[ny][nx] == '#') continue;
				vi nv = v;
				if(in[ny][nx] == 'X'){
					int t = of[root(ny * w + nx)];
					nv[t]++;
					if(2 * nv[t] > size[t]) continue;
				}
				q.push(mp(mp(-dist[gy * w + gx][ny * w + nx] + c, c - 1), mp(nv, ny * w + nx)));
			}
		}
	}
}

Measured memory_bytes: 19812
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;

int main() {
	int A;
	cin >> A;
	if (A == 1)cout << fixed <<setprecision(8)<< (double)A << endl;
	else if((A%2)==0)cout << fixed << setprecision(8) << (double)1/2 << endl;
	else cout << fixed << setprecision(8) << (double)((int)(A / 2)+1)/A << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
# 奇数の時と偶数の時、奇数の場合は真ん中を選ぶかどうか
INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if N - index + 1 < 2 * n:
        return -INF
    if N - index - 2 > 2 * n:
        return -INF
    if n == 0:
        return 0
    elif n == 1:
        return max(A[index:])
    ret = max(A[index] + F(index+2, n-1), F(index+1, n))
    return ret

answer = F(0, N//2)
print(answer)


Measured memory_bytes: 173512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int dfs(vector<string> &vs, int line, int depth=0) {
    if((int)vs.size() <= line) return -1;
    if((int)vs[line].size() <= depth) return -1;
    char c = vs[line][depth];
    if(isdigit(c)) return c - '0';
    int ret = -2;
    if(c == '+') {
        int temp; ret = 0;
        while((temp = dfs(vs, ++line, depth+1)) != -1) {
            if(temp >= 0) ret += temp;
        }
    }
    if(c == '*') {
        int temp; ret = 1;
        while((temp = dfs(vs, ++line, depth+1)) != -1) {
            if(temp >= 0) ret *= temp;
        }
    }
    // printf("line = %lld, value = %lld\n", line, ret);
    return ret;
}

signed main() {
    int n;
    while(cin >> n, n) {
        vector<string> vs(n);
        rep(i,0,n) cin >> vs[i];
        int line = 0;
        cout << dfs(vs, line) << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz(c)             (ll)c.size()
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define F                 first
#define S                 second
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define deb(x) cout << #x << " " << x << endl
#define inf INT_MAX
const ll N = 200010;
const ll MOD = 998244353;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}

void solve(){
    ll n, m;
    cin >> n >> m;
    if(n > m) cout << "safe\n";
    else cout << "unsafe\n";
}

int main(){
    //fin fout
    fast
    ll T = 1; //cin >> T;
    loop(i, 0, T) solve();
}


Measured memory_bytes: 3636
S = [int(i) for i in str(input())]
K = int(input())

k = 1
for i in range(len(S)):
    if S[i] == 1:
        if k < K:
            k += 1
            continue
        else:
            print(1)
            exit()
    else:
        print(S[i])
        exit()

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

int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (s.count(x)) s.erase(x);
    else s.insert(x);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long ExtGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (ExtGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static private long ModInverseInner(long a, long dummy1 = 0, long dummy2 = 0) => ExtGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);
    static public long ModInverse(long a) => ModInverseInner(a, 0, 0);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();
        var waterList = Console.ReadLine().ToLongArray();
        
        var ansList = new long[N];

        long y0 = 0;
        //山0に降った量を求める。
        for (int i = 0; i < N; i++)
        {
            y0 += (i % 2 == 0) ? waterList[i] : -waterList[i];
        }
        ansList[0] = y0;
        

        //山0に降った量が求まったら、残りは連鎖的に求まる。
        for (int i = 1; i < N; i++)
        {
            ansList[i] = waterList[(i - 1 + N) % N] * 2 - ansList[(i - 1 + N) % N];
        }

        Console.WriteLine(string.Join(" ", ansList));
    }
    
}

Measured memory_bytes: 33116
# 2020/01/22
# AtCoder Beginner Contest 063 - C

# Input and Sum
n = int(input())
s_list = list()
s_sum = 0
for i in range(n):
    s = int(input())
    s_list.append(s)
    s_sum = s_sum + s

# Sort
s_list.sort()

# Calc
i = 0
while s_sum > 0 and s_sum % 10 == 0:
    if s_list[i] % 10 != 0:
        s_sum = s_sum - s_list[i]
    i = i + 1
    if i >= n:
        s_sum = 0

ans = s_sum

# Output
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int r = sc.nextInt();
      int g = sc.nextInt();
      int b = sc.nextInt();
      int total = r*100 + g*10 + b;
      if(total % 4 == 0) {
    	  System.out.println("YES");
    	  
      } else {
    	  System.out.println("NO");
      }
     
        
       
    }
 }

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;

int main(){
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=a;i<=maxn;i+=a){
		if(i%b==c){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

s = x / a

if s >= a*b / 2:
    y = 2 * b - 2 * x / a / a
    print(math.degrees(math.atan2(y, a)))
else:
    y = 2 * x / (a * b)
    print(math.degrees(math.atan2(b, y)))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
#define MAX 210000
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;

bool x(int a) {
	int t = a;
	int b = t % 10;
	t /= 10;
//	cout << b << " ";
	while (t) {
		int c = t % 10;
	//	cout << c << " ";
		if (c != b) {
			return false;
		}
		t /= 10;
	}
	return true;
}



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = n; i <= 999; i++) {
		if (x(i)) {
			cout << i;
			return 0;
		}
		//cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int A = Character.getNumericValue(s.charAt(0));
    int B = Character.getNumericValue(s.charAt(1));
    int C = Character.getNumericValue(s.charAt(2));
    int D = Character.getNumericValue(s.charAt(3));
    if(A+B+C+D==7){
      System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
    }else if(A-B+C+D==7){
      System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
    }else if(A+B-C+D==7){
      System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
    }else if(A+B+C-D==7){
      System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
    }else if(A-B-C+D==7){
      System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
    }else if(A-B+C-D==7){
      System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
    }else if(A+B-C-D==7){
      System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
    }else if(A-B-C-D==7){
      System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");
    }
  }
}


Measured memory_bytes: 39472
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    if (S == U) {
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }
}

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

using namespace std;

int main() {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<long long int> a;
    vector<long long int> b;
    char flag = '1';
    if (s[0] != '1') {
        a.push_back(0);
        flag = '0';
    } 
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == flag) {
            count++;
        } else {
            if (flag == '0') {
                b.push_back(count);
                flag = '1';
                count = 1;
            } else {
                a.push_back(count);
                flag = '0';
                count = 1;
            }
        }
    }

    if (flag == '0') {
        b.push_back(count);
    } else {
        a.push_back(count);
    }
    long long int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        long long int kans = 0;
        for (int j = 0; j <= k; j++) {
            if (i+j < a.size()) {
                kans += a[i+j];
            }
        }
        for (int j = 0; j < k; j++) {
            if (i+j < b.size()) {
                kans += b[i+j];
            }
        }
        ans = max(ans, kans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
//#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int & 
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a) {
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int N = 2007;

int parent[N];
int fake_sz[N];
int sz[N];
bool am[N];

void make_set(int v) {
	assert(!am[v]);
	am[v] = 1;
	parent[v] = v;
	sz[v] = 1;
}

int find_set(int v) {
	if (parent[v] == v) return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a == b) return;
	if (sz[a] < sz[b]) swap(a, b);
	sz[a] += sz[b];
	parent[b] = a;
}

int n, k, q;
const ll oo = 1e15;
vi a;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> k >> q;
	set<int> st;
	a.resize(n);
	fori(i, n) {
		cin >> a[i];
		st.insert(-a[i]);
	}
	ll ans = oo;
	for (auto x : st) {
		int cur = -x;
		fori(i, n) {
			if (a[i] == cur) {
				make_set(i);
				if (i && am[i - 1]) union_sets(i - 1, i);
				if (i != n - 1 && am[i + 1]) union_sets(i, i + 1);
			}
		}
		vector<pii> b(n);
		fori(i, n)
			b[i] = mp(a[i], i);
		sort(ALL(b));
		fori(i, n)
			fake_sz[i] = sz[i];
		ll low = cur;
		ll rest = q;
		ll hi;
		for (auto p : b) {
			if (!rest) break;
			int set_ind = find_set(p.second);
			if (p.first >= cur && fake_sz[set_ind] >= k) {
				--fake_sz[set_ind];
				--rest;
				hi = p.first;
			}
		}
		if (!rest) mmin(ans, hi - low);
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,l;
    cin>>n>>l;
    vi v(n);
    int s=0;
    rep(i,n)s+=l+i;
    int m=inf;
    int ans=0;
    rep(i,n){
        int a=l+i;
        int p=s-a;
        if(m>abs(s-p))m=abs(s-p),ans=p;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int X;
  cin >> X;
  int ans = 0;
  ans += X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long A;
  double B;
  cin >> A >> B;
//  long long B_100 = (long long)(B*100); // This is wrong. It needs EPS.
  long long B_100 = (long long)(B*100 + 0.00001);
  cout << A * B_100 / 100 <<endl;
  
}

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

using namespace std;

int main() {

  int a, b;
  int p;
  cin >> a >> b;

  p = (a * b) % 2;

  if(p == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return(0);
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    long n, x[110], y[110], sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }
    for(int i = 0; i < n; i++){
        sum1 += pow(abs(x[i]-y[i]), 1);
        sum2 += pow(abs(x[i]-y[i]), 2);
        sum3 += pow(abs(x[i]-y[i]), 3);
        sum4 =  max(sum4, abs(x[i]-y[i]));
    }
    cout <<fixed;
    cout << setprecision(7) << pow(sum1, 1) << endl;
    cout << setprecision(7) << pow(sum2, 1.0/2) << endl;
    cout << setprecision(7) << pow(sum3, 1.0/3) << endl;
    cout << setprecision(7) << double (sum4) << endl;
    
    return 0;
}



Measured memory_bytes: 3400
void main()
{
    long n = rdElem;

    long cnt;
    long bra, ket;
    Pair[] pair;

    void calc(long x, long y)
    {
        long u = x - y, v = -y;
        pair ~= Pair(u, v);
    }

    foreach (i; 0 .. n)
    {
        string s = rdStr;

        long num, m;
        foreach (x; s)
        {
            num += (x == '(' ? 1 : -1);
            m = min(m, num);
        }

        cnt += num;
        if (num > 0)
        {
            if (m >= 0) bra += num;
            else calc(num, m);
        }
        else if (num < 0)
        {
            if (num == m) ket -= num;
            else calc(num, m);
        }
        else
        {
            if (m < 0) calc(num, m);
        }
    }

    pair.sort!"a.a - a.b > b.a - b.b";
    foreach (p; pair)
    {
        if (bra < p.b)
        {
            "No".writeln;
            return;
        }
        bra += p.a - p.b;
    }

    writeln(bra == ket ? "Yes" : "No");
}

struct Pair
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1]+=32;

    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int w,h,n; cin >> w >> h >> n;
  int ws=0,wb=w,hs=0,hb=h;
  int x,y,a;
  for(int i=0;i<n;i++){
    cin >> x >> y >> a;
  	if(a==1){
      if(ws<x) ws=x;
    }
  	else if(a==2){
      if(x<wb) wb=x;
    }
  	else if(a==3){
      if(hs<y) hs=y;
    }
  	else if(a==4){
      if(y<hb) hb=y;
    }
  }
  int W=wb-ws; if(W<0) W=0;
  int H=hb-hs; if(H<0) H=0;
  cout << W*H << endl;
  return 0;
}

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub 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(){
	ll sum=0,n,m;cin>>n>>m;
	vector<ll> a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(all(a));
	queue<ll> q;
	for(ll i=0;i<n;i++){
		q.push(a[i]);
	}
	vector<pair<ll,ll>> v;
	for(ll i=0;i<m;i++){
		ll x,y;cin>>x>>y;
		v.pb({y,x});
	}
	sort(all(v));
	reverse(all(v));
	for(ll i=0;i<m;i++){
		ll x=v[i].S,y=v[i].F;
		while(x>0){
			x--;
			if(q.size()>0){
				if(q.front()<y){
					q.pop();
					sum+=y;
				}
				else break;
			}
			else break;
		}
	}
	while(q.size()>0){
		sum+=q.front();
		q.pop();
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 4088
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int e;
    while(scanf("%d", &e), e != 0){
        int ans = e;
        int k;
        for(int z = 0; (k = e - z * z * z) >= 0; ++z){
            int y = (int)(sqrt(k));
            int x = k - y * y;
            ans = min(ans, x + y + z);
        }
        printf("%d\n", ans);
    }
}

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


int main(void) {
    int n;
    scanf("%d", &n);
    int a[n+1];
    for(int i=1; i<n+1; i++) {
        scanf("%d", &a[i]);
    }
    int memo=1;
    int counter=0;
    int result;
    while(true) {
        memo = a[memo];
        counter++;
        if(memo == 2) {
            result = counter;
            break;
        }
        if(counter >= n) {
            result = -1;
            break;
        }
    }
    printf("%d", result);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

int main(){
  int N, M;
  cin >> N >> M;
  char A[N][N];
  char B[M][M];
  rep(i, N)rep(j, N)cin >> A[i][j];
  rep(i, M)rep(j, M)cin >> B[i][j];
  bool ans = false;
  rep(i, max(N-M, 1)){
    rep(j, max(N-M, 1)){
      bool temp_flag = true;
      rep(k, M){
        rep(l, M){
          if (A[i+k][j+l] != B[k][l]){
            temp_flag = false;
          }
        }
      }
      if (temp_flag)ans = true;
    }
  }
  if (ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split(" ")]

from itertools import combinations

mod = 1000000007  # 丁度いい大きさの素数だけで意味は特にない。

s = 0
ans = 0
for n in A:
    s += n
    s %= mod

for i in range(N):
    s -= A[i]
    ans += A[i] * s
    ans %= mod

print(ans)

Measured memory_bytes: 31564
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        S : chars
    }
    // 0スタートのコスト
    let (mut cost_0, mut cost_1) = (0usize, 0usize);
    let mut i = 0usize;
    for s in S {
        if 0 == i % 2 {
            if s == '1' {cost_0 += 1;}
            else {cost_1 += 1}
        } else {
            if s == '1' {cost_1 += 1;}
            else {cost_0 += 1}
        }
        i += 1;
    }
    println!("{}", min(cost_0, cost_1));
}


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

int main(void) {
    int N;
    long L_i;
    cin >> N;

    long L_i_2 = 2, L_i_1 = 1;

    if (N == 1) {
        cout << L_i_1 << endl;
    }
    else {
        for (int i = 2; i <= N; i++) {
            L_i = L_i_1 + L_i_2;
            L_i_2 = L_i_1; L_i_1 = L_i;  // 更新
        }
        cout << L_i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# Range Minimum Query (RMQ)
INF = 2**31 - 1
D = [INF]
[n, q] = list(map(int, input().split()))

def initRMQ(n_):
    global D, n
    size = 1
    while size < n_:
        size *= 2
    i = 1
    while i <= 2*size - 1 - 1:
        D.append(INF)
        i += 1
    n = size

def update(k, a):
    global n
    k += n - 1
    D[k] = a
    while k > 0:
        k = int((k - 1)/2)
        D[k] = min(D[k*2 + 1], D[k*2 + 2])

def query(a, b, k, l, r):
    global INF, D
    if r <= a or b <= l:
        return INF
    if a <= l and r <= b:
        return D[k]

    vl = query(a, b, k*2 + 1, l, int((l + r)/2))
    vr = query(a, b, k*2 + 2, int((l + r)/2), r)
    return min(vl, vr)

def findMin(a, b):
    global n
    return query(a, b + 1, 0, 0, n)

initRMQ(n)

for i in range(q):
    data = list(map(int, input().split()))
    if data[0] == 0:
        update(data[1], data[2])
    if data[0] == 1:
        print(findMin(data[1], data[2]))






Measured memory_bytes: 9008
N=int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
S=0
for x in range(0,N):
    if A[x]<=B[x]:
        S=S+A[x]
        if A[x]+A[x+1]<=B[x]:
            S=S+A[x+1]
            A[x+1]=0
        else:
            S=S+B[x]-A[x]
            A[x+1]=A[x+1]-(B[x]-A[x])
    if A[x]>B[x]:
        S=S+B[x]
print(S)



Measured memory_bytes: 19648
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int ih,iwd;
int hx[105];
int hy[105];

double det(double x,double y,double p,double q){
	return x*q - p*y;
}

bool isin(int x,int y,int r,double k,double kai){
	if(r*r<x*x+y*y)return false;
	double r1 = (k+kai/2)/360.0*2*3.14159265358979;
	double r2 = (k-kai/2)/360.0*2*3.14159265358979;
	//printf("%lf %lf %lf %lf\n",r1,r2,det(x,y,cos(r1),sin(r1)), det(x,y,cos(r2),sin(r2)));
	if(det(x,y,cos(r1),sin(r1)) > 0 && det(x,y,cos(r2),sin(r2)) < 0)return true;
	return false;
}

int main(void){
	//printf("%d %d %d\n",true,false,isin(1,3,6,45,30));
	while(1){
		scanf("%d%d",&ih,&iwd);
		if(ih==0)break;
		rep(i,ih){
			scanf("%d%d",&hx[i],&hy[i]);
		}
		int ans[105]={};
		
		int tn[3];
		rep(i,3)scanf("%d",&tn[i]);
		int tr[3];
		rep(i,3)scanf("%d",&tr[i]);
		
		int tx[3][20];
		int ty[3][20];
		rep(i,3){
			rep(j,tn[i]){
				scanf("%d%d",&tx[i][j],&ty[i][j]);
			}
		}
		
		rep(p,iwd){
			int nk,na;
			scanf("%d%d",&nk,&na);
			int ok[105]={};
			rep(i,ih){
				if(isin(hx[i],hy[i],na,nk,tr[0]))ok[i]=1;
			}
			/*
			rep(i,ih){
				printf("%d ",ok[i]);
			}
			printf("\n");*/
			rep(i,3){
				rep(j,tn[i]){
					rep(k,ih){
						int nx = hx[k]-tx[i][j];
						int ny = hy[k]-ty[i][j];
						if(isin(nx,ny,na,nk,tr[i])){
							//printf("%d %d %d %d %d\n",nx,ny,na,nk,tr[i]);
							//printf("out.....%d  %d %d\n",i,j,k);
							ok[k]=0;
						}
					}
				}
			}

			rep(i,ih){
				if(ok[i]==1)ans[i]++;
			}
			
			/*
			rep(i,ih){
				printf("%d ",ans[i]);
			}
			printf("\n");*/
		}
		
		int nmax = 0;
		rep(i,ih){
			//printf("%d ",ans[i]);
			if(ans[i]>nmax)nmax = ans[i];
		}
		//printf("\n");
		vector<int> anss;
		if(nmax==0)printf("NA\n");
		else{
			rep(i,ih){
				if(ans[i]==nmax)anss.push_back(i+1);
			}
			rep(i,anss.size()){
				printf("%d%c",anss[i],i+1==anss.size()?'\n':' ');
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 1072
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int INF = 2e9;
int n;
vector<pii> segs;
int mx = -INF, mn = INF;

void ReadInput()
{
    cin >> n;
    segs.resize(n);
    for(int i = 0; i < n; ++i)
    {
        int l, r;
        cin >> l >> r;
        ++r;
        mx = max(mx, l);
        mn = min(mn, r);
        segs[i] = pii(l, r);
    }
}

void Solve()
{
    int ans = 0;
    for(auto s: segs)
        ans = max(ans, max(0, mn - mx) + s.second - s.first);

    vector<pii> v(n);
    for(int i = 0; i < n; ++i)
    {
        int a = max(0, mn - segs[i].first);
        int b = max(0, segs[i].second - mx);
        v[i] = pii(b, -a);
    }
    sort(v.begin(), v.end());
    int temp = INF;
    for(int i = 0; i < n; ++i)
    {
        auto to = v[i];
        to.second = -to.second;
        if(i > 0) ans = max(ans, temp + to.first);
        temp = min(temp, to.second);
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,N,x=1;
  cin >>D>>N;
  if(D==1)
    x=100;
  if(D==2)
    x=10000;
  if(D==0 && N==100){
    cout << 101 << endl;
  }else if(D==1 && N==100){
    cout << 10100<<endl;
  }else if(D==2 && N==100){
    cout << 1010000<<endl;
  }else
    cout << x*N <<endl;
}


Measured memory_bytes: 256
x = []
flag = 0
for i in range(6):
    x.append(int(input()))

for i in range(4):
    for j in range(i+1, 5):
        if x[j] - x[i] > x[5]:
            flag += 1
            break

if flag == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
const int limn=1e5+5;
int tab[limn];
int dp[limn];
int bzw(int a)
{
    if(a<0)
        return a*-1;
    else
        return a;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        dp[i]=1e9;
    for(int i=0;i<n;i++)
    {
        cin>>tab[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=max(0,i-2);j<i;j++)
            dp[i]=min(dp[i],bzw(tab[i]-tab[j])+dp[j]);
        if(dp[i]==1e9)
            dp[i]=0;
    }
//    for(int i=0;i<n;i++)
//    {
//        cout<<dp[i]<<" ";
//    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024