akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long N;
    scan(N);

    long ans = inf6;
    for (long i = 1; i*i <= N; i++) {
        if (N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }

    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()], reverse=True)

for v in A:
    if K==v:
        print("POSSIBLE")
        quit()
if K > A[0]:
    print("IMPOSSIBLE")
    quit()

d = []
for i in range(N-1):
    d.append(A[i]-A[i+1])

for v in d:
    if v:
        K %= v

if K:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 V> struct MaxFlow { // Dinic O(V^2E)
    struct edge { int to, reve; V cap; edge(int t, int r, V c) : to(t), reve(r), cap(c) {} };
    int MV; vector<vector<edge>> E; vector<int> itr, lev;
    MaxFlow(int n) { init(n); } MaxFlow() { }
    void init(int n){MV=n;itr=vector<int>(MV),lev = vector<int>(MV); E = vector<vector<edge>>(MV); }
    void add_edge(int x, int y, V cap, bool undir = false) {
        E[x].push_back(edge(y, (int)E[y].size(), cap));
        E[y].push_back(edge(x, (int)E[x].size() - 1, undir ? cap : 0));}
    void bfs(int cur) {rep(i, 0, MV) lev[i] = -1; queue<int> q; lev[cur] = 0; q.push(cur);
        while (q.size()) {int v = q.front(); q.pop();
        for (auto e : E[v]) if (e.cap>0 && lev[e.to]<0) lev[e.to] = lev[v] + 1, q.push(e.to);}}
    V dfs(int from,int to,V cf){if(from==to)return cf;for(; itr[from]<E[from].size(); itr[from]++) {
        edge* e = &E[from][itr[from]]; if (e->cap>0 && lev[from]<lev[e->to]) {
        V f = dfs(e->to, to, min(cf, e->cap));if(f>0){e->cap-=f;E[e->to][e->reve].cap+=f;return f; }}
        } return 0;}
    V maxflow(int from, int to) {V fl = 0, tf;while (1) {bfs(from); if (lev[to]<0) return fl;
        rep(i,0,MV)itr[i]=0; while ((tf = dfs(from, to, numeric_limits<V>::max()))>0) fl += tf;}}};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    int n = S.length();
    
    int ans = 0;

    {
        int d = S[0] - '0' - 1;
        d += 9 * (n - 1);
        chmax(ans, d);
    }

    {
        int d = 0;
        fore(c, S) d += c - '0';
        chmax(ans, d);
    }

    cout << ans << endl;
}

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

#define ll long long
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

int main() {
   ll n, k;
   cin >> n >> k;
   
   if (k == 0) {
      cout << n * n << endl;
      return 0;
   }

   ll ans = 0;
   for (int b = k; b <= n; b++) {
      int a = n/b;
      ans += (b - k) * a;
      ans += max(n % b - k + 1, 0LL);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
int mod = 1000000007;
using namespace std;
int a[200005];
double b[1005];
void init ()
{
   b[1]=1;
   for(int i=2;i<=1000;i++)
     b[i]=b[i-1]+i;
   for(int i=2;i<=1000;i++)
     b[i]=b[i]/i;
}
int main()
{    
     init();
     int n,k;
     cin>>n>>k;
     double ans=0,maxs=0;
     for(int i=1;i<=n;i++)
     {
        cin>>a[i];
        if(i==k)
        {
             for(int i=1;i<=k;i++)
              ans+= b[ a[i] ];
              maxs=max(maxs,ans);
        }
        else if( i>k )
        {
           ans= ans- b[a [i-k] ]+b[a[i]];
           maxs=max(maxs,ans);
        }
     }
     cout<< fixed<<setprecision(9) <<maxs<<endl;
   return 0;   
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
int main() {
  int K;
  cin >> K;
  ll sum = 0;
  REP(i, 1, K+1) REP(j, 1, K+1) REP(k, 1, K+1)
    sum += gcd(gcd(i, j), k);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	string str;
	cin>>str;
	vector<int>arr(n,0);
	for(int i=1;i<n;i++){
		arr[i]=arr[i-1];
		if(str[i]=='C' && str[i-1]=='A')
			arr[i]++;
	}
	// for(int i=0;i<n;i++){
	// 	cout<<arr[i]<<" ";
	// }
	// cout<<endl;
	while(q--){
		int l,r;
		cin>>l>>r;
		l--;r--;
		int res=arr[r];
		if(l>=0)
			res-=arr[l];
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = mod * mod;

const string str[4] = { "dream", "dreamer", "erase","eraser" };


int main(){
	string S;
	cin >> S;
	int idx=0;
	int len;
	bool flg = true;
	len = S.size();
	while (idx != len) {
		if (len - idx < 4) {
			flg = false;
			break;
		}
		if (S[idx] == 'd') {
			for (int i = 0; i < 5; i++) {
				if (str[0][i] != S[idx + i]) {
					flg = false;
					break;
				}
			}
			idx += 5;
			if (len - idx<2 || S[idx] != 'e')continue;
			if (S[idx + 1] == 'r') {
				if (S[idx + 2] != 'a') {
					idx += 2;
				}
			}
		}
		else if (S[idx] == 'e') {
			for (int i = 0; i < 5; i++) {
				if (str[2][i] != S[idx + i]) {
					flg = false;
					break;
				}
			}
			idx += 5;
			if (len - idx > 0 && S[idx] == 'r')idx++;
		}
		else {
			flg = false;
			break;
		}
	}
	cout << (flg ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	int S;
	cin>>S;
	int h,m,s;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}
	




Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
using namespace std;
long long max_(long long a,long long b)
{
    return a>b?a:b;
}
long long ceil_(long long a,long long b)
{
    return a/b+(a%b!=0);
}
int main() {
    int n;
    cin>>n;
    long long a=1,b=1;
    while(n--)
    {
        long long t1,t2;
        cin>>t1>>t2;
        long long p=max_(ceil_(a,t1),ceil_(b,t2));
        a=t1*p;
        b=t2*p;
    }
    cout<<a+b<<endl;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a,b,c; cin >> a >> b>> c;
  cout << c <<  " " << a <<  " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int dp[5005][2][2];
int main()
{
	int n;
	int v[10005];
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&v[i]);
	}
	for(int i=0;i<5005;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++) dp[i][j][k]=INF;
	dp[1][0][0]=0;
	int cur=0,nex=1;
	for(int i=1;i<n;i++)
	{
		for(int i=0;i<5005;i++)for(int j=0;j<2;j++) dp[i][j][nex]=INF;
		for(int j=min(n/2,i);j>=max(0,i-n/2);j--)
		{
			dp[j+1][0][nex]=min(dp[j+1][0][nex],dp[j][0][cur]);
			dp[j][1][nex]=min(dp[j][1][nex],dp[j][0][cur]+v[i]);
			
			dp[j][1][nex]=min(dp[j][1][nex],dp[j][1][cur]);
			dp[j+1][0][nex]=min(dp[j+1][0][nex],dp[j][1][cur]+v[i]);
		}
		cur=1-cur; nex=1-nex;
	}
	printf("%d\n",min(dp[n/2][0][cur],dp[n/2][1][cur]));
}

Measured memory_bytes: 1304
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a, b;
    int i;
    int x, min = 1000000000;
    for (i = 1; i <= n / 2; i++)
    {
        a = i;
        b = n - a;
        x = 0;
        while (a != 0)
        {
            x += (a % 10);
            a /= 10;
        }
        while (b != 0)
        {
            x += (b % 10);
            b /= 10;
        }
        if (min > x)
            min = x;
    }
    printf("%d\n", min);
    return 0;
}

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

using namespace std;

int main(){

	int n;
	int ans;

	while(scanf("%d",&n) != EOF){

		if(n % 39 < 10 && n % 39 > 0){
			cout << "3C0" << n % 39 << endl;
		}
		else if(n % 39 == 0){
			cout << "3C39" << endl;
		}
		else if(n % 39 > 10){
			cout << "3C" << n%39 << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e5+20;
const int inf=0x3f3f3f3f;

struct node {
	int v,next,w;
};
node e[maxn<<3];
int cnt=1,start[maxn];
inline void addedge(int u,int v,int w){ e[++cnt]=(node){v,start[u],w};start[u]=cnt;}
inline void Addedge(int u,int v,int w,int op=0){ addedge(u,v,w);addedge(v,u,op?w:0);}

int n,p[maxn],q[maxn],pid[maxn],qid[maxn];
int nump[maxn],numq[maxn];
int ptot,qtot;
int tot,S,T;
int Sn,Tn;
int wp[maxn],wq[maxn];

inline void FJ(int *p,int *pid,int *nump,int &ptot)
{
	static int vis[maxn];
	memset(vis,0,sizeof(int)*(n+1));
	REP(i,1,n)if(!vis[i])
	{
		++ptot; nump[ptot]=++tot; 
		for(int j=i;!vis[j];j=p[j])vis[j]=1,pid[j]=ptot;
	}
}

int ans;

inline void init()
{
	n=read();
	REP(i,1,n)p[i]=read()+1;
	REP(i,1,n)q[i]=read()+1;
	Sn=++tot; Tn=++tot;
	FJ(p,pid,nump,ptot);
	FJ(q,qid,numq,qtot);
	REP(i,1,n)
	{
		if(p[i]==i && q[i]==i);
		else if(p[i]==i)wq[qid[i]]+=2;
		else if(q[i]==i)wp[pid[i]]+=2;
		else if(p[i]==q[i])Addedge(nump[pid[i]],numq[qid[i]],2,1),ans+=2;
		else wp[pid[i]]++,wq[qid[i]]++,ans++,Addedge(nump[pid[i]],numq[qid[i]],1,1);
	}
	REP(i,1,ptot)ans+=wp[i],Addedge(nump[i],Tn,wp[i]);
	REP(i,1,qtot)ans+=wq[i],Addedge(Sn,numq[i],wq[i]);
}

int cur[maxn],lev[maxn];

inline bool bfs()
{
	memset(lev,0,sizeof(int)*(tot+1));
	queue<int>q;
	q.push(S); lev[S]=1;
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		EREP(i,u)
		{
			int v=e[i].v;
			if(!lev[v] && e[i].w)
			{
				lev[v]=lev[u]+1;
				if(v==T)return 1;
				q.push(v);
			}
		}
	}
	return 0;
}

int dfs(int u,int flow)
{
	int tag=0;
	if(u==T)return flow;
	for(int &i=cur[u];i;i=e[i].next)
	{
		int v=e[i].v;
		if(lev[v]==lev[u]+1 && e[i].w)
		{
			int c=dfs(v,min(flow-tag,e[i].w));
			if(c)
			{
				e[i].w-=c;
				e[i^1].w+=c;
				tag+=c;
				if(tag==flow)return tag;
			}
		}
	}
	return tag;
}

inline int min_cost(int _S,int _T)
{
	S=_S; T=_T;
	int ans=0;
	while(bfs())
	{
		memcpy(cur,start,sizeof(int)*(tot+1));
		ans+=dfs(S,inf);
	}
	return ans;
}

inline void doing()
{
	printf("%d\n",ans-min_cost(Sn,Tn)>>1);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 15816
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
long long a,b,c;
long long t[100001];
int ef(long long x)
{
    long long u=x;
    long long t1[100001];
    for(long long i=0; i<a; i++)
    {
        long long r;
        t1[i]=t[i]-c*x;
        if(t1[i]%(b-c)==0&&t1[i]>0)
            r=t1[i]/(b-c);
        if(t1[i]%(b-c)!=0&&t1[i]>0)
            r=t1[i]/(b-c)+1;
        if(t1[i]>0)
            u=u-r;
    }
    if(u>=0)
        return 1;
    else
        return 0;



}
int main()
{
    while(scanf("%lld %lld %lld",&a,&b,&c)!=EOF)
    {
        for(int i=0; i<a; i++)
            cin>>t[i];
        long long st,et;
        sort(t,t+a);
        st=0;
        et=1000000001;
        while(st+1<et)
        {
            int q;
            long long mid=(st+et)/2;
            q=ef(mid);
            if(q==1)
                et=mid;
            else st=mid;

        }
        cout<<et<<endl;
    }
    return 0;
}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N,memo,res=0,num;
    scanf("%d",&N);
    vector<int> v(N);

    REPI(N)
        scanf("%d",&v[i]);
    
    sort(v.begin(),v.end());

    memo=v[0];
    num=1;
    for(int i=0;i<N-1;i++){
        if(v[i]!=v[i+1]){
            if(memo>num)
                res+=num;
            else
                res+=num-memo;
            memo=v[i+1];
            num=1;
        }else{
            num++;
        }

        if(i==N-2){
            if(memo>num)
                res+=num;
            else
                res+=num-memo;
        }
    }
    if(N==1 && v[0]!=1)
        res=1;
            
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    long long a, b, k;
    cin >> a >> b >> k;
    if (a > k) {
        a -= k;
    } else {
        b -= k - a;
        if (b < 0) {
            b = 0;
        }
        a = 0;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <regex>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

string s;
smatch sm;
//"keyence"

int main() {
    cin >> s;

#define Y cout << "YES" << endl; return 0;
    if (regex_match(s, sm, regex(".*keyence"))) {Y}
    if (regex_match(s, sm, regex("k.*eyence"))) {Y}
    if (regex_match(s, sm, regex("ke.*yence"))) {Y}
    if (regex_match(s, sm, regex("key.*ence"))) {Y}
    if (regex_match(s, sm, regex("keye.*nce"))) {Y}
    if (regex_match(s, sm, regex("keyen.*ce"))) {Y}
    if (regex_match(s, sm, regex("keyenc.*e"))) {Y}
    if (regex_match(s, sm, regex("keyence.*"))) {Y}

    cout << "NO" << endl;

    return 0;
}


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

int main()
{
    int a , b ;

    double x ;
    cin >> a >> b ;
    x = (a + b)/2 ;
    if(((a + b)% 2)== 0 )
    {
        cout << x << endl;
    }else
    {
        cout << x +1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3744
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[60];
int ans[11000];
int sz=0;
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	int pr=-1;
	while(b>=0){
		int m=0;
		int v=mod;
		for(int i=0;i<a;i++){
			if(pr==i)continue;
			if(v>p[i]){
				m=i;
				v=p[i];
			}
		}
		if(v==0){
			printf("-1\n");return 0;
		}
		for(int i=0;i<a;i++){
			if(pr!=i){
				p[i]--;
				if(i!=m)ans[sz++]=i;
			}
		}
		ans[sz++]=m;
		pr=m;
		b--;
	}
	printf("%d\n",sz);
	for(int i=0;i<sz;i++){
		if(i)printf(" ");
		printf("%d",ans[i]+1);
	}
	printf("\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <queue>

using namespace std;

const int INF=10000000;
typedef pair<int,int> P;

int h,w;
char maze[60][60];
int d[60][60];
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int sx,sy,gx,gy;

int bfs(){
    queue<P> que;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j] = INF;
        }
    }
    que.push(P(sx,sy));
    d[sx][sy] = 0;
    while(que.size()){
        P p=que.front();
        que.pop();
        if(p.first == gx && p.second == gy){
            break;
        }
        for(int i=0; i<4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0<=nx && nx<h && 0<=ny && ny<w && maze[nx][ny]=='.' && d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second]+1;  
            }
        }
    }
    return d[gx][gy];
}

int main(){
    cin >> h >> w;
    int white=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> maze[i][j];
            if(maze[i][j]=='.'){
                white++;
            }
        }
    }
    sx = 0;
    sy = 0;
    gx = h-1;
    gy = w-1;
    if(bfs()==INF){
        cout << -1 << endl;
        return 0;
    }
    cout << white - bfs()-1 << endl;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
a=[]
b=[]
for i in range(n):
    a.append([int(x) for x in input().split()])
for j in range(m):
    b.append(int(input()))
for a_row in a:
    print(sum([x*y for x,y in zip(a_row,b)]))


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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K <= A) {
		cout << K << endl;
	} else if (A < K && K <= A + B) {
		cout << A << endl;
	} else if (A + B < K) {
		cout << 2 * A + B - K << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string s;
  cin >> s;
  int mi = INF;
  for(int i = 0; i < s.size()-2; i++) {
    int num = (s[i]-'0')*100 + (s[i+1]-'0')*10
    + (s[i+2]-'0');
    mi = min(mi,abs(num-753));
  }
  cout << mi << endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO  
  
  int a, b; cin >> a >> b;
  string input; cin >> input;
  bool ok = true;

  if(input[a] != '-') ok = false;

  for(int idx = 0; idx <= a + b; ++idx){
    if(idx == a) continue;
    if('0' <= input[idx] && input[idx] <= '9') continue;
    ok = false;
  }

  if(ok) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 256
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
a=a.push(x).sort
n=a.each_cons(2).map{|a,b|b-a}
ans = n[0]
n.each_cons(2) do |a,b|
  ans=[ans,a.gcd(b)].min
end

p ans


Measured memory_bytes: 23040
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

char in[1<<21];
char const*o;

void init_in() { 
  o = in; 
  in[fread(in,1,sizeof(in)-4,stdin)] = 0;
}

int readInt(){ 
  unsigned u = 0, s = 0;
  while(*o && *o <= 32){
    ++o; 
  }
  if (*o == '-'){
    s = ~s, ++o;
  } else if (*o == '+'){
    ++o;
  }
   
   while(*o>='0' && *o<='9'){
    u = (u<<3) + (u << 1) + (*o++ - '0');
  }

  return static_cast<int>((u^s) + !!s) ;
}

struct task{
  int year, id;
};

int main(){
  init_in();
  int n = readInt(); int m = readInt();
  vector<vector<task>> v(101010);
  for (int i = 0; i < m; ++i) {
    int p = readInt(); int y = readInt();
    v[p].push_back({y, i + 1});
  }

  vector<int> ans1(101010), ans2(101010);

  for (int i = 1; i <= n; ++i) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end(), [](const task &x, const task &y){
      return x.year < y.year;
    });
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (int) v[i].size(); ++j) {
      ans1[v[i][j].id] = i;
      ans2[v[i][j].id] = j + 1;
    }
  }

  for (int i = 1; i <= m; ++i) {
    cout << setfill('0') << right << setw(6) << ans1[i] << setfill('0') << right << setw(6) << ans2[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 9344
import math

n = int(input())
x = [float(num) for num in input().split()  ]
y = [float(num) for num in input().split()  ]

delta = []
for i in range(n):
  dif = abs(x[i]-y[i])
  delta.append(dif)

dp1 = sum(delta)
print(dp1)

dp2 = 0.0
for i in range(n):
  dp2 += delta[i]**2
dp2 = math.sqrt(dp2)
print(dp2)

dp3 = 0.0
for i in range(n):
  dp3 += delta[i]**3
dp3 = math.pow(dp3,1/3)
print(dp3)

dpe = 0.0
for i in range(n):
  dpe = max(dpe,delta[i])
print(dpe)



Measured memory_bytes: 5724
n = int(raw_input())
[out1, out2, out3, out4, out5, out6] = [0 for i in range(6)] 
for i in range(n):
    k = float(raw_input())
    if k < 165.0: out1 += 1
    elif 165.0 <= k < 170.0: out2 += 1
    elif 170.0 <= k < 175.0: out3 += 1
    elif 175.0 <= k < 180.0: out4 += 1
    elif 180.0 <= k < 185.0: out5 += 1
    elif 185.0 <= k: out6 += 1

for j,k in zip([i for i in range(1,7)],[out1, out2, out3, out4, out5, out6]):
    print str(j) + ':' + '*'*k

Measured memory_bytes: 4252
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

stim_A = [0]
di = {}
ans = 0
for i in A:
    stim_A.append((stim_A[-1]+i)%M)
    if(stim_A[-1] in di):
        di[stim_A[-1]] += 1
    else:
        di[stim_A[-1]] = 1
for i in di:
    if(i==0):
        ans+=di[0]
    if(di[i]>1):
        ans += (di[i]-1)*di[i]//2
    
print(ans)


Measured memory_bytes: 14676
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin >> n >> m;
    vector<pi> arr(n,{0,0});
    F0R(i,m)
    {
        int first;
        string second;
        cin >> first >> second;
        first--;
        if(second=="WA")
        {
            if(arr[first].first==0)
                arr[first].second++;
        }
        else
            arr[first].first++;
    }
    int ac=0,wa=0;
    F0R(i,n)
    {
        ac+=min(1,arr[i].first);
        if(arr[i].first!=0)
            wa+=arr[i].second;
    }
    cout << ac << " " << wa;

    return 0;
}


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

int N;
map<int, int> F;

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int a; cin >> a; ++F[a];
  }
  int el = F.begin()->first, nl = F.begin()->second;
  int eg = F.rbegin()->first;
  if(!((nl == 1 && eg == el * 2) || (nl == 2 && eg == el * 2 - 1))) {
    cout << "Impossible" << endl; return 0;
  } else {
    for(int e = el + 1; e <= eg; ++e) {
      if(F[e] < 2) { cout << "Impossible" << endl; return 0; }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[][] w = new int[N][2];
		boolean beg = false;
		int cost =2000;
		//int res;
		//int time;
		for(int i = 0;i<N;i++) {
			w[i][0] = sc.nextInt();
			w[i][1] = sc.nextInt();
			if(w[i][1]<=T&&beg==false) {
				beg=true;
				//time = w[i][1];
				cost = w[i][0];
            //  System.out.println(cost);
			}

		}
		for(int n = 0;n<N;n++) {
			if(cost>w[n][0] && w[n][1]<=T) {
				cost = w[n][0];
			}
		}
		if(cost==2000) {
		System.out.println("TLE");
		}else {
			System.out.println(cost);
		}



	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define all(vvv) vvv.begin(), vvv.end()
#define sz size()
#define mp make_pair
#define f first
#define s second
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		if(!(x & 1))
			if(x % 3 != 0 && x % 5 != 0) cout << "DENIED", exit(0);
	}
	cout << "APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    vl a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    ll ansa=0,ansb=0;
    rep(i,n){
        ll counta=0;
        for(int j=i+1;j<n;j++){
            if(a[j]<a[i])counta++;
        }
        ansa+=counta*fac(n-i-1);
    }
        rep(i,n){
        ll countb=0;
        for(int j=i+1;j<n;j++){
            if(b[j]<b[i])countb++;
        }
        ansb+=countb*fac(n-i-1);
    }
    cout << abs(ansa-ansb) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int d = sc.nextInt();
        if (d == 22)
            System.out.println("Christmas Eve Eve Eve");
        if (d == 23)
            System.out.println("Christmas Eve Eve");
        if (d == 24)
            System.out.println("Christmas Eve");
        if (d == 25)
            System.out.println("Christmas");
    }
}

Measured memory_bytes: 19156
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 998244353
using namespace std;

typedef pair<int, int> P;

int n;
int idx[maxn], a[maxn];
int ans[maxn];
vector<int> v[maxn];

void dfs(int now, int fa, int len)
{
    int k = lower_bound(a + 1, a + len + 1, idx[now]) - a;
    //printf("now=%d k=%d\n", now, k);
    int tmp = a[k];
    a[k] = idx[now];
    if (k == len + 1)
        ans[now] = len + 1;
    else
        ans[now] = len;
    for (int x : v[now])
    {
        if (x == fa)
            continue;
        dfs(x, now, ans[now]);
    }
    a[k] = tmp;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d", &idx[i]);
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    a[0] = 0;
    dfs(1, 0, 0);
    for (int i = 1; i <= n; i++)
        printf("%d\n", ans[i]);

    return 0;
}


Measured memory_bytes: 30568
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll left = 0;
	ll right = 0;
	ll ans= 1;
	while (right < n-1) {
		if (a[right+1] - a[left] <= 2) {
			right++;
		}
		else {
			left++;
		}
		ans = max(ans, right - left+1);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
import itertools

n, m, x = list(map(int, input().split()))
c = []
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp.pop(0))
    a.append(tmp)

min_cost = 10 ** 5 * 12 + 1
for i in range(1, n + 1):
    for j in list(itertools.combinations(range(n), i)):
        recog = [0] * m
        cost = 0
        for k in j:
            cost += c[k]
            for l in range(m):
                recog[l] += a[k][l]

        for l in range(m):
            if recog[l] < x:
                break
        else:
            if cost <= min_cost:
                min_cost = cost

if min_cost == 10 ** 5 * 12 + 1:
    print(-1)
else:
    print(min_cost)

Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
int main()
{
    ll n;
    cin>>n;
    ll val=1;
    ll arr[n];
    f(i,n) cin>>arr[i];
    ll ans=0;
    f(i,n){
        if(arr[i]!=val)
        ans++;
        else
        {
            val++;
        }
        

    }
    if(ans==n)
    cout<<"-1"<<endl;
    else
    {
        cout<<ans<<endl;
    }
    

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll mod = 1000000007;
  ll N,K;
  cin >> N >> K;
  ll ans = 0;
  for (ll i = K; i <= N + 1; i++) {
    ll left = (i * (i - 1)) / 2;
    ll right = (((2 * N) - i + 1) * i) / 2;
    ans += right - left + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int up(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int n;
	scanf("%d\n",&n);
	int x[n],y[n],MED,med;
	rep(i, n) { scanf("%d", &x[i]); y[i] = x[i]; }
	qsort(y, n, sizeof(int), up);
	med = y[n / 2-1];
	MED = y[n / 2];
	rep(i, n) {
		if (x[i] <= med)printf("%d\n", MED);
		else printf("%d\n", med);
	}
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define mo 1000000007
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if ((i - v[j]) >= 0 && dp[i - v[j]] == 0) {
        dp[i] = 1;
        break;
      }
    }
  }
  if (dp[k] == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}


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

using namespace std;

int main(){
    
    
    
    string s;
    int K;
    cin >> s >> K;
    
    int n = 1;
    vector<string> st;
    
    for (int i = 0; i < s.length(); i++) {
        for (int j = 1; j <= 5; j++) {
            st.push_back(s.substr(i, j));
            
        }
    }
    
    sort(st.begin(), st.end());
    
    
    
    for (int i = 0; i < st.size(); i++) {
        if (n == K) {
            cout << st[i] << endl;
            break;
        }
        
        if (i != 0 && st[i] != st[i-1]) {
            n += 1;
            //cout << n << st[i] << endl;
            
            if (n == K) {
                cout << st[i] << endl;
                break;
            }
        }
        
        
    }

    
    
    
    
    
    
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e3+9, M = 1e7, OO = 0x3f3f3f3f;
double x[10],y[10];
int towns[10];

int main()
{
  double sum=0;
  int n;
  scanf("%d",&n);
  iota(towns,towns+n,0);
  for(int i=0;i<n;++i) scanf("%lf%lf",x+i,y+i);
  
  do
  {
    for(int i=1;i<n;++i)
    {
      double dist = (x[towns[i]]-x[towns[i-1]])*(x[towns[i]]-x[towns[i-1]]) + (y[towns[i]]-y[towns[i-1]])*(y[towns[i]]-y[towns[i-1]]);
      sum+=sqrt(dist);
    }
  } while (next_permutation(towns,towns+n));
  int fact =1;
  for(int i=1;i<=n;++i) fact*=i;
  printf("%.10lf",1.0*sum/fact);
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<int> B(N); rep(i, 0, N)cin >> B[i];

	bool judge = true;
	list<int> ans;
	rep(i, 0, N) {
		if (B[i] == 1)ans.push_front(B[i]);
		else {
			list<int>::iterator tmp = ans.begin();
			rep(j, 1, B[i]) {
				if (tmp == ans.end()) {
					judge = false;
					break;
				}
				tmp++;
			}
			if (judge)ans.insert(tmp, B[i]);
			else break;
		}
	}

	if (judge)
		for (list<int>::iterator itr = ans.begin(); itr != ans.end(); itr++)
			cout << *itr << endl;
	else cout << -1 << endl;


	return 0;
}


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

int main(){
  int x,y,c = 0;
  cin >> x >> y;
  for(int n = x; n <= y; n++){
    int s1,s2,s3,s4,s5;
    s1 = n / 10000;
    s2 = (n - s1 * 10000) / 1000;
    s3 = (n - (s1 * 10000 + s2 * 1000)) / 100;
    s4 = (n - (s1 * 10000 + s2 * 1000 + s3 * 100)) / 10;
    s5 = n - (s1 * 10000 + s2 * 1000 + s3 * 100 + s4 * 10);
    if(s1 == s5 && s2 == s4){
      c++;
    }
    if(n == y)
      cout << c << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    while(1){
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        else{
            if(a < b){
                cout << a << " " << b << endl;
            }
            else cout << b << " " << a << endl;
        }
    }
        return 0;
}











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

int total=0,N,order[20],addt_pts[20];
int main(){
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> order[i];
  }
  for (int i=0;i<N;i++){
    int temp;
    cin >> temp;
    total += temp;
  }
  for (int i=0;i<N-1;i++){
    cin >> addt_pts[i];
  }
  
  //add points
  for (int i=0;i<N-1;i++){
    if (order[i+1] - order[i]==1){
      total += addt_pts[order[i]-1];
    }
  }
  cout << total;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, k;
string s;

void solve() {
  int cnt = 0;
  for (int i=0;i<n-1;i++) {
    if (s[i] != s[i+1]) {
      cnt++;
    }
  }
  cout << (n - cnt - 1 + min(cnt, k * 2)) << endl;
}

int main() {
  cin >> n >> k;
  cin >> s;
  solve();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> S;
}

int solve(){
    bool ok=(S[2]==S[3] && S[4]==S[5]);
    cout << (ok?"Yes":"No" )<< endl;
    return 0;
}   

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


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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    double x;
    string u;
    double sum = 0;
    rep(i, N){
        cin >> x >> u;
        if(u == "JPY"){
            sum += x;
        }else{
            sum += x * 380000.0;
        }
    }

    cout << std::fixed << std::setprecision(15) << sum << endl;

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <cstring>
#define lowbit(x) (x&-x)
using namespace std;
const int MAXN=100005;
int a[MAXN],n,mp[4][MAXN],c[MAXN];
bool sta[MAXN];
inline int sum(int x)
{
	int ret=0;
	for(;x;x-=lowbit(x))ret+=c[x];
	return ret;
}
inline void add(int x)
{
	for(;x<=n;x+=lowbit(x))++c[x];	
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=3;++i)
		for(int j=1;j<=n;++j)
			scanf("%d",&mp[i][j]);
	int need[2]={0};
	for(int i=1;i<=n;++i){
		if(max(mp[1][i],mp[3][i])%3){puts("No");return 0;}
		if(mp[2][i]==mp[1][i]+1 && mp[3][i]==mp[2][i]+1)sta[i]=0;
		else if(mp[1][i]==mp[2][i]+1 && mp[2][i]==mp[3][i]+1)sta[i]=1,++need[i&1];
		else {puts("No");return 0;}
		a[i]=max(mp[1][i],mp[3][i])/3;
		if((a[i]&1)!=(i&1)){puts("No");return 0;}
	}
	long long mov1=0,mov0=0;
	for(int i=1;i<=n;i+=2)
		mov1+=(i/2)-sum(a[i]),add(a[i]);
	memset(c,0,sizeof(c));
	for(int i=2;i<=n;i+=2)
		mov0+=(i/2-1)-sum(a[i]),add(a[i]);
	if((mov1&1)==(need[0]&1) && (mov0&1)==(need[1]&1))puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 2304
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;

        for(int i=0; i<N; i++){
            int L1 = sc.nextInt();
            int L2 = sc.nextInt();
            count +=L2-L1+1;
        }

        System.out.println(count);
                  
    
    }    
}




Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B;

int main(){
    cin>>A>>B;

    int ans=max(A+B,max(A+A-1,B+B-1));

    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Wi = new long[N];
            for (var i = 0; i < N; ++i)
            {
                Wi[i] = Sarray()[0];
            }
            var Wmax = Wi.Max();
            var Wsum = Wi.Sum();
            var Wave = (double)Wsum / N;
            var Wst = new long[N];
            Wi.CopyTo(Wst, 0);
            Array.Sort(Wst);
            var max = 0L;
            for (var i = 0; i < (N + K - 1) / K; ++i)
                max += Wst[N - 1 - i];
            ++max;
            var p = Math.Max(Wmax, (Wsum + K - 1) / K);
            var min = p;
            var mid = 0L;
            var ok = max;
            while (p<=min&& min < max)
            {
                var cnt = 1;
                var sum = 0L;
                mid = (min + max) / 2;
                for (var i = 0; i < N; ++i)
                {
                    sum += Wi[i];
                    if (mid < sum)//積載量超過
                    {
                        cnt++;
                        sum = Wi[i];
                    }
                }
                if (cnt <= K)//範囲内に収まれば
                {
                    ok = mid;
                    max = mid;
                }
                else
                { min = mid + 1; }
            }
            WriteLine(ok);
        }
    }
}


Measured memory_bytes: 23684
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+10;
const ll inf =9;
 

int main(){
	fastio;
	ll tc,n,k;
	string s;
	cin>>k>>s;
	if(s.size()<=k) cout<<s<<endl;
	else{
		cout<<s.substr(0,k)<<"... \n";
	}
}

Measured memory_bytes: 3644
cnt = 0

while True:



    N = int(input())

    if N == 0:
        break

    if cnt != 0:
        print ("")
    cnt = 1

    A,B,C,D = map(int,input().split())

    mon = A * 10 + B * 50 + C * 100 + D * 500

    mon -= N

    d = mon // 500
    mon %= 500
    c = mon // 100
    mon %= 100
    b = mon // 50
    mon %= 50
    a = mon // 10

    if A-a > 0:
        print (10,A-a)
    if B-b > 0:
        print (50,B-b)
    if C-c > 0:
        print (100,C-c)
    if D-d > 0:
        print (500,D-d)


Measured memory_bytes: 5612