akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int rev(int x, int l, int r){
    int n = x-l;
    return r-n;
}

int main(){
    int n,a,d,m;
    cin >>n >>a >>d >>m;

    vector<int> x(m),y(m),z(m);
    rep(i,m){
        cin >>x[i] >>y[i] >>z[i];
        --y[i];
        --z[i];
    }

    int k;
    cin >>k;
    --k;

    int idx = k;
    for(int i=m-1; i>=0; --i){
        if(x[i]==0){
            if(y[i]<=idx && idx<=z[i]) idx = rev(idx, y[i], z[i]);
        }
    }

    ll val = a+idx*d;
    rep(i,m){
        if(y[i]<=idx && idx<=z[i]){
            if(x[i]==0) idx = rev(idx, y[i], z[i]);
            if(x[i]==1) ++val;
            if(x[i]==2) val /= 2;
        }
    }
    cout << val << endl;
    return 0;
}



Measured memory_bytes: 4936
N,M=map(int,input().split())
l=[0]*M
for _ in range(N):
    a=list(map(int,input().split()))
    for i in range(1,len(a)):
        l[a[i]-1]+=1
ans=0
for i in l:
    if i==N:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")



ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
  ll n;
  cin>>n;
  vi v(n);
  rep(i,0,n) cin>>v[i];
  ll ans=0;
  sort(all(v));
  rep(i,0,n)
  {
    rep(j,i,n)
    {
      rep(k,j,n)
      {
        if(v[i]+v[j]>v[k] and v[i]!=v[j] and v[j]!=v[k] and v[k]!=v[i])
          ans++;
      }
    }
  }
  cout<<ans;
}

int main()
{
  ll tt;tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

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

class Main {
    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------

        StringTokenizer st = new StringTokenizer(f.readLine());

        int N = Integer.parseInt(st.nextToken());

        String[] strings = f.readLine().split(" ");
        int counter = 0;
        for(int i = 0; i < N; i++)
        {
            if(i%2==0)if((Integer.parseInt(strings[i])%2) == 1)counter++;
        }
        out.println(counter);
        out.close();
    }
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int main(){
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if((b - a) % 2 == 0){
		printf("Alice\n");
	}else{
		printf("Borys\n");
	}
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    if(s[0] == s[1]) cout << "Bad" << endl;
    else if(s[1] == s[2]) cout << "Bad" << endl;
    else if(s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

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

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

  for(int i = 0; i < S.size(); i++) {
    char moji = S.at(i);
    if(moji + N <= 'Z') {
    //  cout << (char)(moji.at(i) + N)
    cout << (char)(moji + N);
    }
    else {
      // cout << (char)('A' + i);
      cout << (char)(moji + N - ('Z' - 'A' + 1));
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x, y, a, b, c;
    cin>> x>> y >> a >> b >> c;
    ll aa[a], bb[b], cc[c];
    for (int i = 0; i < a; ++i)
    {
    	cin >> aa[i];
    }
    for (int i = 0; i < b; ++i)
    {
    	cin >> bb[i];
    }
    for (int i = 0; i < c; ++i)
    {
    	cin >> cc[i];
    }
    sort(aa, aa+a, greater<>());
    sort(bb, bb+b, greater<>());
    sort(cc, cc+c, greater<>());
    priority_queue <ll, vector<ll>, greater<>> pq;
    ll ans=0;
    for (int i = 0; i < x; ++i)
    {
    	pq.push(aa[i]);
    	ans+=aa[i];
    }
    for (int i = 0; i < y; ++i)
    {
    	pq.push(bb[i]);
    	ans+=bb[i];
    }
    ll k=0;
    	// cout << ans;
    while(pq.top()<=cc[k]&&k<c)
    {
    	ans-=pq.top();
    	pq.pop();
    	pq.push(cc[k]);
    	ans+=cc[k];
    	k++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4852
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
const int inf=1e18;
int32_t main()
{
	
	int n=in();int m=in();int r=in();
	vector<int> rr(r);
	trav(i,rr)i=in();
	int d[204][204];
	for(int i=0;i<201;i++)
	for(int j=0;j<201;j++)d[i][j]=inf;
	for(int i=0;i<201;i++){d[i][i]=0;}
	int u,v,w;
	for(int i=0;i<m;i++)
	{
		cin>>u>>v>>w;
		d[u][v]=d[v][u]=min(d[u][v],w);
	}
	
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	
	
	sort(all(rr));
	int ans=inf;
	do
	{
		int ct=0;
		for(int i=0;i<r-1;i++)
		{
			ct+=d[rr[i]][rr[i+1]];
		}
		ans=min(ans,ct);
		
	}while(next_permutation(all(rr)));
	cout<<ans;
	
	
}

Measured memory_bytes: 4016
import bisect
a, b, q = list(map(int, input().split()))
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
for i in x:
    si = bisect.bisect(s, i)
    ti = bisect.bisect(t, i)
    sl = s[si-1] if si > 0 else s[0]
    sr = s[si] if si < a else s[-1]
    tl = t[ti-1] if ti > 0 else t[0]
    tr = t[ti] if ti < b else t[-1]
    print(min(
        abs(i-sl)+abs(sl-tl),
        abs(i-sl)+abs(sl-tr),
        abs(i-sr)+abs(sr-tl),
        abs(i-sr)+abs(sr-tr),
        abs(i-tl)+abs(sl-tl),
        abs(i-tl)+abs(sr-tl),
        abs(i-tr)+abs(sl-tr),
        abs(i-tr)+abs(sr-tr),
    ))

Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  for(int i=B;i<=C;i++)
    if(i%A==0)
    {
      puts("OK");
      return 0;
    }
  puts("NG");
  return 0;
}

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

def main():
    n, m, l = map(int, input().split())
    dist = [[float('inf')]*n for _ in range(n)]
    
    def Warshall_Floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        return d
      
    for _ in range(m):
        a, b, c = map(int, input().split())
        if c > l:
            continue
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c

    Warshall_Floyd(dist)

    dist2 = [[float('inf')]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if dist[i][j] <= l:
                dist2[i][j] = 1
    
    Warshall_Floyd(dist2)

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if dist2[s][t] == float('inf'):
            print(-1)
            continue
        ans = dist2[s][t]
        print(ans-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 125404
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      //入力
      int g =sc.nextInt();//具材の数
      int val[] = new int[g];
      
      //具の価値を配列へ
      for(int i =0; i<g; i++){
        	val[i] = sc.nextInt();
      }
      //昇順に並び替え
      Arrays.sort(val);
      
      double ans = val[0];
      
      for(int i=1; i<g; i++){
        	 ans = (ans+val[i])/2.0;
      }
      System.out.println(ans);
    }
}
      

Measured memory_bytes: 35924
#include<stdio.h>

int main(void)
{
  unsigned int D; //1-365day
  unsigned int d; 
  unsigned int t[365]; 
  int S[365][26] = {0}; //満足度
  unsigned int i; 
  int s_max=0;
  int C[26] = {0}; //不満度
  unsigned int c; 

  //input
  scanf("%d",&D);
  for(c=0;c<26;c++){scanf("%d",&C[c]);}
  for(d=0;d<D;d++)
  {
    for(i=0;i<26;i++){scanf("%d",&S[d][i]);}
  }
  //day
  for(d=0;d<D;d++)
  {
  s_max=S[d][0];
  
    for(i=0;i<26;i++)
  {
    if(S[d][i]>=s_max)
    {
      t[d] = i+1;
      s_max =S[d][i];
    }
  }
    
  printf("%d\n",t[d]);
  
  }
  
  return 0;
}

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

using namespace std;

int main(){

	long long int A,B,k;
	cin >> A >> B >> k;
	
	for(int i=0;i<k;i++){
		
		if(i%2==0){
			if(A%2==1){
				A = A-1;
				A = A/2;
				B = B + A;
				continue; 	
			}
			else{
				A = A/2;
				B = B+A;
			
			
			}
		}
		
		else{
			if(B%2==1){
				B = B-1;
				B = B/2;
				A = A + B; 
				continue;
			}
			
			else{
				B = B/2;
				A = A+B;
			
			}
		}
	}
	
	
	cout <<A <<" " <<B <<endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int n=s.nextInt();
		long in[][]=new long[n][2];
		long buf[] =new long[n];
		long result=0;
		for(int i=0;i<n;i++) {
			in[i][0]=s.nextInt();
			in[i][1]=s.nextInt();

			buf[i]=in[i][1]-in[i][0]%in[i][1];
		}
		//System.out.println(Arrays.toString(buf));
		for(int i=n-1;i>=0;--i) {
			buf[i]-=result;
			while(buf[i]<0)
				buf[i]+=in[i][1]*500000000;
			buf[i]%=in[i][1];
			result+=buf[i];
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 81864
x,y,a,b,c=map(int, raw_input().split())
As=map(int, raw_input().split())
Bs=map(int, raw_input().split())
Cs=map(int, raw_input().split())
X=x
Y=y
newarr=[]
res=0
for i in xrange(len(As)):
    newarr.append([As[i], 0])
for i in xrange(len(Bs)):
    newarr.append([Bs[i], 1])
for i in xrange(len(Cs)):
    newarr.append([Cs[i], 2])
newarr.sort(reverse=True)
i=-1
t=0
while True:
    i+=1
    if newarr[i][1]==0:
        if x>0:
            x-=1
        else:
            continue
    elif newarr[i][1]==1:
        if y>0:
            y-=1
        else:
            continue
    res+=newarr[i][0]
    # print newarr[i], X, Y, t
    t+=1
    if t>=X+Y:
        break

# print newarr
print res



Measured memory_bytes: 91500
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll poc(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k;cin>>k;
    string s;cin>>s;
    if((int)s.size()<=k)cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}




Measured memory_bytes: 3656
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Measured memory_bytes: 38512
#include<cstdio>
#include<iostream>
#include<algorithm>

#define MAX_N 100
#define MAX_W 10000

struct item {
    int v, w;
};

using namespace std;

item items[MAX_N + 5];
int T[MAX_N + 5][MAX_W + 5];

int main()
{
    int n, w, i, j;
    scanf("%d %d", &n, &w);
    for (i = 1; i <= n; i++) {
        scanf("%d %d", &(items[i].v), &(items[i].w));
    }
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= w; j++) {
            T[i][j] = 0;
        }
    }
    for (i = 1; i <= n; i++) {
        for (j = 0; j <= w; j++) {
            if (j < items[i].w) {
                T[i][j] = T[i - 1][j];
            }
            else {
                T[i][j] = max(T[i - 1][j], T[i - 1][j - items[i].w] + items[i].v);
            }
        }
    }
    printf("%d\n", T[n][w]);

    return 0;
}

Measured memory_bytes: 7172
N,M=map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]
C= [list(map(int, input().split())) for i in range(M)]
for i in A:
    ans=[abs(i[0]-j[0])+abs(i[1]-j[1]) for j in C]
    ans_min=min(ans)
    print(ans.index(ans_min)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	puts(read()+read()>=read()?"Yes":"No");
	return 0;
}



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

using namespace std;

bool isOdd(char c) {
  return ((c == 'R') || (c == 'U') || (c == 'D'));
}

bool isEven(char c) {
  return ((c == 'L') || (c == 'U') || (c == 'D'));
}

int main() {
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (i & 1) {
      if (!isEven(s[i])) {
        flag = false;
        break;
      }
    } else {
      if (!isOdd(s[i])) {
		flag = false;
        break;
      }
    }
  }
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
import math
N, A, B = map(int, input().split())

H = [int(input()) for _ in range(N)]


H.sort(reverse=True)
high = math.ceil(H[0] / B)
low = 0
while high > low+1:
    mid = (high+low) // 2
    cnt = 0
    for i in range(N):
        if H[i] - mid*B > 0:
            # 残りを減らすのに必要な回数を計上
            cnt += math.ceil((H[i] - mid*B)/(A - B))
        else:
            break
    # 残りを減らす回数がmidを超えているならその回数ではすべてを倒しきれない
    if cnt <= mid:
        high = mid
    else:
        low = mid

print(high)

Measured memory_bytes: 50648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
map<long long, long long> memo;
long long calc (long long h) {
  if (memo.count(h)) return memo[h];
  if (h == 1) return 1;
  memo[h] = calc(h / 2) + calc(h / 2) + 1;
  return memo[h];
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  long long h;
  cin >> h;
  cout << calc(h) << endl;
  return 0;
}

Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2)
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline
sys.setrecursionlimit(10**6)

#enumerate input

def main():
    s=input()
    print(min(max(map(len,s.split(i)))for i in s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5372
#include <iostream>
#include <sstream>

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;
    
    int a[n][m];
    int b[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();

		for (int x = 0; x < 2223; x++) {
			for (int y = 0; y < 5000; y++) {
				if (9000 * x + 4000 * y == Y - 1000 * N) {
					if (N-x-y < 0) continue;
					System.out.printf("%d %d %d", x, y, N-x-y);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,A[100000],even=0,odd=0,c,c2,c3;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
        if(A[i]%2==0)
        {
            even++;
        }
        else
        {
            odd++;
        }
    }
    if(odd%2==0 && even%2==1)
    {
        cout<<"YES"<<endl;
    }
    else if(odd%2==1 && even%2==0)
    {
        cout<<"NO"<<endl;
    }
    else if(odd%2==1 && even%2==1)
    {
        cout<<"NO"<<endl;
    }
    else if(odd%2==0 && even%2==0)
    {
        cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	if (n<10)
		cout<<n<<endl;
	else if (n<1e2)
		cout<<9<<endl;
	else if (n<1e3)
		cout<<n-90;
	else if (n<1e4)
		cout<<909<<endl;
	else if (n<1e5)
		cout<<n-9090;
	else if (n==1e5)
		cout<<90909<<endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ 1249: Make a Sequence
// 2017.10.16 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int x, y; } T;
T a[350];

int n, m;
char peg[8][8][8]; char hi[8][8];

int dx[13] = { 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 };
int dy[13] = { 0, 1, 0, 1,-1, 0, 0, 1, 1, 1, 1,-1,-1 };
int dz[13] = { 0, 0, 1, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1 };

int check(int x, int y, int z, int color)
{
	int xx, yy, zz, i, cnt1, cnt2;

	for (i = 0; i < 13; i++) {
		xx = x, yy = y, zz = z, cnt1 = 0;
		while (0 <= xx && xx < n && 0 <= yy && yy < n &&
			   0 <= zz && zz < n && peg[xx][yy][zz] == color) {
			xx += dx[i], yy += dy[i], zz += dz[i];
			if(++cnt1 >= m) return 1;
		}
		xx = x, yy = y, zz = z, cnt2 = -1;
		while (0 <= xx && xx < n && 0 <= yy && yy < n &&
			   0 <= zz && zz < n && peg[xx][yy][zz] == color) {
			xx -= dx[i], yy -= dy[i], zz -= dz[i];
			if(++cnt2 >= m) return 1;
		}
		if (cnt1 + cnt2 >= m) return 1;
	}
	return 0;
}

int main()
{
	int p, i, x, y, z, color;

	while (scanf("%d%d%d", &n, &m, &p) && n > 0) {
		memset(peg, -1, sizeof(peg)); memset(hi, 0, sizeof(hi));
		for (i = 0; i < p; i++) scanf("%d%d", &a[i].x, &a[i].y);
		for (color = 1,i = 0; i < p; i++, color = !color) {
			x = a[i].x-1, y = a[i].y-1, z = hi[x][y]++;
			peg[x][y][z] = color;
			if (check(x, y, z, color)) break;
		}
		if (i == p) puts("Draw");
		else printf("%s %d\n", color ? "Black" : "White", i+1);
    }
	return 0;
}

Measured memory_bytes: 1744
#include <stdio.h>

int main(void) {
  int n, k, p[200000];
  double q[200000], sum = 0, max;
  int i, j;
  
  scanf("%d %d", &n, &k);
  for(i = 0; i < n; i++) {
    scanf("%d", p + i);
    q[i] = (double) (1 + p[i]) / 2;
  }
  for(i = 0; i < k; i++) {
    sum += q[i];
  }
  max = sum;
  j = 0;
  for(i = k ; i < n; i++, j++) {
    sum = sum + q[i] - q[j];
    if(sum > max) {
      max = sum;
    }
  }
  printf("%lf\n", max);
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , d; cin >> n >> d;
    int A[n][d];
    for(int i = 0 ;i < n; i++)
        for(int j = 0;j < d ; j++)  
            cin >> A[i][j];
    int ans = 0;
    for(int i = 0 ;i < n ; i++){
        for(int j = i+1 ;j < n ; j++){
            
            int dis = 0;
            for(int k = 0 ;k < d; k++)
                dis += (A[i][k] - A[j][k])*(A[i][k]-A[j][k]);
            int root = round(sqrt(dis));
            if(root*root == dis)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,S; cin >> N >> S;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    int ans = 1e9;
    int right = 0;
    ll val = 0;
    rep(left,N) {
        while (right < N && val + A[right] < S) {
            val += A[right];
            right++;
        }
        if (right < N) chmin(ans,right - left + 1);
        if (left == right) right++;
        else val -= A[left];
    }

    cout << (ans==1e9 ? 0 : ans) << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[10100][10100];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    rep(i,n-1){
      if(a[i] == a[i+1]){
        print("NO");
        return 0;
      }
    }
    print("YES");
}


Measured memory_bytes: 1792
import sys

def main():
	n = int(input())
	f = []
	for i in range(n):
		f.append(list(map(int,input().split())))
	p = []
	for i in range(n):
		p.append(list(map(int,input().split())))
	ans = -sys.maxsize
	for x10 in range(1,2**10):
		x2 = base_10_to_n(x10,2)
		for _ in range(10-len(x2)):	
			x2 = '0' + x2
		benefit = 0
		for j in range(n):
			count = 0
			for k in range(10):
				if(f[j][k] == 1 and x2[k] == '1'):
					count+=f[j][k]
			benefit+=p[j][count]
		if(ans<benefit): ans = benefit
	print(ans)

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 3064
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define pb push_back
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rii(x,y) ri(x), ri(y)
#define rll(x,y) rl(x), rl(y)

#define fst first
#define snd second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

const int MAXN = 2e5+5;

deque<int> dq;
int n;

int main(){
	bool rev=false;
	ri(n);
	FOR(i,0,n){
		int a; ri(a);
		if(rev) dq.push_front(a);
		else dq.push_back(a);
		rev = !rev;
	}
	if(rev){
		FORR(i,n-1,-1) printf("%d ",dq[i]);
	}else{
		FOR(i,0,n) printf("%d ",dq[i]);
	}
	printf("\n");
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;

struct data{
    int v, w;
    ll d;
    string t, n;
    data(int _v, int _w, string _t, ll _d, string _n) 
    : v(_v), w(_w), t(_t), d(_d), n(_n) {}

    bool operator < (const data other) const{
        if(v != other.v)    return v < other.v;
        if(w != other.w)    return w < other.w;
        if(t != other.t)    return t < other.t;
        if(d != other.d)    return d < other.d;
        return n < other.n;
    }
};

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

    vector<data> v;
    int a, b;
    string c, e;
    ll d;

    for(int i = 0; i < n; i++){
        cin >> a >> b >> c >> d >> e;
        v.push_back(data(a, b, c, d, e));
    }

    sort(v.begin(), v.end());

    for(data x : v){
        cout << x.v << " " << x.w << " " << x.t << " " << x.d << " " << x.n << endl;
    }

    return 0;
}


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

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
#define rep(i,n) for(int i = 0;i<n;i++)

int int_xor(int a,int b){
    int x = max(a,b);
    int y = min(a,b);
    int z = 0;
    int t = 1;
    while(x>0){
        z += ((x+y)%2)*t;
        y/=2;
        x/=2;
        t *= 2;
    }
    return z;
}

int main(){

    int N;cin >> N;
    vector<int> a(N);
    int sum = 0;
    rep(i,N){
        cin >> a[i];
        sum = int_xor(sum,a[i]);
    }
    rep(i,N)cout << int_xor(sum,a[i]) << endl;
    
    
    
    
    

}



Measured memory_bytes: 4056
#include<cstdio>
using namespace std;
int main(void)
{
	int i,c,cnt;
	while(scanf("%d",&c)!=EOF){
		cnt=1;
		for(i=1;i<c;i++){
			cnt++;
			if(cnt==40){
				cnt=1;
			}
		}
		if(cnt<10){
			printf("3C0%d\n",cnt);
		}
		else{
			printf("3C%d\n",cnt);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long 
using namespace std;

ll gcd(ll x ,ll y){
    ll r = x%y;
    if(r==0)return y;
    else return gcd(y ,r);
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll g = gcd(a ,b);
    a /= g;
    b /= g;
    cout << a*b*g << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    buf.pop();
    unsafe { String::from_utf8_unchecked(buf) }
  };

  let (n, a, b, c, d) = {
    let mut iter = input.split(' ').map(|s| s.parse::<u32>().unwrap());

    (iter.next().unwrap(),
     iter.next().unwrap(),
     iter.next().unwrap(),
     iter.next().unwrap(),
     iter.next().unwrap())
  };

  let x = ((n - 1) / a + 1) * b;
  let y = ((n - 1) / c + 1) * d;

  println!("{}", if x <= y { x } else { y });
}


Measured memory_bytes: 5016
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;
P sum[1000001];

int main()
{
  int n;
  while (cin >> n, n){
    for (int i = 0; i < n; i++){
      int c;
      cin >> c;
      sum[i].first = 0;
      sum[i].second = c;
      for (int j = 0; j < 4; j++){
        int m, s;
        cin >> m >> s;
        sum[i].first += m * 60 + s;
      }
    }
    sort(sum, sum + n);
    cout << sum[0].second << endl << sum[1].second << endl << sum[n - 2].second << endl;
  }
  return (0);
}

Measured memory_bytes: 8976
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  let answer = 0;

  for (let i = 1; i <= N; i += 2) {
    let count = 0;

    for (let j = 1; j <= i; j += 1) {
      if (i % j === 0) {
        count += 1;
      }
    }

    if (count === 8) {
      answer += 1;
    }
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 29644
import java.util.*;
import java.math.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		HashMap<String, Integer> mp = new HashMap<>();
		String meh = in.nextLine();
		for(int qq=1; qq<=n; qq++){
			String a = in.nextLine();
			mp.put(a, 1);
		}
		System.out.println(mp.size());
	}
}

Measured memory_bytes: 79488
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

  int N, W;


int main(){
  cin >> N >> W;
  int v[N], w[N];
  REP(i, N) cin >> v[i] >> w[i];
  int dp[N+1][W+1]={};
  for(int i=1; i<N+1; ++i){
    for(int j=1; j<W+1; ++j){
      if(j-w[i-1]>=0)
        dp[i][j]=max(dp[i-1][j], dp[i][j-w[i-1]] + v[i-1]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  int max=0;
  REP(i, W+1){
    if(max<dp[N][i])max=dp[N][i];
  }

  cout << max << endl;
  return 0;
}



Measured memory_bytes: 7048
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    int H = sc.nextInt();
    int W = sc.nextInt();
    sc.nextLine();
    for (int i = 0; i < H; ++i) {
      String C = sc.nextLine();
 
      for (int ct = 0; ct < 2; ++ct) {
        out.println(C);
      }
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  if(S[N-1]=='s')S+="es";
  else{
    S+='s';
  }
cout<<S<<endl;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; string s; cin>>n>>s;
    bool dp[n+2][5][1000]={};
    dp[0][0][0]=1;

    rep(i,n)
    {
        rep(j,4)
        {
            rep(k,1000)
            {
                if(!dp[i][j][k])continue;

                int current=k*10+s[i]-'0';
                if(j<3)
                {
                    dp[i+1][j+1][current]=true;
                    //cout<<current<<endl;
                }
                dp[i+1][j][k]=true;
            }
        }
    }

    int ans=0;
    rep(k,1000)
    {
        //if(dp[n][3][k])cout<<k<<endl;
        ans+=dp[n][3][k];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 146816
function reverse(s) {
  return s.split('').reverse().join('');
}
 
function r_search(input){
  const words = ['dreamer', 'dream', 'eraser', 'erase'];
  const reversed_words = words.map(x => reverse(x));
  var current_input = reverse(input);

  length_check_loop: while(current_input!=""){
    if(current_input==""){return true;}
    for(word of reversed_words){
      
      if(current_input.startsWith(word)){
        current_input = current_input.substring(word.length)
        continue length_check_loop;
      }
    }
    return false;
  }
  return true;
}
 
function main(input) {
  if(r_search(input.split('\n')[0])){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11520
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

ll N;
ll A[100001];

int main() {

  cin >> N;
  rep(i, N) cin >> A[i];

  ll b0, b1, b2;
  b0 = b1 = b2 = 0;
  rep(i, N) {
    if(A[i]%4==0) ++b2;
    else if(A[i]%2==0) ++b1;
    else ++b0;
  }

  if(b1==0) {
    if(b0<=b2+1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else {
    if(b0<=b2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  string s,t; cin >> s >> t;
  itn sn=s.size();
  itn tn=t.size();
  itn ans=0;
  rep(i,sn-tn+1){
    int cnt=0;
    rep(j,tn){
      if(s[i+j]==t[j]) cnt++;
    }
    chmax(ans,cnt);
  }
  cout << tn-ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_A=55555;

bool flg[MAX_A+1];
vector<int> pri;

void era(){
	memset(flg,true,sizeof(flg));
	FOR(i,2,MAX_A+1){
		if (flg[i]){
			if (i%5==1) pri.push_back(i);
			for(int j=i*2;j<=MAX_A;j+=i){
				flg[j]=false;
			}
		}
	}
}

int main(){
	era();
	int N;
	cin>>N;
	REP(i,N){
		if (i) cout<<" ";
		cout<<pri[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int a[200010];
int main() {
  ll n, k;
  cin >> n >> k;
  rep(i,n)
  {
    cin >> a[i];
    a[i]--;
  }
  map<int, int> mp;
  ll j = 1, t;
  mp[0] = j++;
  t = a[0];
  k--;
  while (k > 0) {
    if (mp.find(t) != mp.end()) {
      k %= (j - mp[t]);
      while (k > 0) {
        k--;
        t = a[t];
      }
      break;
    } else {
      mp[t] = j++;
      t = a[t];
      k--;
    }
  }
  cout << t + 1;
  return 0;
}

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

int main () {
    string c1, c2, c3;
    cin >> c1 >> c2 >> c3;

    string ans;
    ans += c1[0];
    ans += c2[1];
    ans += c3[2];

    cout << ans << endl;

    return 0;
}

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

int main()
{
    long long n, m;
    cin >> n >> m;
    if (n == 1 || m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    long long ans = 0;
    ans += ((n / 2) + (n % 2)) * ((m / 2) + (m % 2));
    ans += (n / 2) * (m / 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import datetime

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
'''
before = datetime.date(2019, m1, d1)
check = before + datetime.timedelta(day=1)

after = datetime.date(2019, m2, d2)
'''
if (m2 - m1 == 1):
    print(1)
else:
    print(0)


Measured memory_bytes: 3312
import collections
import math
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = {}
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - C(d[a]) + C(d[a]-1))


Measured memory_bytes: 38844
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 2e6 + 9;
const int mod = 1e9 + 7;

ll a, b, c;
ll k;

int main(){

scanf("%I64d", &a);
scanf("%I64d", &b);
scanf("%I64d", &c);
scanf("%I64d", &k);

if(k % 2 == 0){
    printf("%I64d", a - b);
} else{
    printf("%I64d", b - a);
}


return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int ,int> P;
struct edge {int to,cost;};
const int INF=1000000000;
int N;
int d[10000];
vector<edge> G[10000];
void dijkstra(int s){
  for(int i=0;i<N;i++)d[i]=INF;
  d[s]=0;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int u,k,c,v;
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      edge e;e.to=v;e.cost=c;
      G[u].push_back(e);
    }
  }
  dijkstra(0);
  for(int i=0;i<N;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

Measured memory_bytes: 8000
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int main(){
    int K;
    cin>>K;
    int gu,ki;
    if(K%2==0){
        gu = K/2;
        ki = K/2;
   }else{
        gu = K/2;
        ki = K/2+1;
    }
    cout<<gu*ki<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,k,sum1 = 0,sum2 = 0,sum3 = 0,sum,ans;
cin>>a>>b>>c>>k;
for(int i = 0; i<k; i++){
    sum1 = a*2+b+c;
    sum2 = a+b*2+c;
    sum3 = a+b+c*2;
    sum = max(sum1,sum2);
    ans = max(sum,sum3);
    if(ans == sum1){
        a = a*2;
    }
    
    else if(ans == sum2){
        b = b*2;
    }
    
    else{
        c = c*2;
    }
    
}

cout<<ans<<endl;
return 0;
}

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

using namespace std;

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

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, T;
    cin >> N >> T;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    // vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(T + 1, vector<ll>(2, 0)));
    vector<vector<ll>> dp(N + 1, vector<ll>(T + 3005, 0));
    sort(items.begin(), items.end());
    rep(i, N) {
        P p = items[i];
        rep(t, T + 3001) {
            if (t - p.first >= 0 && T > t - p.first) {
                dp[i + 1][t] = max(dp[i + 1][t], dp[i][t - p.first] + p.second);
            }
            dp[i + 1][t] = max(dp[i + 1][t], dp[i][t]);
        }
    }
    ll ans = 0;
//    print(dp);
//    print(dp[N][60]);
    rep(t, T + 3004) {
        ans = max(ans, dp[N][t]);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

struct Vertex {
    vector<lint> edge;
    bool visited = false;
    lint distT = 0;
    lint distA = 0;
};

int main() {
    lint n, u, v;
    cin >> n >> u >> v;
    u--, v--;

    vector<Vertex> g(n);
    for(lint i=0; i<n-1; i++) {
        lint a, b;
        cin >> a >> b;
        a--, b--;
        g[a].edge.push_back(b);
        g[b].edge.push_back(a);
    }

    // 高橋くんからの距離
    queue<lint> queT;
    queT.push(u);
    g[u].distT = 0;
    g[u].visited = true;

    while(!queT.empty()) {
        lint node = queT.front(); queT.pop();
        for(auto next : g[node].edge) {
            if(g[next].visited)  continue;
            g[next].visited = true;
            g[next].distT = g[node].distT + 1;
            queT.push(next);
        }
    }

    // 初期化処理を書く
    for(auto &e : g)  e.visited = false;

    // 青木くんからの距離
    queue<lint> queA;
    queA.push(v);
    g[v].distA = 0;
    g[v].visited = true;

    while(!queA.empty()) {
        lint node = queA.front(); queA.pop();

        for(auto next : g[node].edge) {
            if(g[next].visited)  continue;
            g[next].visited = true;
            g[next].distA = g[node].distA + 1;
            queA.push(next);
        }
    }

    // 高橋くんからの距離 < 青木くんからの距離　かつ　青木くんからの距離が最大
    lint ans = -1;
    for(auto e : g) {
        if(e.distT >= e.distA)  continue;
        ans = max(ans, e.distA);
    }

    cout << --ans << endl;
}

Measured memory_bytes: 8832