akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<V<int>> edge(N);
	REP(i,N-1) {
		int x,y; cin >> x >> y;
		x--;y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	V<int> dist(N,-1);
	dist[0] = 0;
	queue<int> q;
	q.push(0);
	while(q.size()){
		int from = q.front();
		q.pop();
		for(auto to:edge[from]){
			if(dist[to]==-1){
				dist[to] = dist[from] + 1;
				q.push(to);
			}
		}
	}
	V<P<int,int>> ord;
	REP(i,N) ord.push_back({-dist[i],i});
	sort(ALL(ord));
	V<ll> dpw(N,0),dpb(N,0);
	REP(i,N){
		int from = ord[i].second;
		ll w = 1, b = 1;
		for(auto to:edge[from]){
			if(dist[to]<dist[from]) continue;
			(b *= dpw[to]) %= MOD;
			(w *= (dpw[to]+dpb[to])%MOD ) %= MOD;
		}
		dpw[from] = w;
		dpb[from] = b;
	}
	cout << (dpw[0]+dpb[0])%MOD << endl;
	return 0;	
}



Measured memory_bytes: 9460
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a[5];
int k;

int main() {
	for(int i = 1; i <= 3; i++) scanf("%d", &a[i]);
	scanf("%d", &k);
	int sum = 0;
	while(k--) {
		sort(a + 1, a + 4);
		a[3] *= 2;
	}
	for(int i  =1; i <= 3; i++) sum += a[i];
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll a,b;
cin>>a>>b;
ll v[3];
v[0]=a+b;
v[1]=a-b;
v[2]=a*b;
sort(v,v+3);
c(v[2]);

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

        solve();
    }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const int INF = 1e9 + 15;
int dp[maxn];
int soma(int a,int b){
    if(a+b>=MOD)return a+b-MOD;
    else return a+b;
}
int subt(int a, int b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    memset(dp,0,sizeof dp);
    dp[0]=1;
    int vet[n+2];
    rep(i,0,n){
        cin>>vet[i];
        // cout<<vet[i]<<endl;
    }
    rep(i,0,n){
        vector<int> pf(k+1,0);
        per(j,k+1,0){
            int tmp = dp[j];
            int l = j+1;
            int r = j+min(vet[i],k-j);
            if(l<=r){
                pf[l]=soma(pf[l],tmp);
                if(r+1<=k)pf[r+1]=subt(pf[r+1],tmp);
            }
        }
        int pfx=0;
        rep(j,0,k+1){
            pfx=soma(pfx,pf[j]);
            dp[j]=soma(pfx,dp[j]);
        }
    }
    cout<<dp[k]<<"\n";
    return 0;   
}

Measured memory_bytes: 1148
#include <stdio.h>
int main(void){
 long long int a,b,c,d;
 scanf("%lld%lld",&a,&b);
 c=a/b;
 d=(a/(b/2))-c;
 if(b%2==1){
  if(c==0) printf("0");
  else if(c==1) printf("1");
  else printf("%lld",c+c*(c-1)*3+c*(c-1)*(c-2));
 }else{
  if(d==0) printf("0");
  else if(d==1&&c==0) printf("1");
  else if(d==1&&c==1) printf("2");
  else if(d==2&&c==1) printf("9");
  else printf("%lld",c+c*(c-1)*3+c*(c-1)*(c-2)+d+d*(d-1)*3+d*(d-1)*(d-2));
 }
return 0;
}


Measured memory_bytes: 128
def examA():
    N, A, B = LI()
    ans = min(A*N,B)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()
#define maxel max_element
#define minel min_element
#define Bit(i) pow(2, i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vcTable;
  repeat(i, 1, m + 1) { vcTable.push_back(i); }
  rep(i, n) {
    int k;
    cin >> k;
    vector<int> vcTable2;
    rep(j, k) {
      int a;
      cin >> a;
      vcTable2.push_back(a);
    }
    sort(all(vcTable2));
    vector<int> vcIntersection;
    set_intersection(all(vcTable), all(vcTable2),
                     back_inserter(vcIntersection));
    vcTable = vcIntersection;
  }
  cout << vcTable.size() << endl;
}


Measured memory_bytes: 256
xy = input('')
x = int(xy.split(' ')[0])
y = int(xy.split(' ')[1])

result = False
for a in range(x+1):
    b = x - a
#    print("a:{} b:{} =>{}".format(a,b,a*2+4*b))
    if (a*2 + 4*b) == y:
        result = True

if result:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	string  s; cin>>s;
	if(s == "Sunny") cout<<"Cloudy"<<"\n";
	if(s == "Rainy") cout<<"Sunny"<<"\n";
	if(s == "Cloudy") cout<<"Rainy"<<"\n";
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))
# 先手目線で考える。手元にj枚あって、勝てるならTrue
dp = [False]*(k+1)
for i in range(1,k+1):
    flag = False
    for j in range(n):
        if i-A[j] >= 0:
            if dp[i-A[j]] == False:
                flag = True
                break
    if flag:
        dp[i] = True
    else:
        dp[i] = False
if dp[k]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 43220
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,c,dp[405][405],pre[405][405];
ll prepow[405][405];
ll a[404],b[404];
ll rec(ll i,ll j)
{
	if(i>n)
	{
		if(j==0)
			return 1;
		return 0;
	}
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll an=0;
	for(int h=0;h<=j;h++)
		an=(an+rec(i+1,j-h)*pre[i][h])%MOD;
	return dp[i][j]=an;
}
int main()
{	
	SPEED;
	memset(dp,-1,sizeof dp);
	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=0;i<=400;i++)
		prepow[i][0]=1;
	for(int i=0;i<=400;i++)
		for(int j=1;j<=400;j++)
			prepow[i][j]=(prepow[i][j-1]*i)%MOD;
	for(int i=1;i<=n;i++)
		pre[i][0]=(b[i]-a[i]+1)%MOD;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=400;j++)
		{
			ll an=0;
			for(int h=a[i];h<=b[i];h++)
			{
				an=(an+prepow[h][j])%MOD;
			}
			pre[i][j]=an;
		}
	}
	cout<<rec(1,c)<<endl;
	return 0;
}

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

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

    string s;
    cin >> s;

    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
#include<typeinfo>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 

lli power(lli x,lli y)
{
     lli res=1;
     while(y>0)
     {
        if(y&1)res = ((res%mod)*(x%mod))%mod;
        y>>=1;
        x= ((x%mod)*(x%mod))%mod;
     }
     return res;
}

int main()
{
    
         

    fio

    lli n;
    cin>>n;
    pair<lli,lli> p[n];
    fr(i,0,n)cin>>p[i].first>>p[i].second;

    fr(i,1,n-1)
    {
        if(p[i-1].first==p[i-1].second && p[i].first==p[i].second && p[i+1].first==p[i+1].second){cout<<"Yes";return 0;}
    }
    


  
      cout<<"No";

    


  
     

    


     

     


    
      




 

return 0;}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int64_t i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main() {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    int64_t res = 0;
    int64_t two_factor = 1;
    for (int d = 0; d < 60; ++d) {
        int64_t even = 0, odd = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] & (1LL<<d)) ++odd;
            else ++even;
        }
        int64_t add = (odd * even) % MOD * two_factor % MOD;
        res = (res + add) % MOD;
        two_factor = (two_factor * 2) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
long long n,b=1;
int ans=0,a[1001];
int main()
{
	cin>>n;
	for(int i=1;i>=1;i++)
	{
		if(b+pow(26,ans+1)>n)
			break;
		b+=ceil(pow(26,ans+1));
		ans++;
	}
	n-=b;
	for(int i=0;i<=ans;i++)
	{
		a[i+1]=n%26;
		n/=26;
	}
	for(int i=ans+1;i>=1;i--)
		cout<<char(a[i]+'a');
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26) cin >> s[i][j];
    vector<vector<int>> last(d, vector<int>(26));
    rep(i, d)rep(j, 26) last[i][j] = 0;
    vector<int> ans(d + 1, 0);
    int max_score;
    int max_con;
    int score, sum;
    rep(i, d){
        max_score = 0;
        rep(j, 26){
            sum = 0;
            rep(k, 26){
                if(k != j) sum += c[k] * ((i + 1) - last[i][k]);
            }
            score = s[i][j] - sum;
            if(max_score < score){
                max_score = score;
                max_con = j;
            }
        }
        last[i][max_con] = i + 1;
        ans[i] = max_con + 1;
    }
    rep(i, d) cout << ans[i] << endl;
}


Measured memory_bytes: 3728
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 200003
#define M 2003
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
    
    int n;
    cin>>n;
    pii p[n+1];
    int i;
    for(i=1;i<=n;++i)
        cin>>p[i].second>>p[i].first;
    
    sort(p+1,p+n+1);
    int curr=0;
    for(i=1;i<=n;++i)
    {
        if(curr+p[i].second>p[i].first)
        {
            cout<<"No";
            return 0;
        }
        curr+=p[i].second;
    }   
    cout<<"Yes";
    
    
    
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ull unsigned long long
#define pq priority_queue
#define ll long long
#define pp pair<ull,ull>
#define rush() int T;scanf("%d",&T);while(T--)  
#define forr(n) for(int i=1;i<=n;i++)
using namespace std;
const int maxn = 200005;  
const ll mod = 1e9+7;  
const int INF = 0x3f3f3f;  
const double eps = 1e-9;  
int a[2][maxn]; 
int n; 
struct node
{
	int v,l,r;
	bool operator <(const node&b)const
	{
		return v>b.v;
	}
}no[maxn];
int s[2][maxn][18];
int pos[maxn];
void initRmq(int t)
{
	forr(n)
	{
		s[t][i][0]=a[t][i];
	}
	for(int j=1;(1<<j)<=n;j++)
	for(int i=1;i+(1<<j)-1<=n;i++)
	s[t][i][j]=min(s[t][i][j-1],s[t][i+(1<<(j-1))][j-1]);
}
int RMQ(int l,int r,int v)
{
	int k=0;
	while((1<<(k+1))<=r-l+1)k++;
	return min(s[v][l][k],s[v][r-(1<<k)+1][k]);
}
int main()
{
	node tmp;
	int temp;
	pq <node>q;
	cin>>n;
	forr(n)
	{
		scanf("%d",&temp);
		pos[temp]=i;
		a[i&1][i]=temp;
		a[(i&1)^1][i]=INF;
	}
	initRmq(1);
	initRmq(0);
	tmp.v=RMQ(1,n,1);
	tmp.l=1;
	tmp.r=n;
	q.push(tmp);
	int v1,v2;
	while(!q.empty())
	{
		node x=q.top();
		q.pop();
		v1=x.v,v2=RMQ(pos[v1]+1,x.r,(pos[v1]&1)^1);
		printf("%d %d ",v1,v2);
		v1 = pos[v1], v2 = pos[v2];
		if(v1!=x.l)
		{
			tmp.v=RMQ(x.l,v1-1,x.l&1);
			tmp.l=x.l;
			tmp.r=v1-1;
			q.push(tmp);
		}
		if(v1!=v2-1)
		{
			tmp.v=RMQ(v1+1,v2-1,(v1+1)&1);
			tmp.l=v1+1;
			tmp.r=v2-1;
			q.push(tmp);			
		}
		if(v2!=x.r)
		{
			tmp.v=RMQ(v2+1,x.r,(v2+1)&1);
			tmp.l=v2+1;
			tmp.r=x.r;
			q.push(tmp);			
		}
	}
	return 0;
}

Measured memory_bytes: 34936
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, x = map(int, input().split())
        a = list(map(int, input().split()))

        a.sort()

        for i in range(N):
            if x >= a[i]:
                x -= a[i]
                a[i] = 0
            else:
                break
        if x > 0:
            a[-1] += x

        print(a.count(0))


if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0,rad;cin>>N;ll A[N];
  REP(i,N){cin>>A[i];A[i]-=i;}sort(A,A+N);
  if(N%2==0)rad=(A[N/2-1]+A[N/2]+1)/2;
  else rad=A[N/2];
  REP(i,N)ans+=abs(A[i]-rad);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ans=0;
  map<int,int>A;
  cin>>N;
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    A[tmp]++;
  }
  for(auto itr = A.begin(); itr != A.end(); ++itr){
    if(itr->second%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int ask(const string &s) {
  cout << "? " << s << endl;
  int x;
  cin >> x;
  return x;
}

int main() {

  string chars = "";
  for (char c = 'a'; c != 'z' + 1; ++c) chars.push_back(c);
  for (char c = 'A'; c != 'Z' + 1; ++c) chars.push_back(c);
  for (char c = '0'; c != '9' + 1; ++c) chars.push_back(c);

  priority_queue<string, vector<string>, function<bool(const string &, const string &)>> que(
          [&](const string &s, const string &t) { return s.size() > t.size(); });
  int len = 0;
  for (char c : chars) {
    int occ = 128 - ask(string(128, c));
    if (occ)que.push(string(occ, c));
    len += occ;
  }
  while (que.size() > 1) {
    string s = que.top();
    que.pop();
    string t = que.top();
    que.pop();
    string tmp = t;
    int ptr = (int) s.size() - 1;
    for (int i = (int) t.size(); i >= 0; --i) {
      while (true) {
        tmp.insert(i, string() + s[ptr]);
        if (len - ask(tmp) == tmp.length()) {
          t = tmp;
          if (--ptr < 0) break;
        } else {
          tmp = t;
          break;
        }
      }
      if (ptr < 0) break;
    }
    que.push(t);
  }
  cout << "! " << que.top() << endl;

  return 0;
}


Measured memory_bytes: 3720
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;
const ll MOD = 1e9+7;

ll addM(ll a, ll b){
	return (a+b) % MOD;
}
ll mulM(ll a, ll b){
	return ((a%MOD) * (b%MOD)) % MOD;
}
ll f(ll n){ // 2^n を計算	
  	if(n==0) return 1;
  	else if(n==1) return 2;
  	else if(n%2 == 0) return mulM(f(n/2),f(n/2));
	else return mulM(mulM(2, f((n-1)/2)),f((n-1)/2)); 
}

void Main()
{
  	int N;
  	cin >> N;
  	vector<int> c(N);
  	rep(i,N) cin >> c[i];
	sort(c.begin(), c.end());
    ll ans = 0;
  	ll temp = 0;
	rep(i,N){
      	temp = mulM(N+1-i, c[i]);
    	ans = addM(ans, temp);
    }  
   	ans = mulM(ans, f(2*N-2)); 
	cout << ans << endl;
	return;
}

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

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

int main() {
  int N;
  cin >> N;
  int M;
  double ans;
  
  M = N / 2;
  
  if(N%2==0) M = N / 2;
  else M = (N / 2) + 1;
  
  cout << (double)M/N << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final String input = stdin.nextLine().trim();
	    if ( "0".equals( input ) ){
		break;
	    }
	    String[] inputs = new String[ 3 ];
	    inputs[ 0 ] = input;
	    inputs[ 1 ] = stdin.nextLine();
	    inputs[ 2 ] = stdin.nextLine();
	    
	    for ( int i = 0; i < 3; i++ ) {
		int a = 0;
		int b = 0;
		for ( int j = 1; j < inputs[ i ].length(); j++ ) {
		    final char ch = inputs[ i ].charAt( j );
		    if ( 'A' == ch ) {
			a++;
		    } else {
			b++;
		    }
		}
		if ( a > b ) {
		    a++;
		} else {
		    b++;
		}				
		System.out.printf( "%d %d\n", a, b );
	    }
	}	
    }    
}

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

#define NIL -1
#define MAX 500000

// 1 originとして使う
int heap[MAX*2 + 1];
int H;

int parent(int i) { return i/2;}
int left(int i) {return 2*i;}
int right(int i){return 2*i + 1;}

void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int largest;

  if(l <= H && heap[i] < heap[l]) largest = l;
  else largest = i;
  if(r <= H && heap[largest] < heap[r]) largest = r;

  if(largest != i){
    swap(heap[i], heap[largest]);
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i=H/2; i>0; i--){
    maxHeapify(i);
  }
}

int main(){

  scanf("%d", &H);

  for(int i=1; i<=H; i++){
    scanf("%d", &heap[i]);
  }

  buildMaxHeap();

  for(int i=1; i<=H; i++){
    printf(" %d", heap[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 5156
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))



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

int64_t f(int64_t n){
    return n*(n-1)/2;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    rep(i,n){
        //cout << ans -f(m[a[i]]) + f(m[a[i]]-1) << endl;
        printf("%lld\n", ans +1 - m[a[i]]);
    }
    
    return 0;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);

		String S = sc.next();
		String T = sc.next();

		int ans = 0;
		for (int n=0; n<S.length(); n++) {
			if (S.charAt(n) != T.charAt(n)) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

	}
}


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

int a, b, c, d;

signed main () {
  cin >> a >> b >> c >> d;
  a += b; c += d;
  if (a > c) cout << "Left" << endl;
  else if (a < c) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
#d=["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"]
#import numpy as np
#import math
#n=int(input())
#li=input().split()
#n=int(input())
#S=input()

ab=[0]*(10**5+1)
lis=list(map(int,input().split()))
for i in range(lis[0]):
    t=list(map(int,input().split()))
    ab[t[0]]+=t[1]

ans=0
i=1
count=0
while count<lis[1]:
    count+=ab[i]
    ans=i
    i+=1

print(ans)


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

a = list(map(int,input().split()))
cnt_4 = 0
cnt_2 = 0
for v in a:
    if v % 4 == 0:
        cnt_4 += 1
    elif v % 2 == 0:
        cnt_2 += 1
if cnt_2 <= 1:
    if N//2 <= cnt_4:
        print('Yes')
    else:
        print('No')
else:
    if (N-(cnt_2-1))//2 <= cnt_4:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 19968
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
struct yyz
{
	int m,n;
}k[100001];

using namespace std;

bool cmp(yyz aa,yyz bb)
{
	return aa.m<bb.m;
}

signed main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	
	for(int i=1;i<=x;i++)
	{
		scanf("%d%d",&k[i].m,&k[i].n);
	}
	
	sort(k+1,k+x+1,cmp);
	
	int ans=0;
	for(int i=1;i<=x;i++)
	{
		if(y>k[i].n) ans+=k[i].m*k[i].n,y-=k[i].n;
		else
		{
			ans+=k[i].m*y;
			break;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
import string

N = int(input())
al = string.ascii_lowercase

s = ''
num = 26
while N > 26:
    amari = N % num
    N //= 26
    if (amari == 0):
        N -= 1
    if (amari == 0):
        s += al[25]
    else:
        s += al[amari - 1]
if (N == 0):
    s += al[25]
else:
    s += al[N - 1]
print(s[::-1])


Measured memory_bytes: 9900
// This  Program is made by Jan(Codezebra)
#include<bits/stdc++.h>
using namespace std;
signed main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n,k;
	string s;
	cin>>n>>k>>s;
	vector<int> c={0};
	bool what=1;
	for(int i=0;i<n;i++){
		if((s[i]=='1')==what){
			c[c.size()-1]++;
		}
		else{
			c.push_back(1);
			what=!what;
		}
	}
	if(what==0){
		c.push_back(0);
	}
/*	for(int e:c){
		cout<<e<<" ";
	}cout<<"\n";*/
	int l=0,r=2*k+1;
	int curr=0;
	for(int i=0;i<min(r,(int)c.size());i++){
		curr+=c[i];
	}
	int best=curr;
	while(r<c.size()){
		curr+=c[r]+c[r+1];
		r+=2;
		curr-=c[l]+c[l+1];
		l+=2;
		best=max(best,curr);
	}
	cout<<best;
	return 0;
}



Measured memory_bytes: 1020
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

x = intl()
for i in range(5):
	if x[i] == 0:
		print(i+1)
		exit()


Measured memory_bytes: 9040
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int n;
  vector <pair<string, pair<int, int> > > v;
  cin >> n;
  REP(i, n) {
    string s;
    int a;
    cin >> s >> a;
    v.PB(make_pair(s, make_pair(-a, i+1)));
  }
  sort(ALL(v));
  REP(i, SZ(v)) cout << v[i].second.second << endl;

}

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


Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, T;
	cin >> N >> T;

	vector<P> ct;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		ct.emplace_back(P{a, b});
	}

	int ans = INF;
	REP(i, N) {
		if (ct[i].second <= T) {
			ans = min((ll)ans, ct[i].first);
		}
	}

	if (ans == INF) {
		cout << "TLE" << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[10];
bool flag = false;

//B:=B?????????????????° C*=C?????????????????° cnt:=??????????????°??????
void dfs(int B, int C, int cnt){
	if(cnt == 9){
		if(B < a[cnt]) flag = true;
		if(C < a[cnt]) flag = true;
		return;
	}
	if(B < a[cnt]){
		dfs(a[cnt], C, cnt + 1);
	}
	if(C < a[cnt]){
		dfs(B, a[cnt], cnt + 1);
	}
	if(B > a[cnt] && C > a[cnt]){
		return;
	}
}
int main(void){
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		rep(j, 10) cin >> a[j];
		flag = false;
		dfs(0, 0, 0);
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
#define test ll t;cin>>t;while(t--)
#define input(a,b) vector<ll>v(b);for(auto i=a;i<b;i++)cin>>v[i]
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
typedef vector<ll> vi;
typedef vector<vi> vii;
typedef unordered_map<ll,ll> mpp;
typedef pair<ll,ll> ii;
#define mod 100000007

vector<ll>v(102);
int dp[102][4][2];
int k;
int find(int pos,int cnt,int f)
{
	if(cnt>k)
		return 0;
	if(pos==v.size())
	{
		if(cnt==k)
			return 1;
		return 0;
	}
	if(dp[pos][cnt][f]!=-1)
	{
		return dp[pos][cnt][f];
	}
	int res=0;
	int LMT;
	if(f==0)
	{
		LMT=v[pos];
	}
	else
		LMT=9;
	
	for(auto dgt=0;dgt<=LMT;dgt++)
	{
		int nf=f;
		int ncnt=cnt;
		if(f==0&&dgt<LMT)
			nf=1;
		if(dgt!=0)
			ncnt++;
		if(ncnt<=k)
			res+=find(pos+1,ncnt,nf);
	}
	return dp[pos][cnt][f]=res;
}

int32_t main()
{
	fast;
	string s;
	cin>>s;
	cin>>k;
	v.resize(s.length());
	memset(dp, -1, sizeof(dp));
	for(auto i=0;i<s.length();i++)
	{
		v[i]=(int)(s[i]-48);
	}
	
	cout<<find(0,0,0)<<endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[1005];
int main()
{
    int n,ans;
    double temp,tmin=0x3f3f3f3f,b,t;
    cin>>n>>t>>b;
    for(int i=0;i<n;i++){
        cin>>a[i];
        temp=t-a[i]*0.006;
        if(tmin>abs(b-temp)){
        tmin=abs(b-temp);
        ans=i+1;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  rep(i, Size(s)) { ans += (s[i] - '0'); }
  if (ans % 9 == 0)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 3760
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

				int sum1 = N*A;
				int sum2 = B;

				if(sum1>=sum2){
					System.out.println(sum2);
				}else{
					System.out.println(sum1);
				}

    }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main()
{
    int t[4][14];
    int n, i, j, c;
    char m, d;
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 14; j++)
        {
            t[i][j] = 0;
        }
    }
    scanf("%d", &c);
    for (i = 0; i < c; i++)
    {
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        if (m == 'S')
        {
            t[0][n] = 1;
        }
        else if (m == 'H')
        {
            t[1][n] = 1;
        }
        else if (m == 'C')
        {
            t[2][n] = 1;
        }
        else if (m == 'D')
        {
            t[3][n] = 1;
        }
    }
    for (j = 1; j < 14; j++)
    {
        if (t[0][j] != 1)
        {
            printf("S %d\n", j);
        }
    }

    for (j = 1; j < 14; j++)
    {
        if (t[1][j] != 1)
        {
            printf("H %d\n", j);
        }
    }

    for (j = 1; j < 14; j++)
    {
        if (t[2][j] != 1)
        {
            printf("C %d\n", j);
        }
    }

    for (j = 1; j < 14; j++)
    {
        if (t[3][j] != 1)
        {
            printf("D %d\n", j);
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
	int key;
	Node *prev, *next;
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
    }
    return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 1;
	while(1){
		if ( cur == nil ) break;
		if ( isf == 0)  printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
	}

void deleteNode(Node *t) {
	if (t == nil)
	return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);
		if ( com[0] == 'i' ) {insert(key); np++; size++;}
		else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ) deleteFirst();
				else if ( com[6] == 'L' ) deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int x, n;
  cin >> x >> n;
  set < int > s;
  int dif = INT_MAX, val = -1;
  for (int i = 1; i <= n; i++) {
    int a; cin >> a;
    s.insert (a);
  }

  for (int i = -200; i <= 200; i++) {
    if (!s.count (i)) {
      if (abs (i - x) < dif) {
        dif = abs (i - x);
        val = i;
      }
    }
  }

  cout << val << '\n';
}


Measured memory_bytes: 3636
try:
    while True:
        A=0
        B=0
        
        a=list(str(input()))
        b=len(a)
        for i in range(b-2):
            c=a[i]+a[i+1]+a[i+2]
            if c=="JOI":
                A+=1
            if c=="IOI":
                B+=1
                
        print(A)
        print(B)
        
except EOFError:
    pass


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

int n, mn, mx, mn_count, mx_count;
int a;

int main() {
    mn_count = mx_count = 0;
    mn = 2000 * 1000 * 1000;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a > mx) {
            mx = a;
            mx_count = 0;
        }
        if (a < mn) {
            mn = a;
            mn_count = 0;
        }
        if (a == mn)
            mn_count++;
        if (a == mx)
            mx_count++;
    }
    if (mx - mn > 1)
        return cout << "No" << '\n', 0;
    if (mx - mn == 1)
        if (mx <= mn_count || mx > mn_count + mx_count / 2)
            return cout << "No" << '\n', 0;
    if (mn == mx) 
        if (mx > n / 2 && mx != n - 1) 
            return cout << "No" << '\n', 0;
    cout << "Yes" << '\n';
    return 0;
}



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

values = [0]
weights = [0]

for _ in range(N):
    v, w = map(int, input().split())
    values.append(v)
    weights.append(w)

dps = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, W + 1):
        if j >= weights[i]:
            dps[i][j] = max(dps[i - 1][j], dps[i - 1]
                            [j - weights[i]] + values[i])
        else:
            dps[i][j] = max(dps[i - 1][j], dps[i][j - 1])
# print(dps)
print(dps[N][W])



Measured memory_bytes: 25936
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
	int a, b,i,j;
	while (1)
	{
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		for(i = 1;i <= a;i++)
		{
			for (j = 1; j <= b; j++)
			{
				if (i == 1 || j == 1 || i == a || j == b)
				{
					cout << '#';
				}
				else
				{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

const int MAX = 21;

struct Edge{int to, cost;};
vector<Edge> E[MAX];
int N;

void init(){
  for(int i = 0; i < MAX; i++) E[i].clear();
}

void input(){
  for(int i = 0; i < N-1; i++){
    int a,b,c;
    cin >> a >> b >> c;
    E[a].push_back((Edge){b,c});
    E[b].push_back((Edge){a,c});
  }
}

int dfs(int now, int pre){
  int dis = 0;

  for(int i = 0; i < (int)E[now].size(); i++){
    int nex = E[now][i].to;
    int cos = E[now][i].cost;
    
    if(nex == pre) continue;
    if(E[nex].size() == 1) continue;
    dis += dfs(nex,now)+cos*2;
  }
  return dis;
}

int dfs2(int now, int pre){
  int dis = 0;

  for(int i = 0; i < (int)E[now].size(); i++){
    int nex = E[now][i].to;
    int cos = E[now][i].cost;
    
    if(nex == pre) continue;
    if(E[nex].size() == 1) continue;
    dis = max(dis,dfs2(nex,now)+cos);
  }
  return dis;
}

int main(){
  while(cin >> N && N){
    init();
    input();
    cout << dfs(1,0)-dfs2(1,0) << endl;
  }
  return 0;
}

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n+1,0);
  rep1(i,n){
    cin>>a[i];
  }
  map<int,int> sum;
  map<int,int> sub;
  rep1(i,n){
    int bufs=i+a[i];
    int bufd=i-a[i];
    sum[bufs]+=1;
    if(bufd>0){
      sub[bufd]+=1;
    }
  }
  auto it=sum.begin();
  int res=0;
  while(it!=sum.end()){
    int buf=it->first;
    auto it2=sub.find(buf);
    if(it2==sub.end()){
      ++it;
      continue;
    }
    else{
      res+=it->second*it2->second;
      ++it;
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 21032
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int s[100005];
Int t[100005];
Int x[100005];
Int ans[100005];
Int A, B, Q;

Int calc(Int x){
    Int ret[15] = {0};
    
    auto itr1 = lower_bound(s, s+A, x);
    if (itr1 != s+A) ret[0] = abs(x - *itr1);
    auto itr2 = lower_bound(t, t+B, *itr1);
    if (itr1 != s+A && itr2 != t+B) ret[0] += abs(*itr1 - *itr2);
    else ret[0] = 0;

    if (itr1 != s+A) ret[1] = abs(x - *itr1);
    if (itr2 != t) itr2--;
    if (itr1 != s+A) ret[1] += abs(*itr1 - *itr2);

    if (itr1 != s) itr1--;
    ret[2] = abs(*itr1 - x);
    itr2 = lower_bound(t, t+B, *itr1);
    if (itr2 != t+B) ret[2] += abs(*itr1 - *itr2);
    else ret[2] = 0;

    ret[3] = abs(x - *itr1);
    if (itr2 != t) itr2--;
    ret[3] += abs(*itr1 - *itr2);

    itr1 = lower_bound(t, t+B, x);
    if (itr1 != t+B) ret[4] = abs(x - *itr1);
    itr2 = lower_bound(s, s+A, *itr1);
    if (itr1 != t+B && itr2 != s+A) ret[4] += abs(*itr1 - *itr2);
    else ret[4] = 0;

    if (itr1 != t+B) ret[5] = abs(x - *itr1);
    if (itr2 != s) itr2--;
    if (itr1 != t+B) ret[5] += abs(*itr1 - *itr2);
    else ret[5] = 0;

    if (itr1 != t) itr1--;
    ret[6] = abs(x - *itr1);
    itr2 = lower_bound(s, s+A, *itr1);
    if (itr2 != s+A) ret[6] += abs(*itr1 - *itr2);
    else ret[6] = 0;

    if (itr2 != s) itr2--;
    ret[7] = abs(x - *itr1);
    ret[7] += abs(*itr1 - *itr2);

    Int ans = 10000000000000;
    for (int i = 0; i < 8; i++){
        if (ret[i] != 0){
            ans = min(ans, ret[i]);
        }
    }
    return ans;
}

int main(){
    cin.tie(0);

    cin >> A >> B >> Q;
    for (int i = 0; i < A; i++){
        cin >> s[i];
    }
    for (int i = 0; i < B; i++){
        cin >> t[i];
    }
    for (int i = 0; i < Q; i++){
        cin >> x[i];
    }
    
    for (int i = 0; i < Q; i++){
        cout << calc(x[i]) << endl;
    }    
}


Measured memory_bytes: 3712
s=gets.chomp.to_s

leng = s.length

def abs(n)
  return n if n>0
  return -n
end

ans = 100000000000000
for i in 0..leng-3 do
  tmp = s[i..i+2].to_i
  ans = abs(tmp-753) > ans ? ans : abs(tmp-753)
end

puts ans


Measured memory_bytes: 1788
n=int(input())
ab=[[0]*2 for ii in range(n)]
for ii in range(n):
	ab[ii][1],ab[ii][0]=map(int,input().split())

#ab = sorted(ab, reverse=True, key=lambda x: x[1])  #[1]に注目してソート
ab.sort(reverse=True)
#print(ab)
r=ab[0][0]
for ii in range(n):
  r=min(ab[ii][0],r)-ab[ii][1]
  if r<0:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 35744
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

bool ada[300];

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	string s; cin >> s;

	for(char c : s)
		ada[c] = 1;

	if(s.size() == 26)
	{
		if(s == "zyxwvutsrqponmlkjihgfedcba")
			cout << -1 << "\n";
		else
		{
			char bef = s.back(); s.pop_back();
			ada[bef] = 0;
			while(s.back() > bef)
			{
				bef = s.back();	s.pop_back();
				ada[bef] = 0;
			}
			for(char c = 'a'; c <= 'z'; c++)
			{
				if(!ada[c] && s.back() < c)
				{
					s[s.size()-1] = c;
					break;
				}
			}	
			cout << s << "\n";
		}
		return 0;
	}

	for(char c = 'a'; c <= 'z'; c++)
	{
		if(!ada[c])
		{
			s = s + c;
			break;
		}
	}
	cout << s << "\n";
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(all(A));
    
    int ans=0;
    for(int i=0;i<K;i++){
        ans+=A[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3652