akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int armiin(long long int arr[50])
{
	long long int min=10000000000000000+1010;
	int mini;
	for(int i=0;i<50;++i)
	{
		if(arr[i]<min)
		{
			min=arr[i];
			mini=i;
		}
	}
	return mini;
}
int main(void)
{
	long long int k;
	int n,miin;
	scanf("%lld\n",&k);
	long long int arr[50];
	for(int i=0;i<50;++i){
		arr[i]=i+k/50;
	}
  n = k % 50;
  for(int i=0;i<n;++i){
  	miin=armiin(arr);
  	for(int j=0;j<50;++j){
  		if(j==miin) arr[j]+=50;
  		else arr[j]-=1;
  	}
  }
  printf("50\n");
  for(int i=0;i<50;++i)
  {
  	printf("%lld ",arr[i]);
  }
  printf("\n");
}



Measured memory_bytes: 128
#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 L, R, d;
    cin >> L >> R >> d;
    cout << R / d - (L - 1) / d << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  vector<int> vec_o = vec;
  for (int i = 0; i < N-1; i++)
  {
    vec[i+1] += vec[i];
  }
  int pos = 0;
  // DEBUG(vec);
  for (int i = 0; i < N-1; i++)
  {
    if(vec_o[i+1] > vec[i]*2) pos = i + 1; 
    // DEBUG(pos);
  }
  cout<<N - pos<<endl;
  
  

  
  
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
//void ckmin(int &x,int y){
//	if (x>y)
//		x=y;
//}
const int N=100005;
int w,h,k;
LL calc(LL w,LL h,LL k){
	k=k*2-2;
	//s*2-b<=k
	LL ans=0;
	For(x,1,w-1)
		For(y0,1,h-1){
			LL b=__gcd(x,y0);
			LL mins=(w-x)*y0;
			if (mins-w*3>k)
				break;
			if (mins-b-w*2>k)
				continue;
			//w * y0 + (y1 - y0) * (w - (w - x)) = w * y0 - y0 * x + y1 * x = mins + y1 * x
			//mins + y1 * x - b <= k Ê±±ØÈ»³É¹¦ 
			//y1 <= (k + b - mins) / x
			LL miny1=min(h-1,max(0LL,(k+b-mins)/x));
			ans+=miny1;
			For(y1,miny1+1,h-1){
				LL s=mins+(LL)y1*x;
				if (s-b-w*2>k)
					break;
				if (s-b-__gcd(w-x,(LL)y1)-__gcd(w,(LL)abs(y1-y0))<=k)
					ans++;
			}
		}
	return ans;
}
int main(){
	w=read(),h=read(),k=read();
	cout<<calc(w,h,k)*2+calc(h,w,k)*2<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int A, B;

	cin >> A >> B;

	cout << ((A>8 || B>8)?":(":"Yay!") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m,sum;
	int a[10009];
	while(~scanf("%d %d",&n,&m))
	{
		for(int i=0;i<m;i++)
		{
			scanf("%d",&a[i]);
		} 
		sum=0;
		for(int i=0;i<m;i++)
		{
			sum+=a[i];
		}
		if(sum>n)
		{
			printf("-1\n");
		}
		else{
			printf("%d\n",n-sum);
		}
	}
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;



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

  vector<ll> D;

  for(int i=0; i<n; i++)
  {
    ll tmp;
    cin >> tmp;
    D.push_back(tmp);
  }

  ll max;
  max = -INT_MAX;

  int m;
  m = min(n,k);

  for(int a=0; a<=m; a++){
    for(int b=0; b<=m-a; b++){
      vector<ll> V;
      vector<ll> D_tmp;
      D_tmp = D;
      for(int i=0; i<a; i++){
        V.push_back(D_tmp.front());
        D_tmp.erase(D_tmp.begin());
      }
      for(int j=0; j<b; j++){
        V.push_back(D_tmp.back());
        D_tmp.pop_back();
      }
      if(V.empty()==1){
        continue;
      }
      sort(V.begin(),V.end());
      for(int i=0; i<k-a-b; i++){
        if(V.empty()==1){
          break;
        }
        if(V.front()<0){
          V.erase(V.begin());
        }
      }
      ll tmp;
      tmp = accumulate(V.begin(),V.end(),0);
      if(max < tmp){
        max = tmp;
      }
    }
  }

  cout << max;

  return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> dp(n + 1, vector<int>(n + 1));
  int r = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (s[i - 1] == s[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
      r = max(r, min(abs(i - j), dp[i][j]));
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=101,mod=1e9+7;
int n,nn,ans,a[N],b[N],f[N][N],g[N][N];
int main(){
	cin>>n;nn=n*2-1;
	ref(i,1,nn)cin>>a[i];
	sort(a+1,a+nn+1);
	ref(i,1,n-1)b[i]=(a[i]!=a[i+1]);
	ref(i,n+1,nn)b[i]=(a[i]!=a[i-1]);
	b[n]=1; f[0][0]=1;
	ref(i,1,n-1){
		memset(g,0,sizeof g);
		ref(x,0,nn)ref(y,0,nn)if(f[x][y])
			g[x+b[n-i]][y+b[n+i]]=f[x][y];
		memset(f,0,sizeof f);
		ref(x,0,nn)ref(y,0,nn)if(g[x][y]){
			ref(z,0,x-1)(f[z][y+1]+=g[x][y])%=mod;
			ref(z,0,y-1)(f[x+1][z]+=g[x][y])%=mod;
			(f[x][y]+=g[x][y])%=mod;
		}
	}
	ref(x,0,nn)ref(y,0,nn)(ans+=f[x][y])%=mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
H, W = [int(_) for _ in input().split()]
S = [input() for i in range(H)]

def solve(H, W, S):
    s = [row + "." for row in S] + ["." * (W + 1)]
    for y in range(H):
        for x in range(W):
            if s[y][x] == "#" \
                and s[y-1][x] == "." and s[y+1][x] == "." \
                and s[y][x-1] == "." and s[y][x+1] == ".":
                return False
    return True

if solve(H, W, S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38896
N, K = map(int, input().split())

cnt_k = 0
for i in range(1, N+1):
    if i % K == 0:
        cnt_k += 1

cnt_k_half = 0
for i in range(1, N+1):
    if i % K == K / 2:
        cnt_k_half += 1

ans = cnt_k**3
if K % 2 == 0:
    ans += cnt_k_half**3

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var r int
	fmt.Scan(&r)
	if r < 1200 {
		fmt.Println("ABC")
	} else if r < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}

Measured memory_bytes: 512
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,m;
int a,b,c;
int dp[1010][1 << 12];

signed main(){
    I(n); I(m);
    REP(i,1010) REP(j, (1<<12)) dp[i][j] = INT64_MAX/2;
    dp[0][0] = 0;
    REP(i,m){
        int state = 0;
        I(a); I(b);
        REP(_,b) {
            I(c); c--;
            state |= (1 << c);
        }
        REP(j,(1 << n)){ // i+1
            dp[i+1][j] = dp[i][j];

            if ((j | state) != j) continue;
            REP(k, (1<<n)){ // i
                if (j == (k | state)) dp[i+1][j] = min(dp[i+1][j], dp[i][k] + a);
            }
        }

    }
    cout << (dp[m][(1<<n)-1] < INT64_MAX/4 ? dp[m][(1<<n)-1] : -1) << endl;
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n-k){
        if(a[i]<a[i+k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){

    int n; cin >> n;

    vector<bool> prime(1000000, true);     //1000000までで、素数ならtrue
    prime[0] = prime[1] = false;
    for(int i = 2; i < 1000000; i++){
        if(prime[i] == true){
            for(int j = 2*i; j < 1000000; j += i){
                prime[j] = false;
            }
        }
    }

    int idx = 0;
    vector<int> ans(n);

    for(int i = 2; i < 1000000; i++){
        if(prime[i] && i % 5 == 1){
            ans[idx] = i;
            idx++;
        }

        if(idx == n) break;
    }

    for(int i = 0; i < n; i++){
        if(i == n - 1) cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int cards[5][14], sect, num;
  char mark;
  scanf("%d", &sect);

  // RESET STRUCTURE
  for(int i=0;i<5;i++){
    for(int j=0;j<14;j++){
      cards[i][j]=0;
    }
  }

  // DATA INPUT
  for(int i=0;i<sect;i++){
    scanf("%*c%c %d", &mark, &num);
    if(mark == 'S') cards[0][num]=1;
    else if(mark == 'H') cards[1][num]=1;
    else if(mark == 'C') cards[2][num]=1;
    else if(mark == 'D') cards[3][num]=1;
  }

  // PRESS
  for(int i=0;i<4;i++){
    for(int j=1;j<14;j++){
      if(cards[i][j]==0){
        if(i==0) printf("S %d\n", j);
        else if(i==1) printf("H %d\n", j);
        else if(i==2) printf("C %d\n", j);
        else if(i==3) printf("D %d\n", j);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2732
// ---------- BEG ../defs.hpp BEG ----------
#ifndef atcoder_defs_hpp
#define atcoder_defs_hpp
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };
#endif
// ---------- END ../defs.hpp END ----------

int main() {
  R(H)R(W)R(K)RL(dummy);
  RM(S,H,W);
  //S[y*W+x];

  // vi8t T(H*W,0);
  // F(y,H)F(x,W){
  //   T[y*W+x] = S[y*W+x]=='1'?1:0;
  //   if(y)T[y*W+x] += T[(y-1)*W+x];
  //   if(x)T[y*W+x] += T[y*W+(x-1)]:
  //   if(x&&y)T[y*W+x] -= T[(y-1)*W+(x-1)];
  // }

  //F(y,H){F(x,W){cerr<<S[y*W+x];}cerr<<endl;}

  vi8t acmw1(H,0);
  vi8t acmw2(H);
  i8t ans=H+W;
  i8t nhdiv = 1<<(H-1);
  F(hdiv,nhdiv){
    //printf("hdiv = %lo\n", hdiv);
    i8t nsplit=0;
    acmw1.clear();
    acmw1.resize(H,0);
    F(x,W){
      i8t s=0;
      i8t l=0;
      i8t mxw=0;
      F(y,H){
        if(S[y*W+x]=='1')s++;
        if((hdiv>>y&1)||y+1==H){
          umax(mxw,acmw2[l]=acmw1[l]+s);
          l++;
          s=0;
        }
      }

      if(mxw>K){
        nsplit++;

        mxw=0;
        F(l,H){
          acmw1[l]=acmw2[l]-acmw1[l];
          umax(mxw, acmw1[l]);
        }
        // 1升で区切っても駄目。この縦分割は不可能。
        if(mxw>K){
          nsplit+=H+W;
          break;
        }
      }else{
        acmw1.swap(acmw2);
      }
    }

    //cerr<<"hdiv="<<hdiv<<" xsplit="<<nsplit<<endl;
    F(y,H)if(hdiv>>y&1)nsplit++;

    umin(ans,nsplit);
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = map(int, input().split())
    answer = "U" * (ty - sy) + "R" * (tx - sx) + "D" * (ty - sy) + "L" * (tx - sx)
    answer += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
    answer += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int total = 0;
        for (int i = 0; i < K; i++) {
            if (0 < A) {
                total++;
                A--;
            } else if (0 < B) {
                B--;
            } else {
                total--;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 35776
#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 a,b;
    cin >> a >>b;
    if(a<=b) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
   int x,y;
   cin>>x>>y;
   for(int i=0;i<=x;i++){
      if(i*2+(x-i)*4==y){
         cout<<"Yes";
         return 0;
      }
   }
   cout<<"No";
   return 0;
}

Measured memory_bytes: 3640
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def judge(anums, k, mid):
    if mid == 0:
        return False
    tmp = 0
    for anum in anums:
        tt = anum // mid
        if mid * tt != anum:
            tt += 1
        tmp += tt - 1

    if tmp <= k:
        return True
    else:
        return False

def solve():
    n, k = getList()
    anums = getList()

    mn = 0
    mx = sum(anums) + 1
    while(mx - mn > 1):
        mid = (mn + mx) // 2
        if judge(anums, k, mid):
            mx = mid
        else:
            mn = mid

    if judge(anums, k, mn):
        print(mn)
    else:
        print(mx)


def main():
    n = getN()
    for _ in range(n):
        solve()


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

Measured memory_bytes: 91104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	set<int> s;
	int n,i,a;
	cin>>n;
	rep(i,n){
		cin>>a;
		if(s.find(a)!=s.end()) s.erase(a);
		else s.insert(a);
	}
	cout<<s.size()<<endl;
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 4992
while 1:
	n = input()
	if n == 0: break
	d = [map(int,raw_input().split()) for i in range(n)]
	w = max([sum([d2[0] for d2 in d if d2[1]<=d1[1]<d2[2]]) for d1 in d])
	print "OK" if w <= 150 else "NG"

Measured memory_bytes: 4232
#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                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 fin               freopen( "input.txt", "r", stdin );
#define fout              freopen( "output.txt", "w", stdout );
#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;
}

int minCost(int a[], int n){

    int dp[n];

    dp[0] = 0, dp[1] = abs(a[1]-a[0]);

    for(int i=2;i<n;i++){
        dp[i] = INT_MAX;
    }

    for(int i=2;i<n;i++){
        dp[i] = min(min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2])), dp[i]);
    }

    return dp[n-1];
}


void solve(){
    
    int n;
    cin >> n;
    int a[n];

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

    cout << minCost(a, n) <<endl;

}

int main(){
    //fin fout
    fast
    ll T = 1; //cin >> T;
    loop(i, 0, T) solve();
    /*#ifdef LOCAL
    clock_t tStart = clock();
    cerr<<fixed<<setprecision(10)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
    #endif*/
}


/*339 341 1
342 343 2
342 342 2*/



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	string s;
	cin >> s;

	if (s[5] == '0'&&s[6] - '0' >= 5 || s[5] == '1')
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
 
int main () {
	int a,b,n,i;
	char c;
	string str,s,f,g;
	cin >> str;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> s >>a >> b;
		if(s[2]=='i'){cout << str.substr(a,b-a+1) << endl;}
		else if(s[2]=='v'){
			f=str.substr(a,b-a+1);
			reverse(f.begin(),f.end());
			str = str.replace(a,b-a+1,f);
		}
		else if(s[2]=='p'){
			cin >> g;
			str = str.replace(a,b-a+1,g);
		}
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()


int main (){
    fast;
    
    int n;
    cin>>n;
    vector<pair<int,int>> throws;

    for(int i=0;i<n;i++){
        int d1,d2;
        cin>>d1>>d2;
        throws.pb({d1,d2});
    }
    bool flag = false;
    for(int i=0;i<n;i++){
        int cnt = 0;
        for(int j=i;j<min(n,i+3);j++){
            if(throws[j].first == throws[j].second) cnt++;
        }
        if(cnt == 3){
            flag = true;
            break;
        }
    }


    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    cout << K * (ll)pow(K - 1LL, N - 1LL) << endl;
    return 0;
}


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

ans = 0

k = [0 for _ in range(n+1)]

for i in range(n):
    k[l[i]] += 1
    
ll = len(k)
for i in range(ll):
    a = k[i]
    if a <= 1:
        pass
    else:
        ans += (a * (a - 1))/2
        
for i in range(n):
    a = k[l[i]]
    b = (a * (a - 1))/2
    c = a - 1
    if a < 1:
        print(int(ans))
    else:
        pans = ans - b
        c = (c * (c - 1))/2
        pans = pans + c
        print(int(pans))

Measured memory_bytes: 26140
n,k = (int(i) for i in input().split())
r,s,p = (int(i) for i in input().split())
S = input()

ans_li = []
ans = 0
for t in S:
    if t == 'r':
        ans_li.append('p')
        ans += p

    elif t == 'p':
        ans_li.append('s')
        ans += s
    
    else:
        ans_li.append('r')
        ans += r

for i in range(k,n):
    
    if ans_li[i] == ans_li[i-k]:
       
       if ans_li[i] == 'r': ans -= r
       elif ans_li[i] == 'p': ans -= p
       else: ans -= s

       ans_li[i] = 'x'

print(ans) 

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = INF;
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    cout << "Yes" << endl;
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 1);
    }
    auto d = Dijkstra(0, g);
    for (int i = 1; i < n; i++) {
        for (auto [to, _] : g[i]) {
            if (d[to] + 1 == d[i]) {
                cout << to + 1 << endl;
                break;
            }
        }
    }
}

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

if N == 2:
	print(1)
	exit()
if N == 3:
	print(2)
	exit()
def yakusu(n):
	rn = int(n ** 0.5)
	ret = 2
	for i in range(2, rn+1):
		if n % i == 0:
			ret += 2
	if rn*rn == n:
		ret -= 1
	return ret

#A = [True for i in range(10**6 + 1)]
ans = 1 # K = N
rn = int(N ** 0.5)
for i in range(2, rn+1):
	if N % i > 0:
		continue
	n = N
	while n % i == 0:
		n = n // i
	if n % i == 1:
		ans += 1
	n = N
	j = N // i
	if j <= i:
		continue
	while n % j == 0:
		n = n // j
	if n % j == 1:
		ans += 1
print(ans + yakusu(N-1) - 1)

Measured memory_bytes: 40044
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

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

	string s; cin >> s;

	int c = 0;
	int ans = 0;
	FOR_LT(i, 0, 3) {
		if (s[i] == 'R') {
			c++;
		}
		else {
			c = 0;
		}
		ans = max(ans, c);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int x = 0;
    REP(i,n) x += (s[i] == 'p');
    cout << n/2 - x << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
#define N 100005  //check the limits, man
typedef long long int ll;
// read the constraint properly (ll vs int)
int main()
{
    int n,i,ans;
    in(n);
    vi v(n-1);
    read(v,i,n-1);
    vi ar(n);
    ar[0]=v[0];
    ar[n-1]=v[n-2];
    lp(i,1,n-1)
        ar[i]=min(v[i],v[i-1]);
    ans=0;
    rep(i,n)
        ans+=ar[i];
    out(ans);
}


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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;




int main() {
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
//#include <unordered_set>
#define mkp make_pair
#define err cout<<"here"<<endl
using namespace std;
const double EPS=1e-12;
typedef long long lon;
typedef unsigned long long ull;
typedef set<int>::iterator IT;
const lon SZ=100010,SSZ=30,APB=52,mod=97,one=1;
const lon INF=0x7FFFFFFF;
lon n,m;
struct nd{
	lon to,wt;
	nd(lon a=0,lon b=0):to(a),wt(b){}
};

void init()
{
	cin>>n>>m;
	lon res=0;
	for(lon i=1;i<=n;++i)
	{
		for(lon j=0;;++j)
		{
			if(i*(1LL<<j)>=m)
			{
				res+=(1LL<<20)/(1LL<<j);
				break;
			}
		}
	}
	int num=20;
	for(;res%2==0;res/=2,--num);
	//cout<<res<<endl;
	double ans=res;
	ans/=(1<<num)*n;
	//ans/=n;
	cout<<fixed<<setprecision(16)<<ans<<endl;
}


void work()
{
	
}

void release()
{
	
}

int main()
{
	std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	int casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(int time=1;time<=casenum;++time)
	//for(int time=1;cin>>n>>m;++time)
	{
		//cout<<"Case #"<<time<<": ";
		init();
		work();
		release();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[1001],k,t,i,s=0,j;
    cin>>t>>k;
    for(i=0;i<t;i++){
        cin>>a[i];}
        sort(a,a+t);
    for(j=0;j<k;j++){
        s=s+a[j];
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		cout << s[i];
	}
	cout << ' ';
	for (int i = 4; i < 12; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long lint;

const int MAXN = 2222;
lint dp[MAXN][MAXN];

int main() {
    int N;
    lint A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    lint ans = 0;
    for (int i = 0; i < N-1; i++) {
        lint mini = min(B, A * (X[i+1] - X[i]));
        ans += mini;
    }
    cout << ans << endl;
    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        ll N, K, Q; cin >> N >> K >> Q;
        vector<ll> A(Q); cin >> A;
        vector<ll> P(N, 0);
        rep(i, Q) P[A[i]- 1]++;
        rep(i, N) {
            cout << (K - Q + P[i] > 0 ? "Yes" : "No") << endl;
        }
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
using namespace std;
#define KMAX 30
#define VMAX 1000000
int K[KMAX];
unsigned char T[KMAX][VMAX+1];
void eratos ( int n, bool prime[]){
 for ( int i = 0; i <= n; i++ ) prime[i] = false;
 for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
 prime[2] = true;
 int limit = (int)sqrt((double)n) + 1;
 for ( int i = 3; i <= limit; i += 2 ){
if ( !prime[i] ) continue;
for ( int j = i + i; j <= n; j += i ) prime[j] = false;
 }
}
main(){
 bool prime[VMAX + 1];
 eratos( VMAX, prime );
 int k, v;
 while( cin >> k >> v && !(k == 0 && v == 0) ){
for ( int i = 0; i < k; i++ ) cin >> K[i];
for ( int j = 0; j <= v; j++ ) T[0][j] = 0;
for ( int j = K[0]; j <= v; j += K[0] ) T[0][j] = 1;
for ( int i = 0; i < k; i++ ) T[i][0] = 1;
for ( int i = 1; i < k; i++ ){
 for ( int j = 1; j < K[i]; j++ ) T[i][j] = T[i-1][j];
 for ( int j = K[i]; j <= v; j++ ){
T[i][j] = (T[i-1][j] | T[i][j-K[i]]);
 }
}
int ans = -1;
for ( int i = v; i >= 2; i-- ){
 if ( prime[i] && T[k-1][i] ) { ans = i; break; }
}
if ( ans == -1 ) cout << "NA" << endl;
else cout << ans << endl;
 }
}

Measured memory_bytes: 31428
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final int number = Integer.parseInt(sc.nextLine());
            final Map<Integer, Integer> mem = new HashMap<Integer, Integer>();
            final String[] values = sc.nextLine().split(" ");
            for (int i = 0; i < values.length; i++) {
                final int val = Integer.parseInt(values[i]);
                mem.put(val, i + 1);
            }
            final StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= values.length; i++) {
                sb.append(mem.get(i) + " ");
            }
            final String result = sb.toString().trim();
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 61872
#include <bits/stdc++.h>
#include <string>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> wavec(n, 0);
    vector<bool> aced(n, false);
    ll ac = 0;
    ll wa = 0;
    while (m--)
    {
        int p;
        string s;
        cin >> p >> s;
        if (aced[p]) { continue; }
        if (s == "AC")
        {
            aced[p] = true;
            ++ac;
            wa += wavec[p];
        }
        else
        {
            wavec[p]++; // WA
        }
    }

    cout << ac << ' ' << wa << endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3748
#include <iostream>
    #include <vector>
    #include <utility>
    #include <assert.h>
    using namespace std;
     
    int main(){
      int n,i;
      vector<pair<int,int> > v;
      cin >> n;
      long long a[n];
      int t;
      long long mx = 0,cnt=0;
      bool ch;
      for(i=0;i<n;i++){
        cin >> a[i];
        if(abs(a[i])-abs(mx)>0){
          mx = a[i];
          t=i;
        }
      }
      if(mx>=0)ch=true;
      else ch = false;
      for(i=0;i<n;i++){
        a[i]+=a[t];
        cnt++;
        v.push_back(make_pair(t+1,i+1));
      }
      if(ch){
      	for(i=1;i<n;i++){
          if(a[i]<=a[i-1]){
            a[i]+=a[i-1];
            v.push_back(make_pair(i,i+1));
            cnt++;
          }
        }
      }else{
        for(i=n-2;i>=0;i--){
          if(a[i]>=a[i+1]){
            a[i]+=a[i+1];
            v.push_back(make_pair(i+2,i+1));
            cnt++;
          }
        }
      }
      
      cout << cnt << endl;
      for(i=0;i<v.size();i++){
        cout << v[i].first << " " << v[i].second << endl;
      }
      
      /*
      cout << "===========" << endl;
      for (int i = 0; i < n; i++) {
      	cout << a[i] << endl;
      	if (i + 1 < n) {
      		assert(a[i] <= a[i + 1]);
      	}
      }
      */
      /*for(i=0;i<n;i++)cout << a[i] << " ";
      cout << endl;*/
       return 0;
    }

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) PRINT("Yay!");
    else PRINT(":(");
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int cnt[1000010];
bool used[1000010];
int n;
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ++cnt[x];
    }
    memset(used, 0, sizeof used);
    int ans = 0;
    for (int i = 1; i <= 1e6; i++) {
        if (cnt[i] == 0 || used[i]) continue;
        if (cnt[i] == 1 && !used[i]) ++ans;
        for (int j = i; j <= 1e6; j += i) {
            used[j] = true;
        }
    }
    cout << ans;
}

Measured memory_bytes: 8072
#include <iostream>
#include <string>
using namespace std;
const int maxn = 1e5+5;
const int mod = 3;
string s,t;
int q,a,b,c,d;
int suma[maxn],sumb[maxn];

int main()
{
    cin >> s>>t;
    for(int i = 1; i <= s.length(); i++) 
        suma[i] = suma[i - 1] + ((s[i-1] == 'A')? 1:2); 
    for(int i = 1; i <= t.length(); i++)
        sumb[i] = sumb[i - 1] +( (t[i-1] == 'A')? 1:2);
    cin >>q;
    while(q--){
        cin >> a >> b >> c >> d;
        int A,B;
        A = (suma[b] - suma[a-1]) % mod;
        B = (sumb[d] - sumb[c-1]) % mod;
        if(A == B) cout  << "YES" << endl;
        else cout << "NO" << endl;
    } 
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,K;
  while(cin >> N >> K){
    if(K > (N-1)*(N-2)/2){
      cout << -1 << endl;
    }else{
      int m = N*(N-1)/2 - K;
      vector<unordered_set<int>> g(N);

      REP(i,N){
        FOR(j,i+1,N){
	  g[i].insert(j);
	}
      }

      int c = 0;
      FOR(i,1,N){
	while(g[i].size()){
	  if(c>=K) break;
	  g[i].erase(g[i].begin());
	  ++c;
	}
	if(c>=K) break;
      }

      cout << m << endl;
      REP(i,N){
	for(auto j : g[i]){
	  cout << i+1 << " " << j+1 << endl;
	}
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,m;
int a[200001],b[200001];
set<int> s1; //島1への定期便がある島
set<int> sn; //島Nへの定期便がある島

void input(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        if(a[i] == 1) s1.insert(b[i]);
        if(b[i] == 1) s1.insert(a[i]);
        if(a[i] == n) sn.insert(b[i]);
        if(b[i] == n) sn.insert(a[i]);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(auto e: s1){
        if(sn.find(e) != sn.end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
Int dp[2020];
int main() {
    Int S; cin >> S;
    dp[3] = 1;
    for (int i = 4; i <= S; i++) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }
    cout << dp[S] << endl;
    return 0;
}


Measured memory_bytes: 3648