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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[105][100005];

void Main() {
    int N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;

    rep(i, N) {
        rep(j, W + 1) {
            if (j - items[i].first >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - items[i].first] + items[i].second);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i, W+1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 79360
#include <iostream>

using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;

    if(0 == A % 3) cout << "Possible" << endl;
    else if(0 == B % 3) cout << "Possible" << endl;
    else if(0 == (A + B) % 3) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
int main(){
    int len,i,count = 0;
    char str;
    do{
        scanf("%c",&str);
        //printf((count == 0)?"":" ");
        if(90 >= str && str >= 65){
            str = str+32;
        }else if(122 >= str && str >= 97){
            str = str-32;
        }
        count++;
        printf("%c",str);
    }while(str != '\n');
    return 0;
}




Measured memory_bytes: 2092
ans = []
while True:
    try:
        A = list(input().split(','))
    except EOFError:
        break
    S = int(A [0])
    W,H = float(A [1]),float(A [2])
    if W / H / H >= 25.0:
        ans.append(S)

for i in ans:
    print(i)

Measured memory_bytes: 7676
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
double a[100001];
vector<double>v;
int main(){
    cin>>N;
    REP(i,N){
        cin>>a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    REP(i,N){
        int ans=0;
        ans+=3*(lower_bound(v.begin(),v.end(),a[i])-v.begin());
        ans+=(upper_bound(v.begin(),v.end(),a[i])-lower_bound(v.begin(),v.end(),a[i])-1);
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 4504
#include<iostream>
#include<string>

int main(){
	//標準入力
	std::string s;
	std::cin>>s;
	//処理
	bool flag[3]={false,false,false};
	for(size_t i=0;i<3;i++){
		if(s[i]>='a' && s[i]<'a'+3){
			flag[s[i]-'a']=true;
		}
	}
	//出力
	std::cout<<((flag[0] && flag[1] && flag[2])?"Yes":"No")<<std::endl;

	return 0;
}


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

#include<bits/stdc++.h>
#include<math.h>
using namespace std;


int main(){
  int N;
  int64_t K;
  cin >> N >> K;
  int A[N+1];

  for (int i=1;i<=N;i++) cin >> A[i];
  
  int next = 1;
  bool checked[N+1] = {false};
  vector<int> passed;
  for (int i=1;i<=N;i++){

    checked[next] = true;
    passed.push_back(next);
    next = A[next];
    if (checked[next] == true) break;
  }
  
  int start=0;
  for (int i=0;i<N;i++){
    if (passed[i]==next){
      start = i;
      break;
    }
  }

  int loop_length = passed.size()-start;
  int target_ind;
  if (K<start) target_ind = K;
  else target_ind = start + (K-start)%loop_length;

  //cout << start << endl;
  //cout << loop_length << endl;
  //cout << (K-start)%loop_length << endl;
  cout << passed[target_ind] << endl;


}

Measured memory_bytes: 5304
N, M = map(int, input().split())
H = list(map(int, input().split()))
no_good = []

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        no_good.append(B)
    elif H[A-1] < H[B-1]:
        no_good.append(A)
    else:
        no_good.append(A)
        no_good.append(B)

result = N - len(set(no_good))
print(result)


Measured memory_bytes: 19940
#include"stdio.h"
#include"cstdio"
#include"algorithm"
#include"string.h"
using namespace std;
const int max_n=1e4+10;
char A[max_n];
char S[50]; 
int main()
{
	while(scanf("%s",A)!=EOF)
	{
		int i,k=-1,n=strlen(A);
		memset(S,0,sizeof(S));
		for(i=0;i<n;i++)
		{
			if(A[i]=='0')
			{
				S[++k]='0';
			}
			if(A[i]=='1')
			{
				S[++k]='1';	
			}
			if(A[i]=='B')
			{
				if(strlen(S))
				S[k--]=0;
			}
		}
		printf("%s\n",S);
	}
}

Measured memory_bytes: 128
import sys
import numpy as np
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
 
n=int(input())
h=list(map(int,input().split()))

dp=[0]*(n+1)

dp[1]=0
dp[2]=abs(h[1]-h[0])
for i in range(1,n-1):
	dp[i+2]=min((dp[i]+abs(h[i+1]-h[i-1])),(dp[i+1]+abs(h[i+1]-h[i])))


print(dp[n])

Measured memory_bytes: 24736
#include <stdio.h>
int main(void){
    int x,y;
while(1){
    scanf("%d %d", &x, &y);
    if(x==y && x==0){
    break;
        }else if(x>y){
            printf("%d %d\n",y,x);
        }else{
            printf("%d %d\n",x,y);
}
}
    return 0;
}


Measured memory_bytes: 2064
import java.util.*;
public class Main {
    static int[] dx = {0, 1, 0, -1};
    static int[] dy = {1, 0, -1, 0};
    static int INF = 1000000000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        List<String> str = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            str.add(sc.next());
        }
        int cnt = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (str.get(i).charAt(j) == '#') {
                    cnt++;
                }
            }
        }
        Point s = new Point(0, 0);
        int[][] dist = bfs(s, str);
        if (dist[w - 1][h - 1] == INF) {
            System.out.println(-1);
            return;
        }
        int ans = h * w - (dist[w - 1][h - 1] + 1) - cnt;
        System.out.println(ans);
    }
    public static int[][] bfs(Point s, List<String> str) {
        int[][] dist = new int[51][51];
        for (int[] d : dist) {
            Arrays.fill(d, INF);
        }
        Queue<Point> que = new LinkedList<>();
        que.offer(s);
        dist[s.x][s.y] = 0;
        while (!que.isEmpty()) {
            Point p = que.poll();
            // System.out.println("p = " + p);
            for (int i = 0; i < 4; i++) {
                int ny = p.y + dy[i];
                int nx = p.x + dx[i];
                if (nx < 0 || ny < 0 || nx >= str.get(0).length() || ny >= str.size()) {
                    continue;
                }
                if (str.get(ny).charAt(nx) == '.' && dist[p.x][p.y] + 1 < dist[nx][ny]) {
                    dist[nx][ny] = dist[p.x][p.y] + 1;
                    //       System.out.printf("nx = %d ,ny = %d %n", nx, ny);
                    que.offer(new Point(nx, ny));
                }
            }
        }
        return dist;
    }
}
class Point {
    int x;
    int y;
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public String toString() {
        return String.format("(x = %d,y = %d)", this.x, this.y);
    }
}


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

using namespace std;

typedef long long	ll;

double solve(ll t, ll k){
	double prob = 1.0;

	while(t < k){
		prob *= 0.5;
		t *= 2LL;
	}

	return prob;
}

int main(){
	ll n, k;

	cin >> n >> k;

	double prob = 0.0;

	for(ll t = 1LL ; t <= n ; t++){
		prob += (1.0 / n) * solve(t, k);
	}

//	prob *= (1.0 / n);

	cout << setprecision(13) << fixed << prob << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
# abc108_b

t = input().rstrip().split(' ')
tl = list(map(lambda x:int(x), t)) 
x = tl[2] - tl[0]
y = tl[3] - tl[1]

c3 = (tl[2] - y, tl[3] + x)
c4 = (tl[0] - y, tl[1] + x)

print('{} {} {} {}'.format(c3[0], c3[1], c4[0], c4[1]))



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

typedef long long ll;

void solve(ll N, set<ll>& res){
    if(N==0) return;

    ll n = 0;
    ll s = N / abs(N);
    for(ll i=0; i<16; i++){
        auto j = 2 * i;
        if(N < 0) j++;
        n += ((ll)1) << j;
        if(abs(N) <= n){
            N -= s * ((ll)1 << j);
            res.insert(j);;
            solve(N, res);
            return;
        }
    }
}

int main()
{
    ll N;
    cin >> N;
    set<ll> digits;
    solve(N, digits);
    string res;
    for(int i=0; i<32; i++){
        if(digits.count(i)) res += '1';
        else                res += '0';
    }
    while(res.back() == '0') res.pop_back();
    reverse(res.begin(), res.end());
    if(res == "") res = "0";
    cout << res << endl;

    return 0;
}

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

d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.extend(list(map(int,input().split())))

n = list(range(1,N+1))

itazura = set(A) ^ set(n)

print(len(itazura))


Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main() {

  int i;
  int a[30];

  int res;
  
  int index;


  while(1) {

    cin >> i;

    if(i==0) break;

    for(int j=0;j<i;j++) cin >> a[j];

    res=32;

    index=0;

    while(res>0) {

      res-=(res-1)%5;

      cout << res << endl;

      res-=a[(index%i)];

      if(res<0) res=0;

      index++;

      cout << res << endl;

    }

  }

  return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

string make_string(int p,int y){
	ostringstream ss1;
	ss1 << setw(6) << setfill('0') << to_string(p);
	ostringstream ss2;
	ss2 << setw(6) << setfill('0') << to_string(y);

	return ss1.str()+ss2.str();
}

int main(){
	//source
	int n,m;
	cin >> n >> m;
	int p[m],y[m];
	vector<pair<int,int>> vec[n+1];
	rep(i,m){
		cin >> p[i] >> y[i];
		vec[p[i]].push_back(make_pair(y[i],i));
	}


	rep(i,n+1){
		if(vec[i].size()==0)
			continue;
		sort(vec[i].begin(),vec[i].end());
	}

	string str[m];
	rep(i,n+1){
		rep(j,(int)vec[i].size()){
			int index=vec[i][j].second;
			str[index]=make_string(p[index],j+1);
		}
	}

	rep(i,m){
		cout<<str[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main(int argc, char const *argv[])
{
	ll n, p;
	cin >> n >> p;
	map<ll, ll> mp;
	mp = prime_factor(p);
	ll ans = 1;
	for (auto x : mp){
		if (x.second >= n) ans*=pow(x.first, x.second/n);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int n;
    vector<int> p;
    int tmp_p;
    int ans=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_p;
        tmp_p--;
        p.push_back(tmp_p);
    }

    int tmp=0;
    for(int i=0; i<n; i++){
        if(i==p[i]){
            tmp++;
            if(i==n-1){
                if(tmp%2==0){
                    ans+=tmp/2;
                }else{
                    ans+=tmp/2+1;
                }                
            }
        }else{
            if(tmp%2==0){
                ans+=tmp/2;
            }else{
                ans+=tmp/2+1;
            }
            tmp=0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
import itertools
from scipy.sparse.csgraph import floyd_warshall

N, M, R = map(int, input().split())
r = tuple(map(int, input().split()))

INF = 10**10

d = [[INF] * N for _ in range(N)]

for i in range(N):
    d[i][i] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if d[a][b] > c:
        d[a][b] = c
        d[b][a] = c

# for k in range(N):
#     for i in range(N):
#         for j in range(N):
#             d[i][j] = min(d[i][j], d[i][k] + d[k][j])

d = floyd_warshall(d)


ans = INF
for p in itertools.permutations(r):
    dist = 0
    for i in range(R-1):
        dist += d[p[i]-1][p[i+1]-1]

    ans = min(ans, dist)

print(int(ans))


Measured memory_bytes: 15288
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 998244353;
const ll INF = 1e18;
const ld E = 1e-12;
const ld PI=acos(-1);
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 37, p3 = 7, p4 = rnd() % 100 + 1, md1 = MOD, md2 = 998244353, md3 = 998244357, md4 = rnd() % 1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m;
ll dp[301][301][301];

ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l %= md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

void solve()
{
    ll k;
    string s;
    cin >> s;
    ll o=0, p=0;
    vector<ll> v;
    for (int i = 0; i < s.size(); i++)
    {
        o+=(s[i]=='1');
        if (s[i]=='1') p++; else
            v.pb(p), p=0;
    }
    if (p!=0) v.pb(p);
    cin >> k;
    k=min(k,o);
    dp[0][0][0]=1;
    for (int i = 0; i < v.size(); i++)
        for (int j = 0; j <= k; j++)
            for (int u = 0; u <= k; u++)
                if (dp[i][j][u])
                {
                    for (int y = max(0ll, v[i]-u); y <= v[i]+(k-j); y++)
                    {
                        if (y<=v[i]) dp[i+1][j][u-(v[i]-y)]=(dp[i+1][j][u-(v[i]-y)]+dp[i][j][u])%MOD; else
                        {
                            dp[i+1][j+y-v[i]][u+y-v[i]]=(dp[i+1][j+y-v[i]][u+y-v[i]]+dp[i][j][u])%MOD;
                        }
                    }
                }
    ll ans=0;
    for (int i = 0; i <= k; i++)
        ans=(ans+dp[v.size()][i][0])%MOD;
    cout << ans << "\n";
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

/*
8 2
2 2 2 2 2 2 2 2
1 2

*/


Measured memory_bytes: 57284
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }else if(A >=6 && A <=12){
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char mapa[1001][1001];
int dp[1001][1001];
int main(int argc, char const *argv[]) {
    int n,m;
    scanf("%d %d", &n ,&m);
    for(int i=0;i<n;++i) 
        scanf("%s", mapa[i]);
    dp[n-1][m-1] = 1;
    int mod = 1e9 + 7, nj;
    for(int j = m-1;j >-n;--j) {
        for(int i=n-1;i>=0;--i) {
            nj = j + n-i-1;
            if(nj < m && nj >=0){
                if(mapa[i][nj] == '.') {
                    if(i+1 < n)
                        dp[i][nj] = (dp[i][nj] + dp[i+1][nj]) % mod; 
                    if(nj+1 < m)
                        dp[i][nj] = (dp[i][nj] + dp[i][nj+1]) % mod; 
                }
            }
        }
    }
    printf("%d\n", dp[0][0]);
    return 0;
}

Measured memory_bytes: 8512
import java.io.*;
import java.util.*;
 
/**
 * Only By Abhi_Valani
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Unstoppable solver = new Unstoppable();
	//	int t=in.nextInt();
	//	while(t-->0)
        solver.solve(in, out);
        out.close();
    }
 
    static class Unstoppable {
        public static long c(int n,int k)
        {
            long mul=n;
            while(k-1>0)
            {
                
                mul=(mul*(--n))/k;
                k--;
            }
            return mul;
        }
        public void solve(InputReader in, PrintWriter out) {
          //from here...
		  //int[] a = readArray(in, n);
		  int n=in.nextInt();
		  int abc[]=new int[n];
		  for(int i=0;i<n;i++)
		       abc[i]=in.nextInt();
		       Arrays.sort(abc);
		        int ans=0;
	
		         for(int i=0;i<n-2;i++){
		       int a=abc[i];    
		      for(int j=i+1;j<n-1;j++)
		      {
		        int b=abc[j];
		        for(int k=j+1;k<n;k++)
		        {
		            int c=abc[k];
		            if(a<b+c&&b<a+c&&c<a+b) ans++;
		            else break;
		        }
		         
		      }
		  }
		 
		  out.println(ans);
        }
 
    }
 
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
    }
}
 

Measured memory_bytes: 23508
// 2011/02/06 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	for(int i=0; i<n; i++){
		string str;
		cin >> str;

		char train[52];
		for(int j=0; j<52; j++)
			train[j] = '/';

		int trn_i = 26;
		train[trn_i] = str[0];

		for(int j=1; j<str.size();){
			if(str[j]=='-'&&str[j+1]=='>')
				trn_i++;
			else if(str[j]=='<'&&str[j+1]=='-')
				trn_i--;
			j += 2;

			train[trn_i] = str[j];
			j++;
		}

		for(int j=0; j<52; j++)
			if(train[j]!='/')
				cout << train[j];
		cout << endl;
	}

	return 0;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int n,m,x;
llint c[15];
int a[15][15];



void solve(){
  cin >> n >> m >> x;
  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=1;j<=m;j++)cin >> a[i][j];
  }
  llint N=1<<n,ans=inf,sum[15],cost;
  for(int i=0;i<N;i++){
    cost=0;
    for(int j=1;j<=m;j++)sum[j]=0;
    for(int j=0;j<n;j++){
      if(!(i&(1<<j)))continue;
      cost+=c[j];
      for(int k=1;k<=m;k++)sum[k]+=a[j][k];
    }
    bool f=true;
    for(int j=1;j<=m;j++){
      if(sum[j]<x)f=false;
    }
    if(f)ans=min(cost,ans);
  }
  if(ans==inf)cout << -1 << endl;
  else cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int>a;
int n,k;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>k;
		if(a.find(k)==a.end())
		a.insert(k);
		else
		a.erase(k);
	}
	cout<<a.size()<<"\n";
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<PII> array(n);
    VI a(n);
    rep(i,n){
      cin >> a[i];
      array[i] = make_pair( a[i] , i );
    }
    sort(all(array));
    int ans= 0;
    rep(i,n){
      if(i%2 == 0){
        if(array[i].second % 2 == 1) ans++;
      }else{
        if(array[i].second % 2 == 0) ans++;
      }
    }
    ans = (ans+1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(N: int, B: "List[int]"):
    prev = B[0]
    res = 0
    for b in B:
        res += min(b, prev)
        prev = b
    res += prev
    print(res)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.*;
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();
        if(a + b >= c) {
        System.out.println("Yes");
        }
        else {
        	System.out.println("No");
        }
}
}

Measured memory_bytes: 21844
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
k = int(input())
p = 1
for i in range(n):
    p = min(2*p,p+k)
print(p)

Measured memory_bytes: 3316
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readInt();
            var ans = (s >= 30) ? "Yes" : "No";
            WriteLine(ans);
        }
    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }


}

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

int cmp(const void *a,const void*b){
  return *(int*)b -*(int*)a;
}

int main(void){
  int N,H,i,a,a_max=0,ans=0;
  scanf("%d %d",&N,&H);
  int b[N];
  for(i=0;i<N;i++){
    scanf("%d %d",&a,&b[i]);
    if(a_max<a) a_max = a;
  }
  
  qsort(b,N,sizeof(int),cmp);
  
  while(H>0){
    if(N<=ans ||b[ans]<=a_max) break;
    H-=b[ans];
    ans++;
  }
  if(H>0) ans += H%a_max==0?H/a_max:H/a_max+1;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=15;
int dp[N][N];
int m,a,b,c;

int main()
{
    while (true) {
        scanf("%d",&m);
        if (m==0) break;
        memset(dp,INF,sizeof(dp));
        for (int i=1;i<=m;i++) {
            scanf("%d%d%d",&a,&b,&c);
            dp[a][b]=dp[b][a]=c;
        }
        for (int k=0;k<10;k++) {
            for (int i=0;i<10;i++) {
                for (int j=0;j<10;j++) {
                    if (k!=i&&k!=j&&i!=j) {
                        if (dp[i][k]!=INF&&dp[k][j]!=INF)
                            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
                    }
                }
            }
        }
        int val=INF,idx=-1;
        for (int i=0;i<10;i++) {
            int tmp=0;
            for (int j=0;j<10;j++) {
                if (dp[i][j]!=INF) tmp+=dp[i][j];
            }
            if (tmp>0) {
                if (tmp<val) {
                    idx=i;
                    val=tmp;
                }
            }
        }
        printf("%d %d\n",idx,val);
    }
}


Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var S = Read();
            var que = new Queue<int>();
            var idx = 0;
            while (idx < N)
            {
                var chk = S[idx];
                var cnt = 1;
                while (idx + cnt < N)
                {
                    if (chk == S[idx + cnt])
                    {
                        cnt++;
                    }
                    else break;
                }
                que.Enqueue(cnt);
                idx += cnt;
            }
            idx = 0;
            while (idx < K)
            {
                if (que.Count() <= 3)
                {
                    Console.WriteLine(N - 1);
                    return;
                }
                var sum = 0;
                var cnt = 0;
                while (cnt < 3)
                {
                    sum += que.Dequeue();
                    cnt++;
                }
                que.Enqueue(sum);
                idx++;
            }
            var ans = 0;
            while (que.Any()) ans += que.Dequeue() - 1;

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int n;
		cin >> n;
		string ans = "Yes";
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		reverse(a.begin(),a.end());
		for(int i=1;i<a.size();i++){
				if(a[i] - a[i-1] >= 2){
						ans = "No";
						break;
				}else if(a[i] - a[i-1] == 1) a[i] -= 1;
		}
		cout << ans;
}



Measured memory_bytes: 1400
a,b,k = map(int,input().split())
ansa = 0
if a + b <k:
    print("0 0")
elif a < k:
    ansa =0
    ansb = b-(k-a)
    print(str(ansa)+" "+str(ansb))
else:
    ansa = a-k
    ansb = b
    print(str(ansa)+" "+str(ansb))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while (true) {
		int h, w;
		cin >> h >> w;
		if (h == 0 || w == 0) return 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

int main(){
	ll k;
	cin >> k;
	if(k % 2 == 0){
		cout << -1 << endl;
		return 0;
	}
	ll seven = 7;
	ll count = 1;
	while(true){
		if(seven % k == 0){
			cout << count << endl;
			return 0;
		}
		seven *= 10;
		seven += 7;
		seven %= k;
		count++;
		if(count > k){
			cout << -1 << endl;
			return 0;
		}
	}
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n = 0;
	cin >> n;
	int res = 0;
	for(int i=0;i<n;i++) {
		int x = 0;
		cin >> x;
		while (x % 2==0) {
			x /=2;
			res++;
		}
	}
	cout<<res;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

vector<bool> visited;
vector<vector<int> > g;
vector<int> distance_from_zero, distance_from_N;

void dfs1(int s, int d) {
    if (visited[s] == true) return;

    visited[s] = true;
    distance_from_zero[s] = d;
    rep(i, g[s].size()) {
        dfs1(g[s][i], d + 1);
    }

    return;
}

void dfs2(int s, int d) {
    if (visited[s] == true) return;

    visited[s] = true;
    distance_from_N[s] = d;
    rep(i, g[s].size()) {
        dfs2(g[s][i], d + 1);
    }

    return;
}

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

    int n;
    cin >> n;
    g.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    visited.resize(n, false);
    distance_from_zero.resize(n, 0);
    dfs1(0, 0);

    rep(i, n) visited[i] = false;
    distance_from_N.resize(n, 0);
    dfs2(n - 1, 0);

    int f_cnt = 0, s_cnt = 0; 
    rep(i, n) {
        // if (i == 0 || i == n - 1) continue;
        if (distance_from_zero[i] <= distance_from_N[i]) ++f_cnt;
        else ++s_cnt;
    }

    if (f_cnt > s_cnt) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}

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

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

    int n, r;
    cin >> n >> r;
    if (n < 10)
        cout << r + 100 * (10 - n) << endl;
    else
        cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=405;
bitset<maxn> a[maxn];
bool die[maxn];
int n,m,ans,x[100005],y[100005];
int main(){
	read(n);read(m);
	rep(i,1,m)read(x[i]),read(y[i]);
	rep(i,1,n){
		a[i][i]=1;
		per(j,m,1){
			if(a[i][x[j]]&&a[i][y[j]])die[i]=1;
			if(a[i][x[j]]||a[i][y[j]])a[i][x[j]]=a[i][y[j]]=1;
		}
	}
	rep(i,1,n)rep(j,i+1,n){
		if(die[i]||die[j])continue;
		if((a[i]&a[j]).none())ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

N = int(input())  # type: int

dic = {}
for i in range(N):
    word = input()
    if word in dic:
        dic[word] = dic[word] + 1
    else:
        dic[word] = 1

max = max(dic.values())
keys = [k for k, v in dic.items() if v == max ]
for i in sorted(keys):
    print(i)


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
}


Measured memory_bytes: 23252
#include <stdio.h>
#define N 100000
#define NIL -1
 
typedef struct tree {
  int p,l,r;
}tax;
tax T[N];
 
int main()
{
  int n,i,j,k,id,center,temp1,temp2;
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
   
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&center);
      T[center].p=id;
      if(j==0) T[id].l=center;
      else T[temp1].r=center;
      temp1=center;
    }
  }
   
  for(i=0;i<n;i++){
    id=0;
    k=0;
    temp1=T[i].p;
    temp2=T[i].l;
     
    while(temp1!=NIL){
      k++,temp1=T[temp1].p;
    }
     
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,k);
     
    if(T[i].p==NIL) printf("root, [");
    else if(T[i].l!=NIL) printf("internal node, [");
    else printf("leaf, [");
     
    while(temp2!=NIL){
      if(id==0){
    printf("%d",T[i].l);
    id=1;
      }else printf(", %d",temp2);
      temp2=T[temp2].r;
    }
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 3864
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = nextInt()
	}

	ans := 0
	for i := 0; i < N; i++ {
		if a[a[i]-1] == i+1 {
			ans++
		}
	}
	fmt.Println(ans / 2)
}


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

long long N, K;
string S;

int main(){
	cin >> N >> K >> S;
	if(S[0] == 'R'){
		for(long long i = 0; i <S.size(); i++){
			if(S[i] == 'R'){
				S[i] = 'L';
			}else{
				S[i] = 'R';
			}
		}
	}

	long long rcount = 0;
	char ch = '-';
	for(long long i = 0; i <S.size(); i++){
		if(ch != S[i]){
			if(ch == 'R'){
				rcount++;
			}
			ch = S[i];
		} 
	}

	if(ch == 'R'){
		rcount;
		long long rest = 1;
		if(K <= rcount){
			cout << S.size() - 2LL - 2*max(rcount - K, 0LL) << endl;
		} else {
			cout << S.size() - 1 << endl;
		}
		return 0;
	}

	cout << S.size() - 1LL - 2*max(rcount - K, 0LL) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,k,loop=0;
    ll A[200005];
    ll log[200005];
    bool C[200005];
    cin>>n>>k;
    REP(i,n){
        C[i]=false;
        cin>>A[i];
    }
    log[0]=0;
    while(C[log[loop]]==false){
        C[log[loop]]=true;
        loop++;
        log[loop]=A[log[loop-1]]-1;
    }
    int x=log[loop],z=loop;
    int p=0;
    while(log[p]!=x&&k>0){
        p++;
        z--;
        k--;
    }
    //REP(i,loop+1) cout<<log[i]<<" ";
    //cout<<endl;
    //cout<<"z: "<<z<<endl;
    cout<<log[k%z+p]+1<<endl;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n;cin>>n;
  string s; cin>>s;
  int x=0;
  int ans=0;
  for (int i=0; i<n; i++) {
    if (s[i]=='I') x++;
    else x--;
    ans = max(ans, x);
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

using namespace std;

int main() {
  vector<int> a;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    a.push_back(v);
  }

  int cost = 0;
  for (int i = 0; i < a.size(); i++) {
    if (i == 0) {
      cost += abs(a[0]);
      continue;
    }
    // if (i == a.size() - 1) {
    //   cost += abs(a[i]);
    //   continue;
    // }

    cost += abs(a[i - 1] - a[i]);
  }
  cost += abs(a[a.size() - 1]);

  for (int i = 0; i < a.size(); i++) {
    int orig = cost;
    if (i == 0) {
      orig -= abs(a[0]);
      orig -= abs(a[0] - a[1]);
      orig += abs(a[1]);
    } else if (i == a.size() - 1) {
      orig -= abs(a[i]);
      orig -= abs(a[i - 1] - a[i]);
      orig += abs(a[i - 1]);
    } else {
      orig -= abs(a[i - 1] - a[i]);
      orig -= abs(a[i] - a[i + 1]);
      orig += abs(a[i - 1] - a[i + 1]);
    }
    cout << orig << endl;
  }
}


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

int main(){
  long long n,march[5]={},ans=1;
  bool exist=false;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    switch(s[0]){
      case 'M':
        march[0]++;
        break;
      case 'A':
        march[1]++;
        break;
      case 'R':
        march[2]++;
        break;
      case 'C':
        march[3]++;
        break;
      case 'H':
        march[4]++;
        break;
      default:
        break;
    }
  }
  cout<<march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+
    march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+
    march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+
    march[2]*march[3]*march[4]<<endl;
}
      

Measured memory_bytes: 256
N = int(input())
bs = list(map(int, input().split()))
js = []
for i in range(N):
  k = -1
  for j in reversed(range(N-i)):
    if bs[j] == j+1:
      k = j
      break
  if k < 0:
    break
  js.append(k)
  bs.pop(j)
if not len(js) == N:
  print(-1)
  exit()
for j in reversed(js):
  print(j+1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const ll INF = LLONG_MAX - 1e11;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve() {
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	REP(n) cin >> w[i] >> v[i];
	int MAXV = accumulate(all(v), 0);
	vector<vector<long long>> dp(n + 1, vector<ll> (MAXV + 1, INF));
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= MAXV; j++) {
			if(j == 0)
				dp[i][j] = 0;
			else if(i == 0)
				dp[i][j] = INF;
			else if(v[i - 1] <= j)
				dp[i][j] = min(w[i - 1] + dp[i - 1][j - v[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	for(int i = MAXV; i >= 0; i--) if(dp[n][i] <= W) {
		cout << i << "\n";
		return;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++) {
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
	}
	return 0;
}


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

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector<vector<int>> bingo(3, vector<int>(3));
	rep(i, 3) rep(j, 3) cin >> bingo.at(i).at(j);
	int N, num;
	cin >> N;
	rep(i, N){
		cin >> num;
		rep(i, 3) {
			rep(j, 3) {
				if (num == bingo.at(i).at(j))
					bingo.at(i).at(j) = 0;
			}
		}
	}
	rep(i, 3) {
		if (count(bingo.at(i).begin(), bingo.at(i).end(), 0) == 3) {
			cout << "Yes\n";
			return (0);
		}
	}
	rep(col, 3) {
		int count = 0;
		rep(row, 3) {
			if (bingo.at(row).at(col) == 0)
				count++;
			if (count == 3) {
				cout << "Yes\n";
				return (0);
			}
		}
	}
	if (!bingo[0][0] && !bingo[1][1] && !bingo[2][2]) {
		cout << "Yes\n";
		return (0);
	}
	if (!bingo[0][2] && !bingo[1][1] && !bingo[2][0]) {
		cout << "Yes\n";
		return (0);
	}
	cout << "No\n";
}


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

long long C[51][51];
void comb_table(int N) {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0 || j == i) {
				C[i][j] = (long long)1;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}
}

int main() {
	// 前処理
	int N, A, B;
	cin >> N >> A >> B;
	comb_table(N);
	vector<long long>V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}
	sort(V.rbegin(), V.rend());

	pair<long long, long long>pans = make_pair(0,100);
	long long anscount = 0;
	long long sum = 0;		
	for (int i = 0; i < A -1; ++i) {
		sum += V[i];
	}
	{
		for (long long i = A; i <= B; ++i) {
			sum += V[i - 1];
			int count0 = 0;
			int count1 = 0;
			for (int j = 0; j < N; ++j) {
				if (V[i - 1] == V[j]) {
					count0++;
					if (j <= i - 1) {
						count1++;
					}
				}
			}
			long long anscountsub = C[count0][count1];
			if ((pans.first*i) < (sum*pans.second)) {
				pans = make_pair(sum, i);
				anscount = anscountsub;
			}
			else if ((pans.first*i) == (sum*pans.second)) {
				anscount += anscountsub;
			}
			//cout << count0 <<"_"<<count1<< endl;
		}
	}
	long double dans = (long double)pans.first / (long double)pans.second;
	printf("%.10Lf\n", dans);
	cout << anscount << endl;
	return 0;

}

Measured memory_bytes: 3744