akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, d;
    cin>>n>>d;
    int ans;
    if(n%(2*d+1)==0) {
        ans=n/(2*d+1);
    } else {
        ans=n/(2*d+1)+1;
    }

    cout<<ans<<
        endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NIL -1
long long int min(long long int a, long long int b){
	if(a<b)
		return a;
	else
		return b;
}
int main(){
long long int n;
  cin>>n;
 long long int ans[n];
 long long int a[n];
  for(int i=0;i<n;i++){
  cin>>a[i];
  }
   ans[1]=abs(a[0]-a[1]);
   ans[0]=0;
  for(int i=2;i<n;i++){
    ans[i]=min(ans[i-2]+abs(a[i]-a[i-2]),ans[i-1]+abs(a[i]-a[i-1]));
  }
  cout<<ans[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int i=0; 
do {
	if(a%2==1) {a-=1;}
	b=b+(a/2);
	a=a/2;
	i++;
	if(c==i) {break;}
	if(b%2==1) {b-=1;}
	a=a+(b/2);
	b=b/2;
	i++;
	if(c==i) {break;}

}while(true);
System.out.println(a+" "+b);
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    ll n; 
    cin>>n; ll a[n+1], s, sum=0, p=0, ans, q;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        sum%=MOD;
        p+=((a[i]*a[i])%MOD);
        p=p%MOD;
    }
    s=sum*sum; s%=MOD;
    q=s-p; 
    if(q<0)q=MOD-(abs(q)%MOD);
    ll x = 1, b=2, po=MOD-2;
        b=(b%MOD);
        while (po>0){
            if(po & 1)
            x=(x*b) % MOD;
            po=po>>1;
            b=(b*b) % MOD;
        }
    ans=((q%MOD)*(x%MOD))%MOD;
    cout<<ans<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/


Measured memory_bytes: 5152
H, W, K, *S = open(0).read().split()
H, W = int(H), int(W)

c = 0
n = 0
for s in S:
    l, r = -1, s.find("#")
    n += 1
    if r == -1:
        continue
    T = []
    while r != -1:
        c += 1
        T += [c] * (r - l)
        l, r = r, s.find("#", r + 1)
    T += [c] * (W - l - 1)
    for i in range(n):
        print(*T)
    n = 0

for i in range(n):
    print(*T)

Measured memory_bytes: 4152
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

long long factorial(int n){
	long long sum = 1;

	for(int i=n; i>0; i--){
		sum *= i;
	}
	return sum;
}

long long binomial_coefficients(int n, int r){
	return factorial(n) / (factorial(r) * factorial(n - r));
}

int main(int argc, const char * argv[]) {
	int i, j;
	int N = 0;
	int D = 0;
	int count = 0;
	int distanceindex = 0;
	double *distance;

	scanf("%d %d", &N, &D);

	distance = (double *)calloc(binomial_coefficients(N, 2), sizeof(double));
	int X[N][D];

	for(i=0; i<N; i++){
		for(j=0; j<D; j++){
			cin >> X[i][j];
		} 
	} 

	for(i=0; i<N; i++){
		for(j=i+1; j<N; j++){
			for(int k=0; k<D; k++){
				distance[distanceindex] += pow(X[i][k] - X[j][k], 2);
			}
			distance[distanceindex] = sqrt(distance[distanceindex]);
			if (ceil(distance[distanceindex]) == floor(distance[distanceindex])){
				count++;
			}
			distanceindex++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a, b, c, d, e, f = map(float, input().split())
        n = a*e - b*d
        if n != 0:
            x = (c*e - b*f) / n
            y = (a*f - c*d) / n
        print('{:.3f} {:.3f}'.format(x+0, y+0))
    except:
        break


Measured memory_bytes: 5592
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

llong N;
unsigned long long K;

vvecllong multiple(vvecllong A, vvecllong B) {
    vvecllong C(N, vecllong(N, 0));
    FOR(i, N) {
        FOR(j, N) {
            FOR(k, N) {
                C[i][j] += (A[i][k] * B[k][j]) % MOD;
                C[i][j] %= MOD;
            }
        }
    }
    return C;
};

vvecllong add(vvecllong A, vvecllong B) {
    vvecllong C(N, vecllong(N, 0));
    FOR(i, N) {
        FOR(j, N) {
            C[i][j] = (A[i][j] + B[i][j]) % MOD;
        }
    }
    return C;
};

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

    cin >> N >> K;

    vvecllong A(N, vecllong(N, 0));

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

    vvecllong ans(N, vecllong(N, 0));
    FOR(i, N) {
        ans[i][i] = 1;
    }
    while(K > 0) {
        if((K & 1) != 0) {
            ans = multiple(ans, A);
        }
        A = multiple(A, A);
        K /= 2;
    }

    llong count = 0;
    FOR(i, N) {
        FOR(j, N) {
            count = (count + ans[i][j]) % MOD;
        }
    }

    cout << (count % MOD) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
using namespace std;

int main(){
	int n;
	string str;
	list< char > lst;
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		cin >> str;
		bool dir = false;
		lst.clear();
		
		for(int j = 0; j < str.length(); ++j){
			char ch = str[j];
			
			if(ch >= 'a' && ch <= 'z'){
				if(find(lst.begin(), lst.end(), ch) == lst.end()){
					if(dir){
						lst.push_front(ch);
					}else{
						lst.push_back(ch);
					}
				}
			}else if(ch == '<'){
				dir = true;
			}else if(ch == '>'){
				dir = false;
			}
		}
		
		for(list< char >::iterator it = lst.begin(); it != lst.end(); ++it){
			cout << (char)(*it);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>

using u4t = std::uint32_t;
using i4t = std::int32_t;
using u8t = std::uint64_t;
using i8t = std::int64_t;

u8t N;
std::vector<u8t> a;

u8t solve(int sig){
  i8t S=0;
  u8t ret=0;
  for (int i=0;i<N;i++){
    S+=a[i];
    if(sig*S<=0){
      ret+=1+std::abs(S);
      S=sig;
    }
    sig=-sig;
  }
  return ret;
}

int main() {
  std::cin >> N;
  for (int i=0;i<N;i++) {u8t x; std::cin >> x;a.push_back(x);}

  std::cout<<std::min(solve(1),solve(-1))<<std::endl;
  return 0;
} 

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K, long long A, long long B) {
    bool flg = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) flg = true;
    }
    if (flg)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}

int main() {
    long long K;
    scanf("%lld", &K);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
     cin>>a[i];
    int c=0;
    sort(a,a+n);
    for(int i=0;i<n;i++)
     for(int j=i+1;j<n;j++)
      for(int k=j+1;k<n;k++)
      {
          if(a[i]!=a[j] && a[i]!=a[j] && a[j]!=a[k])
          {
              if(a[i]+a[j]>a[k])
               c++;
          }
      }
    cout<<c<<endl;
}

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

using namespace std;

int N, a[109], b[109];
bool dp[109][109];

bool canDo (long long msk)
{
    for (int i=0; i<=50; i++)
        for (int j=0; j<=50; j++)
            dp[i][j] = (i == j);
    for (int i=0; i<=50; i++)
        for (int j=1; j<=50; j++)
            if (msk & (1LL << j))
                dp[i][i % j] = 1;
    for (int k=0; k<=50; k++)
        for (int i=0; i<=50; i++)
            for (int j=0; j<=50; j++)
                dp[i][j] |= (dp[i][k] & dp[k][j]);
    bool ok = 1;
    for (int i=1; i<=N; i++)
        ok &= dp[a[i]][b[i]];
    return ok;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=1; i<=N; i++)
    scanf ("%d", &b[i]);
long long msk = (1LL << 51) - 2;
if (!canDo (msk))
{
    printf ("-1\n");
    return 0;
}
for (int i=50; i>0; i--)
    if (canDo (msk ^ (1LL << i)))
        msk ^= 1LL << i;
printf ("%lld\n", msk);
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
using namespace std;

int digitsum (int n){
	int sum = 0;
	while (n > 0){
		sum += n % 10;
		n = n / 10;
	}
	
	return sum;
}

int main(void) {
	int ans = 0;
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	FORq(i,1,N){
		int dsum = digitsum (i);
		if ( A <= dsum && dsum <= B) {
			ans = ans + i;
			
		}
	}
	
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C,K = MI()

def result(K):
   if K <= 0:
    print(sum)
    exit()

sum = 0

if K <= A:
    sum += K
    print(sum)
    exit()
else:
    sum += A
    K -= A

K -= B
result(K)

sum -= K

print(sum)

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

int main(){
  int n,l,sum=0,m=10000;
  cin>>n>>l;
  for(int i=0;i<n;i++){
    sum += l+i;
    if(abs(m)>abs(l+i)) m=l+i;
  }
  
  cout<<sum-m<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<cctype>
#include<climits>
#include<cstddef>
#include<typeinfo>
#include<stack>
#include<queue>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;
	if (a > b) {
		int temp;

		temp = a;
		a = b;
		b = temp;
	}
	if (b > c) {
		int temp;

		temp = b;
		b = c;
		c = temp;
	}
	if (a == 5 && b == 5 && c == 7) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int MAX=INT_MIN;
    int MIN=INT_MAX;
    int temp;
    for(int i=0;i<n;++i)
    {
        cin>>temp;
        MAX=max(MAX,temp);
        MIN=min(MIN,temp);
    }
    cout <<MAX-MIN<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	lli a, b, c, d, k, i, L, ans;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	L = c*d/gcd((int)c,(int)d);
	k = b/c + b/d - b/L - ((a-1)/c + (a-1)/d - (a-1)/L);
	ans = b-(a-1) - k;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    vector<vector<int>> p(3,vector<int>(3,0)), q;
    q=p;
    rep(i,3){
        rep(j,3){
            cin>>p[i][j];
        }
    }
    rep(i,3){
        rep(j,3){
            q[i][j]=p[j][i];
        }
    }
    bool ok=true;
    rep(i,2){
        if(!(p[i][0]-p[i+1][0]==p[i][1]-p[i+1][1] && p[i][1]-p[i+1][1]==p[i][2]-p[i+1][2])){
            ok=false;
        }
    }
    p=q;
    rep(i,2){
        if(!(p[i][0]-p[i+1][0]==p[i][1]-p[i+1][1] && p[i][1]-p[i+1][1]==p[i][2]-p[i+1][2])){
            ok=false;
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

class UnionFind {
    int n;
public:
    vector<int> uni;
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

int main() {
    int w, h;
    while(cin >> w >> h, w|h){
        UnionFind uf(h*w);
        vector<vector<int>> v(h+2, vector<int> (w+2, 0));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                int x;
                cin >> x;
                v[i+1][j+1] = x;
            }
        }
        auto f = [&](int p, int q){ return p*w+q; };
        int dy[] {1, 1, 1, 0, 0, -1, -1, -1},
            dx[] {-1, 0, 1, -1, 1, -1, 0, 1};
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if(v[i+1][j+1] == 0) continue;
                for (int k = 0; k < 8; ++k) {
                    if(v[i+dy[k]+1][j+dx[k]+1]){
                        uf.unite(f(i, j), f(i+dy[k], j+dx[k]));
                    }
                }
            }
        }
        set<int> s;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if(v[i+1][j+1]) s.insert(uf.root(f(i, j)));
            }
        }
        cout << s.size() << "\n";
    }
    return 0;
}



Measured memory_bytes: 3072
h,w=map(int,input().split())
a=[]
k=[]
for _ in range(h):
  s=input()
  if '#' in s:
    a.append(s)
l=len(a)
for i in range(w):
  for j in range(l):
    if a[j][i]=='#':
      k.append(i)
      break
m=max(k)
for i in range(l):
  for j in k:
    if j==m:
      print(a[i][j])
    else:
      print(a[i][j],end="")

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

ll dp[110][110000];
int main()
{
	int N, W;
	cin >> N >> W;
	vec(w);
	vec(V);
	fx(N) {
		vecp(w);
		vecp2(V);
	}
	fx(N+1) {
		fy(W+1) {
			if (y==0) {
				dp[x][y] = 0;
			}
			else {
				dp[x][y] = -1;
			}

		}
	}
	fx(N) {
		fy(W) {
			if (dp[x][y]>=0) {
				if (y + w[x] <= W) {
					dp[x + 1][y + w[x]] = max(dp[x + 1][y + w[x]], dp[x][y] + V[x]);
				}
				dp[x + 1][y] = max(dp[x + 1][y], dp[x][y]);

			}
		}
	}

	ll ans = 0;
	fx(W+1) {
		ans = max(ans, dp[N][x]);
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 88192
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

bool flag[3005][3005];
llong dp[3005][3005];
int a[3005];
llong f(int l, int r) {
   if (flag[l][r]) return dp[l][r];
   flag[l][r] = true;
   if (l == r) return dp[l][r] = a[l];
   return dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1));
}
int main() {
   int n;
   cin >> n;
   rep(i, 0, n) cin >> a[i];
   cout << f(0, n - 1) << endl;
   return 0;
}

Measured memory_bytes: 79744
#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>

using namespace std;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef long long ll;
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define NEXTP(c) next_permutation(ALL(c))
#define SUM(c) accumulate(ALL(c),0)
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define ANS(x) cout << (x) << endl;
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF 1000000000 // 10^9
const double EPS = 1e-10;

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

    int T[N+2], A[N+2];
    REP(i,N)cin>>T[i+1];
    REP(i,N)cin>>A[i+1];
    T[0] = T[N+1] = A[0] = A[N+1] = 0;

    int p[N+2] = {};

    FOR(i,1,N+1){
        if(T[i]>T[i-1] || A[i]>A[i+1]){
            if (T[i]>T[i-1] && T[i] > A[i]) p[i] = 0;
            else if (A[i]>A[i+1] && A[i] > T[i]) p[i] = 0;
            else p[i] = 1;
        }else{
            p[i] = min(T[i], A[i]);
        }
    }

    ll ret = 1;
    FOR(i,1,N+1) ret = (ret * p[i]) % 1000000007;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;
int A[MAX_N];
int rA[MAX_N];

void pre(int B[MAX_N]) {
	rep(i, 0, N - 1) {
		if(B[i] >= 0 && S[i] == '<') B[i + 1] = B[i] + 1;
	}
}

void solve() {
	cin >> S;
	N = sz(S) + 1;
	memset(A, -1, sizeof(A));
	rep(i, 0, N) {
		if(i == 0) {
			if(S[0] == '<') A[i] = 0;
		}
		else if(i == N - 1) {
			if(S[i - 1] == '>') A[i] = 0;
		}
		else {
			if(S[i - 1] == '>' && S[i] == '<') A[i] = 0;
		}
	}
	rep(i, 0, N) rA[i] = A[i];

	pre(A);
	// debug(vi(A, A + N));

	reverse(all(S));
	rep(i, 0, N - 1) {
		S[i] = (S[i] == '<' ? '>' : '<');
	}
	// debug(S);
	reverse(rA, rA + N);
	pre(rA);
	reverse(rA, rA + N);
	// debug(vi(rA, rA + N));
	ll ans = 0;
	rep(i, 0, N) {
		ans += max(rA[i], A[i]);
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 4764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int A;
int ans = 0;
int main(){
	
	cin>>N;
	REP( i, N ){
		cin>>A;
		while( !(A%2) ){
			ans++;
			A>>=1;
		}
	}
	
	cout<<ans<<endl;
}


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

int main(){
	cout << fixed << setprecision(7);
	while(true){
		int n, s;
		int sqSUM = 0;
		int SUM = 0;
		
		cin >> n;
		
		if(n==0) break;
		
		for(int i=0; i<n; i++){
			cin >> s;
			
			SUM   += s;
			sqSUM += s * s;
		}
		cout << sqrt((double)(sqSUM * n - SUM * SUM)) / n << "\n";
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		String nStr = "";
		String mStr = "";

		for (int i = 0; i < m; i++) {
			nStr += n;
		}

		for (int i = 0; i < n; i++) {
			mStr += m;
		}
		String re = mStr;

		if (nStr.compareTo(mStr) < 0) {
			re = nStr;
		}

		System.out.println(re);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   string S,T;
   T="";
   int K;
   cin >> K >> S;
   if(S.length()>K){
      T=S.substr(0,K);
      T=T+"...";
      cout << T << endl;
   }else{
      cout << S <<endl;
   }
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, m = MI()
    dct = {}
    for i in range(m):
        p, y = MI()
        dct.setdefault(p, [])
        dct[p].append((i, y))
    # print(dct)

    ans = ['' for _ in range(m)]
    for key, value in dct.items():
        st = sorted(value, key=lambda x: x[1])
        # print(st)
        for idx, (i, year) in enumerate(st):
            id = str(key).zfill(6) + str(idx+1).zfill(6)
            # print(id)
            ans[i] = id

    for iid in ans:
        print(iid)

if __name__ == '__main__':
    solve()

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

void CountingSort(vector<int>& A, vector<int>& B){
    int n = *max_element(A.begin(), A.end()) + 1;
    vector<int> C(n, 0);
    for (const auto& a : A) C[a]++;
    for (int i = 1; i < n; i++) C[i] += C[i-1];
    for (const auto& a : A) {
        B[C[a]-1] = a;
        C[a]--;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    vector<int> B(n);
    CountingSort(A, B);
    for (int i = 0; i < n; i++) {
        cout << B[i] << (i < n - 1 ? " " : "\n");
    }
    return 0;
}

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

using namespace std;

typedef pair<int, int> ii;

#define X first
#define Y second

string s;
int n;


vector <ii> ans;
void solve(){
    ans.push_back(ii(1, 2));
    int m = 2, head = 2;
    for(int i = 2; i <= (n + 1) / 2; i++){
        if (s[i] == '1'){
            ans.push_back(ii(head, m + 1));
            head = ++m;
            continue;
        }
        int need = 0;
        while (i + need <= (n + 1) / 2 && s[i + need] == '0') {
            need++;
        }
        if (i + need > (n + 1) / 2){
            for(int j = m + 1; j <= n; j++) 
                ans.push_back(ii(head , j));
            m = n;
            break;
        }
        for(int j = 1; j <= need; j++){
            ans.push_back(ii(head, m + j));
        }
        m += need;
        i += need - 1;
    }
    for(int j = m + 1; j <= n; j++)
        ans.push_back(ii(j, head));
    for(auto i: ans) cout << i.X << " " << i.Y << '\n';
}
int main(){
    cin >> s;
    n = s.length();
    s = '0' + s;
    for(int i = 0; i <= n; i++) if (s[i] != s[n - i]){
        cout << "-1" << endl;
        return 0;
    }
    if (s[1] == '0'){
        cout << "-1" << endl;
        return 0;
    }
    solve();
}


Measured memory_bytes: 2416
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K,Q,t,i;
  cin>>N>>K>>Q;
  int a[N]={0};
  int temp=Q;
  while(Q--)
  {
    cin>>t;
    a[t-1]=a[t-1]+1;
  }
  /*for(i=0;i<N;i++)
  {
      cout<<a[i]<<endl;
  }*/
  for(i=0;i<N;i++)
  {
      if((K-(temp-a[i]))>0)
      {
          cout<<"Yes"<<endl;
      }
      else
          cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = a[i]+1
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i+1]+1,a[i])

print(sum(a))

Measured memory_bytes: 23336
#include <bits/stdc++.h>
#define ll long long int 
#define pb push_back
using namespace std;

int main() {
    int t;
    t = 1;
    while(t--){
    ll a, b, c, k, ans ;
    cin >> a >> b >> c >> k;
    if(k <= a)
        ans = k;
    else if(k <= a + b)
        ans = a;
    else if(k <= a + b + c)
        ans = a - (k - a - b);
    std::cout << ans << std::endl;
    }
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    vector<int> f(60000);
    int N;
    cin >> N;
    int n = sqrt(N);
    for (int x=1; x<=n; x++) {
        for (int y=1; y<=n; y++) {
            for (int z=1; z<=n; z++) {
                int F = x*x + y*y + z*z + x*y + y*z + z*x;
                f[F-1]++;
            }
        }
    }
    for (int i=0; i<N; i++) {
        cout << f[i] << endl;
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

ll fac[200200],refac[200200];

ll mypow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}

ll comb(ll n,ll r){
  if(n < r)return 0;
  ll res = fac[n]*refac[r]%MOD;
  res = res*refac[n-r]%MOD;
  return res;
}

int main(){

  string s;
  vector<ll> pows(200200,1);
  REP(i,200100)pows[i+1] = pows[i]*10%2019;
  cin >> s;
  ll n = s.size();
  vector<ll> v(n+1,0);
  REP(i,n)v[i+1] = (v[i]*10 + s[i] - '0')%2019;
  REP(i,n)v[i+1] = v[i+1]*pows[n-i-1]%2019;
  vector<ll> sum(2019,0);
  REP(i,n+1)sum[v[i]]++;
  ll res = 0;
  REP(i,2019){
    res += (sum[i]*(sum[i]-1))/2;
  }
  cout << res << endl;
  




  

  return 0;
}


Measured memory_bytes: 6752
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

long calc(string s) {
    long ans = 0;

    auto xs = new int[26];
    for (int i = 0; i < s.length; i++) {
        int p = s[i] - 'a';

        for (int j = 0; j < xs.length; j++) {
            if (j != p)
                ans += xs[j];
        }
        xs[p]++;
    }
    return ans + 1;
}

void main() {
    auto s = readln.chomp;
    writeln(calc(s));
}


Measured memory_bytes: 764
N,M=map(int,input().split())
ans=0
ALL=[]
for i in range(M+1):
  a=list(map(int,input().split()))
  ALL+=[a]
ans=0  
for i in range(2**N):
  switch=[0 for _ in range(N)]
  for k in range(N):
    if (i>>k)&1:
      switch[k]=1
  for t in range(M):
    check=0
    for p in range(1,ALL[t][0]+1):
      if switch[ALL[t][p]-1]==1:
        check+=1
    if check%2!=ALL[-1][t]:
      break
    elif t==M-1:
      ans+=1
print(ans)      

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
  int a,b,x;
  while(cin >> x && x){
    a = b = 0;
    while(x--){
      int in1,in2;
      cin >> in1 >> in2;
      if(in1 > in2){
	a += in1+in2;
      }else if(in1 == in2){
	a += in1;
	b += in2;
      }else{
	b += in1+in2;
      }
    }
    cout << a << " " << b << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define rep(i,j) for(int i=0;i<(j);i++)
#define INF (1LL<<60)

typedef long long ll;

ll W,H,N;
ll X[100005],Y[100005];
vector<int> sX,sY;
ll maxd;
ll sx[2],sy[2];

ll dist(ll ax, ll bx, ll ay, ll by){
  ll ret = abs(ax-bx)+abs(ay-by);
  maxd = max(maxd, ret);
  return 2*ret;
}

int main(){
  scanf("%lld%lld%lld",&W,&H,&N);
  rep(i,N) scanf("%lld%lld", &X[i], &Y[i]);

  rep(i,N){
    sX.push_back(X[i]);
    sY.push_back(Y[i]);
  }
  sort(sX.begin(), sX.end());
  sort(sY.begin(), sY.end());
  //  sX.erase(unique(sX.begin(), sX.end()), sX.end());
  //  sY.erase(unique(sY.begin(), sY.end()), sY.end());

  sx[0] = sX[(sX.size()-1)/2]; sx[1] = sX[(sX.size()+1)/2];
  sy[0] = sY[(sY.size()-1)/2]; sy[1] = sY[(sY.size()+1)/2];
  ll res=INF, rx, ry;
  rep(i,4){
    ll x = sx[i/2], y = sy[i%2];
    //    cout << x << " " << y << endl;
    ll sum = 0; maxd = 0;
    rep(j,N) sum += dist(x, X[j], y, Y[j]);
    sum -= maxd;
    if(sum < res){
      res = sum;
      rx = x;
      ry = y;
    }
  }
  
  /*  ll resX=W, distX=INF, resY=H, distY=INF;
  rep(k,N){
    ll mY=W, mX=H, mdX=INF, mdY=INF;
    rep(i,N){
      if(i==k) continue;
      ll dist = 0;
      rep(j,N) dist += abs(X[i]-X[j])*2;
      dist -= abs(X[i]-X[k]);
      if(dist < mdX){
	mdX = dist;
	mX = X[i];
      }
    }
    
    rep(i,N){
      if(i==k) continue;
      ll dist = 0;
      rep(j,N) dist += abs(Y[i]-Y[j])*2;
      dist -= abs(Y[i]-Y[k]);

      if(dist < mdY){
	mdY = dist;
	mY = Y[i];
      }
    }
    if(distX+distY > mdX+mdY){
      distX = mdX, distY = mdY;
      resY = mY, resX = mX;
    }else if(distX+distY == mdX+mdY && mX < resX){
      resY = mY;
      resX = mX;
    }else if(distX+distY == mdX+mdY && mX == resX && mY < resY){
      resY = mY;
      resX = mX;
    }
    }*/

  printf("%lld\n%lld %lld\n", res, rx, ry);
  //  printf("%lld\n", distX+distY);
  //  printf("%lld %lld\n", resX, resY);
  return 0;
}

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



int main(){
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	
	for(int i=0;i<H;i++)cin>>S[i];
	
	vector<vector<int>> imos1(H,vector<int>(W,0));
	vector<vector<int>> imos2(H,vector<int>(W,0));
	
	for(int i=0;i<H;i++){
		int first = -1;
		int cnt = 0;
		for(int j=0;j<W;j++){
			if(first==-1){
				if(S[i][j]=='.'){
					first=j;
					cnt=1;
					if(j==W-1){
						imos1[i][j]+=1;
					}
				}
			}
			else{
				if(S[i][j]=='.'){
					cnt++;
					if(j==W-1){
						imos1[i][first]+=cnt;
					}
				}
				else{
					imos1[i][j]+=-cnt;
					imos1[i][first]+=cnt;
					cnt=0;
					first=-1;
				}
			}
		}
	}
	for(int i=0;i<W;i++){
		int first = -1;
		int cnt = 0;
		for(int j=0;j<H;j++){
			if(first==-1){
				if(S[j][i]=='.'){
					first=j;
					cnt=1;
					if(j==H-1)imos2[j][i]=1;
				}
			}
			else{
				if(S[j][i]=='.'){
					cnt++;
					if(j==H-1){
						imos2[first][i]+=cnt;
					}
				}
				else{
					imos2[j][i]+=-cnt;
					imos2[first][i]+=cnt;
					cnt=0;
					first=-1;
				}
			}
		}
	}

	
	for(int i=0;i<H;i++){
		for(int j=1;j<W;j++){
			imos1[i][j]+=imos1[i][j-1];
		}
	}

	for(int i=0;i<W;i++){
		for(int j=1;j<H;j++){
			imos2[j][i]+=imos2[j-1][i];
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans = max(ans,imos1[i][j]+imos2[i][j]-1);
			//cout<<imos1[i][j]<<' ';
		}
		//cout<<endl;
	}
	/*
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<<imos2[i][j]<<' ';
		}
		cout<<endl;
	}*/

	

	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 35712
R, G, B, N = map(int, input().split())
li = sorted([R,G,B])
ans = 0
for i in range(N//li[2]+1):
    for j in range((N-R*i)//li[1]+1):
        t = N - li[2]*i - li[1]*j
        if t < 0:
            continue
        if t % li[0] == 0:
            ans+=1
print(ans)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i,j,a,b;
	t = 1;
	while(t--) {
	 a = b = 0, j = 100;
	 cin >> n;
	 int arr[n];
	 for(i = 0; i < n; i++) {
	  cin >> arr[i];
	  b = b + arr[i];
     }
	 for(i = 0; i < n - 1; i++) {
	  a = a + arr[i];
	  if(abs(a - (b - a)) < j)
	   j = abs(a - (b - a));	
	 }
	 cout << j << endl;
	}
	return 0;
}



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

int main(void){

    int n, k, q;
    cin >> n >> k >> q;
    
    vector<int> a(n, 0);
    for(int i=0; i<q; i++) {
        int temp;
        cin >> temp;
        a[temp-1]++;
    }
    
    for(int i=0; i<n; i++) {
        if(k-(q-a[i])<=0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
vector<int>distan(90001, 0);
int sx[] = { 1,0,-1,0 };
int sy[] = { 0,1,0,-1 };
int main(void)
{
	const int INF = 1000000;
	const int BANPEI = 11451481;
	int Y, X; cin >> Y >> X;
	vector<vector<int>>arr(X + 2, vector<int>(Y + 2, INF));
	vector<vector<int>>mapp(X + 2, vector<int>(Y + 2, 0));
	for (int i = 0; i < Y; i++)
	{
		arr[0][i] = BANPEI;
		arr[X + 1][i] = BANPEI;
	}
	for (int i = 0; i < X; i++)
	{
		arr[i][0] = BANPEI;
		arr[i][Y + 1] = BANPEI;
	}
	int count = 0;
	arr[1][1] = 0;
	for (int i = 1; i <= Y; i++)
	{
		for (int j = 1; j <= X; j++)
		{
			char abc; cin >> abc;
			if (abc == '.')
			{
				mapp[j][i] = 1;
				count++;
			}
		}
	}
	queue<pair<int, int>>que;
	que.push({ 1, 1 }); arr[1][1] = 0;
	while (que.size())
	{
		int firs = que.front().first;
		int secon = que.front().second; que.pop();
		if (firs == X && secon == Y)
		{
			cout << count - arr[X][Y]-1 << "\n";
			return 0;
		}
		for (int i = 0; i < 4; i++)
		{
			int x = sx[i] + firs, y = sy[i] + secon;
			if (arr[x][y] == INF && arr[x][y] != BANPEI && mapp[x][y] == 1)
			{
				que.push({ x,y });
				arr[x][y] = arr[firs][secon] + 1;
			}
		}
	}
	/*for (int i = 1; i <= Y; i++)
	{
		for (int j = 1; j <= X; j++)
		{
			cout << arr[j][i]
		}
	}*/
	cout << -1 << "\n";
}

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

int main() {

    int d ,n;
    cin >> d >> n;

    int ans = 0;

    if (n == 100) n++;

    for (int i = 0; i < d; i++) n *= 100;

    cout << n << endl; 
    
    return 0;
    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc163/tasks/abc163_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  map<ll, ll> m;
  rep(i, N - 1) {
    ll a;
    cin >> a;
    m[a]++;
  }

  rep1(i, N) cout << m[i] << "\n";
}


Measured memory_bytes: 16120
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main()
{
	int n, i, j, k=1, wareru=0;
	int sosu[500000];
	sosu[0] = 2;
	for (i = 3; i < 1000000; i += 2)
	{
		wareru = 0;
		for (j = 3; j <= sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				wareru = 1;
				break;
			}
		}
		if (wareru == 0)
		{
			sosu[k++] = i;
		}
	}

	while (scanf("%d", &n) != EOF)
	{
		for (i = 0; (sosu[i] <= n) && (sosu[i] != NULL); i++);
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    if(s.size() == 3) reverse(ALL(s));
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

void dfs(int now, int N, vector<bool> &seen, vector<vector<bool>> &graph){
  seen[now]=true;
  REP(i,N){
    if(graph[now][i] && !seen[i]){
      dfs(i, N, seen, graph);
    };
  }
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M,ans=0;
  cin>>N>>M;
  vector<vector<bool>> graph(N,vector<bool>(N));
  vector<int>a(M),b(M);
  REP(i,M){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=true;
    graph[b[i]][a[i]]=true;
  }
  REP(i,M){
    graph[a[i]][b[i]]=false;
    graph[b[i]][a[i]]=false;
    vector<bool>seen(N);
    dfs(0,N,seen,graph);
    bool flag=false;
    REP(i,N){
      if(seen[i]==false)flag=true;
    }
    ans+=flag;
    graph[a[i]][b[i]]=true;
    graph[b[i]][a[i]]=true;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int tmp = a;
	a = b;
	b = tmp;
	tmp = a;
	a = c;
	c = tmp;
	printf("%d %d %d\n",a,b,c);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; ++i) {
    cin >> x.at(i);
  }

  long long min =  __LONG_MAX__;
 
  for(int p = 1; p < n*4+1; ++p) {
    long long sum = 0;
    for(int i = 0; i < n; ++i) {
      sum += (x.at(i) - p) * (x.at(i) - p);
      if(sum > min) break;
    }
    if(min > sum) min = sum;
  }

  cout << min << endl;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double xp1, xp2, yp1, yp2;
    int q;
    double[] xp, yp;
    double ansx, ansy, t;
    int i;

    xp1 = sc.nextDouble();
    yp1 = sc.nextDouble();
    xp2 = sc.nextDouble();
    yp2 = sc.nextDouble();
    q = sc.nextInt();
    xp = new double[q];
    yp = new double[q];

    for(i = 0;i < q;i++){
      xp[i] = sc.nextDouble();
      yp[i] = sc.nextDouble();
    }
    sc.close();

    for(i = 0;i < q;i++){
      t = (xp2 - xp1) * (xp[i] - xp1) + (yp2 - yp1) * (yp[i] - yp1);
      t = t / ((xp2 - xp1) * (xp2 - xp1) + (yp2 - yp1) * (yp2 - yp1));
      ansx = xp1 + t * (xp2 - xp1);
      ansx = ansx + (ansx - xp[i]);;
      ansy = yp1 + t * (yp2 - yp1);
      ansy = ansy + (ansy - yp[i]);
      System.out.printf("%.10f %.10f%n", ansx, ansy);
    }

  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 36952