akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);
uniform_int_distribution<> DD(0, 1000000000);

ll random(ll r){
    return (ll(DD(eng))*1000000000 + ll(DD(eng)))%r;
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

ll upp(ll i, ll j){
    if(j == 0)return 1;
    ll h = upp(i,j/2);
    if(j%2 == 0){
        return (h*h)%big;
    }
    return (i*((h*h)%big))%big;
}
const ll MAXN = 600004;
ll FAC[MAXN] = {0};
ll INV[MAXN] = {0};

void setup(){
    ll t = 1;
    for(int c1 = 0; c1 < MAXN; c1++){
        FAC[c1] = t;
        t *= c1+1;
        t %= big;
    }

    INV[MAXN-1] = upp(FAC[MAXN-1],big-2);

    for(int c1 = MAXN-2; c1 >= 0; c1--){
        INV[c1] = (INV[c1+1]*(c1+1))%big;
    }

}

ll bin(ll i, ll j){
    if(i < j ||i < 0 || j < 0)return 0;
    ll tal = FAC[i];
    ll nam = (INV[j]*INV[i-j])%big;
    return (tal*nam)%big;
}

ll i100;

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d;
    setup();
    i100 = upp(100, big-2);
    cin >> n >> a >> b >> c;
    a *= i100;
    b *= i100;
    a %= big;
    b %= big;
    c *= i100;
    c %= big;
    ll ic = upp(big+1-c, big-2);
    ll ans = 0;

    a *= ic;
    b *= ic;
    a %= big;
    b %= big;

    for(ll c1 = n; c1 < 2*n; c1++){
        ll temp = upp(a,n)*upp(b,c1-n) + upp(b,n)*upp(a,c1-n);
        temp %= big;
        temp *= bin(c1-1,c1-n);
        temp %= big;
        temp *= (c1*ic)%big;
        temp %= big;
    //    temp *= upp(ic, c1);
    //    temp %= big;
        ans += temp;
        ans %= big;
    }
   // ans *= ic;
    ans %= big;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

double choose(int n, int k){
  double res = 1.;
  for(int i=0;i<k;++i)
	res *= (n - i) * 1. / (k - i);
  return res;
}

double bin(double p, int M, int x, int T){
  double res = 0.;
  for(int i=0;i<=M;++i)
	res += choose(M,i) * pow(p,i) * pow(1-p,M-i) * i * T;
  return res;
}

int main(){
  int N, M, L; cin >> N >> M >> L;
  vector<int> P(N), T(N), V(N);
  for(int i=0;i<N;++i){
	cin >> P[i] >> T[i] >> V[i];
  }

  double S[110][100], prob[110][100];
  vector<double> ans(N,0);
  for(int i=0;i<N;++i){
	for(int j=0;j<=M;++j){
	  prob[i][j] = choose(M,j) * pow(P[i]/100.,j) * pow((100-P[i])/100.,M-j);
	  S[i][j] = L *1./V[i] + j*T[i];
	}
  }

  for(int i=0;i<N;++i)
	for(int j=0;j<=M;++j){
	  double p = 1.;
	  for(int i1=0;i1<N;++i1){
		if(i == i1) continue;
		double q = 0.;
		for(int j1=0;j1<=M;++j1){
		  if(S[i1][j1] > S[i][j])
			q += prob[i1][j1];
		}
		p *= q;
	  }
	  ans[i] += p * prob[i][j];
	}
  for(int i=0;i<N;++i)
	cout << fixed << setprecision(9) << ans[i] << endl;
  

  return 0;
}

Measured memory_bytes: 1512
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
bool used[13][13]={};
char field[13][13];
typedef pair<int,int> P;
bool in(int x,int y){
	if(x>=0 && x<12 && y>=0 && y<12){
		return true;
	}
	return false;
}
int main(){
	while(scanf("%s",field[0])!=EOF){
		for(int i=1;i<12;i++){
			scanf("%s",field[i]);
		}
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(field[i][j]=='1'){
					used[i][j]=false;
				}else{
					used[i][j]=true;
				}
			}
		}
		int ans=0;
		queue<P>que;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(!used[i][j]){
					ans++;
					que.push(make_pair(i,j));
					while(!que.empty()){
						P p=que.front();
						que.pop();
						int dx[4]={0,1,0,-1};
						int dy[4]={1,0,-1,0};
						for(int k=0;k<4;k++){
							if(in(p.first+dx[k],p.second+dy[k])){
								if(!used[p.first+dx[k]][p.second+dy[k]]){
									used[p.first+dx[k]][p.second+dy[k]]=true;
									que.push(make_pair(p.first+dx[k],p.second+dy[k]));
								}
							}
						}
					}
				}
			}
		}
		printf("%d\n",ans);
 	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    int ans = 0;

    priority_queue<p, vector<p>, greater<p>> pq;
    REP(i, n)
    {
        int tmp = 0;
        cin >> tmp;

        pq.push(make_pair(tmp, i + 1));
    }

    REP(i, n - 1){
        ans = pq.top().second;
        pq.pop();
        cout << ans << " ";
    }
    ans = pq.top().second;
    cout << ans << endl;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define hell 1000000007
using namespace std;
void solve( ll n)
{
  ll m,i,j,k,c=0,y=0,ans=0,a,b;
  string s;
  cin>>n;
  if(n>=30) cout<<"Yes";
  else cout<<"No";
  //cout<<ans;


}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve(t);
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)



ll n;vector<ll> v;
ll dp[3009][3009];
ll fun(int a,int b){
	ll &ref = dp[a][b];
	if(ref!=-1)
		return ref;
	ref = max(v[a]-fun(a+1,b),v[b]-fun(a,b-1));
	return ref;
}
int main(){
	fast;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	ll sum=0;
	for(ll i=0;i<n;++i){
		ll c;cin>>c;v.push_back(c);	
		sum +=c;
		dp[i][i] = c;
	}
	/*for(int i=0;i<n-1;++i){
		dp[i][i+1] = abs(arr[i]-arr[i+1]);
	}*/
	cout<<fun(0,n-1);
	
	return 0;
}


Measured memory_bytes: 71296
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N, M = LI()

AB = []
for i in range(N):
    a,b = LI()
    AB.append([a, b])



# ただ安い店から買い叩いていくだけの話
AB = sorted(AB, key=lambda x:x[0])
#  print(AB)


count = 0
idx = 0
cost = 0
while count < M:
    #  print('idx', idx)
    if AB[idx][1] > M - count:
        # この店で終わりの場合
        cost += (M-count)*AB[idx][0]
        count = M
        break
    else:
        # 全部買う
        cost += AB[idx][0] * AB[idx][1]
        count += AB[idx][1]
    idx += 1

print(cost)


Measured memory_bytes: 24508
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <sstream>
#include <string>
using namespace std;

typedef long long ll;

struct ap
{
	char c;
	int v;
};

bool cmp(ap a1, ap a2)
{
	return a1.v < a2.v;
}

int main()
{
	int x, y, a, b, c;
	ll sum = 0;
	cin >> x >> y >> a >> b >> c;
	vector <ap> aps(a + b + c);
	
	for (int i = 0; i < a; ++i)
	{
		cin >> aps[i].v;
		aps[i].c = 'r';
	}
	for (int i = a; i < a + b; ++i)
	{
		cin >> aps[i].v;
		aps[i].c = 'g';
	}
	for (int i = a + b; i < a + b + c; ++i)
	{
		cin >> aps[i].v;
		aps[i].c = 'c';
	}


	sort(aps.begin(), aps.end(), cmp);
	int n = x + y;
	while (n)
	{
		ap app = aps.back();
		if (app.c == 'c')
		{
			sum += app.v;
			n--;
		}
		else if (app.c == 'r' && x)
		{
			sum += app.v;
			n--; x--;
		}
		else if (app.c == 'g' && y)
		{
			sum += app.v;
			n--; y--;
		}
		aps.pop_back();
	}
	cout << sum << endl;


}


Measured memory_bytes: 2688
#include <stdio.h>

int main(void){
	long i, j, k, n, m, l,s, a[100][100], b[100][100];
	scanf("%ld""%ld""%ld", &n, &m, &l);

	//行列A
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%ld", &a[i][j]);
		}
	}

	//行列B
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%ld", &b[i][j]);
		}
	}

	//行列C
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			s = 0;
			for (k = 0; k < m; k++)
			{
				s = s + (a[i][k] * b[k][j]);
			}

			printf("%ld", s);

			if (j + 1 == l)
			{
				printf("\n");
			}
			else
			{
				printf(" ");
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2108
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
import math
a, b = LI()

# a は電源タップの口数
# b　は欲しい口数>
# 何個電源タップが必要ですか？
# ただしもとから一つの差し込み口がある。

kuchi = 1
ans = 0

while kuchi < b:
    kuchi += -1 + a
    ans += 1
print(ans)

Measured memory_bytes: 9084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

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

int main(){
    int n;
    while(cin >> n,n){
        vector<int> a(n);
        int sum = 0;
        for(int i=0;i<n;i++){
            cin >> a[i];
            sum += a[i];
        }
        int ans = 0;
        for(int i=0;i<n;i++){
            if(n*a[i]<=sum) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main()
{
    int n,a,b;
    while(scanf("%d%d%d",&n,&a,&b)!=EOF)
    {
        if(a>b)
        {
            swap(a,b);
        }
        int a_b=b-a-1;
        //printf("%d\n",a_b);
        if(a_b%2==1)
            printf("Alice\n");
        else
            printf("Borys\n");
    }
    return 0;
}


Measured memory_bytes: 256
class HitBlow
  def check(a, b)
    hits = [a, b].transpose.select { |x, y| x == y }.flatten.uniq
    blows = a & b - hits
    [hits.size, blows.size]
  end
end

inputs = STDIN.read.split("\n")

inputs.each_slice(2) do |a, b|
  result = HitBlow.new.check(a.split.map(&:to_i), b.split.map(&:to_i))
  printf "%s %s\n", result[0], result[1]
end

Measured memory_bytes: 8540
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 10;
   const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 179;
   const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(3) << (double)r * (double)2.0 * (double)3.141;
}
/*

*/


Measured memory_bytes: 3804
n,m = map(int,input().split())
if n==1 and m==0:
    print(0)
    exit()
S = []
C = []
for i in range(m):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)

flg = True
res = [10]*n

for i in range(m):
    s,c = S[i], C[i]
    if res[s-1]!=10 and res[s-1]!=c:
        flg=False
        break
    elif res[s-1]==10:
        res[s-1] = c
        
if not flg:
    print(-1)
else:
    ans = ''
    for i in range(n):
        if i==0 and res[i]==10:
            ans += '1'
        elif i==0:
            ans += str(res[i])
        elif res[i]==10:
            ans += '0'
        else:
            ans += str(res[i])
    if n==1:
        print(ans)
    else:
        if ans=='0'*n:
            print(-1)
        else:
            print(ans)

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

using namespace std;

typedef long long ll;

int main()
{
	string s;
	cin >> s;

	int cur = 0;
	for(int i = 0; i < s.size(); i++)
		cur = (cur + (s[i] - '0')) % 9;

	if(!cur)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>; 



int main(){
  int n; cin>>n;
  queue<int> a;
  bool cannot = true;
  rep(i,n){
      int b; cin>>b;
      if(b == 1) cannot = false;
      a.push(b);   
  }
  if(cannot){
      cout<<-1<<endl;
      return 0;
  }
  int ans = 0;
  int i = 1;
  while(!a.empty()){
      if(a.front() == i) i++;
      else ans++;
      a.pop();
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
from collections import Counter
h,w,n = map(int,input().split())
need = []
append = need.append
for i in range(n):
    a,b = map(int,input().split())
    for x in range(-2,1):
        for y in range(-2,1):
            s = a + x
            t = b + y
            if 1 <= s <= h-2 and 1 <= t <= w-2:
                append(s*10**9 + t)

data = Counter(need).most_common()
ans = [0 for i in range(10)]
for x,y in data:
    ans[y] += 1

print((h-2)*(w-2)-sum(ans))
for i in ans[1:]:
    print(i)

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

int count(int n,vector<int> &a)
{
  int i;
  vector<int>dp(n);
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  if(n>1)
  {
    for(i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
   return dp[n-1];                       
}
int main()
{
  int n,k,i;
  cin>>n;
  vector<int>a(n);
  for(i=0;i<n;i++)
    cin>>a[i];
  k=count(n,a);
  cout<<k<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int N,K;
	cin>>N>>K;
	int i,j,k;
	long long int A[N];
	for(i=0;i<N;i++)
	{
		cin>>A[i];
	}
	for(i=K;i<N;i++)
	{
		if(A[i]>A[i-K])
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = n; i > 0; i--){
        string tmp = to_string(i);
        if (tmp.size()%2 == 1) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;
ll h,w;
ll ok(ll y, ll x){
    if(0<=y && y<h && 0<=x && x<w){
        return 1;
    }
    return 0;
}

int main(void){
    // char ;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    char s[h][w];
    rep(i,0,h){
        scanf("%s",s[i]);
    }
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    ll mk;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#'){
                mk=0;
                rep(k,0,4){
                    // if( ok(i+dy[k],j+dx[k]) ){
                    //     // printf()
                        if(s[i+dy[k]][j+dx[k]] == '#' ){
                            mk=1;
                            break;
                        }
                    // }
                }
                if(mk==0){
                    // printf("%lld %lld",i,j);
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
N,M = map(int,input().split())

A = [[] for i in range(N)]

for i in range(N):
    A[i] = list(map(int,input().split()))

B = [[0]*1 for i in range(M)]

for i in range(M):
    B[i] = int(input())


for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print(tmp)


Measured memory_bytes: 6024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

string s[100];

int main(){
	int n, l;
	
	cin >> n >> l;
	
	REP(i,n) cin >> s[i];
	
	sort(s,s+n);
	
	REP(i,n) cout << s[i];
	
	puts("");
	
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll R, ll mod){
  ll ans = 1; R = min(R, N - R);
  for (ll i = 1; i <= R; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}


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

  ll DP[S.length()][2];
  DP[0][0] = S[0] - '0'; DP[0][1] = 10 - (S[0] - '0');

  for (int i = 1; i < S.length(); i++){
    int num = S[i] - '0';

    DP[i][0] = min(DP[i - 1][0] + num, DP[i - 1][1] + 1 + num);
    DP[i][1] = min(DP[i - 1][0] + 10 - num, DP[i - 1][1] + 9 - num);
  }
  
  int ans = min(DP[S.length() - 1][0], DP[S.length() - 1][1] + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 17028
#include <iostream>
#include <cstdio>
#include<math.h>
#include <cstring>
#include <algorithm>
using namespace std;


int main()
{	int x,a,b,c;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	int num=0;
	for(int i=0;i<=a&&i*500<=x;i++)
	for(int j=0;j<=b&&j*100<=x;j++)
	for(int k=0;k<=c&&k*50<=x;k++)
	{
		if(i*500+j*100+k*50==x) num++;
		else if(i*500+j*100+k*50>x) break;
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a,b,a1=0;
    scanf("%d %d",&a,&b);
    for(i=1;i<=999;i++)
    {
        a1=a1+i;
        if(a1>a)
        {
            if(a1-a==a1+i+1-b)
            {
                printf("%d\n",a1-a);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
class Main
{
	static int gcd( int a, int b )
	{
		if( a%b==0 )return b;
		return gcd( b, a%b );
	}
	public static void main( String[] args )
	{
		Scanner sc = new java.util.Scanner( System.in );
		
		System.out.println( gcd(sc.nextInt(),sc.nextInt()) );
		
		return;
	}
}

Measured memory_bytes: 26092
CHARACTER(150) JOGE
CHARACTER(150) BUTSUGIRI_PICTURE
INTEGER H,W
READ*,H,W

JOGE=""
DO I=1,W+2
  JOGE=TRIM(JOGE)//"#"
END DO

PRINT"(A)",TRIM(JOGE)
DO I=1,H
  READ*,BUTSUGIRI_PICTURE
  PRINT"(A)","#"//TRIM(BUTSUGIRI_PICTURE)//"#"
END DO
PRINT"(A)",TRIM(JOGE)
END

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
    vector<int> a;
    char bb[10][10];
    int cnt = 0;
    char b[3];
    void pos(int x){
    if(x == 3){

        for(int j = 0 ; j < 3 ;j ++)
            bb[cnt][j] = b[j];
            cnt++;
        return;
    }
    b[x] ='+';
    pos(x+1);
    b[x] ='-';
    pos(x+1);


    }
    main(){
    int n;
    cin >> n;
    pos(0);

    int x = 0;
    while(1){
            x = n % 10;
            a.push_back(x);
            n /= 10;
            if(a.size() == 4)break;

    }
    reverse(a.begin(),a.end());

    int pos1,pos2;
    pos1 = pos2 = 0;
    for(int i= 0 ; i <cnt;i++){
        for(int j = 0 ; j < a.size();j++){
            int suma = 0;
            suma = a[j];
            pos1 = i;
            for(int k = 0 ; k < 3 ;k++){

                if(bb[i][k]=='+')suma += a[k+1];
                if(bb[i][k]=='-')suma -= a[k+1];
            }
            if(suma == 7){pos2 = i;break;}
            break;
        }
        if(pos2)break;
    }




    string s="";
    for(int i = pos2;i <=pos2;i++){
        for(int j = 0 ; j < a.size();j++){
            //cout << a[j]<<bb[i][j];
            s +=(char)(a[j]+48);
            s += bb[i][j];

        }

    }

    s= s.substr(0,7);
    s +="=7";
    cout << s;





    }


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

using namespace std;

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

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

#endif

void solve() {
    ll H, W, M;
    cin >> H >> W >> M;
    map<ll, ll> row, col;
    vector<P> items(M);
    set<P> used;
    rep(i, M) cin >> items[i].first >> items[i].second;
    rep(i, M) {
        P p = items[i];
        row[p.first]++;
        col[p.second]++;
        used.insert(p);
    }
    ll m = 0;
    rep2(i, 1, W + 1) {
        m = max(m, col[i]);
    }
    ll m2 = 0;
    rep2(i, 1, H + 1) {
        m2 = max(m2, row[i]);
    }
    vector<ll> tar1, tar2;
    rep2(i, 1, W + 1) {
        if (col[i] == m) tar1.push_back(i);
    }
    rep2(i, 1, H + 1) {
        if (row[i] == m2) tar2.push_back(i);
    }
    ll ans = 0;
    for (ll r : tar2) {
        for (ll c: tar1) {
            if (used.count({r, c})){
                ans = max(ans, m + m2 - 1);
            }else {
                ans = max(ans, m + m2);
            }
            if (ans == m + m2) break;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 72572
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

const int LG = 60;
int basis[LG + 1];

bool check_basis(int msk){
    for(int b = LG ; b >= 0 ; --b){
        if(msk >> b & 1LL){
            if(!basis[b]){
                return false;
            }
            msk ^= basis[b];
        }
    }    
    return true;
}


void insertVec(int msk){
    for(int b = LG ; b >= 0 ; --b){
        if(msk >> b & 1LL){
            if(!basis[b]){
                basis[b] = msk;
                return ;
            }
            msk ^= basis[b];
        }
    }    
}

void reset(){
    for(int b = LG ; b >= 0 ; --b)
        basis[b] = 0;
}


void solve()
{
    reset();
    int n ;
    cin >> n; 
    int a[n];
    string s;
    rep(i , n) cin >> a[i];
    cin >> s;
    for(int i = n - 1 ; i >= 0 ; --i){
        if(s[i] == '0')
            insertVec(a[i]);
        else{
            if(!check_basis(a[i])){
                cout << "1";
                return;
            }
        }
    }
    cout << "0";
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3576
def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = 0
    for i in range(n-1):
        if x[i] > x[i+1]:
            ans += x[i]-x[i+1]
            x[i+1] = x[i]
    print(ans)


main()


Measured memory_bytes: 94016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int c[4][4];
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0;i < 3;i++){
        for(int j = 1;j < 3;j++){
            c[i][j] -= c[i][0];
        }
        c[i][0] = 0;
    }

    bool flg = true;
    for(int j = 0;j < 3;j++){
        for(int i = 1;i < 3;i++){
            if(c[i][j] != c[0][j])flg = false;
        }
    }
    cout << (flg ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::vector<int> dfs(long long d, long long x)
{
  if (d == 0)
    return {};

  std::vector<int> a;
  
  if (std::abs(d - x) <= std::abs(- d - x)) {
    a = dfs(d / 2, x - d);

    a.push_back(1);
  }
  else {
    a = dfs(d / 2, x + d);
    
    a.push_back(-1);
  }

  return std::move(a);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long X[1111], Y[1111], Z[1111], D[1111];

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> X[i] >> Y[i];

    Z[i] = (D[i] = std::abs(X[i]) + std::abs(Y[i])) % 2;
  }

  int c = std::count(Z, Z + N, 0);

  if (c != 0 && c != N) {
    std::cout << -1 << std::endl;

    return 0;
  }

  std::vector<long long> d;

  long long x = 1;

  for (int i = 0; i < 40; i ++, x <<= 1)
    d.push_back(x);

  if (c == N) {
    d.pop_back();

    d.insert(std::begin(d), 1);
  }

  // d.resize(5);

  std::reverse(ALL(d));

  std::cout << d.size() << std::endl;

  for (const auto& i : d)
    std::cout << i << ' ';
  std::cout << std::endl;
  
  for (int i = 0; i < N; i ++) {
    int x = X[i] - Y[i], y = X[i] + Y[i];

    std::vector<int> u = dfs(d[0], x), v = dfs(d[0], y);

    std::reverse(ALL(u));
    std::reverse(ALL(v));

    assert(u.size() == v.size());

    std::string s;

    for (int i = 0, size = u.size(); i < size; i ++)
      if (u[i] == 1) {
        s.push_back(v[i] == 1 ? 'R' : 'D');
      }
      else {
        s.push_back(v[i] == 1 ? 'U' : 'L');
      }

    long long xx = 0, yy = 0;

    for (int i = 0, size = s.size(); i < size; i ++)
      if (s[i] == 'R') {
        xx += d[i];
      }
      else if (s[i] == 'U') {
        yy += d[i];
      }
      else if (s[i] == 'L') {
        xx -= d[i];
      }
      else {
        yy -= d[i];
      }

    if (s.size() < d.size()) {
      if (X[i] > xx) {
        s.push_back('R');

        xx ++;
      }
      else if (Y[i] > yy) {
        s.push_back('U');

        yy ++;
      }
      else if (X[i] < xx) {
        s.push_back('L');

        xx --;
      }
      else {
        s.push_back('D');

        yy --;
      }
    }

    std::cout << s << std::endl;
  }

  return 0;
}


Measured memory_bytes: 384
import sys


def getTheNumberOfCoin(n, m, c):
    T = {}
    for j in range(0, n+1):
        T[j] = 100000
    T[0] = 0

    for i in range(0, m):
        for j in range(c[i], n+1):
            T[j] = min(T[j], T[j-c[i]]+1)

    return T[n]


n, m = (int(x) for x in sys.stdin.readline().split())
c = sorted([int(x) for x in sys.stdin.readline().split()])

print(getTheNumberOfCoin(n, m, c))

Measured memory_bytes: 13916
/*
       .-.,     ,.-.
 '-.  /:::\\   //:::\  .-'
 '-.\|':':' `"` ':':'|/.-'
 `-./`. .-=-. .-=-. .`\.-`
   /=- /     |     \ -=\
  ;   |      |      |   ;
  |=-.|______|______|.-=|
  |==  \  0 /_\ 0  /  ==|
  |=   /'---( )---'\   =|
   \   \:   .'.   :/   /
    `\= '--`   `--' =/'
      `-=._     _.=-'
           `"""`
*/

#include<bits/stdc++.h>

#define ll   	long long
#define pb	    push_back
#define F   	first
#define S	    second
#define B   	begin()
#define E	    end()
#define FASTIO   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


using namespace std ;

int main()
{
    FASTIO
    string s , d ;
    cin >> s >> d ;
    ll ans = 0 ;
    for ( int i = 0 ; i < s.size() ; i++ )
    {
        if ( s[i] != d[i] )
            ans++;
    }
    cout << ans ;
    return 0 ;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> l(c);
    priority_queue<pair<int, int>> cw;

    rep(i, l.size())
    {
        cin >> l[i];
    }
    rep(i, n)
    {
        pair<int, int> hoge;
        cin >> hoge.second >> hoge.first;
        hoge.second = hoge.second - 1;
        cw.push(hoge);
    }
    long long int ans = 0;
    while (m > 0 && !cw.empty())
    {
        auto temp = cw.top();
        cw.pop();
        if (l[temp.second] > 0)
        {
            ans += temp.first;
            m--;
            l[temp.second]--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4228
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();long[] a = new long[n];
		for(int i=0;i<n;i++)a[i]=sc.nextLong()-(i+1);
		Arrays.sort(a);
		long median=0;
		switch (n % 2) {
		   case 0:
		     median=a[(n/2)-1];
		    break;
		   case 1:
		    median=a[n/2];
		    break;
		  }
		long sum=0;
		for(int i=0;i<n;i++) sum+=Math.abs(a[i]-median);
		System.out.println(sum);
	}
}


Measured memory_bytes: 91648
# problem C
N, M = map(int,input().split())

SC = []

for i in range(0,M):
    x = list(map(int,input().split()))
    SC.append(x)

if N != 1:
    suuji = [1]
else:
    suuji = [0]
suuji.extend([0]*(N-1))


hantei = 0

for i in SC:
    if (i[0] == 1) and (i[1] == 0) and (M != 0) and (N != 1):
        hantei = -1
        print(hantei)
        break
    else:
        pass

if hantei != -1:    
    for i in range(0,M):
        if hantei == -1:
            break
        else:
            for j in range(0,M):
                if SC[i][0] == SC[j][0]:
                    if SC[i][1] != SC[j][1]:
                        hantei = -1
                        print(hantei)
                        break
                    else:
                        pass
                else:
                    pass
else:
    pass
        
if hantei != -1:
        for i in SC:
            suuji[i[0]-1] = i[1]
        print(int(''.join(list(map(str,suuji)))))
else:
    pass

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

int main()
{
    int h,n;
    cin >> h >> n;
    int a[n] = {};
    int b[n] = {};
    int ma = 0;
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        ma = max(ma,a[i]);
    }
    int h2 = h+ma;
    vector<int> dp(h2+1, 1e9);
    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int w=0; w<=h2; w++){
            if(w >= a[i])   dp[w] = min(dp[w-a[i]] + b[i], dp[w]);
        }
    }
    auto ans = min_element(&dp[h], &dp[h2]);
    cout << *ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
char s[75];int n,K,ans,a[75],p[305],inv[305];
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
void Check(int num,int sum)
{
	int pos=num+1,res=p[num],rnum=0,leftr=0,nxt=0,left=0;
	for(int i=1;i<=K;++i)
		if(s[i]=='r') rnum<num?leftr+=(a[++rnum]>1):(left?--left:0);
		else leftr?(--leftr,left+=a[++nxt]-2):(left?--left:0);
	if(left||rnum<num||leftr) return;
	for(int i=1,j;i<=num;i=j+1)
	{
		for(j=i;j<num&&a[j+1]==a[i];++j);
		res=1LL*res*inv[j-i+1]%mod;
		pos+=(j-i+1)*(a[i]*2-1);
	}
	ans=(ans+1LL*res*C(n-sum+pos-1,pos-1))%mod;
}
void dfs(int x,int num,int sum)
{
	if(sum>n) return;Check(num,sum);
	for(int i=x;i;--i) a[num+1]=i,dfs(i,num+1,sum+(i>1?i*2-3:1)+(num>0));
}
int main()
{
	scanf("%d%d%s",&n,&K,s+1);
	p[0]=inv[0]=p[1]=inv[1]=1;
	for(int i=2;i<=300;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=300;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod; 
	dfs(70,0,0);cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();

        long sum = 0;
        sc.close();
        int count = 0;
        int count9 = 0;

        if(N / 10 == 0){
            sum = N;
        } else{
            while(N/10 != 0){
                count++;
                if(N%10 == 9)
                    count9++;
                sum += 9;
                N /= 10;
            }
            if(count9 != count)
                sum += N-1;
            else
                sum += N;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 23764
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int l=0,r=0;
    for (int i = 0; i < s.length(); i++) {
        if(s.charAt(i)=='A'){l=i;break;}
    }
    for (int i = s.length()-1; i >=0; i--) {
        if(s.charAt(i)=='Z'){r=i+1;break;}
    }
    out.println(s.substring(l,r).length());
}}

Measured memory_bytes: 24732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

bool cmp(const int& a, const int& b) {
    return a%int(1e9+1) < b%int(1e9+1);
}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi x(2*n);
    rep(i, n) {
        cin >> x[i];
    }
    rep(i, n) {
        cin >> x[i+n];
        x[i+n] += 1e9+1;
    }
    sort(all(x), cmp);

    mint ans = 1;
    int sum = 0;
    rep(i, 2*n) {
        if(!sum) {
            sum += (x[i] > 1e9 ? 1:-1);
        } else {
            if(sum > 0) {
                if(x[i] > 1e9) sum++;
                else {
                    ans *= sum;
                    sum--;
                }
            } else {
                if(x[i] > 1e9) {
                    ans *= -sum;
                    sum++;
                } else sum--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3960
import java.util.Scanner;

//Divisor is the Conqueror
public class Main{

	int n;
	int[] c, res;
	
	boolean dfs(int k, int rest){
		if(k<0)return true;
		for(int i=1;i<14;i++){
			if(c[i]==0||(rest-i)%i!=0)continue;
			c[i]--; res[k] = i;
			if(dfs(k-1, rest-i))return true;
			c[i]++;
		}
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			c = new int[14]; res = new int[n];
			int s = 0;
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				s += x;
				c[x]++;
			}
			if(dfs(n-1, s)){
				for(int i=0;i<n;i++)System.out.print(res[i]+(i==n-1?"\n":" "));
			}
			else System.out.println("No");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

int main(){

    int n, h, w, a, b, soma = 0;

    cin >> n >> h >> w;
    
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if((a >= h  && b >= w)){
            soma++;
        }
    }

    cout << soma << endl;

    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

ll a, b, c;

int main() {
    fastio();

    cin >> a >> b >> c;

    ll d = (c - (a + b));

    bool ok = c >= a + b;

    ok &= 4LL * a * b < d * d;

    cout << (ok ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
X = int(input())
expo = [False for i in range(X+1)]

def solve():
    expo[1] = 1
    for b in range(2,X+1):
        v = b*b
        while v <= X:
            expo[v] = True
            v *= b
    for i in range(X,0,-1):
        if expo[i]:
            print(i)
            return


if __name__ == '__main__':
    solve()

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

using namespace std;

int n;
int ans[100001];
int mx = 0;
vector<pair<int, int> > g[100001];

void dfs(int v, int w, int color) {
    int colorId = 0;
    for (auto vv:g[v])
        if (vv.first != w) {
            if (color == colorId) ++colorId;
            ans[vv.second] = colorId;
            mx = max(mx, colorId);
            dfs(vv.first, v, colorId);
            ++colorId;
        }
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].emplace_back(make_pair(b, i));
        g[b].emplace_back(make_pair(a, i));
    }

    dfs(0, -1, -1);
    cout << mx + 1 << endl;
    for (int i = 0; i < n - 1; ++i) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#else
#define Dump(x)
#endif


int main()
{
    ull_t N, K;
    cin >> N >> K;

    if (N >= K)
        N %= K;

    if (N > 0)
    {
        ull_t M = K / 2;
        if (M < N)
            N = K - N;
    }

    cout << N << endl;
}


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

pair<int,int> dfs(const vector<vector<int>> &G, int v, vector<int> &C){
  pair<int,int> ret(0,0);
  int c = C[v];
  if(c) ++ret.first;
  else ++ret.second;
  for(int v_ : G[v]){
    if(C[v_] < 0){
      C[v_] = 1-c;
      pair<int,int> p = dfs(G,v_,C);
      if(p.first < 0) return {-1,-1};
      ret.first += p.first;
      ret.second += p.second;
    }else if(C[v_] == c){
      return {-1,-1};
    }
  }
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> E(N,vector<bool>(N,false));
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    E[a][b] = true;
    E[b][a] = true;
  }
  for(int i = 0; i < N; ++i) E[i][i] = true;
  vector<vector<int>> G(N);
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      if(!E[i][j]) G[i].push_back(j);
    }
  }
  vector<int> C(N,-1);
  vector<bool> dp(N+1,false);
  dp[0] = true;
  for(int i = 0; i < N; ++i){
    if(C[i] >= 0) continue;
    C[i] = 0;
    pair<int,int> p = dfs(G,i,C);
    // cerr << p.first << " " << p.second << endl;
    if(p.first < 0){
      cout << -1 << endl;
      return 0;
    }
    vector<bool> dp_(N+1,false);
    for(int j = 0; j <= N; ++j){
      if(!dp[j]) continue;
      if(j+p.first <= N) dp_[j+p.first] = true;
      if(j+p.second <= N) dp_[j+p.second] = true;
    }
    swap(dp,dp_);
  }
  int ans = 1e9;
  for(int i = 0; i <= N; ++i){
    if(!dp[i]) continue;
    ans = min(ans,i*(i-1)/2+(N-i)*(N-i-1)/2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,q;
	cin>>n>>m;
	vector<int> a(m),b(m),mx(n+1,-1),ans(n+1,0);
	vector<vector<int>> g=vector<vector<int>>(n+2,vector<int>());
	FOR(i,0,m){
		cin>>a[i]>>b[i];
		g[a[i]].PB(b[i]);
		g[b[i]].PB(a[i]);
	}
	cin>>q;
	vector<int> v(q),d(q),c(q);
	FOR(i,0,q)cin>>v[i]>>d[i]>>c[i];

	FORD(i,q,0){
		queue<pair<pair<int,int>,int>> q;
		q.push(MP(MP(v[i],d[i]),c[i]));
		while(q.size()){
			pair<pair<int,int>,int> tpl=q.front();
			q.pop();
			int vv=tpl.ST.ST,dd=tpl.ST.ND,cc=tpl.ND;
			if(mx[vv]>=dd)continue;
			mx[vv]=dd;
			if(ans[vv]==0)ans[vv]=cc;
			int l=g[vv].size();
			FOR(j,0,l){
				if(mx[g[vv][j]]<dd-1){
					q.push(MP(MP(g[vv][j],dd-1),cc));
				}
			}
		}
	}
	FORQ(i,1,n){
		cout<<ans[i]<<endl;
	}
    return 0;
}


Measured memory_bytes: 10104