akhauriyash/Code-Regression huggingface dataset:
from heapq import *
N, M = map(int, input().split())
A = []
for a in map(int, input().split()):
    heappush(A, -a)
for _ in range(M):
    x = -heappop(A)
    x //= 2
    heappush(A, -x)
print(-sum(A))

Measured memory_bytes: 86552
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        ans += a[i] - 1;
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections

def main():
    O = input()
    E = input()

    ans = ''
    for i in range(len(O)):
        ans += O[i]
        if i < len(E):
            ans += E[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65332
#include <stdio.h>

int main(void) {
	int N, d;
	int i;
	int gosennchouenn = 0;
	if (scanf("%d%d", &N, &d) != 2) return 1;
	for (i = 0; i < N; i++) {
		int p;
		if (scanf("%d", &p) != 1) return 1;
		if (p > d) gosennchouenn += p - d;
	}
	if (gosennchouenn >= 1) {
		printf("%d\n", gosennchouenn);
	} else {
		puts("kusoge");
	}
	return 0;
}



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

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

  int n, m;
  cin >> n >> m;

  vector<int> h(n);
  for (int& e: h) cin >> e;

  vector<int> good(n, 1);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    if (h[x] <= h[y]) good[x] = 0;
    if (h[y] <= h[x]) good[y] = 0;
  }

  cout << accumulate(good.begin(), good.end(), 0) << '\n';
}

Measured memory_bytes: 3988
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

string DoctorTableAD(char c){
	string s;
	const char ctable[] = " ',-.\?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char table[][32] = {"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
	
	for(int i = 0; i < sizeof(ctable)/sizeof(*ctable); i++){
		if(ctable[i] == c){
			s = table[i];
			break;
		}
	}
	return s;
}
int myatoi(string &bin_s){
	int ret = 0;
	unsigned int i = 0;
	while( i < bin_s.length() ){
		ret += (int)((bin_s[i] - '0') * pow(2.0, (double)((bin_s.length() - 1) - i)));
		i++;
	}
	return ret;
}
char DoctorTableDA(string &s){
	int d = myatoi(s);
	char ac[] = " .,-'?";

	for(int i = 0; i < 'Z' - 'A' + 1; i++) if(d == i) return i + 'A';
	for(int i = 0; i < sizeof(ac)/sizeof(*ac); i++) if(i + 26 == d) return ac[i];
	return ' ';
}
string DoctorLovedEncode(string &raw){
	string s;
	string ret;
	for(unsigned int i = 0; i < raw.length(); i++){
		s += DoctorTableAD(raw[i]);
	}
	// padding
	while( s.length() % 5 != 0 ) s += '0';

	for(unsigned int i = 0; i < s.length() / 5; i++){
		string subs = s.substr(i*5,5);
		ret += DoctorTableDA( subs );
	}
	return ret;
}

int main(void){
	while(true){
		string s;

		while( true ){
			char c;
			c = cin.get();
			if( cin.eof() ) return 0;
			if( c == '\n') break;
			else s += c;
		}

		cout << DoctorLovedEncode( s ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=505;
char ans[N][N];
int32_t main(){
    int n,m,d;
    cin>>n>>m>>d;
    if(d&1){
        int u=(d+1)/2,w=d/2;
        for(int x=-500;x<=1000;++x){
            for(int y=-500;y<=1000;++y){
                int a,b,ok=1;char c='?';
                if((x*u+y*w)%(u*u+w*w)==0){
                    a=(x*u+y*w)/(u*u+w*w);
                    if((y-a*w)%u==0)b=(y-a*w)/u;        
                    else ok=0;
                }else ok=0;
                if(ok){
                    if(a&1){
                        if(b&1)c='R';
                        else c='Y';
                    }else{
                        if(b&1)c='G';
                        else c='B';
                    }
                    for(int i=x-w;i<=x+w;++i)
                        for(int j=y-w;j<=y+w;++j)
                            if(0<=i&&i<n&&0<=j&&j<m&&abs(i-x)+abs(j-y)<=w)
                                ans[i][j]=c;
                }
            }
        }
        forn(i,n){
            forn(j,m)cout<<ans[i][j];
            cout<<'\n';
        }
    }else{
        forn(i,n){
            forn(j,m){
                char c;
                int x=i+j,y=i-j;
                if(x&1)--x,++y;
                int xd=(x+d*228228)/d,yd=(y+d*228228)/d;
                if(xd&1){
                    if(yd&1)c='R';
                    else c='Y';
                }else{
                    if(yd&1)c='G';
                    else c='B';
                }
                cout<<c;
            }
            cout<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3892
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner();
		// int A = sc.nextInt();
		// int B = sc.nextInt();
		// if (A <= 8 && B <= 8) {
		// System.out.println("Yay!");
		// } else {
		// System.out.println(":(");
		// }
		int D = sc.nextInt();
		int N = sc.nextInt();
		long base = (long) (Math.pow(100, D));
		int cnt = 1;
		long cur = base;
		while (cnt < N) {
			cur += base;
			long tmp = cur;
			int c = 0;
			while (tmp % 100 == 0) {
				tmp /= 100;
				++c;
			}
			if (c == D) {
				++cnt;
			}
		}
		System.out.println(cur);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

}


Measured memory_bytes: 21200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 100010


int main(){
	long double a[N];
	long double b[N];
	f(i, N){
		a[i] = 0;
		b[i] = 0;
	}
	long double l, r, m, x, y, z;
	l = -1000000.0;
	r = 2000000.0;
	int n, k;
	long double s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n){
		scanf("%Lf %Lf", &a[i],&b[i]);
	}
	while (l + 0.0000000001 < r){
		m = (l + r) / 2;
		v = true;
		ans = 10000000.0;
		f(i, n){
			x = m - a[i];
			x = x*x;
			y = b[i] * b[i];
			z = y - x;
			if (z >= 0)z = sqrt(z);
			else z = -100;
			if (z < ans){
				ans = z;
				if (a[i] < m)v = true;
				else v = false;
			}
		}
		if (v)r = m;
		else l = m;
	}
	if (ans < 0)ans = 0;
	printf("%Lf\n", ans);


	return 0;
}


Measured memory_bytes: 5896
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;
typedef double r32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 500000;

struct item
{
	r32 t;
	int v;
	item() {}
	item(const r32 &_t, const int &_v)
		: t(_t), v(_v) {}

	inline r32 calc() const
	{
		return t * v;
	}
};

int n, l;

int q_l = 1, q_r = 0;
item q[MaxN + 1];

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

	r32 sum = 0;
	for (int i = 0; i < n; ++i)
	{
		r32 t = getint();
		int v = getint();

		int cur = v;
		while (q_l <= q_r && cur >= q[q_l].v)
			cur -= q[q_l].v, sum -= q[q_l++].calc();

		sum += v * t;
		if (q_l <= q_r && cur)
		{
			sum -= q[q_l].calc();
			q[q_l].v -= cur;
			sum += q[q_l].calc();
		}

		while (q_l <= q_r && q[q_r].t > t)
		{
			t = (v * t + q[q_r].calc()) / (v + q[q_r].v);
			v += q[q_r--].v;
		}

		q[++q_r] = item(t, v);

		printf("%.12f\n", sum / l);
	}

	return 0;
}

Measured memory_bytes: 19328
package main

import "fmt"

func solve(a, b, c, x int) {
	var cnt int
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if (500*i + 100*j + 50*k) == x {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	solve(a, b, c, x)
}

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

print(0)
s = str(input())
if s == 'Vacant':
    exit()
s0 = s

print(n-1)
s = str(input())
if s == 'Vacant':
    exit()

def is_ok(x):
    print(x)
    s = str(input())
    if s == 'Vacant':
        exit()
    if x%2 == 1:
        if s != s0:
            return False
        else:
            return True
    else:
        if s == s0:
            return False
        else:
            return True


l = 0
r = n-1
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        r = c
    else:
        l = c


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

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int i=a; i<=b; i++) {
    string s1 = to_string(i);
    string s2 = s1;
    reverse(s2.begin(), s2.end());
    if (s1 == s2) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
from bisect import bisect_left


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


x = int(input())
p = primes(100100)
print(p[bisect_left(p, x)])

Measured memory_bytes: 39408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        while(true) {
            boolean flg = true;
            for (int i = 0; i < a.length; i++) {
                if(a[i] % 2 != 0) {
                    flg = false;
                    break;
                } else {
                    a[i] /= 2;
                }
            }
            if(flg) {
                ans++;
            } else {
                break;
            }
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#"
#define INF 1e9+5
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;	
	vector<ll> ans(3);
	ll a = 0, b = 0, c = 0;
	for(ll x = 0; x < n; x++)
	{
		vector<ll> v(3);
		for(ll y = 0; y < 3; y++)
			cin>>v[y];
		ans[0] = v[0] + max(b, c);
		ans[1] = v[1] + max(a, c);
		ans[2] = v[2] + max(a, b);
		a = ans[0], b = ans[1], c = ans[2];
	}
	cout<<max(a,max(b,c));
}

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

int main() {
  int n, sum=0, ans=0;
  string x;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  REP(i,n) { cin >> s[i] >> t[i]; sum+=t[i]; }
  cin >> x;

  REP(i, n) {
    ans+=t[i];
    if (s[i] == x) break;
  }
  cout << sum-ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

map<ll, ll> mp;

int main()
{
    int n, m;
    cin>>n>>m;
    REP(i,n) {
        ll a;
        cin>>a;
        mp[a]++;
    }
    REP(i,m) {
        ll b, c;
        cin>>b>>c;
        ll e = 0;
        for (auto itr : mp) {
            //cout<<itr.first<<"_"<<itr.second<<endl;
            if (b == 0 || itr.first >= c)
                break;
            mp.erase(e);
            int d = min(b, itr.second);
            mp[itr.first] -= d;
            //cout<<d<<endl;
            mp[c] += d;
            b -= d;

            if (itr.second == 0) {
                e = itr.first;
            }
        }

        /* for (auto itr2 : mp) {
            cout<<itr2.first<<" "<<itr2.second<<endl;
        }
        cout<<endl; */
    }
    ll ans = 0ll;
    for (auto itr : mp) {
         ans += itr.first * itr.second;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 6528
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum_full = 0
prev_dish = -1
for dish in A:
	sum_full += B[dish-1]
	if dish == prev_dish + 1:
		sum_full += C[prev_dish-1]
	prev_dish = dish

print(sum_full)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007

using namespace std;

int main(){
    FAST
    ll cnt =0;
    ll n; cin >> n;
    if(n<10){
        cout << "0" << endl;
        return 0;
    }
    ll a=n;
    if(n%2!=0){
        cout << "0" << endl;
        return 0;
    }

    else{
        ll ans=0,sum=0,i=5;
        while(n/i>=1){
            ans=n/(i*2);
            sum+=ans;
            ans=0;
            i*=5;
        }
        cout << sum << endl;
    }




    return 0;
}


Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    /*String str=reader.readLine();
	    String s1[]=str.split(" ");
	    int a=Integer.parseInt(s1[0]);
	    int b=Integer.parseInt(s1[1]);*/

	    int x=Integer.parseInt(reader.readLine());

	    if(x==1||x==8||x==15||x==22||x==29){
		System.out.println("fri");
	    }else if(x==2||x==9||x==16||x==23||x==30){
		System.out.println("sat");
	    }else if(x==3||x==10||x==17||x==24||x==31){
		System.out.println("sun");
	    }else if(x==4||x==11||x==18||x==25){
		System.out.println("mon");
	    }else if(x==5||x==12||x==19||x==26){
		System.out.println("tue");
	    }else if(x==6||x==13||x==20||x==27){
		System.out.println("wed");
	    }else if(x==7||x==14||x==21||x==28){
		System.out.println("thu");
	    }
	    
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}



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

using namespace std;

const int N = 1000 * 100 + 7;

int pai[N];
int force[N];

int findd(int a){
	if(a == pai[a])return a;
	return pai[a] = findd(pai[a]);
}

void unionn(int a, int b){
	a = findd(a);
	b = findd(b);
	if(a == b)return;
	if(force[a] >= force[b]){
		pai[b] = a;
		force[a] += force[b];
	}else unionn(b, a);
}

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++){
		pai[i] = i;
		force[i] = 1;
	}
	while(m--){
		int x, y, aux;
		scanf("%d %d %d", &x, &y, &aux);
		unionn(x, y);
	}
	set <int> ar;
	for(int i = 1; i <= n; i++)
		ar.insert(findd(i));
	printf("%d\n", (int)ar.size());
	return 0;
}

Measured memory_bytes: 5760
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long


signed main(void){
  int t,s;
  string x;
  cin >> x;
  t = 0;s = 0;

  for(int i = 0; i < x.length(); i++){
    if(x[i] == 'S'){
      s++;
    }else{
      if(s)s--;
      else t++;
    }
  }

  cout << s+t << "\r\n";

}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val wList = readLine()!!.split(" ").map { it.toInt() }

    var absMin = Int.MAX_VALUE
    for (i in 1 until n) {
        val left = wList.subList(0, i).sum()
        val right = wList.subList(i, n).sum()
        val abs = Math.abs(left - right)
        if (abs < absMin) absMin = abs
    }

    println(absMin)
}


Measured memory_bytes: 37832
/*One touch and i IGNITE*/
#include<bits/stdc++.h>
using namespace std;
#define cloud_007 ios_base::sync_with_stdio(false),cin.tie(0)
#define ll long long
#define F first
#define S second
#define endl "\n"
#define Endl "\n"

int tc, n, l, r, mid, ans, val, sum;

int main()
{
#ifdef cloud007
    //freopen ( "in.txt", "r", stdin );
#endif // cloud007
    cloud_007;
    cin >> n;
    cout << (n^1) << endl;

    return 0;
}


Measured memory_bytes: 3644
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll cnt =0;
  string s;
  cin >> s;
  for(auto c:s){
    if(c=='2'){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//1行の和は3Cと予想し, マスを埋めるといける.
#include <iostream>
using namespace std;

int a, b, c;

int main() {
	cin >> a >> b >> c;
	
	cout << a << " " << b << " " << 3 * c - a - b << endl;
	cout << -2 * a - b + 4 * c << " " << c << " " << -2 * c + 2 * a + b << endl;
	cout << -c + a + b << " " << 2 * c - b << " " << 2 * c - a << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
	
		Scanner ob = new Scanner(System.in);
		int N = ob.nextInt();
		int is = 0;

		for(int roll = 1; roll <= N; roll++){
			
			int a = ob.nextInt();
			int b = ob.nextInt();

			if(a == b){
				++is;
			}else{
				is = 0;
			}

			if(is == 3){
				break;
			}
		}
		System.out.println((is == 3) ? "Yes" : "No");
	}
}


Measured memory_bytes: 36004
# -*- coding: utf-8 -*-

#############
# Libraries #
#############
import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = random.choice(range(26))
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 2000000

while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


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

using ll = long long;

void solve(long long N, std::vector<long long> a){
    int cnt = 0;
    for(int i = 0;i < N;i++){
        if(i % 2 == 0 && a[i] % 2 == 1){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3684
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.util.Collections.sort;
import static java.util.Collections.reverseOrder;

public class Main {
  	public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int card = in.nextInt();
        int gate = in.nextInt();
        List<Integer> min = new ArrayList<Integer>(gate);
        List<Integer> max = new ArrayList<Integer>(gate);
        int cch;
        for (int i = 0; i < gate; i++) {
            for (int j = 0; j < 2; j++) {
                cch = in.nextInt();
                if (j == 0) {
                    min.add(cch);
                } else {
                    max.add(cch);
                }
            }
        }
        in.close();
        sort(max);
        sort(min, reverseOrder());
        int ans = max.get(0) - min.get(0) + 1;
        if (ans < 0) ans = 0;
        System.out.println(ans);

    }
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = map<string, ll>();

    REP(i, n) {
        int    q;
        string k;
        cin >> q >> k;
        if (q == 0) {
            int x;
            cin >> x;
            v[k] = x;
        } else if (q == 1) {
            cout << v[k] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 25900
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
void solve()
{
            string n;
            cin>>n;
           ll cnt=0,l,i;
           l=n.length();
          for(i=0;i<l;i++)
          {
            ll z=n[i]-'0';
            cnt+=z%10;
          }
           if(cnt%9==0)
            cout<<"Yes";
          else
            cout<<"No";
} 
int main()
{
  
    solve();
  
    return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <algorithm>

using namespace std;

int abs(int n)
{
    return n>0?n:-n;
}

int main()
{
    int a[3];
    for(int i=0;i<3;i++) scanf("%d",&a[i]);
    int b[3];

    b[0]=abs(a[0]-a[1]);
    b[1]=abs(a[1]-a[2]);
    b[2]=abs(a[0]-a[2]);

    sort(b,b+3);

    printf("%d\n",b[0]+b[1]);
}

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

int main(){
  int n,m,x,y,zahyoux[100],zahyouy[100];
  cin>>n>>m>>x>>y;
  for(int i=0;i<n;i++){
    cin>>zahyoux[i];
  }
  for(int i=0;i<m;i++){
    cin>>zahyouy[i];
  }
  sort(zahyoux,zahyoux+n);
  sort(zahyouy,zahyouy+m);
  for(int i=x+1;i<=y;i++){
    if(zahyoux[n-1]<i&&zahyouy[0]>=i){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

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

int solve(std::string x, std::string y) {
  int m = x.length();
  int n = y.length();
  int lcs[m + 1][n + 1];
  rep(i, m + 1) lcs[i][0] = 0;
  rep(j, n + 1) lcs[0][j] = 0;

  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (x[i - 1] == y[j - 1])
        lcs[i][j] = lcs[i - 1][j - 1] + 1;
      else
        lcs[i][j] = std::max(lcs[i - 1][j], lcs[i][j - 1]);
    }
  }

  return lcs[m][n];
}

int main() {
  int n;
  std::cin >> n;
  std::string x, y;

  rep(i, n) {
    std::cin >> x >> y;
    std::cout << solve(x, y) << '\n';
  }
  return 0;
}



Measured memory_bytes: 7116
#include<iostream>

int main(){
int n;
 std::cin >> n;
 int i=1;
 if(n&(n-1)==0)
     std::cout << n << " ";
 else{
 while(1){
  if(1<<i > n){
     std::cout << (1<<i-1) << std::endl;
     break;
  }
  i++;
 }
}
 return 0;
}



Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int a,b,c,d;
    a=A+C;
    b=A+D;
    c=B+C;
    d=B+D;
    vector <int>vec(4);
    vec={a,b,c,d};
    sort(vec.begin(),vec.end());
    cout<<vec.at(0)<<endl;
}


Measured memory_bytes: 256
import numpy as np

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

a = np.array(a1+a2+a3)
a = a.reshape(3,3)

n = int(input())

for i in range(n):
  b = int(input())
  a = np.where(a==b, 0, a)

bng = 0
for i in range(3):
  r_sum = 0
  c_sum = 0
  for j in range(3):
    r_sum += a[i][j]
    c_sum += a[j][i]
  if r_sum==0 or c_sum==0:
    bng = 1

x_sum = 0
x_sum2 = 0
for i in range(3):
  x_sum += a[i][i]
  x_sum2 += a[2-i][i]
if x_sum==0 or x_sum2 ==0:
  bng = 1

if bng==1:
  print('Yes')
else:
  print('No')
  

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int pcnt(int x){
  return __builtin_popcount(x);
}

int f(int r){
  if(r == 0) return 0;
  return f(r%pcnt(r))+1;
}

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

  vector<int> x(N);
  rep(i, N) x.at(i) = s.at(i) - '0';

  int pc = 0;
  rep(i, N) pc+=x.at(i);


  vector<int> ans(N);

  rep(b,2){
    int npc = pc;
    if(b == 0) npc++; else npc--;
    if(npc <= 0)continue;

    int r0 = 0;
    rep(i,N){
      r0 = (r0*2) % npc;
      r0 += x.at(i);
    }

    int k = 1;
    for(int i = N - 1; i >= 0; --i){
      if(b == x.at(i)){
        int r = r0;
        if(b==0) r = (r + k) % npc; else r = (r-k + npc) % npc;
        ans.at(i) = f(r) + 1;
      }
      k = (k*2) % npc;
    }
  }

  rep(i, N) {cout << ans.at(i) << endl;}
}


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

constexpr int MAX = 200200;
constexpr int INF = (1 << 30);

template<class T>
inline void chmin (T &a, T b) {
    if (a > b) a = b;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &e : a) cin >> e;
    
    vector<vector<int>> dp(n + 1, vector<int>(5, INF));
    for (int j = 0; j < 5; j++) dp[0][j] = 0;
    
    auto cost = [&] (int i, int j) -> int {
        if (j == 0 or j == 4) return a[i];
        if (j == 2) return ((a[i] + 1) % 2);
        return (a[i] == 0 ? 2 : (a[i] & 1));
    };
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            int pre = INF;
            for (int k = 0; k <= j; k++) chmin(pre, dp[i][k]);
            dp[i + 1][j] = pre + cost(i, j);
        }
    }
    
    int ans = INF;
    for (int j = 0; j < 5; j++) chmin(ans, dp[n][j]);
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b != c) || (b == c && c != a) || (c == a && a != b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define println(msg) cout << msg << endl

int main() {
  // 入力
  int N, Y;
  cin >> N >> Y;
  
  // 計算
  int r10000 = -1;
  int r5000 = -1;
  int r1000 = -1;
  for (int a = 0; a <= N; a++) {
    for (int b = 0; (b + a) <= N; b++) {
      int c = N - a - b;
      int yen = 10000*a + 5000*b + 1000*c;
      if (yen == Y) {
        r10000 = a;
        r5000 = b;
        r1000= c;
      }
    }
  }
  // 出力
  cout << r10000 << " " << r5000 << " " << r1000 << endl;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int x, y, z;
multiset<string> ms;


int main() {
  cin >> x >> y >> z;
  rep(i, 0, x) ms.insert("a");
  rep(i, 0, y) ms.insert("b");
  rep(i, 0, z) ms.insert("c");

  while(ms.size() > 1) {
    auto itr1 = ms.begin();
    auto itr2 = ms.end();
    itr2--;
    ms.insert(*itr1 + *itr2);
    ms.erase(itr1);
    ms.erase(itr2);
  }

  cout << *ms.begin() << endl;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(i64, n, m);

  if (n >= m) OUTL(m / 2);

  else {
    i64 res = 0;
    rep(i, n) {
      m -= 2;
      ++res;
      if (m < 0) {
        m += 2;
        --res;
        break;
      }
    }
    OUTL(res + m/4);
  }
  return 0;
}


Measured memory_bytes: 256
from functools import lru_cache

n, m, q = map(int, input().split())
abc2d = {}
a2bcd = {}
for i in range(q):
    a,b,c,d = map(int, input().split())
    a -= 1
    b -= 1
    abc2d[a,b,c] = d
    a2bcd.setdefault(a, [])
    a2bcd[a].append((b,c,d))

a = [0] * n # 各要素は0,1,...,m-1
best = 0

@lru_cache(2**20)
def value(ind, *tmp_a):
    # a[ind:]についての目的関数値, *tmp_aはa[ind](=0), a[ind+1],...が入る
    val = 0
    if ind in a2bcd:
        val = value(ind+1, *(item-tmp_a[0] for item in tmp_a[1:]))
        for bb,cc,dd in a2bcd[ind]:            
            if tmp_a[bb-ind] - tmp_a[0] == cc:
                val += dd
#     print(tmp_a, val)
    return val

def sub(a,ind):
    global best
    # a[ind:]について全探索
    if ind==n:
        val = value(0,*a)
        best = max(best, val)
        return
    for v in range(a[ind-1], m):
        a[ind] = v
        sub(a, ind+1)
sub(a, 1)
print(best)

Measured memory_bytes: 151624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
 
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
 
int H, W;
string S[60];
int x[3] = {-1, 0, 1};
int y[3] = {-1, 0, 1};
 
int get(int h, int w)
{
    int n = 0;
    REP(i, 3)
    {
        REP(j, 3)
        {
            if (i == 1 && j == 1)
                continue;
            int nh = x[i] + h, nw = y[j] + w;
            if (nh < 0 || nh >= H || nw < 0 || nw >= W)
                continue;
            if (S[nh][nw] == '#')
                n++;
        }
    }
    return n;
}
 
int main()
{
 
    cin >> H >> W;
    REP(i, H)
    {
        cin >> S[i];
    }
 
    REP(h, H)
    {
        REP(w, W)
        {
            if (S[h][w] == '.')
            {
                cout << get(h, w);
            }
            else
            {
                cout << S[h][w];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(int(input()))

min1 = 10
temp = 0
for i in range(5):
    if (a[i]-1) %10 < min1:
        min1 = (a[i]-1) %10
        temp = i
        
count = 0
for i in range(5):
    if i == temp:
        count += a[i]
    else:
        count += (int((a[i]-1)/10)+1)*10

print(count)

Measured memory_bytes: 3064
def cmin(a,b):
    if a>b:
        return b
    else:
        return a
 
N = int(input())
h = list(map(int,input().split()))
 
dp = [0] + [float("inf")]*(N-1)
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = cmin(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])

Measured memory_bytes: 20524
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
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(int i=0;i<x;i++)
#define repn(i,x) for(int 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())

const int MAX = 20005;
const int MOD = 1000000007;


// dpで解けそう
vector<vector<ll> > dp(1005, vector<ll>(MAX));

int main(){
  ll H, N; cin>>H>>N;

  vector<ll> a(N);
  vector<ll> b(N);
  rep(i,N){
    cin>>a[i]>>b[i];
  }

  // 今回は最小値を求めたいのでINFに初期化
  rep(i,1005){
    rep(j,MAX){
    dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  rep(i,N){
    rep(j,MAX){
      if(j < a[i]){
        dp[i+1][j] = dp[i][j];
      }
      else{
        dp[i+1][j] = min(dp[i][j] , dp[i+1][j-a[i]] + b[i]);
      }
    }
  }

/*
  rep(i,5){
    rep(j,10){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
*/
  ll ans = (ll)INF;
  for(ll i = H; i < MAX; i++){
    ans = min(ans, dp[N][i]);
  }
  cout<<ans<<endl;




}


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

int main()
{
	int x, t;
	cin >> x >> t;

	if (x >= t) {
		cout << (x - t) << endl;
	}
	else {
		cout << 0 << endl;
	}

    return 0; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int Y[] = new int[N];
        for(int i = 0; i < N; i++) {
            int x = sc.nextInt();
            X[i] = x;
            Y[i] = x;
        }
        Arrays.sort(Y);
        int mid1 = Y[N/2];
        int mid2 = Y[N/2-1];
        
        for(int i = 0; i < N; i++) {
            if( X[i] < mid1 ) {
                System.out.println(mid1);
            } else {
                System.out.println(mid2);
            }
        }
        
    }
}


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

int dp[110][4][4];
int N,M;

int pas[110];

int main(){
		 
	
  cin >> N >> M;
  memset(pas,0,sizeof(pas));	 
  memset(dp,0,sizeof(dp));

  for(int i = 0; i < M; i++){
    int x,y;
    cin >> x >> y;
    pas[x] = y;
  }

  if(pas[1] == 0){
    for(int j = 0; j <= 3; j++){
      dp[1][j][1] = 1;
    }
  }
  else{
    dp[1][pas[1]][1] = 1;
  }


  for(int i = 2; i <= N; i++){
 
    if(pas[i] == 0){ //テ」ツ?敕」ツ?ョテヲツ猟・テ」ツ?古ヲツアツコテ」ツ?セテ」ツ?」テ」ツ?ヲテ」ツ?ェテ」ツ??」ツ?ェテ」ツつ?
      for(int j = 1; j <= 3; j++){
	// k = 2
	if(pas[i+1] == j) //テヲツャツ。テ」ツ?ョテヲツ猟・テ」ツ?古ヲツアツコテ」ツ?セテ」ツ?」テ」ツ?ヲテ」ツ?ヲテ」ツつ「テ」ツつヲテ」ツδ?
	  dp[i][j][2] = 0;
	else{
	  dp[i][j][2] += dp[i-1][j][1];
	  dp[i][j][2] %= 10000;
	}
	// k = 1
	for(int t = 1; t <= 3; t++){
	  if(j != t){
	    dp[i][j][1] += dp[i-1][t][1] + dp[i-1][t][2];
	    dp[i][j][1] %= 10000;
	  }
	}
 
	if( j == pas[i+1] && j == pas[i+2]) dp[i][j][1] = 0;	
      }
    }
    
    if(pas[i] != 0){ //テヲツアツコテ」ツ?セテ」ツ?」テ」ツ?ヲテ」ツつ?
      for(int j = 1; j <= 3; j++){
	if(pas[i] != j){
	  dp[i][pas[i]][1] += dp[i-1][j][1] + dp[i-1][j][2];
	  dp[i][pas[i]][1] %= 10000;
	}
      }

      dp[i][pas[i]][2] += dp[i-1][pas[i]][1];
      dp[i][pas[i]][2] %= 10000;	   
	
    }
    for(int j = 1; j <=3 ;j++){
      for(int k = 1; k <= 2; k++){
	//	cout << dp[i][j][k] << " ";
      }
      //      cout << endl;
    }
    //    cout << endl;
  }



  int ans=0;
  for(int j =1; j <= 3;j++){
    for(int k = 1; k <=2 ;k++){
      ans += dp[N][j][k];
      ans %= 10000;
    }
  }
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a;
	long min = 1000000, max = -1000000, sum = 0;

	cin >> n;

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

		if (a < min)
		{
			min = a;
		}
		if (a > max)
		{
			max = a;
		}
		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200005;
int n;
int f[N],MaxD[N],FaD[N],Lim[N],Min[N],Max[N],tot[N];
vector <int> e[N];
void dfs(int x,int pre){
	MaxD[x]=0;
	tot[x]=f[x];
	for (auto y : e[x])
		if (y!=pre){
			dfs(y,x);
			MaxD[x]=max(MaxD[x],MaxD[y]+1);
			tot[x]+=tot[y];
		}
}
multiset <int> S;
LL ans=0;
void getlim(int x,int pre){
	Lim[x]=max(FaD[x],MaxD[x]);
	S.clear();
	S.insert(FaD[x]);
	for (auto y : e[x])
		if (y!=pre)
			S.insert(MaxD[y]+1);
	for (auto y : e[x])
		if (y!=pre){
			S.erase(S.find(MaxD[y]+1));
			FaD[y]=(*--S.end())+1;
			S.insert(MaxD[y]+1);
		}
	for (auto y : e[x])
		if (y!=pre)
			getlim(y,x);
}
void solve(int x,int pre){
	for (auto y : e[x])
		if (y!=pre){
			solve(y,x);
			Min[y]=min(Min[y],MaxD[y]+1);
			Min[x]=min(Min[x],FaD[y]);
			if (!f[y]&&tot[1]-tot[y]>0)
				Max[y]=min(Max[y],FaD[y]);
			if (!f[x]&&tot[y]>0)
				Max[x]=min(Max[x],MaxD[y]+1);
		}
}
int main(){
	scanf("%d",&n);
	ans=1;
	for (int i=1;i<=n;i++)
		e[i].clear();
	for (int i=1,a,b;i<n;i++){
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int tag=0;
	for (int i=1;i<=n;i++)
		scanf("%1d",&f[i]),tag|=f[i];
	if (!tag)
		return puts("0"),0;
	dfs(1,0);
	getlim(1,0);
	for (int i=1;i<=n;i++)
		Min[i]=Lim[i]-1,Max[i]=f[i]?0:1e9;
	solve(1,0);
	for (int i=1;i<=n;i++)
		ans+=max(Min[i]-Max[i]+1,0);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 30976
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    ll X = nxtll(), K = nxtll(), D = nxtll();

    X = abs(X);

    ll division = X / D;
    if (division >= K) {
        cout << abs(X - D * K) << endl;
    } else {
        ll modulo = (K - division) % 2LL;
        if (modulo == 0) {
            cout << abs(X - D * division) << endl;
        } else {
            cout << abs(X - D * (division + 1)) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int age;cin>>age;
  if(age==1){
  	cout<<"Hello World"<<endl;
  }else{
  	int a, b;cin>>a>>b;cout<<a+b<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n;
    cin >> n;
    auto v = make_v(n, n, 0), S = make_v(n+1, n+1, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> v[i][j];
            S[i+1][j+1] = v[i][j];
            S[i+1][j+1] += S[i][j+1] + S[i+1][j] - S[i][j];
        }
    }
    int ans = -INF<int>;
    auto f = [&](int y1, int x1, int y2, int x2){
        return S[y2][x2]-S[y2][x1]-S[y1][x2]+S[y1][x1];
    };
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            if(j-i == 1){
                int val = 0, mn = 0;
                for (int k = 0; k < n; ++k) {
                    val += v[i][k];
                    chmax(ans, val-mn);
                    chmin(mn, val);
                }
                continue;
            }
            for (int k = 0; k < n; ++k) {
                chmax(ans, f(i, k, j, k+1));
            }
            int mx = f(i, 0, j, 1);
            for (int k = 1; k < n; ++k) {
                chmax(ans, mx+f(i, k, j, k+1));
                mx += v[i][k]+v[j-1][k];
                chmax(mx, f(i, k, j, k+1));
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3668
n = int(input())
for i in range(1, n + 1):
    if (i % 3) == 0:
        print(' ' + str(i), end='')
        continue
    x = i
    while True:
        if (x == 0):
            break
        if (x % 10 == 3):
            print(' ' + str(i), end='')
            break
        x //= 10
print()

Measured memory_bytes: 7880