akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

void mapping(string& s)
{
    char ordered = 'A';
    vector<char> table('z' - 'a' + 1, '\0');
    for(char& c : s)
    {
        if(table[c-'a'] == '\0')
        {
            table[c-'a'] = ordered++;
        }
        c = table[c-'a'];
    }
}

int main()
{
    string s,t;
    cin >> s >> t;
   
    mapping(s);
    mapping(t);
    
    cout << (s == t ? "Yes\n" : "No\n");
    
    return 0;
}

Measured memory_bytes: 904
A,B,C=map(int,input().split())

diff=3*max(A,B,C)-A-B-C
answer=0

big=max(A,B,C)
small=min(A,B,C)
median=A+B+C-big-small

if diff%2==1:
  big=max(A,B,C)+1
  small=min(A,B,C)+1
  answer+=1

while(big!=small):
  if(median!=big and small!=big):
    median+=1
    small+=1
    answer+=1
  elif(small!=big):
    small+=2
    answer+=1
  
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++) cin >> H[i];
  int cnt = 0;
  int ma = H[0];
  for (int i=0; i<N; i++) {
    if (ma <= H[i]) {
      cnt++;
      ma = max(ma,H[i]);
    }
  }
  cout << cnt << endl;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int a,b,c,d;
    cin >> a>>b>>c>>d;

    while (true)
    {
        c -= b;
        if (c<=0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a<=0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll ss(ll x){
  ll d = 0;
  while(x > 0){
    d+=x%10;
    x/=10;
  }
  return d;
}

bool is(ll x, ll y, ll p, ll q){
  return x * 1ll * q > y * 1ll * p; 
}

int main(){
  fastIO;
  vector<ll> cand;
  int len = 1;
  ll p;
  for(int t = 1; t <= 200; t ++ ){
    if(t == 10) len ++ ;
    if(t == 100) len ++ ;
    p = t;
    cand.push_back(t);
    for(int j = 1 ; j <= 16; j ++ ){
      if(len + j > 16) continue;
      p *= 10ll;
      p += 9;
      cand.push_back(p);
    }
  }
  sort(cand.begin(), cand.end());
  cand.resize(unique(cand.begin(), cand.end()) - cand.begin());
  bool valid;
  int k;
  cin >> k;
  for(int i = 0 ; i < cand.size(); i ++ ){
    valid = true;
    for(int j = i + 1; j < cand.size(); j ++ ){
      if(is(cand[i], ss(cand[i]), cand[j], ss(cand[j]))){
        valid = false;
        break;
      }
    }
    if(valid){
      cout << cand[i] << "\n";
      k -- ;
      if(k == 0) return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 384
D,G = map(int,input().split())
P = []
C = []
for i in range(D):
  p,c = map(int,input().split())
  P.append(p)
  C.append(c)

# より少ない問題数で目標を達成したとき、
# 0以上のコンプリートした問題群と、コンプリートしていない1種類の問題が存在する。
# コンプリートした問題群のパターンを全探索する。
ans = 1001
for i in range(1<<D):
  q = 0
  s = 0
  for j in range(D):
    if (i>>j)&1 == 1:
      q += P[j]
      s += 100*(j+1)*P[j] + C[j]
  #print(i,j,q,s)
  # コンプリートした問題群だけで目標を達成した場合
  if i == (1<<D)-1 or s >= G:
    ans = min(ans,q)
  # コンプリートした問題群だけで目標を達成しなかった場合
  # 残りの問題のうち、最も点数が高い問題を、コンプリートしない程度に解く
  else:
    for k in range(D-1,-1,-1):
      if (i>>k)&1 == 0:
        break
    q1 = 0
    while (s < G and q1 < P[k]-1):
      s += 100*(k+1)
      q1 += 1
    #print(i,j,q,s,k,q1)
    if s >= G:
      ans = min(ans,q+q1)
print(ans)


Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  string s;
  cin >> s;
  int i=0;ll k;
  cin >> k;
  while(s[i]=='1'){
    i++;
  }
  --k;
  if(i<=k)cout << s[i] << endl;
  else cout << 1 << endl;
  //  cout << endl << endl;
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;


}


Measured memory_bytes: 256
def k(n, a, p):
    x = 0
    c = 0
    for i in range(n):
        s = x + a[i]
        if p and s > 0 or not p and s < 0: x = s
        else:
            c += abs(s) + 1
            if p: x = 1
            else: x = -1
        p = not p
    return c

n = int(input())
a = [int(x) for x in input().split()]
print(min(k(n, a, True), k(n, a, False)))

Measured memory_bytes: 14332
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;

char g[1005][1005] = {0};
string c[10][10];
LL n;

void init(){
	c[3][0] = "aa.";
	c[3][1] = "..b";
	c[3][2] = "..b";
	
	c[4][0] = "aabc";
	c[4][1] = "ddbc";
	c[4][2] = "efgg";
	c[4][3] = "efhh";
	
	c[5][0] = "aabbc";
	c[5][1] = "dee.c";
	c[5][2] = "d..fg";
	c[5][3] = "h..fg";
	c[5][4] = "hiijj";
	
	c[7][0] = "aabbcc.";
	c[7][1] = "gg.gg.d";
	c[7][2] = "..g..gd";
	c[7][3] = "..g..ge";
	c[7][4] = "gg.gg.e";
	c[7][5] = "..g..gf";
	c[7][6] = "..g..gf";
}

LL cov(LL x,LL y,LL id){
	for(LL i = 0;i < id;i ++){
		for(LL j = 0;j < id;j ++){
			g[x + i][y + j] = c[id][i][j];
		}
	}
}

void solve(LL x,LL y){
	if(x == -1){
		if(y == 2){ cout << -1 << endl; return; }
		if(y == 3) cov(1,1,3);
		if(y == 6){ cov(1,1,3); cov(4,4,3); }
		if(y == 5) cov(1,1,5);
		if(y == 7) cov(1,1,7);
		if(y == 11){ cov(1,1,4); cov(5,5,7); }
	}
	else{
		LL tx = 1;
		for(LL i = 1;i <= x;i ++){
			cov(tx,tx,4);
			tx += 4;
		}
		for(LL i = 1;i <= y;i ++){
			cov(tx,tx,5);
			tx += 5;
		}
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(!g[i][j]) g[i][j] = '.';
			cout << g[i][j];
		}
		cout << endl;
	}
}

int main(){
	cin >> n;
	init();
	if(n <= 2) solve(-1,2);
	if(n == 3) solve(-1,3);
	if(n == 4) solve(1,0);
	if(n == 5) solve(0,1);
	if(n == 6) solve(-1,6);
	if(n == 7) solve(-1,7);
	if(n == 11) solve(-1,11);
	if(n < 8 || n == 11) return 0;
	for(LL i = 0;i <= 1000;i ++){
		if((n - i * 4) % 5 == 0){
			solve(i,(n - i * 4) / 5);
			break;
		}
	}
	return 0;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

const LL mod = 1000000007;

int main()
{
    LL N, M;
    cin >> N >> M;

    LL ans;
    if (N > M/2) ans = M/2;
    else ans = N+(M-2*N)/4;

    cout << ans << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
	c -= b;
	if (c <= 0){
	  cout << "Yes" << endl;
	  return 0;
	}
	a -= d;
	if (a <= 0){
	  cout << "No" << endl;
	  return 0;
	}
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>                                                         
                                                                                 
using namespace std;                                                             
                                                                                 
int num_atk(int atk, int hp) {                                                   
    int num = hp / atk;                                                          
    if (hp % atk != 0)                                                           
        num++;                                                                   
    return num;                                                                  
}                                                                                
                                                                                 
int main() {                                                                     
    int hp1, atk1, hp2, atk2;                                                    
    cin >> hp1 >> atk1 >> hp2 >> atk2;                                           
    int num_takahashi = num_atk(atk1, hp2);                                      
    int num_aoki = num_atk(atk2, hp1);                                           
    if (num_takahashi <= num_aoki)                                               
        cout << "Yes";                                                           
    else                                                                         
        cout << "No";                                                            
    return 0;                                                                    
}   

Measured memory_bytes: 3568
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    vector<int> vec;
    rep(i,N){
        int x;cin>>x;
        if(i%2){
            vec.push_back(x);
        }else{
            vec.insert(vec.begin(),x);
        }
    }
    if(N%2==0) reverse(all(vec));
    rep(i,N){
        if(i) cout<<" ";
        cout<<vec[i];
    }
}

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstring>
using namespace std;
#define MAXN 10
int n;
char s[MAXN+5];
int flag;
int C=1;
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    if(s[1]!='A')C=0;
    if(!(s[2]>='a'&&s[2]<='z'))C=0;
    if(!(s[len]>='a'&&s[len]<='z'))C=0;
    for(int i=3;i<=len-1;i++)
    {
        if(s[i]=='C')
        {
            if(flag)C=0;
            else flag=1;
            continue;
        }
        if(!(s[i]>='a'&&s[i]<='z'))C=0;
    }
    if(C&&flag)printf("AC");
    else printf("WA");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

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

    ll apple = INT_MAX;
    for (ll i = 0; i < N; i++)
    {
        if (abs(L + i) < abs(L + apple))
        {
            apple = i;
        }
    }

    cout << ((L + L + N - 1) * N / 2 - (L + apple)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

int D[100001];
struct tree{
	int p,l,r;
}T[100001];

void gd(int i,int p){
	D[i] = p;
	if(T[i].r!=NIL) gd(T[i].r,p);
	if(T[i].l!=NIL) gd(T[i].l,p+1);
}

void ppt(int n){
	printf("node %d: parent = %d, depth = %d, ",n,T[n].p,D[n]);
	if(T[n].p == NIL){
		printf("root, ");
	}
	else if(T[n].l != NIL){
		printf("internal node, ");
	}
	else if(T[n].l == NIL){
		printf("leaf, ");
	}
	printf("[");
	n=T[n].l;
	while(n!=NIL){
		printf("%d",n);
		n=T[n].r;
		if(n != NIL){
			printf(", ");
		}
	}
	printf("]\n");
}

int main(){
	int i,j,n,k,o,cur,num;
	scanf("%d",&o);
	k=o;
	for( i = 0; i < o; i++ ) T[i].p=T[i].l=T[i].r=NIL;
	while(k--){
		scanf("%d %d",&cur,&n);
		if(n){
			scanf("%d",&num);
			T[cur].l=num;
			T[num].p=cur;	
		}
		for( i = 1; i < n; i++ ){
			scanf("%d",&j);
			T[num].r=j;
			T[j].p=cur;
			num=j;
		}
	}
	for(i=0;i<o;i++){
		if(T[i].p==NIL) break;
	}
	gd(i,0);
	for( i = 0; i < o; i++ ) ppt(i);
	return 0;	
} 


Measured memory_bytes: 7252
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const ll INF =1LL << 62;
using namespace std;

int main(){
	int n; cin >>n;
	vector<string> s(n);
	cinf(n,s);
	int cnta=0; int cntu=0;
	bool a=0;
	for(int i=0;i<n;i++){
		if(s[i]=="A")cnta++;
		else cntu++;
		if(cntu>cnta){
			a=true;
			break;
		}
	}
	if(a||cnta!=cntu){
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double temp = 1.0 / N;
        int n = i;
        while (n < K) {
            n *= 2;
            temp *= 0.5;
        }
        ans += temp;
    }
    cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  cin >> n;
  map<int,int> mo;
  map<int,int> me;
  for(int i=0; i<n; i++) {
    cin >> a;
    if((i+1)%2==1) {
      mo[a]++;
    }
    else {
      me[a]++;
    }
  }
  int Me=0,Mo=0,ei,oi,o2=0,e2=0;
  for(auto p:mo) {
    if(Mo<p.second) {
      o2=Mo;
      Mo=p.second;
      oi=p.first;
    }
    else {
      o2=max(o2,p.second);
    }
  }
  for(auto p:me) {
    if(Me<p.second) {
      e2=Me;
      Me=p.second;
      ei=p.first;
    }
    else {
      e2=max(e2,p.second);
    }
  }
  if(ei==oi) {
    cout << min(n-Me-o2,n-e2-Mo) << endl;
  }
  else {
    cout << n-Me-Mo << endl;
  }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main()
{    long long int n,a,p;
    cin>>n;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        mp[a]++;
        if(mp[a]==2){mp.erase(mp.find(a));}
    }
    p=mp.size();
    cout <<p<<endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;

vi visit;
vector<vi> to;

int DFS(int p, int n){
    if (visit[p] != 0) return visit[p];

    visit[p] = n + 1;
    for (int i: to[p]){
        int r = DFS(i, n + 1);
        if (r > 0) return r;
    }
    visit[p] = -1;
    return -1;
}

int main(){
    int N, M; cin >> N >> M;
    to.resize(N);
    rep(i,M){
        int A, B; cin >> A >> B;
        A--; B--;
        to[A].push_back(B);
    }

    visit.resize(N);
    set<int> ans;
    rep(i,N){
        visit[i] = 0;
        ans.insert(i);
    }

    rep(i,N){
        int r = DFS(i, 0);
        if (r > 0){
            rep(j,N){
                if (ans.count(j)){
                    if (visit[j] < r){
                        ans.erase(j);
                        continue;
                    }
                    for (int k: to[j]){
                        if (ans.count(k)){
                            if (k < j) rep(l,N) if (visit[l] < visit[k] || visit[l] > visit[j]) ans.erase(l);
                            else rep(l,N) if (visit[l] > visit[j] && visit[l] < visit[k]) ans.erase(l);
                        }
                    }
                }
            }
            cout << ans.size() << endl;
            for (int j: ans) printf("%d\n",j+1);
            break;
        }
        if (i == N-1) puts("-1");
    }
    return 0;
}

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

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

    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x = min(a,min(b,min(c,min(d,e))));
    ll ans = ((n+x-1)/x) + 4;
    cout << ans << endl;
}

Measured memory_bytes: 3620
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
sushi = [None] * N
for i in range(N):
    t, d = map(int, input().split())
    sushi[i] = (d, t-1)
sushi.sort(reverse=True)

types = set()
cand = []
s = x = 0

for d, t in sushi[:K]:
    if t in types:
        heappush(cand, d)
    else:
        types.add(t)
        x += 1
    s += d

ans = s + x*x
for d, t in sushi[K:]:
    if t in types:
        continue
    if not cand:
        break
    dr = heappop(cand)
    s += d - dr
    types.add(t)
    x += 1
    ans = max(ans, s + x*x)
print(ans)



Measured memory_bytes: 53724
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define P pair<int, ll>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
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; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i_, SZ(v)) cout << v[i_] << " "; cout << endl
#define ina(a, n) rep(i_, n) cin >> a[i_]
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//ctrl + command + e -> 変数一括変更







int infflg = 0;
vector<ll>  bell(int n, vector<vector<pair<int, ll> > > edge, int s) {
    vector<ll> d(n, -INF);
    d[s] = 0;
    
    
    
    
    rep(loop, 2 * n + 1) {
        int update = 0;
        rep(from, n) {
            if (d[from] == -INF) continue;
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                ll cost = edge[from][j].S;
                
                if (chmax(d[to], d[from] + cost)) {
                    update = 1;
                    if (to == n - 1 && loop == 2 * n) {
                        infflg = 1;
                        out("inf");
                        return d;
                    }
                }
                
            }
        }
        if (update == 0) break;
        
    }
    return d;
    
}
int main() {
    int n, e, r;
    cin >> n >> e;
    r = 0;
    
    int a, b, c;
    vector<vector<pair<int, ll> > > edge(n);
    rep(i, e) {
        cin >> a >> b >> c;
        a--; b--;
        edge[a].eb(b, c);
    }
    
    auto go = bell(n, edge, r);
    if (infflg == 1) return 0;
    out(go[n - 1]);
    
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI a(n), b;
	rep(i, n) cin >>a[i];
	b = a;
	reverse(all(b));
	VI hk(n, MD);
	for(auto x: b) *upper_bound(all(hk), x) = x;
	cout << lower_bound(all(hk), MD) - hk.begin() << endl;

	return 0;
}


Measured memory_bytes: 4508
import sys

def push_vertex(frame, vtx, search_queue, outputs, vertices):
    #print("frame:{} push:{}".format(frame, vtx))
    outputs[vtx] = [frame, None]
    search_queue.append(vtx)
    [vertices[key].remove(vtx) for key in vertices.keys() if vtx in vertices[key]]

    return

def main():
    n = int(input())
    lines = sys.stdin.readlines()
    outputs = {}

    vertices = {}
    for i in range(n):
        idx, idx_n, *idx_vertices = lines[i].rstrip().split()
        vertices[int(idx)] = [int(x) for x in idx_vertices]

    vtx = 1
    frame = 1
    search_queue = []
    push_vertex(frame, vtx, search_queue, outputs, vertices)

    while len(vertices) != 0:
        frame += 1
        if len(search_queue) != 0:
            vtx = search_queue[-1]
        else:
            vtx = list(vertices.keys())[0]
            push_vertex(frame, vtx, search_queue, outputs, vertices)
            continue

        if len(vertices[vtx]) != 0:
            next_vtx = vertices[vtx][0]
            push_vertex(frame, next_vtx, search_queue, outputs, vertices)
        else:
            search_queue.pop()
            #print("frame:{},pop:{}".format(frame, vtx))
            del vertices[vtx]
            outputs[vtx][1] = frame

    #pprint.pprint(outputs)
    for key, value in sorted(outputs.items(), key=lambda x: x[0]):
        print("{} {} {}".format(key, value[0], value[1]))


main()


Measured memory_bytes: 5624
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main(){
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	if i < 1000 {
		fmt.Println("ABC")
	}else{{
		fmt.Println("ABD")
	}}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int const N = 100000+10000;
bool isp[N];
int ps[N / 2];
int c = 0;
void eratos(){
    rep(i, N) isp[i] = true;
    isp[0] = isp[1] = false;
    for (int i = 2; i < N; i++){
        if (!isp[i]) continue;
        ps[c++] = i;
        for (int j = i + i; j < N; j += i){
            isp[j] = false;
        }
    }
}

int solve(int n, int p){
    auto it = upper_bound(ps, ps + c, n);
    vi v(p*p, 1 << 30);
    rep(i, p)loop(j, i, p){
        v[i * p + j] = *(it + i) + *(it + j);
    }
    sort(all(v));
    return v[p - 1];
}

int main(){
    eratos();
    int n, p;
    while (cin >> n >> p && n!=-1 && p!=-1){
        cout << solve(n, p) << endl;
    }
}

Measured memory_bytes: 1396
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt;
ll max_cnt;
ll max_num;

int main(){
	ll n;
	cin >> n;
	arep(1,i,n+1){
		cnt=0;
		ll j=i;
		while(j%2==0){
			cnt++;
			j/=2;
		}
		if(cnt>=max_cnt){
			max_cnt=cnt;
			max_num=i;
		}
	}
	cout << max_num << endl;
}

Measured memory_bytes: 3608
from copy import deepcopy

n, k = map(int, input().split())
r, s, p = map(int, input().split())
l = list(input())

ans = 0
for i in range(k):
  n_ = (n - i) // k + (1 if (n-i) % k > 0 else 0)
  rsp = [0] * 3
  for j in range(n_):
    bef = deepcopy(rsp)
    if l[j * k + i] == "r":
      rsp[2] = max(bef[0], bef[1]) + p
      rsp[1] = max(bef[0], bef[2])
      rsp[0] = max(bef[1], bef[2])
    elif l[j * k + i] == "s":
      rsp[2] = max(bef[0], bef[1])
      rsp[1] = max(bef[0], bef[2])
      rsp[0] = max(bef[1], bef[2]) + r
    elif l[j * k + i] == "p":
      rsp[2] = max(bef[0], bef[1])
      rsp[1] = max(bef[0], bef[2]) + s
      rsp[0] = max(bef[1], bef[2])
  ans += max(rsp)
      
print(ans)

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  vector<int> a(n);
  rep(i,n)  cin >> a.at(i);

  int ans=0;
  for(int i=0; i<n; i+=2){
    if(a.at(i)%2==1)  ans++;
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
	int x;
	int a[4];
	a[0]=0,a[1]=1,a[2]=2,a[3]=3;
	for(int i=0;i<2;i++)
	{
		cin>>x;
		a[x]=0;
	}
	for(int i=0;i<4;i++)
	{
		if(a[i]!=0)
		{
			cout<<a[i];
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,n1,ans=0;scanf("%d",&n),n1=sqrt(--n);
	for(int i=1;i<=n1;i++)
		ans+=(n/i)-i+1;
	printf("%d",ans*2-n1);
	return 0;
} 

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100

int main(){
  int K;
  cin>>K;
  int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<A[K-1]<<endl;
}


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

using namespace std;

char a[100010];
int la ;

int main(){
    gets(a);
    la = strlen(a);
    for (int i = 0; i <= la/2; i++){
        int l = i,r = la-i-1;
        if(a[l] == 'b' && a[r] == 'd' || a[l] == 'd' && a[r] == 'b' || a[l] == 'p' && a[r] == 'q' || a[l] == 'q' && a[r] == 'p');
        else{
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
        cin>>n;
        vll v(n+1);
        forn(i,n)cin>>v[i+1];
        vll ans(n+1);
        for(int i=n/2+1; i<=n; i++){
            ans[i]=v[i];
        }
        for(int i=n/2; i>=1; i--){
            ll p=2;
            ll c=0;
            while(i*p<=n){
                c+=ans[i*p];
                ++p;
            }
            ans[i]=!(c%2==v[i]);
        }
        ll tot=0;
        forn(i,n)tot+=ans[i+1];
        cout<<tot<<endl;
        forn(i,n)if(ans[i+1])cout<<i+1<<' ';
        cout<<endl;
	return 0;
}


Measured memory_bytes: 3968
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class Z { static void Main() => new J(); }
struct P
{
	public int X, Y, I;
	public P(int x, int y, int i) { X = x; Y = y; I = i; }
}
struct E : IComparable<E>
{
	public int F, T, C;
	public E(int f, int t, int c) { F = f; T = t; C = c; }
	public int CompareTo(E other) => C.CompareTo(other.C);
}
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var es = new List<E>();
		var ps = new List<P>();
		for (var i = 0; i < N; i++)
		{
			var I = G();
			ps.Add(new P(I[0], I[1], i));
		}
		ps.Sort((a, b) => a.X.CompareTo(b.X));
		for (var i = 0; i < N - 1; i++) es.Add(new E(ps[i].I, ps[i + 1].I, ps[i + 1].X - ps[i].X));
		ps.Sort((a, b) => a.Y.CompareTo(b.Y));
		for (var i = 0; i < N - 1; i++) es.Add(new E(ps[i].I, ps[i + 1].I, ps[i + 1].Y - ps[i].Y));
		var uf = new UnionFindTree(N);
		var s = 0L;
		es.Sort();
		foreach (var e in es) if (uf.UniteCategory(e.F, e.T)) s += e.C;
		WriteLine(s);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}
class UnionFindTree
{
	int N;
	int[] parent, rank, size;
	public UnionFindTree(int capacity)
	{
		N = capacity;
		parent = new int[N];
		rank = new int[N];
		size = new int[N];
		for (var i = 0; i < N; i++) { parent[i] = i; size[i] = 1; }
	}
	public int GetSize(int x) => size[GetRootOf(x)];
	public int GetRootOf(int x) => parent[x] == x ? x : parent[x] = GetRootOf(parent[x]);
	public bool UniteCategory(int x, int y)
	{
		if ((x = GetRootOf(x)) == (y = GetRootOf(y))) return false;
		if (rank[x] < rank[y]) { parent[x] = y; size[y] += size[x]; }
		else
		{
			parent[y] = x; size[x] += size[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}
	public bool IsSameCategory(int x, int y) => GetRootOf(x) == GetRootOf(y);
}

Measured memory_bytes: 27420
#include <stdio.h>

int main()
{
    int n;
    char s[100005];
    scanf("%d",&n);
    scanf("%s",s);

    int ans=0;
    char last='0';
    for(int i=0;i<n;i++)
    {
        if(last!=s[i])
        {
            ans++;
            last=s[i];
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
const int mod = 1e9+7;
int a[12];
int n,k;
bool chk(int x)
{
    while(x){
        int now=x%10;
        for(int i=1;i<=k;i++){
            if(now==a[i])return false;
        }
        x/=10;
    }
    return true;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=k;i++)
        cin>>a[i];
    for(int i=n;;i++){
        if(chk(i)){
            cout<<i<<endl;break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int a,b;
  cin>>a>>b;
  long long int k,max=0,l=0;
  if(a>=b)
    max=a;
  else
    max=b;
  for(k=0;k<=max;k++)
  {
     if((a-k)*(a-k)==(k-b)*(k-b))
     {
       cout<<k;
       l++;
       break;
     }
  }
  if(l==0)
    cout<<"IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
struct edge
{
  int  from,to,cost;
};

int main()
{
  int  N,M;
  cin >> N>>M;
  int H[N],A[M],B[M];
  int used[N];
  rep(i,N){
    used[i]=1;
  }
  rep(i,N){
    cin >> H[i];
  }

  rep(i,M){
    cin >> A[i] >> B[i];
    if(H[A[i]-1]>H[B[i]-1]){
      used[B[i]-1]=0;    
    }else if(H[A[i]-1]<H[B[i]-1]){
      used[A[i]-1]=0;
    }else{
      used[A[i]-1]=used[B[i]-1]=0;
    }
  }
  int sum=0;
  rep(i,N){
    if(used[i]!=0)sum++;
  }

  cout << sum << endl;
  return 0;

}



Measured memory_bytes: 5152
from math import ceil

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

x = [a, b, c, d, e]
x1 = list(map(lambda x:x%10, x))
last_x = 10
last_i = -1
cnt = 0
for i in range(len(x1)):
    if x1[i]==0:
        cnt+=1
        continue
    if last_x > x1[i]:
        last_x = x1[i]
        last_i = i

if cnt==5:
    print(sum(x))
    exit(0)

tmp = x[:last_i] + x[last_i+1:]
ans = sum(list(map(lambda a:10*ceil(a/10), tmp)))+x[last_i]
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define lowbit(x) (x & (-x))
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' && ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1 << 17, mod = 1e9 + 7;
int a[18], c[MAXN], f[18][MAXN], s[MAXN];
int frac[MAXN], invfrac[MAXN];

inline int qpow(int a, int k) {
  int re = 1;
  for (; k; k >>= 1, a = a * a % mod)
    if (k & 1) re = re * a % mod;
  return re;
}
inline int C(int n, int m) {
  if (m > n) return 0;
  return frac[n] * invfrac[m] % mod * invfrac[n - m] % mod;
}

signed main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  int all = 1 << n;
  for (RI i = 1; i <= m; ++i) read(a[i]);

  for (RI i = 1; i < all; ++i)
    s[i] = s[i ^ lowbit(i)] + lowbit(i);
  frac[0] = 1;
  for (RI i = 1; i <= all; ++i) frac[i] = frac[i - 1] * i % mod;
  invfrac[all] = qpow(frac[all], mod - 2);
  for (RI i = all; i; --i) invfrac[i - 1] = invfrac[i] * i % mod;

  f[m + 1][0] = 1;
  for (RI i = m; i; --i)
    for (RI j = 0; j < all; ++j) {
      (f[i][j] += f[i + 1][j]) %= mod;
      for (RI k = 0; k < n; ++k)
        if (!(j & (1 << k)))
          (f[i][j | (1 << k)] += f[i + 1][j] * C(all - a[i] - s[j], (1 << k) - 1) % mod * frac[1 << k] % mod) %= mod;
    }
  int ans = 0;
  c[0] = mod - 1;
  for (RI i = 0; i < all; ++i) {
    c[i] = c[i ^ lowbit(i)] * (mod - 1) % mod;
    ans = (ans + c[i] * f[1][i] % mod * frac[all - s[i] - 1] % mod) % mod;
  }
  printf("%lld\n", ans * qpow(2, n) % mod);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

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

int main() {
  std::string S;
  int N;
  std::cin >> N >> S;
  for(int i = 0; i < S.length(); ++i){
    char c = S[i];
    S[i] = (char)((c - 'A' + N) % 26 + 'A');
  }

  std::cout << S;
  return 0;
}

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007


void solve(){
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll>A(a), B(b), C(c);
	for(auto &i : A) cin >> i;
	for(auto &i : B) cin >> i;
	for(auto &i : C) cin >> i;
	priority_queue<ll>pq;
	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());
	ll sum = 0;
	for(int i=0; i<x; i++){
		sum += A[i];
		pq.push(-1*A[i]);
	}
	//PRINT(sum);
	for(int j=0; j<y; j++){
		sum += B[j];
		pq.push(-1*B[j]);
	}
	//PRINT(sum);
	for(int i=0; i<c; i++){
		//cout << pq.top() << endl;
		if((-1*pq.top()) >= C[i])
			break;
		else{
			sum += (C[i] + pq.top()); pq.pop();
			pq.push(-1*C[i]);
		}
	}
	cout << sum << endl; 
}

int main(){
	FAST_IO;
	int t=1; //cin >> t;
	while(t--){
		solve();
	}
}			


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
	int n,k,s;
	cin>>n>>k>>s;
	rep(i,k){
		cout<<s<<" ";
	}
	int t;
	t=s-1;
	if(t<=0)t=s+1;
	rep(i,n-k){
		cout<<t<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderPractice
{
    static class Program
    {
        static void Main()
        {
            ulong n = ulong.Parse(Console.ReadLine());
            Console.WriteLine(n.ToBase26());
        }

        static string ToBase26(this ulong self)
        {
            ulong n = self % 26;
            if (n == 0) n = 26;
            string s = ((char)(n + 96)).ToString();
            //(n + 64)で大文字を出力↑
            if (self == n) return s;
            return ((self - n) / 26).ToBase26() + s;
        }
    }
}

Measured memory_bytes: 17540
#include <stdio.h>

int main(){  
int a, b, c, d, e, f, i;  
char op;  
for(i = 0; i < 200000; i++){
	scanf("%d %c %d\n", &a, &op, &b); 
	if ( op == '+' ){     c = a + b;  printf("%d\n", c);  } 
	else if ( op == '-' ){      d = a - b;  printf("%d\n", d);  } 
	else if ( op == '*' ){    e = a * b;  printf("%d\n", e);  } 
	else if ( op == '/' ){     f = a / b;  printf("%d\n", f);  }  
	else break;
	}
return 0;}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vc vector<ll>
#define vcs vector<string>
#define vcp vector<pair<ll, ll>>
#define vct vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

ll k;
vc cost;
Graph g;

void dfs(int prev, int vert, ll dep)
{
	cost[vert] = dep;
	for (auto e : g[vert])
	{
		if (cost[e.to] < 0) dfs(vert, e.to, cost[vert]+e.cost);
	}
}

int main()
{
	int n;
	cin >> n;
	g.resize(n);
	REP(i, n - 1)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		add_edge(g, a - 1, b - 1, c);
		add_edge(g, b - 1, a - 1, c);
	}
	REP(i,n) add_edge(g,i,i,0);
	ll q;
	cin >> q >> k;
	k--;
	cost.resize(n, -1);
	cost[k] = 0;
	dfs(k, k, 0);
	REP(i, q)
	{
		ll a, b;
		cin >> a >> b;
		cout << cost[a - 1] + cost[b - 1] << endl;
	}
}

Measured memory_bytes: 15872
#include <stdio.h>

int main(){
	int N;
	int i;
	int rcnt;
	int bcnt;
	
	scanf("%d",&N);
	
	char S[N];
	
	scanf("%s",&S);
	
	rcnt=0;
	bcnt=0;
	for(i=0;i<N;i++){
		if(S[i]=='R')	rcnt++;
		else	bcnt++;
	}
	
	if(rcnt>bcnt)	printf("Yes");
	else	printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#if defined(LOCAL)
// #define RANDOM_TEST
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(b); a > l(c); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

const l MOD = e9 + 7;

void solve(istream& cin, ostream& cout) {
  l n, m;
  while (cin >> n >> m) {
    if (n < m) swap(n, m);
    if (n - m > 1) {
      cout << 0 << lf;
      continue;
    }
    l t = 1;
    F(i, 2, m + 1) t = (t * i) % MOD;
    l answer = t;
    F(i, m + 1, n + 1) t = (t * i) % MOD;
    answer = (answer * t) % MOD;
    if (n == m) answer = (answer * 2) % MOD;
    cout << answer << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

long long N;

bool chk( std::string input )
{
	int cnt = 0;
	char c[] = { '3', '5', '7' };

	for ( int i = 0; i < 3; i++ )
	{
		cnt += ( input.find( c[i] ) != std::string::npos );
	}

	return ( cnt >= 3 );
}

int solv( std::string input )
{
	if ( std::stoll( input ) > N )
	{
		return ( 0 );
	}
	else
	{
		int ret = ( chk( input ) == true );
		for ( auto &&it : {'3', '5', '7' } )
		{
			ret += solv( input + it );
		}
		return ( ret );
	}
}

int main()
{
	std::cin >> N;

	std::cout << solv( "0" ) << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repf(i,n) for(int i=1; i<(n+1); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int x;
int c;
int ans;

int main(){
  cin >> x;
  c = x%5;
  ans = ((x-c)/500)*1000 + (x-c)%500;
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using static ConsoleReader;

class Program
{
    static void Main(string[] args)
    {
        var n = Read<int>();
        var res = 0;
        if (n % 1000 != 0) res = 1000 - n % 1000;
        Console.WriteLine(res);
    }
}

public static class IntExtentions
{
    public static void Times(this int n, Action<int> action)
    {
        for (var i = 0; i < n; i++)
        {
            action(i);
        }
    }

    public static void Times(this (int n, int m) dimensions, Action<int, int> action)
    {
        var (n, m) = dimensions;
        n.Times(i => m.Times(j => action(i, j)));
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
        where T : IConvertible
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
        where T : IConvertible
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

Measured memory_bytes: 27560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int d[100],a[100010];
signed main(){
	n=read();
	int s=0;
	for(register int i=1;i<=n;i++){a[i]=read();s^=a[i];}
	int ans=s,max_=(1ll<<61)-1;
	for(register int i=1;i<=n;i++){
		a[i]=(a[i] & (~s));
	}
	for(register int i=1;i<=n;i++){
		for(register int j=60;j>=0;j--){
			if((a[i] & (1ll<<j))!=0){
				if(d[j]==0){d[j]=a[i];break;}
				else a[i]=a[i]^d[j];
			}
		}
	}
	int anss=0;
	for(register int i=60;i>=0;i--)
		if((anss^d[i])>anss)anss^=d[i];
	printf("%lld\n",anss*2+ans);
	return 0;
}

Measured memory_bytes: 1024