akhauriyash/Code-Regression huggingface dataset:
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	1000000007
#define inf	1000000000000000005
#define MX1	100005
#define MX2	1000005
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li cnt[MX1];

void solve(){
    li i,n,k;cin>>n>>k;
    rep(i,0,n){
        li x,y;cin>>x>>y;
        cnt[x]+=y;
    }
    rep(i,1,100001){
        if(k<=cnt[i]){
            cout<<i;
            return ;
        }else k-=cnt[i];
    }
}

int main(){
    opt
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,l;
    cin >> n >> l;
    vector<string> s;
    rep(i,n)
    {
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    sort(s.begin(), s.end());

    rep(i,n)
    {
        cout << s[i];
    }
    cout << endl;
    
}


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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

ll dp[100001]={0};

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	ll n;
	cin>>n;
	ll a[n+1]={0};
	for(int i=1;i<=n;i++){
		cin>>a[i];
		dp[i]=LLONG_MAX/2;
	}
	dp[1]=0;
	for(int i=2;i<=n;i++){
		if(i-2>=1){
			dp[i]=dp[i-2]+abs(a[i]-a[i-2]);
		}
		if(i-1>=1){
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i]);
		}
	}
	cout<<dp[n]<<endl;



	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <functional>
#include <string.h>
using namespace std;
const int INF = 1 << 28;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,start,end) for(int i=(start);i<(end);++i)
#define pint(i) printf("%d\n",(i))
#define pint2(i,j) printf("%d %d",(i),(j))
#define pint3(i,j,k) printf("%d %d %d",(i),(j),(k))
#define gint(i) scanf("%d",&(i))
#define gint2(i,j) scanf("%d %d",&(i),&(j))
#define gint3(i,j,k) scanf("%d %d %d",&(i),&(j),&(k))
#define init(tar,val) memset((tar),(val),sizeof((tar)))
#define show(tar,len) for(int i=0;i<(len);++i) \
	cout<<tar[i]<<' ';\
	cout<<endl;


/*

class bignum{
public:
	bignum(int size = 4) :len(size){
	}
	~bignum(){
	}
	int size()const{
		return len;
	}
	//int get(int id)const{
	//	return num[id];
	//}
	friend ostream &operator<<(ostream &output, const bignum &b){
		bool stu = false;
		for (int i = int(b.len - 1); i >= 0; --i){
			if (stu)
				printf("%09d", b.num[i]);
			else if (b.num[i] > 0){
				printf("%d", b.num[i]);
				stu = true;
			}
		}
		if (stu == false)
			printf("0");
		return output;
	}
	const bignum& operator+=(const bignum&right){
		int add = 0;
		for (int i = 0; i < len; ++i){
			int tmp = 0;
			if (i < right.size()){
				tmp = right.num[i] + num[i] + add;
			}
			else{
				tmp = num[i] + add;
			}
			num[i] = tmp%gap;
			add = tmp / gap;
		}
		return *this;
	}
	const bignum& operator=(const bignum&right){
		for (int i = 0; i <len; ++i){
			num[i] = right.num[i];
		}
		return *this;
	}
	void set(int a){
		for (int i = 0; i <len; ++i){
			num[i] = a%gap;
			a /= gap;
		}
	}
private:
	int  num[4];
	int len;
	static const int gap = 1000000000;
};

//int gcd(int a,int b){
//	if(b==0)
//		return a;
//	return gcd(b,a%b);
//}
//
////a*x+b*y=gcd(a,b);
//int extgcd(int a,int b,int &x,int &y){
//	int d=a;
//	if(b!=0){
//		d=extgcd(b,a%b,y,x);
//		y-=(a/b)*x;
//	}
//	else{
//		x=1,y=0;
//	}
//	return d;
//}


//inline int id(int i){
//	return i & 1;
//}
//
//inline int last(int i){
//	return (i - 1) & 1;
//}
//
//void myshow(int i){
//	rep(j, 0, ){
//		cout << dp[id(i)][j] << ' ';
//	}
//	cout << endl;
//}

//int n_stu[MAX_N];
//void n_init(){
//	rep(i, 0, n)
//		n_stu[i] = i;
//}
//int n_getf(int id){
//	if (n_stu[id] != id){
//		n_stu[id] = n_getf(n_stu[id]);
//	}
//	return n_stu[id];
//}
//bool n_same(int i, int j){
//	if (n_getf(i) == n_getf(j))
//		return true;
//	return false;
//}
//void n_union(int i, int j){
//	int fi = n_getf(i), fj = n_getf(j);
//	if (fi != fj){
//		n_stu[fi] = fj;
//	}
//}


*/
#define my_debu



ll gcd(ll a, ll b){
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

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

int main(){
#ifdef my_debug
	freopen("a.in", "r", stdin);
#endif
	ll a, b;
	while (scanf("%lld %lld",&a,&b)!=EOF){
		ll tmp = gcd(a, b);
		printf("%lld %lld\n", tmp, lcm(a, b, tmp));
	}
	return 0;
}

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

int main(){
  int K, X;
  cin >> K >> X;
  
  vector<int> pl(2*K-1);
  for(int i=0; i<2*K-1; i++){
    pl.at(i) = X-K+1+i;
  }
  for(int j=0; j<2*K-1; j++){
    cout << pl.at(j);
    if(j==2*K-2){
      cout << endl;
      break;
    }
    else{
     cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
      int N = Int32.Parse(Console.ReadLine());
      string[] sarr = Console.ReadLine().Split(" ",StringSplitOptions.RemoveEmptyEntries);
      long[] larr = new long[N];
      
      for(int i=0; i<N; i++){
        larr[i] = Int64.Parse(sarr[i]);
      }
      Array.Sort(larr);
      /*
      for(int i=0; i<N; i++){
        Console.Write(larr[i] + ",");
      }*/
      
      decimal L = 1;
      if(larr[0] == 0){
        Console.Write("0");
        return;
      }
      for(int i=0; i<N; i++){
        try{
          checked{
            L *= larr[i];
          }
        }
        catch(OverflowException e){
          Console.Write("-1");
          return;
        }
      }
      
      if(L > 1000000000000000000)
        L = -1;
      Console.Write(L);
      
      /*
      for(int i=0; i<sarr.Length; i++){
        //Console.WriteLine(sarr[i]);
        L *= Int64.Parse(sarr[i]);
      if(L > 1000000000000000000)
        L = -1;
      }
      if(L > 1000000000000000000)
        L = -1;
      else if(L < 0)
        L = -1;*/
     
    }
}

Measured memory_bytes: 41300
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define boost ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
typedef pair<int,int> P;
priority_queue<P,vector<P>,greater<P>> pq;
int32_t main()
{
   string s,s1;
   int k,n,cnt1=0,cnt2=1,i,ans;
   cin>>s;
   s1=s;
   cin>>k;
   n=s.length();
   if(n==1)
   {
       cout<<k/2<<endl;
       return 0;
   }
   for(i=1;i<n;i++)
   {
       if(s[i]==s[i-1])
       {
           s[i]='$';
           cnt1++;
       }
   }
   for(i=2;i<n;i++)
   {
       if(s1[i]==s1[i-1])
       {
           s1[i]='$';
           cnt2++;
       }
   }
   if(s[0]!=s[n-1])
   {
       ans=k*cnt1;
   }
   else if(s[0]==s1[n-1])
   {
       ans=cnt1+(k-1)*cnt2;
   }
   else
   {
       ans=(cnt1+cnt2)*(k/2)+(k%2)*cnt1;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            double v = 0;
            double t = 0;
            double y = 0;
            int N = 0;
            
            v = scanner.nextDouble();
            t = v/9.8;
            y = 4.9 * t* t;
            N = (int)Math.ceil((y+5)/5);
            
            System.out.println(N);
        
        }
    }
}

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

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

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int r, D, X; cin >> r >> D >> X;
	int ans = X;
	rep(i, 10) {
		ans = r * ans - D;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()
l=[["1",0]]
for i in s:
    if l[-1][0]==i:
        l[-1][1]+=1
    else:
        l.append([i,1])
if l[-1][0]=="0":
    l.append(["1",0])
e=[0]
for i in range(len(l)):
    e.append(e[i]+l[i][1])
ans=0 if k<len(l)//2 else e[-1]
for i in range(2*k-1,len(l),2):
    ans=max(ans,e[i+2]-e[i-2*k+1])
print(ans)

Measured memory_bytes: 21540
N=int(input())
A = list(map(int, input().split()))

ans1 = max(A)
kouho = ans1 // 2
A.sort()
for i in range(N):
    if(A[i] >= kouho):
        kouho1 = A[i]
        kouho2 = A[i-1]
        break

if (ans1 == kouho1):
    ans2 = kouho2
elif (abs(ans1-2*kouho1) <= abs(ans1-2*kouho2)):
    ans2 = kouho1
else:
    ans2 = kouho2

print(ans1,ans2)

Measured memory_bytes: 14428
s=input()
ans="Yes"
cn=s.count("N")
cs=s.count("S")
ce=s.count("E")
cw=s.count("W")
if cn==0 and cs!=0:
    ans="No"
elif cn!=0 and cs==0:
    ans="No"
elif cw==0 and ce!=0:
    ans="No"
elif cw!=0 and ce==0:
    ans="No"
print(ans)

Measured memory_bytes: 3064
n, a, b = list(map(int, input().split()))
sum = 0
for i in range(1, n + 1):
    if i == 10000:
        temp = 1
    else:
        temp = int(i / 1000) + int((i % 1000) / 100) + int((i % 100) / 10) + int(i % 10)
    if a <= temp <= b:
        sum += i

print(sum)

Measured memory_bytes: 3060
#include <cstdio>

const int modulo = 1000000007;

int n;
int a[100010],b[100010];
int f[100010],g[100010];

inline long long power(long long a,long long b)
{
    long long answer;
    for(answer = 1;b;(b >>= 1),((a *= a) %= modulo))
        if(b & 1)
            (answer *= a) %= modulo;
    return answer;
}

inline void update(int &x,int y)
{
    x += y;
    x -= x >= modulo ? modulo : 0;
}

inline int C(int n,int m)
{
    if(n < 0)
        return 0;
    if(m > n)
        return 0;
    return 1ll * f[n] * g[m] % modulo * g[n - m] % modulo;
}

int main(void)
{
    int p,q,o;
    int i;

    //freopen("x.in","r",stdin);

    scanf("%d",&n),++n;
    for(i = 1;i <= n;++i)
        scanf("%d",&a[i]),++b[a[i]];
    for(o = 1;o <= n;++o)
        if(b[o] == 2)
            break;
    for(p = 1;p <= n;++p)
        if(a[p] == o)
            break;
    for(q = n;q >= 1;--q)
        if(a[q] == o)
            break;

    f[0] = 1;
    for(i = 1;i <= n;++i)
        f[i] = 1ll * f[i - 1] * i % modulo;
    g[n] = power(f[n],modulo - 2);
    for(i = n - 1;i >= 0;--i)
        g[i] = 1ll * (i + 1) * g[i + 1] % modulo;

    for(i = 1;i <= n;++i)
        printf("%d\n",(0ll + C(n - 2,i) + C(n - 2,i - 2) + 2 * C(n - 2,i - 1) - C(n - 2 - (q - p - 1),i - 1) + modulo) % modulo);

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;

  int ans = 0;
  char c = s[0];
  for(int i = 0;i < s.size();i++){
    if(s[i] != c){
      c = s[i];
      ans++;
    }
  }

  cout << ans << endl;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    int res[1000][1000];
    REP(j, H){
        if (j < B){
            REP(i, W) {
                res[j][i] = 1;
            }
        }
        else {
            REP(i, W) {
                res[j][i] = 0;
            }
        }
    }
    REP(i, A) {
        REP(j, H) {
            if (res[j][i] == 0)
                res[j][i] = 1;
            else res[j][i] = 0;
        }
    }

    REP(j, H) {
        REP(i, W) {
            cout << res[j][i];
        }
        cout << "\n";
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N,K;
double T[33];
double dp[1011][33];
double minc[1011];

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

  {
    int r1,r2;
    cin>>r1>>r2;
    N=r2-r1;
  }
  cin>>K;
  rep(i,K+1)cin>>T[i];

  rep(i,N+1)repl(j,1,K+1)dp[i][j]=INF;
  rep(i,N+1)minc[i]=INF;
  minc[0]=0; minc[1]=0;
  repl(i,2,N+1){
    repl(j,1,K+1){
      repl(k,1,i){
        int l=i-k;
        double p1=(double)l/(double)i;
        double p2=(double)(i-l)/(double)i;
        if(j>1){
          minch(dp[i][j],p2*dp[k][j-1]+p1*(T[j]+minc[l]));
        }else{
          minch(dp[i][j],p2*(minc[i-l]+T[0])+p1*(T[j]+minc[l]));
        }
      }
      minch(minc[i],dp[i][j]);
    }
  }
  printf("%.10f\n", minc[N]);
  return 0;
}



Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
using namespace std;
static const int Nil = -1;
static const int Inf = 1 << 30;

int main()
{
    int C[9];
    REP(i, 9)
    {
        cin >> C[i];
    }
    int a2 = C[3] - C[0];
    int a3 = C[6] - C[0];
    int b2 = C[1];
    int b3 = C[2];
    if (a2 + b2 != C[4])
        cout << "No" << endl;
    else if (a3 + b2 != C[7])
        cout << "No" << endl;
    else if (a2 + b3 != C[5])
        cout << "No" << endl;
    else if (a3 + b3 != C[8])
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//string _(){
//    ll n;
//    cin >> n;
//    ll c[3] = {};
//    vl arr(n);
//    cin >> arr;
//    for(ll x : arr)
//        if(x%4 == 0)
//            c[2]++;
//        else if(x%2 == 0)
//            c[1]++;
//        else
//            c[0]++;
//    //if(c[0] && !c[2])
//    if(c[0] > c[2] && c[1])
//        return "No";
//    if(c[0] > c[2]+1)
//        return "No";
//    return "Yes";
//
//}
//
//
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
string _(){
    ll n;
    cin >> n;
    ll c[3] = {};
    vl arr(n);
    cin >> arr;
    for(ll x : arr)
        if(x%4 == 0)
            c[2]++;
        else if(x%2 == 0)
            c[1]++;
        else
            c[0]++;
    //if(c[0] && !c[2])
    if(c[0] > c[2] && c[1])
        return "No";
    if(c[0] > c[2]+1)
        return "No";
    return "Yes";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100],t[100];
    int n,i,j,k,count=0,m=0;
    scanf("%s %s",&s,&t);
    n=strlen(s);
    while(m<n){
        char temp=s[0];

        for(i=0;i<n;i++)
        {
            s[i]=s[i+1];
        }
            s[n-1]=temp;

        for(k=0;k<n;k++)
        {
            if(s[k]==t[k])
            {
                count++;
            }
        }
        if(count==n)
        {
            printf("Yes\n");
            break;
        }
        else {count=0;}
    m++;
}
    if(count!=n)
    {
        printf("No\n");
    }
    return 0;

}


Measured memory_bytes: 128
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
  
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define popb pop_back
#define popf pop_front

using namespace std;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 2e9+7, mod=1e9+7;
const int N = 2e6+321, E=14e5;

ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

int a[N], b[N], used[N], ans;

vector <int> v[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(!used[a[i]]){
			used[a[i]]=1;
			for(int j=2; j*a[i]<=N/2; j++)
				b[j*a[i]]=1;
		}
		else
			b[a[i]]=1;
	}
	for(int i=0; i<n; i++)
		if(!b[a[i]])
			ans++;
	cout << ans;
    return 0;
}

Measured memory_bytes: 59032
#include<stdio.h>

int selectionSort(int A[], int n){
    int i, j, minj, swap;
    int cnt = 0;
    for(i=0;i<n;i++){
        minj = i;
        
        for(j=i;j<n;j++){
            if(A[minj] > A[j]){
                minj = j;
            }
        }
        swap = A[i]; A[i] = A[minj]; A[minj] = swap;  //swap
        if(i != minj)   cnt++;                        //swap回数を記録
    }
    return cnt;
}

int main(){
    int i, n, ans;
    int A[100];

    scanf("%d", &n);                //nと数列Aを入力
    for(i=0;i<n;i++){
        scanf("%d", &A[i]);
    }

    ans = selectionSort(A, n);      //ソートを実行

    for(i=0;i<n;i++){               //ソートした数列とswap回数を出力
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", ans);

    return 0;
}


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

using namespace std;

using ll = long long;
const int MOD = 1e9;

ll S;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> S;
  ll x = (MOD - S % MOD) % MOD;
  ll y = (x + S) / MOD;
  cout << "0 0 1000000000 1 " << x << ' ' << y;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  3 16:28:12 2020

@author: 藤原聖士
"""

count=0
N,Y=map(int,input().split())

for a in range(N+1):
    for b in range(N+1-a):
        if Y==a*10000+b*5000+(N-a-b)*1000:
                print (a,b,N-a-b)
                count+=1
                break
    else:
        continue
    break

if count==0:
    print(-1,-1,-1)             

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  ll n,k; cin >> n >> k;
  if(k>(n+1)/2) no();
  else yes();
}

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

int main(){
  int len;
  int ans=0;
  string S;
  cin >> S;
  len = (int)(S.length());
  string temp="";
  for(int i=len-1;i>=0;i--){
    for(int j=1;j<1000000;j++){
      //cout<<i<<j<<endl;
      if(temp!=S.substr(i,j)){
        temp = S.substr(i,j);
        ans++;
        break;
      }else if(i!=0){
        i--;
      }else if(i==0){
        break;
      }

    }
  }

  cout << ans <<endl;
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32
    }
    println!("{}", if a + b + c > 21 {"bust"} else {"win"});
}


Measured memory_bytes: 4352
#include <stdio.h>
     
    int main(void){
        int N;
        int sum = 0;
       
        scanf("%d",&N);
        int b[N];
        for(int i=0;i<N;i++){
		scanf("%d",&b[i]);
		sum = sum + b[i];
	}
        printf("%d\n",sum-N);
        return 0;
    }

Measured memory_bytes: 128
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		Integer[] array = new Integer[n];
		
		for(int i = 0; i < n; ++i) {
		    int tmp = sc.nextInt();
		    array[i] = tmp;
		}
		
		int total = 0;
		int sum_1 = 0;
		int sum_2 = 0;
		
		int mini = 100;
		
		for(int i = 0; i < n; ++i) {
		    total += array[i];
		}
		
		for(int i = 0; i < n; ++i) {
		        sum_1 += array[i];
		        sum_2 = total - sum_1;
		        
		        if(mini > Math.abs(sum_1 - sum_2)) {
		            mini = Math.abs(sum_1 - sum_2);
		        }
		}
		
		System.out.println(mini);
	
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))
#define setbits(x)      __builtin_popcountll(x)
 
 
void solve() {
    int a, b;
    cin>>a>>b;
    int res = ceil((b-1)/(float)(a-1));
    cout<<res<<endl;
}
 
 
int main() {
    fast
    solve();
    return 0;
}

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

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int N, D; cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int NIL=-1;
const int Max=105;
int p[Max],l[Max],r[Max];
void Pre(int i)
{
    if(i==NIL)return ;
    cout<<' '<<i;
    Pre(l[i]);
    Pre(r[i]);
}
void In(int i)
{
    if(i==NIL)return ;
    In(l[i]);
    cout<<' '<<i;
    In(r[i]);
}
void Post(int i)
{
    if(i==NIL)return ;
    Post(l[i]);
    Post(r[i]);
    cout<<' '<<i;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)p[i]=l[i]=r[i]=NIL;
    for(int i=0;i<n;i++)
    {
        int v;
        cin>>v;cin>>l[v]>>r[v];
        if(l[v]!=NIL)p[l[v]]=v;     //!=代表该节点，不是空的，所以才进行赋值父节点的操作
        if(r[v]!=NIL)p[r[v]]=v;
    }
    int root=0;
    for(int i=0;i<n;i++)if(p[i]==NIL)root=i;
    cout<<"Preorder"<<endl;
    Pre(root);cout<<endl;
    cout<<"Inorder"<<endl;
    In(root);cout<<endl;
    cout<<"Postorder"<<endl;
    Post(root);cout<<endl;
    return 0;
}

/*
case 1:
5
3 4 0
4 -1 -1
1 -1 -1
2 -1 -1
0 1 2

case 2:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/



Measured memory_bytes: 3116
#include<stdio.h>
int main(){
  int a,b,n=0,m=0,i=0;
  double c,d,v;
  while(scanf("%d,%d",&a,&b)!=EOF){
    n=n+a*b;
    m=m+b;
    i=i+1;
  }
  v=(double)m/i;
  d=v+0.5;
  d=(double)(int)d;
  printf("%d\n%g\n",n,d);
  return (0);
}

Measured memory_bytes: 624
/*input
5 7
1 99
1000 999
*/
fn main() {
    let mut input;
    let mut total: u64;
    loop {
        input = format!("");
        match std::io::stdin().read_line(&mut input) {
            Ok(0) => {
                break;
            }
            _ => {}
        }
        total = 0;
        for i in input.trim().split_whitespace() {
            total = total + i.parse::<u64>().expect("");
        }
        println!("{}", total.to_string().len());
    }
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define assn(n,a,b) assert(n<=b && n>=a)
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n)
{LL ret=1;LL b=a;while(n) {if(n&1)
    ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
#define MAXK 100000
#define MAXN 1000000000
int ar[MAXK];
int get(int n, int k){
    int i=0;
    while(i<k and ar[i]<=n)i++;
    return n-i;
}
typedef unsigned long long int ULL;
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
bool isSafe(int r, int c, vector<vector<int> > arr) {
	int n = arr.size();
	int m = arr[0].size();
	return (r>=0 && r<n && c>=0 && c<m);
}
bool diffSign(int a,int b) {
	return ((a>0 && b<0) || (a<0 && b>0));
}  
/////////////////////////////////////////////////////////////
void printArray(vector<LL> arr) {
    for(LL i=0;i<arr.size();i++) {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}

int main() 
{ 
	LL n,m,i,x,b,c,j;
    cin>>n>>m;
    vector<LL> arr(n,0L);
    rep(i,n) {
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    vector<pair<LL,LL> > points;
    rep(i,m) {
        cin>>b>>c;
        points.pb(mp(c,b));
    }
    sort(points.begin(),points.end());
    reverse(points.begin(),points.end());
    j=0;
    LL total =0;
    rep(i,n) {
        if(j<m && points[j].second > 0 && points[j].first>arr[i]) {
            arr[i] = points[j].first;
            points[j].second--;
        }
        total += arr[i];
        if(j<m && points[j].second == 0) j++;
    }
    cout<<total;
	return 0; 
} 


Measured memory_bytes: 3188
N = int(input())
A = []
for i in range(N):
    a = int(input())
    xy = [list(map(int, input().split())) for _ in range(a)]
    A.append([a, xy])
# print(A)

# 下からi桁目のbitが1->人iは正直
# 下からi桁目のbitが0->人iは不親切
# 不親切な人の証言は無視して良い

ans = 0
for i in range(2**N):
    for j in range(N):
        flag = 0
        if (i >> j) & 1:
            for k in range(A[j][0]):
                l = A[j][1][k][0]
                m=A[j][1][k][1]
                # print(i,j,k,(l,m),(i >> (l-1)))
                if not (i >> (l-1)) & 1 == A[j][1][k][1]:
                    flag = 1
                    break
            if flag == 1:
                break
    else:
        # print(bin(i))
        ct = 0
        for l in range(N):
            ct += ((i >> l) & 1)
        ans = max(ans, ct)
print(ans)


Measured memory_bytes: 68672
#include <stdio.h>

int main(void) {

  int id;
  double weight,height;
  //int i=0;

  while(scanf("%d,%lf,%lf",&id,&weight,&height)!=EOF) {
    
    if(weight/(height*height) >= 25) printf("%d\n",id);
    //i++;
    //if(i==3) break;
  }

  return 0;
}

  

Measured memory_bytes: 0
void main()
{
    long n, k;
    rdVals(n, k);
    long[] h = rdRow;

    long[] dp = new long[n];
    dp[] = inf;
    dp[0] = 0;
    foreach (i; 1 .. n)
    {
        foreach (j; 1 .. k+1)
        {
            if (i - j < 0) break;
            dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]));
        }
    }

    dp[n-1].writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 4260
a, b, c, d, e = (int(input()) for _ in range(5))
L = [a, b, c, d, e]
last = 10
for i in range(5):
    C = L[i] % 10
    if C != 0:
        if C < last:
            last = C
    L[i] = ((L[i] + 9) // 10) * 10
print(sum(L) + last - 10)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N, M;
vector<int> adj[100001];

int cnt[100001];
bool vis[100001];
int dfsn[100001];
int dfscc;
void dfs(int p, int c) {
    vis[c] = true;
    dfsn[c] = dfscc++;
    repi(i, adj[c]) if (i != p) {
        if (vis[i]) {
            if (dfsn[c] > dfsn[i])
            cnt[c]++, cout << c << ' ' << i << endl;
        } else {
            dfs(c, i);
            if (cnt[i]&1) {
                cout << i << ' ' << c << endl;
            } else {
                cnt[c]++;
                cout << c << ' ' << i << endl;
            }
        }
    }
}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> M;
    rep(i, M) {
        int a, b; cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);       
    }

    if (M&1) return cout << -1 << endl, 0;
    dfs(0, 1);
}

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

class Program
{
    static int N;
    static int[] A;
    static int[] B;
    static int[] C;

    static void Main(string[] args)
    {
        var s = new Scanner();
        N = s.ReadInt();
        A = s.ReadIntArray(N);
        B = s.ReadIntArray(N);
        C = s.ReadIntArray(N - 1);

        Solve();
    }

    static void Solve()
    {
        var ans = 0;
        var before = int.MinValue;
        checked
        {
            for (int i = 0; i < N; i++)
            {
                var ai = A[i] - 1;
                var m = B[ai];
                ans += m;
                if (before + 1 == ai)
                {
                    ans += C[ai - 1];
                }
                before = ai;
            }
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int A, B, C, D ,E ,F;
  string S,Sa,Sb,Sc;
  cin >> A >> B;
  C = A + B;
  D = A - B;
  E = A * B;
  cout << max({C,D,E}) << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    }
    else {
        cout << 2 * N << endl;
    }
}

Measured memory_bytes: 3584
X,Y=map(int, input().split())

ans=0
if X==1 and Y==1:
    print(1000000)
    quit()
if X==3:
    ans+=100000
if Y==3:
    ans+=100000
if X==2:
    ans+=200000
if Y==2:
    ans+=200000
if X==1:
    ans+=300000
if Y==1:
    ans+=300000
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

int main() {
    int N;
    cin >> N;
    set<string> s;
    REP (i, N) {
        string t; cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19260
#include<stdio.h>

int a[20],b[200],n,q;

int calc(int i,int tar,int sum);

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

  
  for(i=0;i<q;i++){
    if(calc(0,b[i],0))
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}
int calc(int i,int tar,int sum){
  int ch1,ch2;
  ch1=0;
  ch2=0;
  
  if(sum==tar)return 1;
  if(i==n)return 0;
  
  ch1=calc(i+1,tar,sum);
  ch2=calc(i+1,tar,sum+a[i]);

  if(ch1==1 || ch2==1)return 1;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e6+10,MOD=1e9+7;
ll K,Fac[MAXN],InF[MAXN],Len;
string s;
inline ll fpow(ll a,ll x){
    ll ans=1;
    for(;x;x>>=1,a=a*a%MOD) if(x&1) ans=ans*a%MOD;
    return ans;
}
inline void pre(){
    (cin>>K).get();
    getline(cin,s);
    Len=s.size();
    Fac[0]=1;
    for(int i=1;i<=2e6;i++)
        Fac[i]=Fac[i-1]*i%MOD;
    InF[int(2e6)]=fpow(Fac[int(2e6)],MOD-2);
    for(int i=2e6-1;i>=0;i--)
        InF[i]=InF[i+1]*(i+1)%MOD;
}
inline ll C(ll n ,ll m){
    return (n<m)?0:Fac[n]*InF[m]%MOD*InF[n-m]%MOD;
}
int main(){
    pre();
    ll Sum=0;
    for(int i=0;i<=K;i++)
        Sum+=fpow(26,i)*C(K-i+Len-1,Len-1)%MOD*fpow(25,K-i)%MOD;
    cout<<(Sum%=MOD);
    return 0;
}

Measured memory_bytes: 35596
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        int c = t/1000;
        if(t%1000!=0)
            c++;
        System.out.println(c*1000-t);
    }
}


Measured memory_bytes: 35828
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,a,b;
int cnt1,cnt2;
int total;
char kata;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        cin>>kata;
        if(kata=='a'){
            cnt1++;
            total=cnt1+cnt2;
            if(total<=(a+b)){
                cout<<"Yes"<<endl;
            }
            else cout<<"No"<<endl;
        }
        else if(kata=='b'){
            if(cnt2<b){
                cnt2++;
                total=cnt1+cnt2;
                if(total<=(a+b)){
                    cout<<"Yes"<<endl;
                }
                else cout<<"No"<<endl;
            }
            else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define SIZE 1000010

int dp1[SIZE], dp2[SIZE];

int calc(int n) { return n * (n + 1) * (n + 2) / 6; }

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

    vector<int> v;
    for (int i = 0; calc(i) < 1000000; i++)
        v.push_back(calc(i));
    for (int i = 0; i < 1000010; i++)
        dp1[i] = dp2[i] = INF;
    dp1[0] = dp2[0] = 0;
    for (int i = 0; i < SIZE; i++)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i - v[j] >= 0)
                dp1[i] = min(dp1[i], dp1[i - v[j]] + 1);
            if (v[j] % 2 == 1 && i - v[j] >= 0)
                dp2[i] = min(dp2[i], dp2[i - v[j]] + 1);
        }
    }
    int N;
    while (1)
    {
        cin >> N;
        if (N == 0)
            break;
        cout << dp1[N] << " " << dp2[N] << endl;
    }
}


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

//int _; 

int n;
long long cnt[10000000],ans=0;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=1;i <= n;i++)
		for(int j=1;i*j <= n;j++)
			ans += i*j;
	printf("%lld\n",ans);
	return 0;
}





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

using namespace std;
long long XOR(long long a, long long b)
{
	if (a == b)
		return a;
	else if (b - a == 1)
		return a^b;
	else if ((a % 2 == 0) && (b % 2 == 1))
	{
		if ((((b - a + 1) / 2 ) % 2) == 0)
			return 0;
		else
			return 1;
	}
	else if ((a % 2 == 0) && (b % 2 == 0))
		return (XOR(a, b - 1) ^ b);
	else if ((a % 2== 1) && (b % 2 == 0))
		return a^XOR(a + 1, b - 1)^b;
	else
		return (a^XOR(a + 1, b));
}
int main()
{
	
	long long a, b;
	cin >> a >> b;
	long long ans = XOR(a,b);
	cout << ans;
	//system("pause");
	return 0;
}

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;
using P = pair<int,int>;
 
int main() {
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
n = [int(i) for i in input().split()]
a = []
for i in range(n[1]):
    a.append(int(input()))

a.append(n[0]+1)
a = sorted(list(set(a)))


def k(i):
    ans = 1
    pri = 0
    for idx in range(i):
        tmp = ans
        ans += pri
        pri = tmp
    return ans


for i in range(1, len(a)):
    if a[i]-a[i-1] == 1:
        print(0)
        sys.exit()
j = -1
ans = 1
for i in a:
    ii = i-j-2
    ans = ans*k(ii)
    j = i
if len(a) == 1:
    ans = k(n[0])
print(ans % 1000000007)


Measured memory_bytes: 13212
#include <iostream>

using namespace std;

int main(){
  int R, G, B, N, i, j, k, ans=0;
  cin >> R >> G >> B >> N;
  for(i=0; i<=N; i++){
    for(j=0; j<=N; j++){
      if(R*i + G*j > N) break;
      if((N-R*i-G*j) % B == 0){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int a[N],m[N][N];

void M(int);
int main(){
  int n,i;
 
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&a[i-1],&a[i]);
  }
 
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  M(n);
  printf("%d\n",m[1][n]);
 
  return 0;
}



void M(int n){
  int i,l,j,k,b;
  for(k=2;k<=n;k++){
    for(i=1;i<=n-k+1;i++){
      j = i + k - 1;
      m[i][j] = 100000;
      for(l=i;l<j;l++){
        b = m[i][l] + m[l+1][j] + a[i-1] * a[l] * a[j];
        if(m[i][j]>b) m[i][j]=b;
      }
    }
  }
}




Measured memory_bytes: 2052
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

typedef long long          ll;
typedef unsigned int       uint;
typedef unsigned long long ull;

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    sort(s.begin(), s.end());
    std::cout << accumulate(s.begin() + 1, s.end() - 1, 0) / (s.size() - 2) << std::endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for( int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int V = 0;
  if (N%2 == 0){
    for( int i = 0; i < N/2; i++){
      V += vec[2*i+1] - vec[2*i];
    }
  }else{
    for( int i = 0; i < N/2; i++){
      V += vec[2*i+2] - vec[2*i+1];
    }
    V += vec[0];
  }
  cout << V << endl;
}


Measured memory_bytes: 256