akhauriyash/Code-Regression huggingface dataset:
# 長さLの文字列がN個
N,L = map(int, input().split())

# 入力した文字を保存する変数を初期化
moji=[]
# N個の文字列を入力するために、入力を繰り返す
for i in range(N):
    # 文字列を入力
    tmp = input()
    # 文字列をリストに追加
    moji.append(tmp)
    
# 文字列をアルファベット順に並び替える
moji.sort()

# 文字列を結合して表示する
print("".join(moji))


Measured memory_bytes: 3060
from collections import deque
import sys
input = sys.stdin.readline


x = int(input().strip())
abs_x = abs(x)

def X(a, b):
    return a**5 - b**5

def X_plus(a, b):
    return a**5 + b**5

a = -118
b = -119


for a in range(-118, 119):
    #print(a)
    for b in range(-119, 118):
        #print(b)
        if X(a,b) == x:
            print(a,b)
            exit()

#print("not found")

Measured memory_bytes: 9384
using System;
using System.Linq;

namespace ABC134
{
    class abc134c
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = new System.Collections.Generic.List<int>();
            for (var i = 0; i != n; ++i)
                a .Add( int.Parse(Console.ReadLine()));
            var sorted = a.OrderByDescending(x => x).ToList(); ;
            var largest = sorted[0];
            var second = sorted[1];

            for(var i =0; i!=n; ++i)
            {
                if (a[i] == largest)
                    Console.WriteLine(second);
                else
                    Console.WriteLine(largest);
            }
        }
    }
}


Measured memory_bytes: 24788
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int solve(int *pnum, int len) {
	if (len == 0) {
		return 1;
	}

	for (int index = 1; index < 10; index++) {
		if (pnum[index] != 0) {
			if (pnum[index] >= 3) {
				pnum[index] -= 3;
				int result = solve(pnum, len - 3);
				pnum[index] += 3;
				if ( result == 1) {
					return 1;
				}
			}

			if (pnum[index] >= 2 && len % 3 == 2) {
				pnum[index] -= 2;
				int result = solve(pnum, len - 2);
				pnum[index] += 2;
				if (result == 1) {
					return 1;
				}
			}

			if (pnum[index] >= 1 && pnum[index + 1] >= 1 && pnum[index + 2] >= 1) {
				pnum[index] -= 1;
				pnum[index + 1] -= 1;
				pnum[index + 2] -= 1;
				int result = solve(pnum, len - 3);
				pnum[index] += 1;
				pnum[index + 1] += 1;
				pnum[index + 2] += 1;
				if (result == 1) {
					return 1;
				}
			}
		}
	}

	return 0;
}

int main(void) {
	int i,flag;
	string str;
	int num[12];

	while (cin >> str) {
		//cout << str << endl;
		flag = 0;
		for (i = 0; i < 12; i++) {
			num[i] = 0;
		}
       
		for (i = 0; i < 13; i++) {
			num[str[i] - '0']++;
		}

		for (i = 1; i < 10; i++) {
			if (num[i] == 4) {
				continue;
			}

			num[i]++;
			if (solve(num, 14) == 1) {
				if (flag == 1) {
					cout << " ";
				}
				cout << i;
				flag = 1;
			}
			num[i]--;
		}
		if (flag == 0) {
			cout << "0";
		}
		cout << endl;
		/*for (i = 1; i < 10; i++) {
			cout << endl << i << " : " << num[i] << endl;
		}*/
	}

	return 0;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n;
  cin>>n;
  vector<int>d(n);
  rep(i,n) cin>>d[i];
  int a=n/2;
  sort(d.begin(),d.end());
  int ans=0;
  if(d[a-1]==d[a]){
    cout<<ans<<endl;
    return 0;
  }
  else{
    ans=d[a]-d[a-1];
    cout<<ans<<endl;
    return 0;
  }
    
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const int mxN = 200005;
ll h, w, a, b, ans, f[mxN], inv[mxN];

ll binpow(ll a, ll b)
{
	if (b == 0)	return 1;
	if (b % 2 == 0) {
		ll temp = binpow(a, b/2) % mod;
		return (temp * temp) % mod;
	}
	else {
		return binpow(a, b-1)*a % mod;
	}
}

ll inverse(ll n) {
	return binpow(n, mod - 2);
}

void fact() {
	f[0] = inv[0] = 1;
	for(ll i = 1; i < mxN; i++)
	{
		f[i] = (f[i-1]*i)%mod;
		inv[i] = inverse(f[i]);
	}
}

ll calc(ll n, ll m) 
{
	return ((f[m]*inv[n]%mod)*inv[m-n])%mod;
}

signed main() {
	fact();
	cin >> h >> w >> a >> b;
	for(ll i = 0; i <= h - a; i++)
	{
		ans += (calc(i-1,i+b-2)%mod * calc(h - i,h - i + w - b - 1)) % mod;
		ans%=mod;
		// cout<<ans<<endl;	
	}
	cout << ans << endl;
}

Measured memory_bytes: 6768
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
  long N,K;
  cin>>N>>K;
  if(N==1){cout<<1<<endl;return 0;}
  long* A=(long*)malloc(sizeof(long)*N);
  long* dp=(long*)malloc(sizeof(long)*N);
  for(long i=0;i<N;i++){
    cin>>A[i];
    dp[i]=1;
  }
  for(int i=1;i<N;i++){
    bool up=false;
    bool down=false;
    for(int j=i-1;j>=0;j--){
      if(A[j]<=A[i] and A[i]-A[j]<=K){
        down=true;
        dp[i]=max(dp[i], dp[j]+1);
      }
      if(A[j]>=A[i] and A[j]-A[i]<=K){
        up=true;
        dp[i]=max(dp[i], dp[j]+1);
      }
      if(up and down){break;}
    }
  }
  long retval=0;
  for(long i=0;i<N;i++){
    retval=max(retval,dp[i]);
  }
  cout<<retval<<endl;
  return 0;
}


Measured memory_bytes: 7852
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<stack>
using namespace std;

void dfs(vector<vector<int> > &ed, int par, vector<bool> &vis){
    if( vis[par]) return;  vis[par]=1; //cout<<par<<" ";
    int len=ed[par].size();

    int ch;
    for(int i=0; i<len; i++){
        ch=ed[par][i];
        dfs(ed,ch,vis);
    }
    return;
}


int main(){
    int n,m; cin>>n>>m;
    vector<vector<int> > ed(n+1);

    int u,v,w;
    for(int i=0; i<m; i++){
        cin>>u>>v>>w;
        ed[u].push_back(v);
        ed[v].push_back(u);
    }

    vector<bool> vis(n+1); int ans=0;
    for(int i=1; i<=n; i++){
        if(!vis[i]){
            dfs(ed,i,vis);  ans++;
        }
    }
    cout<<ans<<endl;
}








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

int main()
{
  int N,x;
  int happy=0;
  cin>>N>>x;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++)
  {
    x-=a[i];
    if(x>=0) happy++;
    else break;
  }
  if(x>0) happy--;
  cout<<happy<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin)>(end)); i != (end)-((begin)>(end)); i += 1-2*((begin)>(end)))
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 101010
#define LOGN 20
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

int n, cnt[MAXN], ans;

int main(){
	scanf("%d", &n);
	rep(i,0,n){
		int v;
		scanf("%d", &v);
		if(v >= MAXN) ans++;
		else cnt[v]++;
	}
	rep(v,0,MAXN) if(cnt[v] < v) ans += cnt[v];
	else ans += cnt[v]-v;
	printf("%d\n", ans);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

#define MA 196471
#define BY 200
#define NY 195
#define SetY 590
#define BM 20 
#define SM 19
#define SetM 39

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

	rep(i,n){
		int Y,M,D;
		cin>>Y>>M>>D;
		int aY,aM,aD;
		aY = Y-1;
		aM = M-1;
		aD = D;
		int alive = 0;
		int maY;
		maY = aY%3;
		alive += D;//D
		alive += SetY*(aY/3);//Y
		alive += maY*NY;
		if(Y%3==0){//M
			alive+=BM*aM;
		}else{
			alive+=SetM*(aM/2);
			if(aM%2==1){
				alive+=BM;
			}
		}
		cout<<MA-alive<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    ll a[n];
    for (int i=0; i<n; i++) cin >> a[i];
    
    sort(a, a+n);

    ll A = a[n-1];
    ll B = a[0];
    double diff = (double)(A/2);
    for (int i=0; i<n; i++) {
        if (diff > abs(((double)A/2 - a[i]))) {
            B = a[i];
            diff = abs(((double)A/2 - a[i]));
        }
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    int H[N];
    rep(i,N) cin >> H[i];
    int ans=0;
    int s=0;
    while(s<N){
        int l=0;
        while(H[s]>=H[s+1] && s<N-1){
            s++;
            l++;
        }
        s++;
        if(ans<l) ans=l;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define MOD 10000
#define tam 301024
#define F first
#define pb push_back
#define mp make_pair
#define S second
#define INF 1E9 +7
#define ll long long 
#define offset tam/2
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define fore(i, b, e) forr(i,b,e)
using namespace std;
typedef pair<int,int> ii;
int dist[22][22][22][22];
int maxx=0;
int qy[]={1,0,-1,0};
int qx[]={0,1,0,-1};
int n,m;
string mapa[22];
bool valid(int y,int x)
{
    if (y<0|| x<0|| y>=n|| x>=m || mapa[y][x]=='#')
        return 0;
    return 1;
}
void bfs(int y,int x)
{
    dist[y][x][y][x]=0;
    queue<ii> cola;
    cola.push(mp(y,x));
    int yy,xx;
    while(!cola.empty())
    {
        ii par=cola.front();cola.pop();
        maxx=max(maxx,dist[y][x][par.F][par.S]);
        forr(i,0,4)
        {
            yy=par.F+qy[i];
            xx=par.S+qx[i];
            if (valid(yy,xx)==0)continue;
            if (dist[y][x][yy][xx]==-1)
                dist[y][x][yy][xx]=dist[y][x][par.F][par.S]+1,cola.push(mp(yy,xx));
        }
    }
}
int main()
{
    
    cin>>n>>m;
    forr(i,0,n)
    {
        cin>>mapa[i];
    }
    memset(dist,-1,sizeof dist);
    forr(i,0,n)
    {
        forr(j,0,m)
        {
            if (mapa[i][j]=='.')
                bfs(i,j);
        }
    }
    cout<<maxx<<endl;
}   

Measured memory_bytes: 1152
using System;
namespace program
{
    class test
    {
        static void Main()
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int n = int.Parse(str[0]);
                int x = int.Parse(str[1]);
                if (n == 0 && x == 0) break;
                int count = 0;
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1 + i; j <= n; j++)
                    {
                        for (int k = 1 + j; k <= n; k++)
                        {
                            if (i + j + k == x) count++;
                        }
                    }
                }
                Console.WriteLine(count);
            }
            return;
        }
    }
}

Measured memory_bytes: 9164
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A + B >= C ? "Yes": "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, d, x; cin >> n >> d >> x;
  int ans = 0;
  for(int i = 1; i <= n; i++){
  	int dt; cin >> dt;
	int j = -1;
    while((j+1) * dt + 1 <= d) j++;
    ans += j + 1;
  }
  cout << ans + x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		BigInteger ans = new BigInteger("1");
		final BigInteger TEN_EIGHTEEN = new BigInteger("1000000000000000000");
		final BigInteger ZERO = new BigInteger("0");
		final BigInteger OVER = new BigInteger("-1");
		String[] s = new String[N];
		Boolean flag_z = false;
		for (int i = 0; i < N; ++i) {
			s[i] = sc.next();
			if (s[i].equals("0")) {
				flag_z = true;
			}
		}
		if (flag_z) {
			ans = ZERO;
		} else {
			for (int i = 0; i < N; ++i) {
				BigInteger A = new BigInteger(s[i]);
				if (A.compareTo(ZERO) != 0) {
					if (ans.multiply(A).compareTo(TEN_EIGHTEEN) <= 0) {
						ans = ans.multiply(A);
					} else {
						ans = OVER;
						break;
					}
				} else {
					ans = ZERO;
					break;
				}
			}
		}
		// System.out.println(" "+ans.toString());
		sc.close();
		if (ans.compareTo(ZERO) == -1) {
			System.out.println("-1");
		}else{
			System.out.println(ans.toString());
		}
	}
}


Measured memory_bytes: 65536
n,m,c = map(int,input().split())
blist = list(map(int,input().split()))
cnt = 0
for _ in range(n):
    alist = list(map(int,input().split()))
    if sum([a*b for a,b in zip(alist,blist)]) + c > 0:
        cnt += 1

print(cnt)



Measured memory_bytes: 2940
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        double[] a = new double[n];
        for (int i=0; i < n; i++) {
            a[i] = (double) in.nextInt();
        }

        double ans = 0;
        for (int i=0; i < n; i++)
            ans += (1 / a[i]);

        out.println(1 / ans);
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define maxn 100000
using namespace std;
int n,k,a[maxn],s,dp[maxn],ans=0;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i) 
	  {
	  	scanf("%d",&a[i]);
		a[i]=min(k,a[i]),s+=a[i];
	  }
	sort(a+1,a+n+1),dp[0]=1;
	for (int i=n;i>=1;--i)
	  {
	  	bool flag=true;
	  	for (int j=k-1;j>=0&&j>=k-s;--j)
	  	  {
	  	  	if (dp[j])
	  	  	  {
	  	  	  	flag=false;
	  	  	  	break;
	  	  	  }
	  	  }
	  	s-=a[i];for (int j=k-a[i];j>=0;--j) if (dp[j]) dp[j+a[i]]=1;
	  	if (flag) ans++;
	  }
	return printf("%d",ans),0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/keyence2019/tasks/keyence2019_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N1,N2,N3,N4; cin>>N1>>N2>>N3>>N4;
    map<ll,ll> tbl;
    tbl[N1]++;
    tbl[N2]++;
    tbl[N3]++;
    tbl[N4]++;
    if (tbl.count(1)==1
    && tbl.count(9)==1
    && tbl.count(7)
    && tbl.count(4)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y)
{
    int res = 1;
    x = x % M;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % M;
        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
int main()
{
	IOS;
	string s1,s2;
	cin>>s1>>s2;
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	if(s==s1)
	a--;
	else if(s==s2)
	b--;
	cout<<a<<" "<<b;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;
ll k;

vector<int> graph[MAX_N];

ll ans;

ll dfs(int cur, int parent, bool root_parent) {
  ll remain = root_parent ? k - 1 : k - 2;

  int num_child = graph[cur].size();
  if (!root_parent) num_child -= 1;

  if (num_child > remain) {
    return 0;
  }

  ll ret = 1LL;

  for (int i = 0; i < num_child; ++i) {
    ret *= remain;
    ret %= MOD;
    remain -= 1LL;
  }

  for (auto e: graph[cur]) {
    if (e == parent) continue;

    ret *= dfs(e, cur, false);
    ret %= MOD;
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  ans = k * dfs(1, 0, true);
  ans %= MOD;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 10368
H, W = map(int,input().split())
G = ["."*(W+2)]
for k in range(H):
    G.append("."+input()+".")
G.append("."*(W+2))
for k in range(1,H+1):
    for l in range(1,W+1):
        if G[k][l] == "#":
            if G[k+1][l] == "." and G[k-1][l] == "." and G[k][l-1] == "." and G[k][l+1] == ".":
                print("No")
                exit(0)
print("Yes")


Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 4e5 + 20;
const int mod = 1e9 + 7;
const int inf = 2e9 + 7;

int n, k;
string s;
ll dp[10010][110];

ll get(string& s) {
	ll ans = 0;
	int cur = 0;
	for (int i = 0; i < sz(s); i++) {
		int z = s[i] - '0';
		for (int j = 1; j <= z; j++) {
			int sum = (cur + j - 1) % k;
			ans = (ans + dp[sz(s) - 1 - i][(k - sum) % k]) % mod;	
		}	
		cur = (cur + z) % k;
	}
	if (cur % k == 0) ans = (ans + 1) % mod;
	re ans;
}

int main() {
	cin >> s >> k;
	dp[0][0] = 1;
	for (int i = 1; i < 10010; i++)
		for (int j = 0; j < k; j++) 
			for (int p = 0; p < 10; p++)
				dp[i][j] = (dp[i][j] + dp[i - 1][(j - p + 10 * k) % k]) % mod;
	cout << (get(s) - 1 + mod) % mod;
}

Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }

int32_t main(){
	IOS;
	int n, k;
	cin >> n >> k;
	int sum = 0, ans = 1;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		sum += x;
		if(sum <= k)
			ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S = input()
if S[0] == "A":
    if "C" in S[2:-1] and S[2:-1].find("C") == S[2:-1].rfind("C"):
        S = S.replace("A","a",1)
        S = S.replace("C","c",1)
        if S == S.lower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#include <stdio.h>
#include <limits.h>
 
int main()
{
  long int nn, kk, min = LONG_MAX;
  scanf("%ld %ld", &nn, &kk);
  long int old_nn = nn;
  if(nn > kk)
    nn = kk + (nn % kk);
  while(nn < min)
  {
    old_nn = nn;
    min = nn;
    if(nn > kk)
      nn = nn -kk;
    else if(kk > nn)
      nn = kk -nn;
    else
    {
      old_nn = 0;
      break;
    }
  }
  printf("%ld\n", old_nn);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
    #include<string.h>
    int main(void){
    int A,B,C,D,E,N,M,x,y,i,j,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
        char S[100][100],W[100],s[10],X,Y;
    scanf("%d",&A);
    for(i=0;i<A;i++){
        scanf("%d",&v[i]);
    }
    min_i=0;
    for(i=1;i<A;i++){
        if(v[i]>v[min_i]){
            min_i=i;
        }
    }
    v[min_i]=v[min_i]/2;
    for(i=0;i<A;i++){
        cou+=v[i];
    }
    printf("%d",cou);
    return 0;
    }

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int islandCnt = sc.nextInt(); // N
        int bridgeCnt = sc.nextInt(); // M
        int[] startIsland = new int[bridgeCnt]; // A[i]
        int[] endIsland = new int[bridgeCnt]; // B[i]
        for (int i = 0; i < bridgeCnt; i++) {
            startIsland[i] = sc.nextInt();
            endIsland[i] = sc.nextInt();
            // 島をプログラミングの慣習に合わせて「0～N-1」で扱いたいので、ここで引いておく。
            startIsland[i]--;
            endIsland[i]--;
        }

        long[] answers = new long[bridgeCnt];
        IslandManager islandMgr = new IslandManager(islandCnt);
        //answers[bridgeCnt - 1] = islandMgr.getAns();
        for (int i = bridgeCnt - 1 ; i >= 0; i--) {
            answers[i] = islandMgr.getAns();
            islandMgr.mergeIslands(startIsland[i], endIsland[i]);
        }

        for (int i = 0; i < bridgeCnt; i++) {
            System.out.println(answers[i]);
        }
    }

    // 各島の「親の島番号」と「島群のサイズ」を管理する。
    private class IslandManager {
        int[] parent;
        int[] size;
        long ans; // 不便さ

        IslandManager(int num) {
            parent = new int[num];
            size = new int[num];
            for (int i = 0; i < num; i++) {
                parent[i] = i;
                size[i] = 1;
            }
            ans = (long) num * (num - 1) / 2;
        }

        // 一番上位の親の島番号を返す。
        private int findRoot(int islandNum) {
            if (parent[islandNum] == islandNum) {
                return islandNum;
            }
            else {
                // 他の人の回答では、ここが
                // parent[islandNum] = findParent(parent[islandNum]);
                // となっており、親の値の代入も同時に行っているが、こんなの無理、、、なので、別箇所で行う。
                int rootNum = findRoot(parent[islandNum]);
                return rootNum;
                //return parent[islandNum] = findRoot(parent[islandNum]);
            }
        }
        void mergeIslands(int islandNumX, int islandNumY) {
            int rootX = findRoot(islandNumX);
            int rootY = findRoot(islandNumY);
            // 同じルートを持っている島はマージする必要がないので、何もしない。
            if (rootX == rootY) return;

            // 違うルートを持つ島なので、マージ処理する。その際、ansも更新する。
            // マージすると、以下の分だけ不便さ(ans)が減る。
            ans -= (long) size[rootX] * size[rootY];

            if (size[rootX] < size[rootY]) {
                parent[rootX] = rootY;
                size[rootY] += size[rootX];
            }
            else {
                parent[rootY] = rootX;
                size[rootX] += size[rootY];
            }
        }
        long getAns() {
            return ans;
        }


        private boolean hasSameRoot(int islandNumX, int islandNumY) {
            return findRoot(islandNumX) == findRoot(islandNumY);
        }

    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

}


Measured memory_bytes: 73416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;

ll modnum = 1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    string a,b; cin >> a >> b;
    string tmp = a+b;
    int num = stoi(tmp);
    int i=1;
    while(true) {
        if(i*i == num) {
            cout << "Yes" << endl;
            return 0;
        }
        if(i*i > num) {
            break;
        }
        i++;
    }

    cout << "No" << endl;

}


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

using namespace std;
#define long long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n;
long f[N][2];
vector<int> g[N];

void Dfs(int k, int par)
{
    f[k][0] = f[k][1] = 1;
    for (int node : g[k]) if (node != par) {
        Dfs(node, k);
        (f[k][0] *= f[node][0] + f[node][1]) %= MOD;
        (f[k][1] *= f[node][0]) %= MOD;
    }
}

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1, x, y; i < n; ++i) cin >> x >> y, g[x].push_back(y), g[y].push_back(x);
    Dfs(1, 0);
    cout << (f[1][0] + f[1][1]) % MOD;

    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>

using namespace std;

const int MOD = 1000003;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return a.n == 0 || b.n == 0 ? 0 : (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(n); return I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

mint modinv(mint n) {
  int a = n.n;
  int b = MOD;
  int s = 1;
  int t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  if (s < 0) s += MOD;
  return s;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int Q;
  cin >> Q;
  while (Q--) {
    mint a, d;
    int n;
    cin >> a.n >> d.n >> n;
    if (d.n == 0) {
      cout << modpow(a, n) << '\n';
      continue;
    } //else if (a.n == 0) {
      //cout << 0 << '\n';
      //continue;
   // }
    mint ans = modpow(d, n);
    mint x = a * modinv(d);
    if (x.n + n - 1 >= MOD) {
      cout << 0 << '\n';
    } else {
      ans *= F(x.n + n - 1) * R(x.n - 1);
      cout << ans.n << '\n';
    }
  }
}


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

public class Main {

    private static final int M = 1_000_000_007;

    public Main(FastScanner in, PrintWriter out, int test) {
        long N = in.nextLong();
        long n = N;
        int x = 0;
        while (n % 2 == 0) {
            x++;
            n /= 2;
        }
        int res = count(x);

        for (int d = 3; d <= N / d; d += 2) {
            x = 0;
            while (n % d == 0) {
                x++;
                n /= d;
            }
            res += count(x);
        }

        if (n > 1)
            res++;

        out.println(res);
    }

    private int count(int x) {
        int i = 1, sum = 0, res = 0;
        while (i + sum <= x) {
            sum += i;
            i++;
            res++;
        }
        return res;
    }

    private long pow(int x, int p) {
        long res = 1, a = x;
        while (p > 1) {
            if (p % 2 == 1)
                res = res * a % M;

            a = a * a % M;
            p /= 2;
        }
        res  = res * a % M;
        return res;
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 32740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
void solve(){
    map<int,int> mp;
    int n,q,a,b,c,tot;
    ll sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
        sum+=a;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        tot=mp[b];
        mp[b]=0;
        mp[c]+=tot;
        sum+=(c-b)*tot;
        cout<<sum<<endl;
    }
    return;
}
int main(){
    //IO FO
    //TEST
    solve();

    return(0);
}


Measured memory_bytes: 8088
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int n;

int solve(const string &s, int b, int g, int now, bool f) {
  if (b == 0 || g == 0) {
    return b;
  }
  int m = s.size();
  int res = 0;
  if (!f) {                     // 0-origin
    int p = (now + n) % m;
    string t = s.substr(0,p);
    if (p<m-1) t += s.substr(p+1);
    int tb = b, tg = g;
    if (s[p] == 'B') tb--; else tg--;
    res = max(res, solve(t,tb,tg,p,1));
  }
  // 1-origin
  int p = (now + n - 1) % m;
  string t = s.substr(0,p);
  if (p<m-1) t += s.substr(p+1);
  if (s[p] == 'B') b--; else g--;
  res = max(res, solve(t,b,g,p,f));
  return res;
}
int main() {
  int T;
  cin >> T;
  while(T--) {
    cin >> n;
    string s;
    cin >> s;
    int b = 0, g = 0; 
    REP(i,s.size()) {
      if (s[i] == 'B') b++;
      else g++;
    }
    cout << solve(s, b, g, 0, 0) << endl;
  }
}

Measured memory_bytes: 972
#include <stdio.h>

int is_prime(int);

int main(){
  int N,a,i,count = 0;

  scanf("%d" ,&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d" ,&a);
    if(is_prime(a)){
      count++;
    }
  }
  printf("%d\n" ,count);

  return 0;
}

int is_prime(int a){
  int i;

  for(i = 2 ; i*i <= a ; i++){
    if(a % i == 0){
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x);
        x=(x*x);
        y=y/2;
    }
    return res;
}
int main()
{
    ll n,p,k;
    cin>>n>>k;
    vector<ll>v,dp(n+1);
    dp[0]=0;//if one stone then cost incurred=0
    for(ll i=0;i<n;i++)
    {
        cin>>p;
        v.pb(p);
    }
    dp[1]=abs(v[0]-v[1]);
    for(ll i=2;i<n;i++)
    {
        ll ans=INT_MAX;
        for(ll j=1;j<=k&&i-j>=0;j++)//here at one time max k stones can be jumped so all k ways are found
            ans=min(ans,dp[i-j]+abs(v[i]-v[i-j]));
        dp[i]=ans;
    }
    cout<<dp[n-1];
}

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

int main() {
	int n,k;
	cin>>n>>k;
	long long int a[200004];
	a[0]=0;
	for(int i=1;i<200004;i++)
	a[i]=i+a[i-1];
	long long s=0;
	for(int i=k;i<=n+1;i++){
	    if(i==n+1)
	    s=(s+1)%1000000007;
	    else{
	    long long int m1=0,m2=0;
	    m1=a[i-1];
	    m2=a[n]-a[n-i];
	    s=(s+m2-m1+1)%1000000007;}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 5200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int n = Integer.parseInt(r.readLine());
    if(n == 1)
    {
      System.out.println("Hello World");
    }
    else
    {
      int x = Integer.parseInt(r.readLine());
      int y = Integer.parseInt(r.readLine());
      System.out.println(x + y);
    }
  }

}

Measured memory_bytes: 22356
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	double ans=0;
	double v[55];
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
  sort(v, v+n);
	ans=(v[0]+v[1])/2.0;
	for(int i=2; i<n; i++){
		ans=(ans+v[i])/2.0;
	}
	printf("%.6lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    string s;
    stack <ll> st;

    while(cin>>s){
        if(s[0]<'0'){
            ll a,b;
            a=st.top();
            st.pop();
            b=st.top();
            st.pop();

            if(s[0]=='+') st.push(a+b);
            else if(s[0]=='-') st.push(b-a);
            else if(s[0]=='*') st.push(a*b);
            else st.push(b/a);
        }
        else st.push(intConvert(s));
    }
    pf("%lld\n",st.top());

    return 0;
}



Measured memory_bytes: 3300
a = []
check = []
for i in range(3):
    a.append([int(j) for j in input().split()])

d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[1][0], a[2][0]]
col2 = [a[0][1],a[1][1], a[2][1]]
col3 = [a[0][2],a[1][2], a[2][2]]

n = input()
n = int(n)
for i in range(n):
    check.append(int(input()))

if all(elem in check for elem in d1):
    print("Yes")
elif all(elem in check for elem in d2):
    print("Yes")
elif all(elem in check for elem in col1):
    print("Yes")
elif all(elem in check for elem in col2):
    print("Yes")
elif all(elem in check for elem in col3):
    print("Yes")
elif all(elem in check for elem in a[0]):
    print("Yes")
elif all(elem in check for elem in a[1]):
    print("Yes")
elif all(elem in check for elem in a[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

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

    int n, K, l = 0;
    string s;
    cin >> n >> K >> s;
    vector<pii> block;
    for (int i = 0; i < n; ++i) {
        if (i > 0 && s[i] != s[i-1]) { // block ended
            block.push_back({s[i-1]-'0', i-l});
            l = i;
        }
    }
    block.push_back({s[n-1]-'0', n-l});

    l = 0;
    int ans = 0, curr = 0, r = 0;
    while (l < block.size()) {
        if (r < block.size() && (block[r].first == 1 || K > 0)) {
            curr += block[r].second;
            K -= block[r].first == 0;
            ++r;
        } else {
            curr -= block[l].second;
            K += block[l].first == 0;
            ++l;
        }
        ans = max(ans, curr);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
	return 0;
}


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

const int K = 10005;
const int MAX = 2000005;
int B[MAX], C[K];

void countingSort(int A[], int n) {
  for (int i = 0; i < K; i++) {
    C[i] = 0;
  }
  
  for (int i = 0; i < n; i++) {
    C[A[i]]++;
  }

  for (int i = 0; i < K - 1; i++) {
    C[i+1] += C[i];
  }

  for (int i = 0; i < n; i++) {
    B[C[A[i]] - 1] = A[i];
    C[A[i]]--;
  }
}

int main() {
  int n, A[MAX];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  countingSort(A, n);
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << B[i];
  }
  cout << endl;
}



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

typedef pair <int, int> pii;

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;

int N;
int l[MAXN], r[MAXN];
pii lft[MAXN], rig[MAXN];

inline int len(int x, int y) {
	return max(y - x + 1, 0);
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d%d", l + i, r + i);
	
	if (N == 1) {
		printf("%d\n", len(l[0], r[0]));
		return 0;
	}
	
	multiset <int> L, R;
	for (int i = 0; i < N; i++) {
		lft[i] = {l[i], i};
		rig[i] = {r[i], i};
		L.insert(l[i]);
		R.insert(r[i]);
	}
	
	sort(lft, lft + N);
	sort(rig, rig + N);
	
	int ans = 0;
	int maks = -INF, mini = INF;
	for (int i = N - 1; i >= 0; i--) {
		if (mini < INF)
			ans = max(ans, len(lft[i].first, rig[0].first) + len(maks, mini));
		maks = max(maks, l[lft[i].second]);
		mini = min(mini, r[lft[i].second]);
	}
	
	maks = -INF, mini = INF;
	for (int i = 0; i < N; i++) {
		if (mini < INF)
			ans = max(ans, len(lft[N - 1].first, rig[i].first) + len(maks, mini));
		maks = max(maks, l[rig[i].second]);
		mini = min(mini, r[rig[i].second]);
	}
	
	for (int i = 0; i < N; i++) {
		L.erase(L.find(l[i]));
		R.erase(R.find(r[i]));
		ans = max(ans, len(l[i], r[i]) + len(*L.rbegin(), *R.begin()));
		L.insert(l[i]);
		R.insert(r[i]);
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
const ll inf = (1ll<<60);

int n, q, a, b;

ll dp[200010];
int x[200010];

struct SEG {
	const static int M = 262144;
	ll tree[M<<1];
	SEG(){ for(ll& x:tree) x=inf; }
	void upd(int p, ll v){
		p += M; while(p) tree[p]=min(tree[p], v), p>>=1;
	}
	ll rmin(int l, int r){
		ll ret=inf;
		l+=M; r+=M;
		while(l<=r){
			if(l&1) ret=min(ret, tree[l++]);
			if(r%2==0) ret=min(ret, tree[r--]);
			l>>=1; r>>=1;
		}
		return ret;
	}
} sL, sR;

void in(){
	read(n, q, x[0], x[1]);
	for(int i=1; i<=q; ++i) read(x[i+1]);
}

ll ps[200010];

void build(){
	for(int i=1; i<=q+1; ++i) ps[i] = ps[i-1] + abs(x[i]-x[i-1]);
	for(int i=1; i<=q+1; ++i){
		if(i!=1) dp[i] = ps[i-1] + min(
			sL.rmin(1, x[i]) + x[i],
			sR.rmin(x[i], n) - x[i]
		);
		sL.upd(x[i-1], dp[i] - ps[i] - x[i-1]);
		sR.upd(x[i-1], dp[i] - ps[i] + x[i-1]);
	}
}

int main()
{
	in();
	build();
	ll ans = inf;
	for(int i=1; i<=q+1; ++i) ans = min(ans, dp[i] + ps[q+1] - ps[i]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 12288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129A
{
    class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine()
                    .Split(' ').Select(x => int.Parse(x))
                    .ToArray();
            var p = new List<int>() { n[0]+n[1], n[1]+n[2], n[2]+n[0] };
            Console.WriteLine(p.Min());
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include<cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int n,a[100],sum=0;
	while(scanf("%d",&n)!=EOF)
	{
	    for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        int k=sum/n;
        int p=k+1;
        int b=0,c=0;
        for(int i=0;i<n;i++)
        {
            b+=(k-a[i])*(k-a[i]);
            c+=(p-a[i])*(p-a[i]);
        }
        if(b<c)printf("%d\n",b);
        else printf("%d\n",c);
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back


char c;
string str;
int pos;

map<int,int> tree;

void dfs(int th){
  tree[th]++;
  if(str[pos+1]=='('){
    ++pos;
    dfs(th*2+1);
  }
  if(str[pos+1]==','){
    ++pos;
  }
  if(str[pos+1]=='('){
    ++pos;
    dfs(th*2+2);
  }
  ++pos;
}

void parse(int th){
  if((c=='i' && tree[th]==2) || (c=='u' && tree[th])){
    cout<<'(';
    parse(th*2+1);
    cout<<',';
    parse(th*2+2);
    cout<<')';
  }
}

main(){
  while(cin>>c){
    tree.clear();
    pos=0;
    cin>>str;
    dfs(0);
    pos=0;
    cin>>str;
    dfs(0);
    parse(0);
    cout<<endl;
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] abc = Console.ReadLine().Split();
            int[] list = {0,0,0};
            int max = 0;
            int max_index = 0;

            for (var i = 0; i < abc.Length; i++)
            {
                list[i] = int.Parse(abc[i]);
            }
            for (var i = 0; i < list.Length;i++)
            {
                if(list[i]>max)
                {
                    max = list[i];
                    max_index = i;
                }
            }
            list[max_index] = list[0];
            list[0] = max;
            Console.WriteLine(list[0] * 10 + list[1] + list[2]);
        }
    }
}


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

int main(void)
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b || b == c || c == a) {
		if (a == b && b == c) {
			cout << 1 << endl;
		}
		else {
			cout << 2 << endl;
		}
	}
	else {
		cout << 3 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()




int main() {
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256