akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//
// year, p
priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > opt[MAX+1];
int n, m;
int p[MAX+1], y[MAX+1];
string answer[MAX];
int d[MAX];

//----------//

string make(string a){
    while(a.size() < 6){
        a = '0' + a;
    }
    return a;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    cin >> n >> m;
    rep(i, m){
        cin >> p[i] >> y[i];
        opt[p[i]].push(make_pair(y[i], i));
    }

    rep(i, m){
        pair<int, int> f = opt[p[i]].top(); opt[p[i]].pop();
        d[p[i]]++;
        answer[f.second] = make(to_string(p[i])) + make(to_string(d[p[i]]));
    }

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

    
    return 0;
}


Measured memory_bytes: 14336
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n,k=0;
	 n=Integer.parseInt(input.readLine());
	String str=input.readLine();
	String str_ary[]=str.split(" ");
	int a[]=new int[n];
	for(int i=0;i<n;i++)
	    {
		a[i]=Integer.parseInt(str_ary[i]);
	    }
	for(int i=0;i<n;i++)
	    {
		for(int j=n-1;j>i;j--)
		    {
			if(a[j]<a[j-1])
			    {
				int tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
				k++;
			    }
		    }
	    }
	for(int i=0;i<n;i++)
	    {
		System.out.print(a[i]+((i!=n-1)?" ":"\n"));
	    }
	System.out.println(k);
    }
}

Measured memory_bytes: 17060
#include<bits/stdc++.h>
using namespace std;
long long calc(long long N, long long X) {
  long long ans = N;
  if (X * 3 == N) return ans;
  N -= X;
  while (X) {
    long long u = N / X;
    long long v = N % X;
    ans += u * 2 * X;
    N = X;
    X = v;
  }
  return ans - N;
}
int main () {
  long long N, X;
  cin >> N >> X;
  cout << calc(N, X) << endl;
}



Measured memory_bytes: 764
#include <iostream>
#include <string>

int main() {
    std::string N;
    int sum = 0;

    std::cin >> N;

    for(auto tmp : N) {
        sum += tmp - '0';
    }

    if(sum % 9 == 0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

int root(int i,vector<int> &parent){
    if(parent[i]==-1){
        //親がいない時
        return i;
    }else{
        int result=root(parent[i],parent);
        parent[i]=result; //パス圧縮
        return result;
    }
}

void unite(int x,int y,vector<int> &parent){
    if(root(x,parent)!=root(y,parent)){
        parent[root(y,parent)]=root(x,parent);
    }
}

bool issame(int x,int y,vector<int> &parent){
    return root(x,parent)==root(y,parent);
}

int main(){
    int n;
    cin >> n;
    //first:cost,second:(first:from,second:to)
    vector<pair<int,pair<int,int> > > bridges(n*n);

    //入力
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            int cost;
            if(cin >> cost,cost!=-1){
                bridges.push_back(pair<int,pair<int,int> >(cost,pair<int,int>(i,j)));
            }
        }
    }

    //sort
    sort(bridges.begin(),bridges.end());

    //島を管理する用
    vector<int> parents(n*n,-1);

    int sum=0;

    for(int i=0;i<bridges.size();++i){
        if(!issame(bridges[i].second.first,bridges[i].second.second,parents)){
            unite(bridges[i].second.first,bridges[i].second.second,parents);
            sum+=bridges[i].first;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int a[23333333];
int main()
{
	int n,m,ans=0;
	cin>>n>>m;
	for(int j=1;j<=n;j++) cin>>a[j];
	for(int i=1;i<=n;i++)
	{
		m=m-a[i];
	}
	sort(a+1,a+n+1);
	
	while(n>0)
	{
	  if(m>=a[1]) 
	  {
	  m=m-a[1];
	  ans++;
 	  }
 	  else break;
	}
	cout<<ans+n<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        System.out.println(solve(N));
    }
    public static String solve(int N) {
        String str = Integer.toString(N, 10);
        char[] data = str.toCharArray();
        int base = 0;
        for(char c : data) {
            base += (c-48);
        }
        return N % base == 0 ? "Yes" : "No";
    }
}


Measured memory_bytes: 21972
//コンパイル
//mcs ソース
//実行
//mono exe

using System;
using System.Linq;

class TestClass {
	static void Main(string[] args) {
		// W, H, x, y, r(半径)
		int[] num = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
		int W = num[0];
		int H = num[1];
		int x = num[2];
		int y = num[3];
		int r = num[4];

		//x,yの位置が00~WH(半径込み)ならtrue
		if(x<r || x>(W-r) || y<r || y > (H-r)){
			Console.WriteLine("No");
		}else{
			Console.WriteLine("Yes");	
		}
	}
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * ABCBCBC - BCABCBC - BCBCABC - BCBCBCA
 *
 * A moves from left to right.
 */

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s) {
        const int n = s.size();
        int i = 0, cnt = 0; LL ans = 0;
        while (i < n) {
            int j = i;
            while (j < n && s[j] == 'A')
                j++;
            if (j == i)
                cnt = 0, i++;
            else {
                cnt += j-i;
                while (j+2 <= n && s[j] == 'B' && s[j+1] == 'C') {
                    ans += cnt; j += 2;
                }
                i = j;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 720
N,M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
from collections import defaultdict

P = defaultdict(set)
for _ in range(M):
    a,b = [int(x) for x in input().split()]
    P[a-1].add(b-1)
    P[b-1].add(a-1)

ans = 0
for i in range(N):
    h = [H[j] for j in P[i]]
    m = max(h) if len(h) > 0 else 0
    if H[i] > m:
        ans += 1

print(ans)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  for(i=0;i<26;i++){
    ll maxbuf=0;
    buf=0;
    for(j=0;j<s.size();j++){
      if(s[j]-'a'-i==0){
        chmax(maxbuf,buf);
        buf=0;
        //cout<<maxbuf<<endl;
      }
      else buf++;
    }
    chmax(maxbuf,buf);
    chmin(res1,maxbuf);
  }
  cout<<res1<<endl;
  return 0;
}

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

const int N=100100;
int n,clk;
vector<int>vec,ans,g[N];

void dfs(int x,int fa=-1){
	int dfn=++clk,sz=g[x].size();
	if(sz==1&&fa!=-1){vec.push_back(clk);return;}
	int id=0;
	for(int j:g[x])if(j!=fa){
		if((int)g[j].size()>1){
			if(id&&(int)g[id].size()>1)return;
			if(id)dfs(id,x);id=j;
		}else if(!id)id=j;else dfs(j,x);
	}
	vec.push_back(dfn);
	dfs(id,x);
}

void gofail(){
	cout<<-1<<'\n';
	exit(0);
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	int cnt=0;
	for(int i=1;i<=n;++i){
		int tmp=0;
		for(int j:g[i])if((int)g[j].size()>1)++tmp;
		if(tmp<=1&&(n==2||(int)g[i].size()>1)){
			++cnt;if(cnt>=3)gofail();
			vec.clear();clk=0;
			dfs(i);
			if((int)vec.size()==n){
				if(ans.empty())ans=vec;
				else ans=min(ans,vec);
			}
			for(int j:g[i])if((int)g[j].size()==1){
				vec.clear();clk=0;
				dfs(j);
				if((int)vec.size()==n){
					if(ans.empty())ans=vec;
					else ans=min(ans,vec);
				}
				break;
			}
		}
	}
	if(ans.empty())gofail();
	for(int i=0;i<n;++i)cout<<ans[i]<<" \n"[i==n-1];
	return 0;
}



Measured memory_bytes: 14968
#include<bits/stdc++.h>
    #define maxn 4002
    #define kcz 924844033
    #define int long long
    using namespace std;
    inline int read()
    {
    	char x = getchar();
    	int lin = 0, f = 1;
    	while(x < '0' || x > '9')
    	{
    		if(x == '-') f = -1;
    		x = getchar();
    	}
        while(x >= '0' && x <= '9')
    	{
    		lin = lin * 10 + x - '0';
    		x = getchar();
    	}
    	return lin * f;
    }
    #define PII pair<int,int>
    #define fir first
    #define sec second
    #define ma(a,b) make_pair(a,b)
    int n,fac[maxn],k,f[maxn][maxn][2],li[maxn],ed[maxn],tot,g[maxn],ans;
    signed main(){
    	n = read(); k = read();
    	fac[0] = 1;
    	for(int i = 1; i <= n; i++)
    		fac[i] = fac[i - 1] * i % kcz;
    	for(int i = 1; i <= k; i++)
    		for(int t = 2; t--;)
    			for(int j = i; j <= n; j += k)
    			{
    				++tot;
    				if(j != i) ed[tot] = 1;
    			}
    	f[0][0][0] = 1;
    	for(int i = 0; i < 2 * n; i++)
    		for(int j = 0; j <= n; j++)
    		{
    			f[i + 1][j][0] = (f[i][j][0] + f[i][j][1]) % kcz;
    			if(ed[i + 1]) f[i + 1][j + 1][1] = f[i][j][0];
    		}
    	for(int i = 0; i <= n; i++)
    		g[i] = (f[2 * n][i][0] + f[2 * n][i][1]) % kcz;
    		
    	for(int i = 0; i <= n; i++)
    	{
    		int t;
    		if(i & 1) t = -1;
    		else t = 1;
    		ans = (ans + t * g[i] * fac[n - i] % kcz) % kcz;
    	}
    	cout << (ans + kcz) % kcz;
    }

Measured memory_bytes: 249472
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc093/tasks/abc093_a
S = input()
if len(set(S)) == 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
width, height, x, y, r = list(map(int, input().split(' ')))

def isCircleInRect(w, h, x, y, r):
    isInX = x - r >= 0 and x + r <= w
    isInY = y - r >= 0 and y + r <= h
    return isInX and isInY

result = 'Yes' if isCircleInRect(width, height, x, y, r) else 'No'
print(result)


Measured memory_bytes: 5600
#include <stdio.h>

int main(void){

	int a,b,c;
	
	scanf ("%d %d %d",&a,&b,&c);
	
	if(a < b && b < c){
	
		printf ("Yes\n");
		
	}else{
	
		printf ("No\n");
		
	}
	
	return 0;
	
}


Measured memory_bytes: 2048
/***
	chauhan176's code

	Nothing Happens , It's True
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define maxn 300005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

typedef pair<int,ll>pi;
const ll inf = 1e10;//0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 10000000;
#define PI 3.14159265
int main()
{
    fastio;
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int f=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[i+n/2])
            f=1;
    }
    if(f)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

int main()
{
    std::size_t K, N;
    std::cin >> N >> K;
    std::vector<std::int32_t> A(N);
    for(auto& a : A)
    {
        std::cin >> a;
    }

    std::sort(A.begin(), A.end());

    std::cout << std::accumulate(A.begin(), A.begin() + K, 0) << std::endl;



    return 0;
}


Measured memory_bytes: 3624
// AOJ 2013: Osaki
// 2017.11.1 bal4u@uu
// 2017.12.30

#include <stdio.h>
#include <stdlib.h>

typedef struct { int t; int a; } T;
T tbl[20005]; int sz; 
char buf[30], *p;

int in()
{
	int n;
	n = *p++ & 0xf;
	n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int cmp(T *a, T *b) { return a->t - b->t; }

int main()
{
	int n, h, m, s, ans;
	T *tp;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		tp = tbl;
		sz = n << 1;
		while (n--) {
			fgets(p=buf, 30, stdin);
			h = in(), m = in(), s = in();
			tp->t = (((((h<<6)+m)<<6)+s)<<1)+1, tp->a = 1;
			tp++;

			h = in(), m = in(), s = in();
			tp->t = ((((h<<6)+m)<<6)+s)<<1, tp->a = -1;
			tp++;
		}

		qsort(tbl, sz, sizeof(T), cmp);

		ans = n = 0;
		tp = tbl;
		while (sz--) {
			n += tp->a, tp++;
			if (n > ans) ans = n;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2032
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	a=1;
	for(i=0;i<n;i++){
		if(a>=m)break;
		a*=2;
	}
	for(;i<n;i++){
		a+=m;
	}
	cout<<a<<endl;
}

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

int main(){
    string s;
    cin>>s;
    string ans="keyence";
    int cnt=0;
    bool canerace=true;
    for (int i = 0; i < s.size(); ++i) {
        if(ans[cnt]==s[i])++cnt;
        else break;
    }
    int bcnt=0;
    for (int i = s.size()-1; i >= 0; --i) {
        if(ans[6-bcnt]==s[i])++bcnt;
        else break;
    }
    if(cnt+bcnt>=7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
  
bool pal(string s)
{
  int n=s.size();
  for(int i=0;i<n/2;i++)if(s[i]!=s[n-i-1])return false;

  return true;
}

int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {

  int n,x;
  cin>>n;
  map<int,int> m;
  vi a(n);
for(int i=0;i<n;i++)
{
  cin>>a[i];
  m[a[i]]++;
}

int sum=0;
for(auto i:m)
{
  sum+=((i.se)*((i.se)-1))/2;
}
//cout<<sum;
  for(int i=0;i<n;i++)
  {
    cout<<sum-m[a[i]]+1<<endl;
    //cout<<m[a[i]]<<endl;
  }

    //while loop ending 
  }


  return 0;
  }

Measured memory_bytes: 11136
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int N,T,A,i,j;
    double x,y;
    int H[30000];
    cin>>N>>T>>A;
    for(i=0;i<N;i++)
    {
        cin>>H[i];
    }
    x=(A*1.0)-((T*1.0)-(H[0]*0.006));
    if(x<0.0)
    {
        x=x*(-1.0);
    }
    j=0;
    for(i=1;i<N;i++)
    {
        y=(A*1.0)-((T*1.0)-(H[i]*0.006));
        if(y<0.0)
        {
            y=y*(-1.0);
        }
        if(y<x)
        {
            x=y;
            j=i;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x; cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
A2 = A.copy()
sum1 = sum(A)

for i in range(len(A)):
    if A [i] < sum1/(4*M):
        A2[i] = 0
    else:
        A2[i] = 1

if sum(A2) < M:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N,K; cin >> N >> K;
	vector<ll> x(N),y(N);
	rep(i,N){
		cin >> x[i] >> y[i];
	}
	ll ans = LINF;
	rep(l,N)rep(r,N)rep(u,N)rep(d,N){
		if(x[l] != x[r] && y[u] != y[d] && x[l] <= min(x[r],min(x[u],x[d])) && x[r] >= max(x[l],max(x[u],x[d])) && y[u] >= max(y[l],max(y[r],y[d])) && y[d] <= min(y[r],min(y[l],y[u]))){
			int cnt = 0;
			rep(k,N){
				if(x[k] >= x[l] && x[k] <= x[r] && y[k] <= y[u] && y[k] >= y[d]){
					cnt++;
				}
			}
			if(cnt >= K) ans = min(ans,(x[r]-x[l])*(y[u]-y[d]));
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <string> str;
int n;
 
void tasu() {
  for(int i=0;i<n;i++)
    if(str[i][0] == '.')
      for(int j=0;j<str[i].size();j++) {
	if(str[i][j] != '.') {
	  str[i][j-1] = '+';
	  break;
	}
	if(str[i][j] == '.')str[i][j] = ' ';
      }
}
 
void bou() {
  
  for(int i=0;i<n;i++)
    for(int j=0;j<str[i].size();j++) {
      
      if(str[i][j] == '+')
	for(int k=i+1;k<n;k++){
	  if(str[k].size() <= j) break;
	  if(str[k][j] != '+' && str[k][j] != ' ') break;
	  if(str[k][j] == '+'){
	    for(int r=i+1;r<k;r++)
	      if(str[r][j] == ' ')
		str[r][j] = '|';
	    break;
	  }
	}
    }
}
   
 
int main() {
 
  while(1) {
    cin >> n;
    if(n==0) break;
 
    str.resize(n);
    for(int i=0;i<n;i++){
      str[i].clear();
      cin >> str[i];
    }
    tasu();
    bou();
 
    for(int i=0;i<n;i++) cout << str[i] << endl;
     
  }
 
  return 0;
}

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

int main() {

    int N;
    bool hasY = false;
    char S;

    cin >> N;

    for (int i = 0; i < N; i++){
        cin >> S;

        if (S == 'Y') { // Yがどこかで出ればFour 
            hasY = true;
        }

    }

    if (hasY) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three"  << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int x,y,z;
    
    cin>>x>>y>>z;
    
   cout<<(x-z)/(y+z)<<endl;    
  
    return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    int ans=1e9;
    for (int z = -100; z <= 100; z++) { // 0(N) = 2000 * 100
        int sum = 0;
        rep(j, N) {
            sum += (a.at(j) - z) * (a.at(j) - z);
        }
        ans = min(ans, sum);
    }

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


Measured memory_bytes: 3496
n = list(input())
head = int(n[0]+n[1])
tail = int(n[2]+n[3])
if (12 < head <=99 or head==0) and 0< tail <= 12 :
	print("YYMM")
elif 0<head<=12 and (12<tail<=99 or tail==0):
	print("MMYY")
elif 0<head<=12 and 0<=tail<=12 :
	print("AMBIGUOUS")
else :
	print("NA")

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

using namespace std;

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

	long long n, a, b;
	cin >> n >> a >> b;

	long long x = n / (a + b) * a;
	x += min(n % (a + b), a);

	cout << x << "\n";
}

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

int const N = 1e2 + 10;

int n, a[N];

int f[N];

bool solve ()
{
	int amax = 0, amin = n;

	for (int i = 1; i <= n; i++)
	{
		amax = max (amax, a[i]);
		amin = min (amin, a[i]);

		f[a[i]]++;
	}

	if (amin < (amax + 1) / 2)
		return false;

	amin = (amax + 1) / 2;

	if (amax % 2 == 0)
	{
		if (f[amin] != 1)
			return false;
	}

	if (amax % 2 != 0)
	{
		if (f[amin] != 2)
			return false;
	}

	for (int i = amin + 1; i <= amax; i++)
		if (f[i] < 2)
			return false;

	return true;
}

int main ()
{
	cin.sync_with_stdio (false);

	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	if (solve())
		cout << "Possible\n";
	else
		cout << "Impossible\n";

	return 0;
}

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

long long int kansu( long long int n, long long int k ) {

  long long int ans;

  if ( n == 1 ) {
    ans = 0;
  }else {
    ans = ( kansu( n - 1, k ) + k ) % ( n - 1 );
  }

  //  cout << "n = " << n << " : k = " << k << " : ans = " << ans << endl;
  return ans;

}

int main() {

  while( true ) {

    long long int n, k, m;
    cin >> n >> k >> m;
    if ( n == 0 ) break;

    cout << ( kansu( n, k ) + m ) % n + 1 << endl;

  }

  return 0;

}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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...);
}

struct monoid {
	public:
	  static int64 op(const int64 a, const int64 b) {
	    return max(a, b);
	  }
	  static int64 e() { return -INF_LL; }
	};

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

  int64 N, Q;
  cin >> N >> Q;
  vector<int64> A(N);
  REP(i, N) cin >> A[i];
  segtree<int64, monoid::op, monoid::e> sg(A);
  REP(_, Q) {
    int64 t, a, b;
    cin >> t >> a >> b; a--;
    if (t == 1) {
      sg.set(a, b);
    } else if (t == 2) {
      cout << sg.prod(a, b) << endl;
    } else {
      cout << sg.max_right(a, [&](int64 x) { return x < b; }) + 1 << endl;
    }
  }
}



Measured memory_bytes: 9020
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

const int N = 1001;
const int inf = INT_MAX;

int h, w, k, mat[11][N], pr[11][N], ans = inf;
string s[11];

signed main() {
    scanf("%d %d %d", &h, &w, &k);
    for (int i = 1; i <= h; ++i)
        cin >> s[i];
    for (int i = 1; i <= h; ++i)
        for (int j = 0; j < w; ++j)
            mat[i][j + 1] = (s[i][j] - '0');
    for (int i = 1; i <= h ; ++i)
        for (int j = 1; j <= w; ++j)
            pr[i][j] = pr[i][j - 1] + mat[i][j];
    for (int mask = 0; mask < (1 << (h - 1)); ++mask) {
        int cnt = __builtin_popcount(mask);
        int last = 0;
        for (int i = 1; i <= w ; ++i) {
            int col = 0;
            int mx = 0;
            for (int j = 1; j <= h; ++j) {
                col += pr[j][i] - pr[j][last];
                if (mask & (1<<(j - 1))) {
                    mx = max(mx , col);
                    col = 0;
                }
            }
            mx = max(mx , col);
            if(i - last == 1 && mx > k){
				cnt += 10000;
				break; 
			}
            if (mx > k) {
			    last = i - 1;
                cnt++;
            }
            col = 0;
        }
        ans = min(ans, cnt);
    }
    printf("%d", ans);
}
/*
3 3 1
111
111
111
*/

Measured memory_bytes: 384
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
# import statistics
import heapq
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())


ans = [-1]*n

g = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1;v-=1
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1]*n
def dfs(x,y):
    for i,j in g[x]:
        if ans[i] == -1:
            ans[i] = (y+j)%2
            dfs(i,y+j)
dfs(0,0)
for i in ans:
    print(i)

Measured memory_bytes: 97060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
 
int main() {
  int A, B;
  char c;
  cin >> A >> c >> B;
  if (c == '+') {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }
  return 0;
}

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


int main(){
    
    int n;
    typedef  unsigned long long ll;
    ll k;
    cin >> n >> k;
    vector<ll> vecA(n);
    for(int i = 0; i < n; i++){
        cin >> vecA.at(i);
    }

    ll res = 0;

    for (int d = 40; d >= -1; --d){
        if(d != -1 && !(k & (1LL<<d))) continue;

        ll tmp = 0;

        for(int e = 40; e >= 0; --e){
            ll mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < n; ++i) if (vecA[i] & mask) ++num;

            if (e > d) {
                if (k & mask) tmp += mask * (n - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, n - num);
            }
        }
     res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  int ans = 1;
  rep(i,n){
    int a;
    cin >> a;
    if(a == ans) ans++;
  }
  if(ans == 1){
    cout << -1 << endl;
    return 0;
  }
  cout << n-ans+1 << endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8
while True:
    A = list(map(int,input().split()))
    H,W = A[0],A[1]

    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if i % 2 == 0:
                if j % 2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
            elif i % 2 != 0:
                if j % 2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
                
        print()
    print()


Measured memory_bytes: 7008
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

int main()
{
    ll N,M;
	cin >> N >> M;
	vector< vector < ll > > x(N, vector<ll>(3));
	for(int i=0; i<N; i++){
		cin >> x[i][0] >> x[i][1] >> x[i][2];
	}
	ll ans=-10000000000000;
	for(int flag=0; flag<8; flag++){
		vector<ll> pm;
		int tmp=flag;
		for(int i=0; i<3; i++){
			if(tmp%2==0) pm.push_back(-1);
			else pm.push_back(1);
			tmp/=2;
		}
		vector<ll> cnt(N, 0);
		for(int i=0; i<N; i++){
			for(int j=0; j<3; j++){
				cnt[i]+=x[i][j]*pm[j];
			}
		}
		sort(cnt.begin(), cnt.end(), greater<ll>());
		ll Mans=0;
		for(int i=0; i<M; i++){
			Mans+=cnt[i];
		}
		ans = max(Mans, ans);
	}
	cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Prob: dp_x
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 WoXiHuanNiA

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template <typename T> inline T read() {
	register T _, __; register char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int MAXN = 1e3 + 5, MAXM = 2e4 + 5;

struct Item {
	int w, s, v;
	bool operator < (const Item& rhs) {
		return w + s < rhs.w + rhs.s;
	}
}ob[MAXN];

int main() {
#ifdef hany01
	freopen("dp_x.in", "r", stdin);
	freopen("dp_x.out", "w", stdout);
#endif

	int n;
	static LL dp[MAXM];

	n = read<int>();
	For(i, 1, n)
		ob[i] = (Item){read<int>(), read<int>(), read<int>()};
	sort(ob + 1, ob + 1 + n);

	For(i, 1, n)
		Fordown(j, ob[i].s, 0)
			chkmax(dp[j + ob[i].w], dp[j] + ob[i].v);
	LL ans = 0;
	For(i, 1, 2e4) chkmax(ans, dp[i]);
	printf("%lld\n", ans);

	return 0;
}
//如果满足ob[i].s - ob[j].w > ob[j].s - ob[i].w
//那么i一定放在j的后面
//我们按s+w排序, 依次插入即可

Measured memory_bytes: 384
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

s = ns()
o = 0
e = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            e += 1
    else:
        if s[i] == '0':
            o += 1
if len(s) % 2 == 0:
    half = len(s) // 2
    print(min((half - e) + o, e + (half - o)))
else:
    half = len(s) // 2
    print(min((half + 1 - e) + o, e + (half - o)))


Measured memory_bytes: 3564
object Main extends App {
  val a = readLine.toInt
  val b = readLine.toInt
  val c = readLine.toInt
  val x = readLine.toInt
  
  val seqA = (0 to a).toList
  val seqB = (0 to b).toList
  val seqC = (0 to c).toList
  
  val matched = for {
    aa <- seqA
    bb <- seqB
    cc <- seqC
    if 500 * aa + 100 * bb + 50 * cc == x
  } yield {
    (aa, bb, cc)
  }
  
  println(matched.length)
}

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


void solve(long long N, long long M){
    int count = 1;
    if (N % 2 == 1) {
        for (int i = 2; i <= (N+1)/2; i++) {
            cout << i << " " << (N - i + 2) << endl;
            if (count >= M) return;
            count++;
        }
    } else {
        for (int i = 2; i <= (N+1)/2; i++) {
            if (i <= (N/2+1)/2) {
                cout << i << " " << (N - i + 2) << endl;
            } else {
                cout << i << " " << (N - i + 1) << endl;
            }
            if (count >= M) return;
            count++;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3768
import sys


def test():
    A, B, C, K = map(int, input().split())
    ans = 0
    if A > 0 and (K - A) > 0:
        ans += A
        K -= A
    elif A > 0 and (K - A) <= 0:
        ans += K
        print(ans)
        sys.exit()

    if B > 0 and (K - B) > 0:
        K -= B
    elif B > 0 and (K - B) <= 0:
        print(ans)
        sys.exit()

    ans -= K
    print(ans)


if __name__ == "__main__":
    test()


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

int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;

  if(S==U)  cout << A-1 << " " << B << endl;
  else  cout << A << " " << B-1 << endl;

  return 0;
}


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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n, k;
    cin >> n >> k;
    vector< int> in(n);
    for (int &i : in) cin >> i;
    sort(begin(in), end(in));
    int result = 2e9;

    for (int i = 0; i + k - 1 < n; i++) result = min(result, in[i + k - 1] - in[i]);
    cout << result << endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

char sub(char ch){
	if(ch=='a')return 'z';
	else return ch-1;
}


bool solve(string s){
	string tmp="";
	rep(i,s.size()){
		if(isalpha(s[i])){
			tmp+=s[i];
		}
		else{

			if( tmp=="the" || tmp=="this" || tmp=="that" )return true;

			tmp="";
		}
	}
	return false;
}

int main(){
	string s;
	while(getline(cin,s)){
		while(1){
			rep(i,s.size()){
				if(isalpha(s[i]))s[i]=sub(s[i]);
			}
			if(solve(s))break;
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1196
import heapq

N,M = map(int, input().split())
A = list(map(int, input().split()))
AA = [-n for n in A]

heapq.heapify(AA)

for _ in range(M):
    tmp = heapq.heappop(AA)*-1
    heapq.heappush(AA,(tmp//2)*-1)


print(sum(AA)* -1)


Measured memory_bytes: 14180
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c, n, q;std::cin >> n >> q;
  multiset<vll> s;
  re(i, n){
    std::cin >> a >> b >> c;
    s.insert(vll{a-c, -1, c});
    s.insert(vll{b-c, -2, c});
  }
  re(i, q){
    std::cin >> a;
    s.insert(vll{a, i, 10000000000});
  }
  vll ans(q);
  set<ll> t;

  for(auto itr = s.begin();itr!=s.end();itr++){
    vll now = (*itr);
    if(now[1]==-1) t.insert(now[2]);
    else if(now[1]==-2) t.erase(now[2]);
    else{
      if(!t.empty()) ans[now[1]] = (*t.begin());
      else ans[now[1]] = -1;
    }
  }
  re(i, q) std::cout << ans[i] << '\n';
  return 0;
}



Measured memory_bytes: 68480
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int a;
    cin >>a;
    cout<<(ll)a+(ll)a*a+(ll)a*a*a<<endl;
    return 0; 
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String s1 = s.substring(0, 4);
		String s2 = s.substring(4, s.length());
		System.out.println(s1 + " " + s2);
	}

}


Measured memory_bytes: 9684
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x;
  cin >> n >> x;
  vl m(n);
  ll s = 0;
  rep(i, n) {
    cin >> m[i];
    s += m[i];
  }
  sort(ALL(m));
  ll ans = n;
  ans += (x - s) / m[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl c(10, vl(10));  // c[i][j] : 先頭の数がiで末尾の数がjの1以上n以下の数の個数
    exrep(x, 1, n) {
        string s = to_string(x);
        ll m = s.size();
        c[s[0] - '0'][s[m-1] - '0']++;
    }

    ll ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            ans += c[i][j]*c[j][i];
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

long long pow(long long x,long long k){
	if(k == 0)return 1;
	return pow(x,k-1)*x;
}

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

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

void f(long long x, long long y){
	if(max(x,y)%min(x,y) != 1){
		puts("No");
		exit(1);
	}
}

int main(){
	vector<long long> p;
	int t = 5;
	while(p.size() < 100){
		bool b = true;
		for(int i = 2 ; i*i <= t ; i ++){
			if(t%i == 0){
				b = false;
				break;
			}
		}
		if(b)p.push_back(t);
		t ++;
	}
	long long k[10] = {1,2,5,6,7,8,9,10,3,4};
	
	long long x[502],y[502];
	for(int i = 0 ; i < 500 ; i ++){
		x[i] = p[i/10]*pow(2,k[i%10]);
		y[i] = p[i/10+50]*pow(3,k[i%10]);
	}
	
	set<long long> S;
	long long m = 0;
	long long a[502][502] = {};
	for(int i = 0 ; i < 500 ; i ++){
		for(int j = 0 ; j < 500 ; j ++){
			if((i+j)&1){
				a[i][j] = x[i]*y[j];
				S.insert(a[i][j]);
				m = max( m , a[i][j] );
			}
		}
	}
	//cout << S.size() << endl;
	for(int i = 0 ; i < 500 ; i ++){
		for(int j = 0 ; j < 500 ; j ++){
			if((i+j)&1){}
			else {
				a[i][j] = 1;
				if(i > 0)a[i][j] = lcm(a[i][j],a[i-1][j]);
				if(i+1 < 500)a[i][j] = lcm(a[i][j],a[i+1][j]);
				if(j > 0)a[i][j] = lcm(a[i][j],a[i][j-1]);
				if(j+1 < 500)a[i][j] = lcm(a[i][j],a[i][j+1]);
				long long d = a[i][j];
				a[i][j] += 1;
				while(S.find(a[i][j]) != S.end())a[i][j] += d;
				S.insert(a[i][j]);
			}
		}
	}
	
	set<long long> T;
	long long M;
	for(int i = 0 ; i < 500 ; i ++){
		for(int j = 0 ; j < 500 ; j ++){
			T.insert(a[i][j]);
			if(a[i][j] <= 0 || a[i][j] > 1000000000000000)puts("No");
			if(j+1 < 500)f(a[i][j],a[i][j+1]);
			if(i+1 < 500)f(a[i][j],a[i+1][j]);
			M = max(M,a[i][j]);
		}
	}
	//cout << T.size() << endl;
	//cout << m << " " << M << endl;
	//puts("Yes");
	
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < n ; j ++){
			printf("%lld%c",a[i][j],(j==n-1)?'\n':' ');
		}
	}
}


Measured memory_bytes: 28416