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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int n; string s; cin >> n >> s;
  if (n % 2) {
    cout << "No\n";
    return 0;
  }
  if (
  string(s.begin(), s.begin() + n / 2)
  + string(s.begin(), s.begin() + n / 2)
  == s
  ) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    vector<vector<mint>> dp(n+1, vector<mint>(s+1));
    dp.at(0).at(0) = 1;
    rep(i, n) {
        rep(j, s+1) {
            dp.at(i+1).at(j) += dp.at(i).at(j) *2;
            if(j+a.at(i) <= s) dp.at(i+1).at(j+a.at(i)) += dp.at(i).at(j);
        }
    }
    cout << dp.at(n).at(s) << endl;
    return 0;
}

Measured memory_bytes: 73656
#include <iostream>

using namespace std;

bool isRightTriangle(int a, int b, int c){
    if ((a * a + b * b) == (c * c)){
        return true;
    }else{
        return false;
    }
}

int main(int argc, const char * argv[])
{

    int a, b, c, n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        if (isRightTriangle(a, b, c) || isRightTriangle(b, c, a) || isRightTriangle(a, c, b)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

string cap[26] = { "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z" };

int main() {

	string S;
	cin >> S;

	for (int i = 0; i < 26; i++) {
		if (S.find(cap[i]) == string::npos) {
			cout << cap[i] << endl;
			break;
		}
		else if (i == 25) cout << "None" << endl;
	}

	return 0;
}


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

int main(){
  string str, order, p, rev;
  int q, a, b;
  cin >> str >> q;
  
  for ( int i = 0; i < q; i++ ){
  	cin >> order;
  	
  	if ( order == "print" ){
  	  cin >> a >> b;
  	  cout << str.substr(a, b-a+1) << endl;
  	} else if ( order == "reverse" ){
  	  cin >> a >> b;
  	  rev = str;
  	  int k = 0;
  	  
  	  for ( int j = a; j <= b; j++ ){
  	  	str[j] = rev[b-k++];
  	  }
  	  
  	} else{
  	  	cin >> a >> b >> p;
  	  	str = str.replace(a, b-a+1, p);
  	}
  }
  
  return 0;
}


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

typedef std::pair<std::string, int> Process;

typedef struct Node {
  Node *left, *right;
  Process data;
} Node;

Node* base;

void Node_init() {
  base = new Node();
  base->left  = base;
  base->right = base;
  return;
}

void Node_push(Process x) {
  Node *node = new Node();
  node->data = x;
  node->right = base;
  node->left  = base->left;
  node->right->left = node;
  node->left->right = node;
  return;
}

Process Node_front(void) {
  if( base->right != nullptr ) {
    return base->right->data;
  }
  return Process(0, 0);
}

void Node_pop(void) {
  Node *node = base->right;
  node->right->left = node->left;
  node->left->right = node->right;
  delete node;
  return;
}

bool Node_empty() {
  return (base == base->right);
}
  
int main() {  
  int N;
  int ltime;
  std::string name;
  int time;
  int ttime = 0;

  Node_init();

  std::cin >> N >> ltime;
  for(int i = 0; i < N; ++i) {
    std::cin >> name >> time;
    Node_push(Process(name, time));
  }

  while( not Node_empty() ) {
    Process pp;
    pp = Node_front(); Node_pop();
    pp.second -= ltime;
    if( pp.second > 0 ) {
      Node_push(pp);
      ttime += ltime;
      continue;
    }
    else {
      ttime += ltime + pp.second;
      std::cout << pp.first << " " << ttime << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 5900
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int c = 0;
  string s;
  cin >> s;
  for(int i=0;i<s.size()/2;i++)
  {
    	if(s[i] != s[s.size()-1-i])
        {
          c++;
        }
  }
  cout << c;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;

int main(){
    char S[101]={};
    cin >> S;
    char key[]="keyence";
    int len = strlen(S);
    int a;
    for(a=0;a<7;a++){
        if(S[a]!=key[a]){ break; }
    }
    int b;
    for(b=0;b<7;b++){
        if(S[len-1-b]!=key[6-b]){ break; }
    }
    if(a+b>=7){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;

int main(void) {
    string s;
    set<string> sets;
    int K;
    cin >> s >> K;
    for(int i=0; i<s.size(); i++) {
        for(int j=1; j<=5 && i+j<=s.size(); j++)
            sets.insert(s.substr(i, j));
    }
    vector<string>vecs = vector<string>(sets.begin(), sets.end());
    cout << vecs[K-1] << endl;
}


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

n,m,q = map(int,input().split())
item = []
for i in range(q):
    a,b,c,d = map(int,input().split())
    item.append([a,b,c,d])
a = [0 for i in range(11)]
ans = 0
for i1 in range(1,11):
    a[1] = i1
    for i2 in range(i1,m+1):
        a[2] = i2
        for i3 in range(i2,m+1):
            a[3] = i3
            for i4 in range(i3,m+1):
                a[4] = i4
                for i5 in range(i4,m+1):
                    a[5] = i5
                    for i6 in range(i5,m+1):
                        a[6] = i6
                        for i7 in range(i6,m+1):
                            a[7] = i7
                            for i8 in range(i7,m+1):
                                a[8] = i8
                                for i9 in range(i8,m+1):
                                    a[9] = i9
                                    for i10 in range(i9,m+1):
                                        a[10] = i10
                                        s = 0
                                        for e,f,g,h in item:
                                            if a[f] - a[e] == g:
                                                s+=h
                                        ans = max(ans,s)
print(ans)





Measured memory_bytes: 9380
fun main() {
    val (a, b, c, k) = readLine()!!.split(" ").map { it.toInt() }
    
    var x = k - a
    var res = 0
    if (k >= a) {
        res = a
        if (x > 0) {
            x -= b
            if (x > 0) {
                res -= x
            }
        }
    } else {
        res = k
    }
    println(res)
}


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

using namespace std;
typedef long long ll;

string s,t;

int main(){
    cin >> s;
    cin >> t;
    for(int i=0;i<s.size();i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3620
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

S_A = [0] * (N + 1)
S_B = [0] * (M + 1)
for i in range(N):
  S_A[i+1] = S_A[i] + A[i]

for i in range(M):
  S_B[i+1] = S_B[i] + B[i]
  
ans = 0
a = 0
for i in range(M, -1, -1):
  s = S_B[i]
  if s>K:
    continue
  while a<N:
    if s + S_A[a + 1]<=K:
      a += 1
    else:
      break
  ans = max(ans, i + a)
print(ans)

Measured memory_bytes: 111220
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t k;
    cin >> k;

    int64_t m = 50;
    int64_t q = k / m, r = k % m;
    vector<int64_t> a(m);

    fill(a.begin(), a.end(), q - r);
    rep(i, m)
    {
        a[i] += i;
    }

    rep(i, r)
    {
        a[i] += m + 1;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int a;
	in(a);
	out(a+a*a+a*a*a);
	return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] s = str.split(" ");

		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);

		if((0 < a) && (b < Math.pow(10,9))){ //10???9???
			int d = a / b;
			int r = a % b;
			double f = ((double)a / b);


			System.out.printf("%d %d %05f",d ,r ,f);
		}
	}
}

Measured memory_bytes: 24800
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int64_t N,K;
  cin>>N>>K;
  if(N%K>K-(N%K)){
  cout << K-(N%K) << endl;}
  else{cout<<N%K<<endl;}
}


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

void merge_sort(long long x[], int n)
{
	static long long y[1001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

typedef struct {
	long long key;
	int id[3];
} data;

typedef struct {
	data *obj;
	int size;
} max_heap;

void push(data x, max_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key > h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(max_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key > h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key > h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

#define Mod 10007

typedef struct List {
	struct List *next;
	int id[3];
} list;

int main()
{
	int i, j, k, X, Y, Z, K;
	long long A[1001], B[1001], C[1001];
	scanf("%d %d %d %d", &X, &Y, &Z, &K);
	for (i = 0; i < X; i++) scanf("%lld", &(A[i]));
	for (i = 0; i < Y; i++) scanf("%lld", &(B[i]));
	for (i = 0; i < Z; i++) scanf("%lld", &(C[i]));
	merge_sort(A, X);
	merge_sort(B, Y);
	merge_sort(C, Z);
	
	list *hash[Mod] = {}, appear[10001], *p;	
	data d;
	max_heap h;
	h.size = 0;
	h.obj = (data*)malloc(sizeof(data) * K * 3);
	d.key = A[X-1] + B[Y-1] + C[Z-1];
	d.id[0] = X - 1;
	d.id[1] = Y - 1;
	d.id[2] = Z - 1;
	push(d, &h);
	appear[0].id[0] = X - 1;
	appear[0].id[1] = Y - 1;
	appear[0].id[2] = Z - 1;
	appear[0].next = hash[d.key % Mod];
	hash[d.key % Mod] = &(appear[0]);
	for (i = 1, k = 1; i <= K; i++) {
		d = pop(&h);
		printf("%lld\n", d.key);
		for (j = 0; j < 3; j++) {
			if (d.id[j] > 0) {
				d.id[j]--;
				d.key = A[d.id[0]] + B[d.id[1]] + C[d.id[2]];
				for (p = hash[d.key % Mod]; p != NULL; p = p->next) if (p->id[0] == d.id[0] && p->id[1] == d.id[1] && p->id[2] == d.id[2]) break;
				if (p == NULL) {
					push(d, &h);
					appear[k].id[0] = d.id[0];
					appear[k].id[1] = d.id[1];
					appear[k].id[2] = d.id[2];
					appear[k].next = hash[d.key % Mod];
					hash[d.key % Mod] = &(appear[k++]);
				}
				d.id[j]++;
			}
		}
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2e5+7;

int a[MAXN];
int nonZero[MAXN];

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

    nonZero[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i]==0) nonZero[i] = nonZero[i-1];
        else nonZero[i] = i;
    }

    LL ans = 0;
    for (int i = 1; i <= n; i++) {
//        cout << "from " << i << " " << nonZero[i] << endl;
        int j = nonZero[i];
        ans += i-j;

        int msk = 0;
        while (j > 0) {
            if (msk&a[j]) break;
//            cout << "at " << j << " to " << nonZero[j-1] << endl;
            msk ^= a[j];
            ans += j-nonZero[j-1];
            j = nonZero[j-1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5144
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n, m;
vector<int> g[maxn];
bool visited[maxn];
void dfs(int v){
	visited[v] = 1;
	for(auto u : g[v]){
		if(!visited[u])dfs(u);
	}
}
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int brojac = 0;
	for(int i=1;i<=n;i++){
		if(visited[i])continue;
		dfs(i);
		brojac++;
	}
	cout << brojac - 1 << endl;
    return 0;
}

Measured memory_bytes: 9692
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int x; cin>>x;
    int cur = 100;
    int yr = 0;
    while(cur<x){
        yr++;
        cur=cur+cur/100;
    }
    cout<<yr;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 3652
#include<stdio.h>

int main()
{
	int n;
	int ctr[26] = {0}, flag = 1;
	
	scanf("%d", &n);
	
	char str[n + 1];
	
	scanf("%s", &str);
	
	for(int i = 0; str[i] != '\0'; i++){
		if(str[i] >= 'a' && str[i] <= 'z'){
			++ctr[str[i] - 'a'];
		}
	}
	
	if(n % 2 != 0){
		printf("No\n");
		return 0;
	}else{
		for(int i = 0; i < 26; i++){
			if(ctr[i] > 0){
				if(ctr[i] % 2 != 0){
					flag = 0;
				}
			}
		}
	}
	if(flag == 1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

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

using namespace std;

constexpr uint64_t base = 998244353ULL;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int max_depth = 0;
  unordered_map<int, int> counts;
  int D;
  cin >> D;
  if (D) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < N; ++i) {
    cin >> D;
    ++counts[D];
    max_depth = max(max_depth, D);
  }
  ++counts[0];
  if (counts[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  uint64_t count = 1;
  for (int i = 1; i <= max_depth; ++i) {
    auto cnt = counts[i];
    if (!cnt)  {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 0; j < cnt; ++j) {
      count = count * counts[i - 1] % base;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 4388
def rolliha(t, p):
    b = 1007
    h = 1000000007
    n = len(t)
    m = len(p)
    if n < m:
        return
    thsh = 0
    phsh = 0
    bpow = [1 for i in range(m+1)]
    for i in range(m):
        bpow[i+1] = bpow[i]*b % h
    for i in range(m):
        thsh = (thsh+bpow[m-1-i]*ord(t[i])) % h
        phsh = (phsh+bpow[m-1-i]*ord(p[i])) % h
    if thsh == phsh:
        print(0)
    ind = 0
    while ind+m < n:
        thsh = ((thsh*b % h) - bpow[m]*ord(t[ind]) + ord(t[ind+m])) % h
        if thsh == phsh:
            print(ind+1)
        ind += 1
    
t = input()
p = input()
rolliha(t, p)


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

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

  if(s == "hi"){
      printf("Yes\n");
  } else if (s == "hihi") {
    printf("Yes\n");
  } else if (s == "hihihi") {
    printf("Yes\n");
  } else if (s == "hihihihi") {
    printf("Yes\n");
  } else if (s == "hihihihihi") {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    int i=1;
    // Your code here!
    while(true)
    {
        std::cin >> x;
        if(x==0)break;
        std::cout << "Case " << i << ": " << x << std::endl;
        i++;
    }
}



Measured memory_bytes: 3016
let n = Scanf.scanf "%d" (fun n->n)
let (t,a) = Scanf.scanf " %d %d" (fun t a->t,a)
let hs = Array.init n (fun i-> Scanf.scanf " %d" (fun h->h))
let _ =
  let (v,p,_) = Array.fold_left (fun (v,p,i) h  ->
    let t = t*1000 - h*6 in
    let v1 = abs (t - a*1000) in
    (*Printf.printf "i=%d v1=%d v=%d\n" i v1 v;*)
    if v1 <= v then (v1,i,i+1) else (v,p,i+1)
  ) (50000000000,-1,1) hs in
  Printf.printf "%d\n" p

Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt(),d=sc.nextInt();
		int [][]a=new int [n][d];
		for(int i=0;i<n;i++)
			for(int j=0;j<d;j++)
				a[i][j]=sc.nextInt();
		int ans=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<i;j++) {
				int diff=0;
				for(int k=0;k<d;k++) {
					int dx=a[i][k]-a[j][k];
					diff+=dx*dx;
				}
				int tmp=(int) Math.sqrt(diff);
				if(tmp*tmp==diff)
					ans++;
			}
		out.println(ans);
		out.close();

	}
	
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 21076
#include <iostream>
                    #include<cmath>
                    #include<string>
                    using namespace std;
                    int main()
                    {
                       string s,d,u;
                      int a,b;
                      cin>>s>>d>>a>>b>>u;
                      if(u==s)
                        cout<<a-1<<" "<<b;
                      else
                        cout<<a<<" "<<b-1;
                        
                    }

Measured memory_bytes: 3632
//
//  main.cpp
//  A
//
//  Created by 黄宇凡 on 2017/5/6.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <map>
#include <cstring>
#include <cstdio>

using namespace std;



map<pair<int,pair<int,int> >,int> mp;

int main(int argc, const char * argv[]) {
    int A,B,C;
    cin >> A >> B >> C;
    mp.clear();
    mp[make_pair(A,make_pair(B,C))] = true;
    if(A % 2 || B % 2 || C % 2){
        cout << 0 << endl;
        return 0;
    }
    int num = 0;
    while(true){
        int ta = A,tb = B,tc = C;
        A = tb / 2 + tc / 2;
        B = ta / 2 + tc / 2;
        C = ta / 2 + tb / 2;
       // cout << A << B << C << endl;
        //cout << mp[st(A,B,C)] << endl;
        if(mp[make_pair(A,make_pair(B,C))] == true){
            cout << -1 << endl;
            return 0;
        }
        num++;
        if(A % 2 || B % 2 || C % 2) break;
        mp[make_pair(A,make_pair(B,C))] = true;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;
#define ll long long

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n;
		cin >> n;
		cout << (1000 -  n % 1000) % 1000 << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
using namespace std;
int cnt = 0;
void depth_first_search(int,int,vector< vector<char> > &);
int main(){

  while(true){
    int w,h;
    cin >> w;
    cin >> h;
    
    int fx;
    int fy;
    if(w == 0 && h ==0 )return 0;
    vector< vector<char> > map(w, vector<char>(h));
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	cin >> map[j][i];
	
	if(map[j][i] == '@'){
	  fx = j;
	  fy = i;
	}
      }
    }
    cnt = 1;
    depth_first_search(fx,fy,map);
    cout << cnt << endl;
  }
  return 0;
}
void depth_first_search(int x,int y,vector< vector<char> > &map){
  int dx[4] = {0,1,-1,0};
  int dy[4] = {1,0,0,-1};

  for(int i = 0;i < 4;i++){
    if(!(x+dx[i] == -1 
	|| x+dx[i] == map.size() 
	|| y+dy[i] == -1 
	|| y+dy[i] == map[0].size()
	)
	&& map[x+dx[i]][y+dy[i]] == '.' 
       ){
      map[x+dx[i]][y+dy[i]] = '1';
      cnt++;
      
      depth_first_search(x+dx[i],y+dy[i],map);
      
    }
  }
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> n(3);
  int i;
  for(i=0;i<3;i++){
    cin >> n[i];
  }
  sort(n.begin(),n.end());
  int ans = 0;
  ans += n[2] - n[1];
  n[0] += n[2] - n[1];
  ans += (n[2] - n[0] + 1)/2;
  n[0] += ((n[2] - n[0] + 1)/2)*2;
  if(n[2] != n[0]){
    ans++;
  }
  cout <<ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    lr_list = [list(map(int, input().split())) for _ in range(N)]
    ans = 0
    for lr in lr_list:
        ans += lr[1] - lr[0] + 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
from itertools import zip_longest

s = list(input())

for i in range(2**3) :
    lis = []
    c = ""
    for j in range(3) :
        if (i >> j) & 1 :
            lis.append("+")
        else:
            lis.append("-")
        
    for a, b in zip_longest(s, lis, fillvalue = "") :
        c += a + b
    
    if eval(c) == 7 :
        print(f"{c}=7")
        break

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    for(int i=0;i<k;i++){
        if(b<=a) b=b*2;
        else if(c<=b) c=c*2;
    }
    if(a<b && b<c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <cstdio>

int n, m, stk[100005], top, mn[100005];
char s[100005];

#define gp(x) mn[(x) > 0 ? (x) : 1]

int main() {
    scanf("%d%d%s", &n, &m, s + 1);
    mn[n + 1] = n + 1;
    for (int i = n; i; --i) {
        if (s[i] == '1') mn[i] = mn[i + 1];
        else mn[i] = i;
    }
    //for (int i = 1; i <= n; ++i) printf("%d ", mn[i]); printf("\n");
    int i = n + 1;
    while (i != 1) {
        int p = gp(i - m);
        if (p == i) {
            puts("-1");
            return 0;
        }
        stk[++top] = i - p;
        i = p;
    }
    for (int i = top; i; --i)
        printf("%d ", stk[i]);
    printf("\n");
    return 0;
}

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

int main(void) {
  long long N, A;
  cin >> N;
  vector<long long> member(N, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> A;
    member[A - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << member[i] << endl;
  }
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;

    Scd(N);
    vector<int> b(N,0);
    Rep(i,N){
        Scd(b[i]);
    }

    vector<int> ans(N,0);
    Rep(i,N){
        Rep(j,N-i){
            if( b[j] == j+1 ){
                ans[i] = j+1;
            }
        }
        if( ans[i] ){
            b.erase( b.begin() + (ans[i]-1) );
        }else{
            ans[0] = -1;
        }
    }

    if( ans[0] == -1 ) printf ("%d\n", -1);
    else{
        reverse(ans.begin(), ans.end() );
        for( int k : ans ) printf ("%d\n", k );
    }


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,p,q;
  cin>>n>>p>>q;
  vector<Int> c(n);
  for(Int i=0;i<n;i++) cin>>c[i];
  vector<Int> d(n);
  
  Int res=0;
  for(Int i=0;i<n;i++){
    d[i]=(q+i)*p;
    res+=d[i];
  }
  
  Int ans=res;
  
  vector<Int> v(n);
  for(Int i=0;i<n;i++)
    v[i]=c[i]-d[i]+2*p*(i-n);     
  
  sort(v.rbegin(),v.rend());
  vector<Int> s(n+1,0);
  for(Int i=0;i<n;i++) s[i+1]=s[i]+v[i];

  for(Int i=1;i<=n;i++){
    res+=2*p*i;
    Int tmp=res+s[i];
    chmax(ans,tmp);
  }
  
  cout<<ans<<endl;
  return 0;
}



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

int main(){
  int n;cin >> n;
  long long min1 = 4000000;
  vector<int> a(n);for(int i=0;i<n;i++){
    cin >> a[i];}
  sort(a.begin(),a.end());
  for(int i=a[0];i<=a[n-1];i++){
    long long amin=0;
    for(int j=0;j<n;j++){
     amin+=(a[j]-i)*(a[j]-i);
    }
    min1 = min(amin,min1); 
   }
  cout << min1 << endl;
}

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

dic = {}

ans = 0
for i in range(n):
    if i+1-a[i] in dic:
        ans += dic[i+1-a[i]]
    
    if a[i]+(i+1) in dic:
        dic[(i+1)+a[i]] = dic[(i+1)+a[i]] + 1
    else:
        dic[(i+1)+a[i]] = 1
        
print(ans)

Measured memory_bytes: 40392
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    cin >> N;
    vector<int> a( N );
    for( auto &x : a )
    {
        cin >> x;
    }
    bool flag = false;
    int now = 0, i = 0, cnt = 0;
    vector<int> visited( N + 1, -1 );
    while( true )
    {
        if( i == N )
        {
            break;
        }
        if( visited[ now ] == -1 )
        {
            now = a[ now ] - 1;
            cnt++;
        }
        if( now == 1 )
        {
            flag = true;
            break;
        }
        i++;        
    }
    cout << ( cnt && flag ? cnt : -1 ) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y,z;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[200101];
int l[1];
int j[1],pa[200101];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;
stack<P> s[200101];

vector<int> v[200101];

bool as(P a,P b)
{
  return a.x<b.x;
}


int f(int n)
{
  if(o[n]==n) return n;
  return o[n]=f(o[n]);
}

bool asd(int a,int b)
{
  return s[f(a)].size()<s[f(b)].size();
}

P ss(P a,P b)
{
  return {(a.x)*(b.x)%mod,((a.x)*b.y%mod+(b.x)*a.y%mod)%mod,(a.z+a.y*b.y%mod)%mod};
}

void g(int n)
{
  for(int h=0;h<v[n].size();h++)
  g(v[n][h]);
  sort(v[n].begin(),v[n].end(),asd);
  if(v[n].size()==0) s[n].push({(mod+1)/2,(mod+1)/2,0});
  else
  {
    int p=0;
    for(int h=0;h+1<v[n].size();h++)
    {
      stack<P> s1;
      int k=1;
      for(;s[f(v[n][h])].size();k++)
      {
        P d=s[f(v[n][h])].top(),e=s[f(v[n][h+1])].top();
        if(p<=k) d.x+=d.z,d.x%=mod,d.z=0;
        e.x+=e.z,e.x%=mod,e.z=0;
        //printf("$$%d %d %lld %lld\n",n,v[n][h],ss(d,e).x*z%mod,d.x*e.x%mod*z%mod);
        s1.push(ss(d,e));
        s[f(v[n][h])].pop();
        s[f(v[n][h+1])].pop();
      }
      for(;s1.size();s1.pop())
        s[f(v[n][h+1])].push(s1.top());
      p=max(p,k);
    }
    o[n]=f(v[n].back());
    s[f(n)].push({(mod+1)/2,(mod+1)/2,0});
  }
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&pa[t]);
    v[pa[t]].push_back(t);
  }
  iota(o+1,o+a+1,1);
  z=1;
  for(int t=0;t<=a;t++)
  z*=2,z%=mod;
  g(0);
  d=f(0);
  
  
  for(;s[d].size();s[d].pop())
  {
    long long z=(1<<12);
    x+=s[d].top().y;
    //printf("# %lld %lld %lld\n",z*s[d].top().x%mod,z*s[d].top().y%mod,z*s[d].top().z%mod);
    x%=mod;
  }
  
  printf("%lld",x*z%mod);
}
//2
//800 1760 1536


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

int main(){
  int a,b,c,d,count=0;
  cin >> a >> b >> c >> d;
  r(i,101){
    if(i>=a&&i<=b&&i>=c&&i<=d)count++;
  }
  cout <<max(0,count-1)<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;

    for (int i = 1; i <= 50000; i++) {
        if (N == i * 108 / 100) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
 
int main(){
    int n;
    scanf("%d", &n);
 
    int a[100];
    for (int i=0; i<n; ++i)
        scanf("%d", &a[i]);
 
    int ans = 2147483647;
    for (int i=-100; i<=100; i++) {
        int sum = 0;
        for (int j=0; j<n; ++j){
            sum += (a[j]-i)*(a[j]-i);
        }
        if (ans > sum)
            ans = sum;
    }
 
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long long int n;
  cin >> n;
  vector<long long int> vi;
  for(long long int i=1; i * i <= n; i++){
    if(n % i == 0){
      vi.push_back(i);
      if(n/i != i){
        vi.push_back(n/i);
      }
    }
  }
  long long int min_dist = n;
  for(auto d : vi){
    min_dist = min(min_dist, d + n/d -2);
  }
  cout << min_dist << endl;
  return 0;
}
      

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int r; cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 3528
n,m=map(int,input().split())

a=[list(map(int,input().split())) for i in range(n)]
b=[[0]*(m+1) for i in range(n+1)]

for i in range(n):
    for j in range(m):
        b[i][j]=a[i][j]

for i in range(n):
    tmp=0
    for j in range(m):
        b[i][m]+=b[i][j]
    print(*b[i])
    
for i in range(m+1):
    tmp=0
    for j in range(n):
        b[n][i]+=b[j][i]
print(*b[n])


Measured memory_bytes: 6256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static final int MAX_WH = 1002;

	static int matrix[][] = new int[MAX_WH][MAX_WH];
	static boolean prime[] = new boolean[1000001];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		isPrime();
		map();

		while (true) {
			String str[] = br.readLine().split(" ");
			int m = Integer.parseInt(str[0]);
			int n = Integer.parseInt(str[1]);

			if (n == 0 && m == 0) {
				break;
			}

			int sx = -1;
			int sy = -1;
			for (int i = 0; i < MAX_WH; i++) {
				for (int j = 0; j < MAX_WH; j++) {
					if (matrix[i][j] == n) {
						sy = i;
						sx = j;
					}
				}
			}

			int[][] dp = new int[MAX_WH][MAX_WH];
			dp[sy][sx] = 1;
			int ansSize = 1;
			int ansRoute = 0;
			for (int i = sy; i < MAX_WH; i++) {
				for (int j = 0; j < MAX_WH; j++) {
					if (i == sy && matrix[i][j] != n)
						continue;
					if (matrix[i][j] > m)
						continue;
					if (dp[i][j] == 0)
						continue;

					if (prime[matrix[i][j]]) {
						dp[i][j]++;
						if (ansSize < dp[i][j]) {
							ansSize = dp[i][j];
							ansRoute = matrix[i][j];
						} else if (ansSize == dp[i][j]) {
							if (ansRoute < matrix[i][j]) {
								ansRoute = matrix[i][j];
							}
						}
					}

					dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
					if (j >= 1) {
						dp[i + 1][j - 1] = Math.max(dp[i + 1][j - 1], dp[i][j]);
					}
					if (j + 1 < 1002) {
						dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j]);
					}
				}
			}
			System.out.println(ansSize - 1 + " " + ansRoute);
		}
	}

	static void map() {
		for (int i = 0; i < MAX_WH; i++) {
			Arrays.fill(matrix[i], Integer.MAX_VALUE);
		}
		int now = 1;
		int x = MAX_WH / 2 - 1;
		int y = MAX_WH / 2 - 1;
		for (int i = 1; now <= 1000000; i++) {
			if (i % 2 == 1) {
				for (int j = 0; j < i && now <= 1000000; j++) {
					matrix[y][x] = now;
					x++;
					now++;
				}
				for (int j = 0; j < i && now <= 1000000; j++) {
					matrix[y][x] = now;
					y--;
					now++;
				}
			} else {
				for (int j = 0; j < i && now <= 1000000; j++) {
					matrix[y][x] = now;
					x--;
					now++;
				}
				for (int j = 0; j < i && now <= 1000000; j++) {
					matrix[y][x] = now;
					y++;
					now++;
				}
			}
		}
	}

	static void isPrime() {
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for (int i = 2; i * i <= 1000000; i++) {
			for (int j = i + i; j <= 1000000; j += i) {
				prime[j] = false;
			}

		}
	}
}



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

int main() {
	int N;
	long ans;

	ans = 0;

	cin >> N;
	vector<int> value(N*3);

	for(int num = 0; num < 3*N; num++){
		cin >> value[num];
	}
	sort(value.begin(), value.end(), greater<int>());

	for(int num = 1; num <= N; num++){
		ans += value[num*2-1];
	}
 	 cout << ans << endl;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b;
    cin >> a >> b;

    if(a%2==0&&b%2==0||a%2!=0&&b%2!=0) {
        cout << (a+b)/2 << endl;
    }
    else cout << (a+b+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#self.r[x] means root of "x" if "x" isn't root, else number of elements
class UnionFind():
    def __init__(self, n):
        self.r = [-1 for i in range(n)]
    
    #use in add-method
    def root(self, x):
        if self.r[x] < 0: #"x" is root
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]

    #add new path
    def add(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        self.r[x] += self.r[y]
        self.r[y] = x
        return True

n, m = map(int, input().split())
UF = UnionFind(n)
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    UF.add(a, b)

ans = 0
for i in UF.r:
    if i < 0:
        ans += 1

print(ans-1)


Measured memory_bytes: 11004
import heapq
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
cand_1 = []
cand_2 = []
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        cand_1.append(b)
    elif b == N:
        cand_2.append(a)

ans = "IMPOSSIBLE"
heapq.heapify(cand_1)
heapq.heapify(cand_2)


while len(cand_1) != 0 and len(cand_2) != 0:
    if cand_1[0] < cand_2[0]:
        heapq.heappop(cand_1)
    elif cand_1[0] > cand_2[0]:
        heapq.heappop(cand_2)
    else:
        ans = "POSSIBLE"
        break
print(ans)


Measured memory_bytes: 11140
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  string s,t;
  bool f=false;
  cin >> s >> t;
  REP(i,s.length()){
    if (s==t) f=true;
    s=s.substr(1,s.length()-1)+s[0];
  }
  Yn(f);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

int n;
int constexpr maxn = 100009;
int constexpr MOD = 1e9 + 7;
vector<vector<int>> G;
int dp[maxn][2];


void read_input()
{
    cin >> n;
    G.resize(n + 1);
    int x, y;
    for(int i = 0; i < n - 1; i++) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

int go(int i, int c, int par) {
    if(dp[i][c] != -1) return dp[i][c];


    int ans = 1;
    for(int adj : G[i]) {
        if(adj == par) continue;

        if(c == 0) {
            ans *= (go(adj, 0, i) + go(adj, 1, i)) % MOD;
        } else {
            ans *= go(adj, 0, i);
        }
        ans %= MOD;
    }
    return dp[i][c] = ans;
}

decltype(0) main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    for(int i = 0; i < maxn; i++) dp[i][0] = dp[i][1] = -1;

    cout << (go(1, 0, -1) + go(1, 1, -1)) % MOD << endl;
}


Measured memory_bytes: 14208
#include<iostream>
using namespace std;
int num[1000010];
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        num[a]++;
        num[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<num[i]<<endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int X,Y,S;
int tax(int a,int b)
{
    return b*(100+a)/100;
}
int solve()
{
    int maximum=0;
    for(int i=1;i<S;i++)
        for(int j=1;j<S;j++)
            if(tax(X,i)+tax(X,j)==S)
                maximum=max(maximum,tax(Y,i)+tax(Y,j));
    return maximum;
}
int main()
{
    while(cin>>X>>Y>>S&&X>0)
        cout<<solve()<<endl;
}


Measured memory_bytes: 3108
import java.util.*

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = ArrayDeque<Long>()

    repeat(9) { q.add(it+1L) }

    var tmp = 0L
    repeat(k) {
        tmp = q.pollFirst()
        if (tmp % 10L != 0L) {
            q.add(10L * tmp + (tmp % 10L) - 1)
        }
        q.add(10L * tmp + (tmp % 10L))
        if (tmp % 10L != 9L) {
            q.add(10L * tmp + (tmp % 10L) + 1)
        }
    }
    println(tmp)
}


Measured memory_bytes: 38684
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(n-i-j>=0&&10000*i+5000*j+1000*(n-i-j)==y){
	cout<<i<<' '<<j<<' '<<n-i-j<<endl;
	return(0);
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return(0);
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A.sort()
ai=A[-1]
A=A[:-1]
ans=10**19
aj=0
if ai%2==0:
    a=ai//2
    for i in range(n-1):
        if ans>abs(A[i]-a):
            ans=abs(A[i]-a)
            aj=A[i]
    print(ai,aj)
else:
    a=(ai-1)//2
    b=a+1
    for i in range(n-1):
        if ans>min(abs(A[i]-a),abs(A[i]-b)):
            ans=min(abs(A[i]-a),abs(A[i]-b))
            aj=A[i]
    print(ai,aj)


Measured memory_bytes: 62704