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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;

	int n ;
	cin >> n;

	bool flag = false;
	int lim4 = n / 4;
	int lim7 = n / 7;
	for (int i = 0 ; i <= lim4 ; i++) {
		for (int j = 0 ; j <= lim7 ; j++) {
			if (4 * i + 7 * j == n) {
				flag = true;
				break;
			}
		}
	}
	flag ? cout << "Yes" : cout << "No";



	return 0;
}


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

typedef pair<int, int> P;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int H, W, d, n;
char field[55][55];
bool used[55][55];
bool walk[55][55];
vector<int> r;

void init(){
  memset(used, true, sizeof(used));
  memset(walk, false, sizeof(walk));
  r.clear();
}

bool isrange(int X, int Y, int x, int y, int range){
  int sx = X - range;
  int gx = X + range;
  int sy = Y - range;
  int gy = Y + range;
  
  return (sx <= x && x <= gx) && (sy <= y && y <= gy);
}

void dowsing(int x, int y, int s){
  if(s == 0){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(!isrange(x, y, j, i, r[0])) used[i][j] = false;
      }
    }
  }
  else if(s == d){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(isrange(x, y, j, i, r[d-1])) used[i][j] = false;
      }
    }
  }
  else{
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(!(isrange(x, y, j, i, r[s]) 
	     && !isrange(x, y, j, i, r[s-1]))) used[i][j] = false;	
      }
    }
  }
}

void display(){   
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cout << used[i][j] << ' ';
    }
    cout << endl;
  }
}

void bfs(int sx, int sy){
  queue<P> que;
  que.push(P(sx, sy));
  
  while(!que.empty()){
    P q = que.front(); que.pop();
    
    int x = q.first, y = q.second;
    if(walk[y][x]) continue;
    walk[y][x] = true;
    
    for(int i = 0 ; i < 4 ; i++){
      int nx = x + dx[i], ny = y + dy[i];      
      if(0 <= nx && nx < W && 0 <= ny && ny < H)
	if(field[ny][nx] != '#') que.push(P(nx, ny));      
    }
  }
}

int main(){

  while(cin >> H >> W >> d >> n){
    init();
    
    int sx, sy;

    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> field[i][j];
	if(field[i][j] == 'D') sx = j, sy = i;
	if(field[i][j] == '#') used[i][j] = false;	
      }
    }
    
    bfs(sx, sy);
    
    r.resize(d);
    
    for(int i = 0 ; i < d ; i++) cin >> r[i];
    
    int x, y, s;
    while(n--){
      cin >> x >> y >> s;      
      dowsing(x, y, s);
    }
    
    bool f1, f2, f3;
    f1 = f2 = f3 = false;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(used[i][j]) f1 = true;
	if(used[i][j] && walk[i][j]) f2 = true;
	if(used[i][j] && !walk[i][j]) f3 = true;
      }
    }
    
    if(!f1) cout << "Broken" << endl;
    else if(f2 && f3) cout << "Unknown" << endl;
    else if(f2) cout << "Yes" << endl;
    else cout << "No" << endl;    
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
//#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double

#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
int32_t main()
{
io

int n;
cin>>n;
cout<<ceil(n/1000.0)*1000-n<<endl;

}


Measured memory_bytes: 3740
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

int n, m, v, p;
vector<long long> a;
vector<long long> sa;

long long GetSum(int l, int r)
{
    return l == 0 ? sa[r] : sa[r] - sa[l - 1];
}

long long GetMin(int l, int r, int w)
{
    assert(l <= r);
    assert(w <= (r - l + 1));
    if (w <= 0) {
        return a[r];
    }
    long long result = m + a[r];
    for (int i = l; i <= r; ++i) {
        long long lower = a[r];
        long long upper = m + a[i];
        if (i > l) {
            lower = max(lower, m + a[i - 1]);
        }
        long long w2 = w - (i - l);
        if (w2 > 0) {
            long long c = r - i + 1;
            long long value = w2 * m + GetSum(i, r);
            long long newLower = value / c;
            if (newLower * c < value) {
                ++newLower;
            }
            lower = max(lower, newLower);
        }
        if (lower <= upper) {
            result = min(result, lower);
        }
    }
    return result;
}

bool Check(int pos)
{
    if (pos >= n - p) {
        return true;
    }
    int l = pos + 1;
    int r = n - p;
    int w = (v - 1) - (p - 1) - pos;
    auto mx = GetMin(l, r, w);
    return a[pos] + m >= mx;
}

void Solve()
{
    sort(a.begin(), a.end());
    sa.assign(n, 0);
    sa[0] = a[0];
    for (int i = 1; i < n; ++i) {
        sa[i] = sa[i - 1] + a[i];
    }
    int l = 0;
    int r = n - 1;
    int result = 0;
    while (l <= r) {
        int middle = (l + r) >> 1;

        if (Check(middle)) {
            result = n - middle;
            r = middle - 1;
        } else {
            l = middle + 1;
        }
    }
    cout << result << endl;
}

bool Read()
{
    if (!(cin >> n >> m >> v >> p)) {
        return false;
    }
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    return true;
}

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

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

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    ll K;
    cin >> K;
    
    vl A(N);
    in(N,A);
    
    ll L = 0;
    rep(i,N) L += A[i];
    
    L = (L+K)/(K+1);
    
    pq2<pair<ll,pair<ll,int>>> B;
    //cout << L << endl;
    rep(i,N){
        ll aa = (A[i]+L-1)/L;
        ll b = (A[i]+aa-1)/aa;
        B.push({b,{A[i],aa}});
        K -= aa-1;
        //cout << b csp aa << endl;
    }
    
    rep(i,K){
        
        auto p = B.top();
        B.pop();
        p.se.se++;
        p.fi = (p.se.fi+p.se.se-1)/p.se.se;
        
    }
    
    cout << B.top().fi << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 11028
N = int(input())
jobs = []

for _ in range(N):
    job = list(map(int, input().split()))
    job.reverse()
    jobs.append(job)

jobs.sort()


sum_v = 0

for job in jobs:
    sum_v += job[1]
    if sum_v > job[0]:
        print("No")
        exit()
    
print("Yes")

Measured memory_bytes: 51168
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Dec  8 00:41:33 2018
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	if N%K == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <bits/stdc++.h>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
 
ll pw[18];
int *c, *c0;
 
void init()
{
    pw[0] = 1;
    rep(i, 1, 18)
        pw[i] = pw[i - 1] * 10;
    c = new int[19];
    c += 9;
    rep(i, -9, 9 + 1)
        c[i] = 0;
    rep(i, 0, 10)
        rep(j, 0, 10)
            c[i - j]++;
    c0 = new int[19];
    c0 += 9;
    rep(i, -9, 9 + 1)
        c0[i] = 0;
    rep(i, 0, 10)
        rep(j, 1, 10)
            c0[i - j]++;
}
 
ll D;
ll ans = 0;
 
void solve(int len, int pos, ll sum, ll cnt)
{
    ll mmm = 0;
    rep(i, pos, len / 2)
        mmm += 9 * (pw[len - i - 1] - pw[i]);
    if (abs(D - sum) > mmm)
        return;
    if (pos == len / 2)
    {
        if (sum == D)
        {
            if (len & 1)
                cnt *= 10;
            ans += cnt;
        }
        return;
    }
    if (pos == 0)
    {
        rep(i, -9, 9)
            solve(len, pos + 1, sum + i * (pw[len - pos - 1] - pw[pos]), cnt * c0[i]);
    }
    else
    {
        rep(i, -9, 9 + 1)
            solve(len, pos + 1, sum + i * (pw[len - pos - 1] - pw[pos]), cnt * c[i]);
    }
}
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    init();
    cin >> D;
    rep(len, 1, 18 + 1)
        solve(len, 0, 0, 1);
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if((a * b) % 2 == 0) cout << "Even" << endl;
    if((a * b) % 2 != 0) cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < 1 || a>9 || b < 1 || b>9) {
        cout << -1 << endl;
    }
    else {
        cout << a * b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define pp pair<int,int>
#define all(x) x.begin(),x.end()
#define pb push_back
#define forx(i,x) for(int i=0;i<x;i++)
#define int long long
using namespace std;
main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int t,a;
	cin>>t>>a;
	vi h(n);
	for(auto &x:h) cin>>x;
	vector<int> tem;
	for(auto &x:h)
	{
		tem.pb(t*1000-x*6);
	}
	int ind=-1;
	int ans=10000000000;
	int i=0;
	for(auto &x:tem)
	{
	//	cout<<x<<endl;
		if(abs(x-a*1000)<ans)
		{
			ans=abs(x-a*1000);
			ind=i;
			
		}
		i++;
	}
	cout<<ind+1<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll inf=0x3f3f3f3f;
const ld pi=acos(-1.0);
ll n,k,num[maxn],b,c;
void run(){
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>k;
        num[k]++;
        ans+=k;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>c;
        ans-=num[b]*b;
        ans+=num[b]*c;
        num[c]+=num[b];
        num[b]=0;
        cout<<ans<<'\n';
    }

}

int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}


Measured memory_bytes: 4432
from collections import deque
d = deque(range(1,10))
k = int(input())

for _ in range(k):
    ans = d.popleft()
    mod = ans % 10
    if mod != 0:
        d.append(ans * 10 + mod - 1)
    d.append(ans * 10 + mod)
    if mod != 9:
        d.append(ans * 10 + mod + 1)

print(ans)

Measured memory_bytes: 74676
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,ww;
    cin >> n >> ww;
    vector<int64> w(n);
    vector<int64> v(n);
    for (int i=0; i<n; i++) cin >> w[i] >> v[i];

    int64 v_max = -1;
    for (int i=0; i<n; i++) v_max = max(v_max, v[i]);
    v_max *= n;

    vector<int64> dp(v_max+1, INT_MAX);
    dp[0] = 0;

    for (int i=0; i<n; i++) {
        for (int j=v_max; j-v[i]>=0; j--) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }

    int ans = INT_MAX;
    for (int i=0; i<=v_max; i++) {
        if (dp[i] <= ww) ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
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 = Integer.parseInt(sc.nextLine());
		int[] h = Arrays.stream(sc.nextLine().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
		int[] dp = new int[N];

		dp[1] = Math.abs(h[1] - h[0]);
		for (int i = 2; i < N; i++) {
			dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + dp[i - 1], Math.abs(h[i] - h[i - 2]) + dp[i - 2]);
		}
		System.out.println(dp[N - 1]);
	}
}

Measured memory_bytes: 44060
#include <iostream>
#include <vector>

using namespace std;

struct Info
{
	int index;
    int number;

    Info(int inputted_index, int inputted_number)
    {
        index = inputted_index;
        number = inputted_number;
    }
    bool operator<(const Info &another) const
    {
        return number < another.number;
    };
};

int main(void)
{
	int N, tmp;

	cin >> N;

    vector<Info> info;
	for(int i=0; i<N; i++){
		cin >> tmp;
		info.push_back(Info(i, tmp));
	}

    sort(info.begin(), info.end());

	for(int i=0; i<N; i++){
		cout << info[i].index + 1 << " ";
	}
	putchar('\n');

    return 0;
}


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

int main(){
    int A; cin>>A;
    vector<int> Ni(A+1,0);
    Ni[0]=1;
    Ni[1]=1;
    for(int i=2;i<=A;i++){
        Ni[i]=Ni[i-1]+Ni[i-2];
    }
    cout<<Ni[A]<<endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

vector<ll> v;
void dfs(ll a) {
	if (a > (ll)3234566667)return;
	if (a == 0) {
		REPO(i, 9)dfs(i);
	}
	else {
		v.push_back(a);
		FOR(i, -1, 2) {
			ll x = a % 10 + i;
			if (x < 0 or x > 9)continue;
			dfs(a * 10 + x);
		}
	}
}

int main() {
	ll n;
	dfs(0);
	cin >> n;
	sort(ALL(v));
	cout << v[n - 1] << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int main()
{
	LL d=read(),t=read(),s=read();
	if(t*s>=d)puts("Yes");
	else puts("No");
	return 0;
}
/*

*/


Measured memory_bytes: 3628
from collections import defaultdict

n = int(input())
S = [input() for i in range(n)]

a = [2500] * 26

for s in S:
    c = defaultdict(int)
    for i in range(len(s)):
        c[s[i]] += 1
    for i in range(26):
        a[i] = min(a[i], c[chr(97 + i)])

ans = ''
for i in range(26):
    ans += chr(97 + i) * a[i]
print(ans)


Measured memory_bytes: 3444
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(test) printf(test ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

#include <stdio.h>
#include <algorithm>
//#include <vector>

using namespace std;


int main() {

	int a, b, h;
	scanf("%d%d%d", &a, &b, &h);
	printf("%d\n", (a + b) * h / 2);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <unordered_map>
#include <cstring>
#include <vector>

using namespace std ;

#define int long long 
#define endl "\n" 

const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ; 

int tree[N] , a[N] , h[N]  ;
int n ; 

void update(int ind , int val )
{
      while( ind < N ) 
      {
         tree[ind] = max(tree[ind],val) ;
         ind += (ind & -ind ) ;
      }
}

int Max(int ind )
{
     int ans = 0 ; 
     while(ind > 0 )
     {
          ans = max(tree[ind],ans) ;
          ind -= (ind & -ind ) ;
     }
     return ans ;
}


int32_t main()
{
    /* #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin) ;
     freopen("output.txt","w",stdout) ;
     #endif */

     cin >> n ;
     for( int i = 0 ; i < n ; i++ ) cin >> h[i] ;
     for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
     int ans = 0 ;
     for(int i = 0 ; i < n ; i++ )
     {
         int prevMax = Max(h[i]-1) ;
         prevMax += a[i] ;
         update(h[i],prevMax) ;
         ans = max(prevMax,ans) ;
     }
     cout<<ans<<endl;

}


Measured memory_bytes: 4992
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())


h,w = readInts()
dist = [['0'] * w for _ in range(h)]
maze = [input() for _ in range(h)]
dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]

def bfs(y,x):
    dist[y][x] = '#'
    for i in range(8):
        nx = x + dx[i]
        ny = y + dy[i]
        if not(0 <= nx < w and 0 <= ny < h):
            continue
        if maze[ny][nx] == '#':
            continue
        dist[ny][nx] = str(int(dist[ny][nx]) + 1)


for y in range(h):
    for x in range(w):
        if maze[y][x] == '#':
            bfs(y,x)
for i in range(h):
    print("".join(dist[i]),sep = '')


Measured memory_bytes: 10164
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  char a,b; 
  cin >> a >> b;
  if(a<b){cout << "<" <<endl;}
  else if(a>b){cout << ">" <<endl;}
  else if(a=b){cout << "=" <<endl;}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll int
#define pp pair<ll,ll>
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll t = 1, n;
const ll inf = hell, N=200005;
inline ll mult(ll x,ll y){return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
vector<ll> dp(N,0), stsz(N,0), fact(N,0), inv(N,0), adj[N], ans(N,0);
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
inline ll invMod(ll x){
	return powMod(x,hell-2);
}
void dfs(ll node,ll par){
	stsz[node]=1;
	dp[node]=1;
	for(auto x : adj[node])
		if(x!=par){
			dfs(x,node);
			stsz[node]+=stsz[x];
			dp[node]=mult(dp[node],mult(dp[x],inv[stsz[x]]));
		}
	dp[node]=mult(dp[node],fact[stsz[node]-1]);
	//cout<<"node: "<<node<<" dp: "<<dp[node]<<"\n";
}
void go(ll node,ll par){
	ll parDp=1, tmp=dp[node];
	if(par){
		parDp=mult(dp[par],mult(fact[stsz[node]],mult(invMod(dp[node]),mult(fact[n-stsz[node]-1],inv[n-1]))));
		dp[node]=mult(dp[node],mult(parDp,mult(inv[n-stsz[node]],mult(fact[n-1],inv[stsz[node]-1]))));
	}
	ans[node]=dp[node];
	for(auto x : adj[node])
		if(x!=par)
			go(x,node);
	dp[node]=tmp;
}
void solve(){
	ll x, y;
	cin>>n;
	rep(i,1,n){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1,0);
	go(1,0);
	rep(i,1,n+1)cout<<ans[i]<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0]=1;
    rep(i,1,N)fact[i]=mult(fact[i-1],i);
    inv[N-1]=invMod(fact[N-1]);
    for(ll i=N-2;i>=0;i--)
    	inv[i]=mult(inv[i+1],i+1);
//    cin >> t;
    while(t--){
        solve();
    }
    return 0 ;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001


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

    string str;
    cin >> str;
    int n = str.size();
    if (str[0] == '0' || str[n - 1] == '1') {
        cout << "-1" << endl;
        return 0;
    }
    for (int i = 1; i < n - 1; i++) {
        if (str[i] != str[n - i - 2]) {
            //cout << "what going on" << i << endl;
            cout << "-1" << endl;
            return 0;
        }
    }
    int s = 0;
    cout << "1 2" << endl;
    for (int i = 1; i < n - 1; i++) {
        cout << s + 1 << " " << i + 2 << endl;
        if (str[i] == '1') {
            s = i + 1;
        }
    }

    return 0;
}


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

// all triplets - all odd triplets

int main() {
	int N, odd = 1;;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp % 2 == 0) {
			odd *= 2;
		} else {
			odd *= 1;
		}
	}
	int ans = pow(3, N);
	cout << ans - odd << endl;
}


Measured memory_bytes: 512
#include<stdio.h>

#define MAX 100000

void partition(int *,int,int);

int main()
{
  int n,A[MAX],i,s;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&A[i]);
    }

  s = A[n-1];

  partition(A,0,n-1);

  for(i = 0 ; i < n ; i++)
    {
      if(A[i] == s && A[i] < A[i+1])
	{
	  printf("[%d]",A[i]);
	}
      else
	{
	  printf("%d",A[i]);
	}
      if(i < n-1) printf(" ");
    }

  printf("\n");
  
  return 0;
}

void partition(int *A,int p,int r)
{
  int x,i,j,change;

  x = A[r];

  i = p-1;

  for(j = p ; j < r ; j++)
    {
      if(A[j] <= x)
	{
	  i++;
	  change = A[i];
	  A[i] = A[j];
	  A[j] = change;
	}
    }
  change = A[i+1];
  A[i+1] = A[r];
  A[r] = change;

  return;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int n,x,dep[2222],lf[2222],val[2222],pa[2222],cnt,ans[44444],ts[2222],cnp,nw,mx,mxi;
bool banned[2222],can[2222];
int used[2222],usedp[2222];
vector<int> g[2222];
void Init(int i,int fa)
{
	pa[i]=fa;dep[i]=dep[fa]+1;
	for (int j=0;j<g[i].size();j++)
	{
		Init(g[i][j],i);
	}
}
void dfs(int i)
{
	int cnt=0,pv;
	for (int j=0;j<g[i].size();j++)
	{
		int to=g[i][j];
		if (banned[to]) continue;
		cnt++;pv=to;
		dfs(to);
	}
	if (cnt>1) return;
	if (cnt==1 && !can[pv]) return;
	can[i]=1;
	if (!cnt) lf[i]=i;
	else lf[i]=lf[pv];
}
void push(int v)
{
	ans[++cnt]=v;
	int p=v;
	memcpy(ts,val,sizeof(val));
	memcpy(usedp,used,sizeof(used));
	while(1)
	{
		if (!p) 
		{
			ts[v]=val[p];
			usedp[v]=used[p];
			break;
		}
		ts[pa[p]]=val[p];
		usedp[pa[p]]=used[p];
		p=pa[p];
	}
	memcpy(val,ts,sizeof(ts));
	memcpy(used,usedp,sizeof(usedp));
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d",&x);
		g[x].push_back(i); 
	}
	for (int i=0;i<n;i++) scanf("%d",&val[i]);
	Init(0,-1);
	while(!banned[0])
	{
		memset(can,0,sizeof(can));
		dfs(0);
		cnp=0;
		for (int i=0;i<n;i++) 
		{
			if (can[i]) cnp++;
		}
		memset(used,0,sizeof(used));
		nw=0;
		while(nw<cnp)
		{
			if (can[val[0]])
			{
				x=lf[val[0]];
				while(1)
				{
					if (used[x]!=1) break;
					if (val[x]<val[0]) break;
					x=pa[x];
				}
				push(x);
				used[x]=1;
				nw++;
			}
			else
			{
				mx=0;
				for (int i=0;i<n;i++)
				{
					if (banned[i] || used[i]) continue;
					if (dep[i]>mx)
					{
						mx=dep[i];
						mxi=i;
					}
				}
				push(mxi);
				used[mxi]=2;
			}
		}
		for (int i=0;i<n;i++) 
		{
			if (can[i]) banned[i]=1;
		}
	}
	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>

#define MAP_COLUMNS (20+3) // \r\n\0

//#define dprintf(arg1, ... ) printf( arg1, __VA_ARGS__)
#define dprintf(arg1, ... ) 

void proc( int width, int height, char map[][MAP_COLUMNS], int x, int y );

inline void docheck( int width, int height, char map[][MAP_COLUMNS], int x, int y ) {
	if ( x<0 || x >= width || y<0 || y >= height ) {
		//invalid
		return;
	}
	dprintf("x=%d y=%d  map[y][x]=%c\n",x,y,map[y][x]);
	if ( map[y][x] != '.' ) { return; }
	
	map[y][x] = '@';
	proc(width, height, map, x, y);
}

void proc( int width, int height, char map[][MAP_COLUMNS], int x, int y ) {

	//Left
	docheck(width, height, map, x-1, y);
	
	//Right
	docheck(width, height, map, x+1, y);
	
	//Up
	docheck(width, height, map, x, y-1);
	
	//Down
	docheck(width, height, map, x, y+1);
}

int main(void) {

	char map[20][MAP_COLUMNS];
	
	while (1) {
		int width, height;
		scanf("%d %d\n", &width, &height);
		if ( width==0 && height==0 ) { break; }
		
		memset( map, 0, sizeof(char) * 20 * MAP_COLUMNS );
		
		int startx=-1, starty=-1;
		for ( int i=0; i<height; i++ ) {
			fgets(map[i], MAP_COLUMNS, stdin);
			char* pos = strchr( map[i], '@' );
			if ( pos != NULL ) {
				startx = pos - map[i];
				starty = i;
			}
		}
		dprintf("%d %d\n",startx,starty);
		proc(width, height, map, startx, starty);
		
		int count=0;
		for ( int i=0; i< 20 * MAP_COLUMNS ; i++ ) {
			if( map[0][i] == '@' ) {
				count++;
			}
		}
		printf("%d\n",count);
	}
		
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int count = 0;
		int M = sc.nextInt();

		int L[] = new int[M];
		int R[] = new int[M];

		int maxL = 1;
		int minR = 100000;

		for (int j = 0; j < M; j++) {
			L[j] = sc.nextInt();
			R[j] = sc.nextInt();

			if (maxL <= L[j]) {
				maxL = L[j];
			}

			if (minR >= R[j]) {
				minR = R[j];
			}

		}

		for (int i = 1; i <= N; i++) {
			if (maxL <= i && i <= minR) {
				count++;
			}
		}

		System.out.print(count);
	}
}

Measured memory_bytes: 66012
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            p.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(p);

        long min = 0;
        for (int i = 0; i < K; i++) {
            min += p.get(i);
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 38876
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool isPrim[100005];
vector<int> p;

void primCheck(int v)
{
	v++;
	REP(i, v)
	{
		isPrim[i] = true;
	}
	isPrim[0] = isPrim[1] = false;
	p.clear();
	REP(i, v)
	{
		if (!isPrim[i])continue;
		p.push_back(i);
		for (int j = i * 2; j < v; j += i)
		{
			isPrim[j] = false;
		}
	}
}

int main()
{
	int N;
	cin >> N;
	primCheck(100000);

	cout << N << ":";
	int index = 0;
	while (index < p.size() &&p[index] <= N)
	{
		if (N%p[index] == 0)
		{
			cout << " " << p[index];
			N /= p[index];
			continue;
		}
		index++;
	}
	if (N != 1)
	{
		cout << " " << N;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

# define MAX_N 1000010 // 10^6 + 10

// UnionFindTree
// 使い方(インスタンス名 : tree)
// インスタンス生成 : UnionFind tree;
// tree.init(要素数)
// uniteしたりsameかどうか判定したり

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int size[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
                size[i] = 1;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
                size[y] += size[x];
            }
            else{
                par_[y] = x;
                groups_--;
                size[x] += size[y];
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
        // 6 / 19 Updated!! (連結成分のサイズを返す)
        int sizeOf(int x){
            return size[rootOf(x)];
        }
};

int main(void){
    int n, m;
    cin >> n >> m;
    UnionFind tree;
    tree.init(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, tree.sizeOf(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	long long n,ans;
	
	cin >> n;

	for (long long i = n;; i++)
	{
		bool flag = false;
		for (long long j = 2; j < i; j++)
		{
			if (i % j == 0)
			{
				flag = true;
				break;
			}
			if (j > 2)
				j++;
		}
		if (flag)
			continue;
		else
		{
			ans = i;
			break;
		}
	}


	cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int main() {
	ll N;
	cin >> N;
	if (N % 2 == 0) { cout << N; }
	else { cout << 2 * N; }
	
	system("PAUSE");
}

Measured memory_bytes: 504
using System;

namespace PrimeNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int i;
                var s = Console.ReadLine();
                if (s == null || s == "")
                {
                    break;
                }
                int count = 0;
                int n = int.Parse(s);
                for (i = 2; i <= n; i++)
                {
                    if (i == 2)
                    {
                        count++;
                        continue;
                    }
                    else if (i < 2 || i % 2 == 0)
                    {
                        continue;
                    }
                    else
                    {
                        int y = 3;
                        bool flag = true;
                        double x = Math.Sqrt(i);
                        while (y <= x)
                        {
                            if (i % y == 0)
                            {
                                flag = false;
                                break;
                            }
                            y += 2;
                            
                        }
                        if (flag)
                        {
                            count++;
                        }

                    }

                }
                Console.WriteLine(count);

            }
        }
    }
}



Measured memory_bytes: 9136
#include<stdio.h>
int main()
{
  int a[10000];
  int i,j;
  for(i=0;;i++)
  {
    scanf("%d",&a[i]);
    if(a[i]==0)
    {
      break;
    }
  }

  for(j=0;j<i;j++)
    printf("Case %d: %d\n",j+1,a[j]);
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

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

    int x;
    cin >> x;
    
    set<int> st;
    st.insert(1);

    for(int i = 2; i <= x; i++){
        int tmp = i;
        while(true){
            tmp *= i;
            if(tmp > x) break;
            st.insert(tmp);
        }
    }
    vector<int> A;
    for(auto x : st) A.push_back(x);
    sort(A.begin(), A.end());
    cout << A[A.size() - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
open System

let a = stdin.ReadLine() |> int
let b = []
let list  = [|0; 0; 0; 0|]

for i=1 to a do
    let b = stdin.ReadLine()
    match b with
    | "AC" -> (list.[0] <- list.[0] + 1)
    | "WA" -> (list.[1] <- list.[1] + 1)
    | "TLE" -> (list.[2] <- list.[2] + 1)
    | "RE" -> (list.[3] <- list.[3] + 1)

for i=1 to 4 do
    match i with
    | 1 -> list.[i-1] |> printf "AC x %d\n"
    | 2 -> list.[i-1] |> printf "WA x %d\n"
    | 3 -> list.[i-1] |> printf "TLE x %d\n"
    | 4 -> list.[i-1] |> printf "RE x %d\n"



Measured memory_bytes: 33128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

ll comb(ll l, ll k) {
	if (l < k) return 0;
	if (k == 0) return 1;
	if (k == 1) return l;
	if (k == 2) return l*(l-1)/2;
	if (k == 3) return l*(l-1)*(l-2)/6;
	return 0;
}

int main(){	
	string N;
	long long K;
	cin >> N;
	scanf("%lld",&K);
	ll nine[4];
	nine[0] = 1;
	nine[1] = 9;
	nine[2] = 81;
	nine[3] = 729;

	ll len = N.length();
	// if (len < K) cout << "0" << endl;
	ll res = 0;
	rep(i, len) {
		ll a = N[i]-'0';
		if (a > 0 && K > 0) {
			res += (a-1)*comb(len-1-i, K-1)*nine[K-1]+comb(len-1-i, K)*nine[K];
			K--;
		}
	}
	if (K == 0) res++;
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, d;
int x, y;

signed main() {
	int i;
	
	cin >> n >> d;
	
	int ans = 0;
	rep(i, n) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  ///////////////////////
  bool ans=true;
  int M=0;
  rep(i,n){
     M=max(h[i],M);
    if(M-h[i]>=2) {
       //cout<<i<<endl;
        ans=false;
        break;  
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}




 





Measured memory_bytes: 640
#include<vector>
#include<iostream>

using namespace std;

int main(){
    int n; 
    cin>>n;
    string s;
    cin>>s;
    for( int i =0; i < s.size(); i++)
    {
        int temp = s[i] - 65;
        temp = (temp + n ) %26;
        temp += 65;
        s[i] = temp;
    }
    cout<<s;


  

    return 0;
}

Measured memory_bytes: 256
n, x = gets.chomp.split.map(&:to_i)
xs = gets.chomp.split.map(&:to_i)

ans = 0

for i in 0...(n-1)
    a, b = xs[i], xs[i+1]
    d = a + b - x
    if d > 0
        ans += d
        xs[i+1] = [0, xs[i+1] - d].max
    end
end

p ans


Measured memory_bytes: 12300
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def std_in():
    return sys.stdin.readline().strip()


def main():
    n = int(std_in())
    a = list(get_ints())
    a.append(0)
    m = 1000
    k = 0

    for i in range(n):
        if i == n:
            break
        if a[i] > a[i+1]:
            m += k * a[i]
            k = 0
        elif a[i] < a[i+1]:
            q, mod = divmod(m, a[i])
            k += q
            m = mod
    print(m)


if __name__ == "__main__":
    main()


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	long long n;
	cin >> n;
	vector<long long> v(n-1);
	for (auto &i : v) cin >> i;
	vector<long long> ans(n);
	for (auto i : v) ans[i-1]++;
	for (auto i : ans) cout << i << "\n";
	return 0;
}

Measured memory_bytes: 6352
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public class Item
        {
            public int X { get; set; }
            public int Y { get; set; }
        }
        
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var towns = new List<Item>();
            for (int i = 0; i < N; i++)
            {
                var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
                var x = items[0];
                var y = items[1];
                towns.Add(new Item { X = x, Y = y});
            }

            var perm = new Permutation().Enumerate(towns);
            List<double> distances = new List<double>();
            foreach(var pattern in perm)
            {
                double distance = 0;
                for (int i = 1; i < pattern.Count(); i++)
                {
                    distance += Math.Sqrt(Math.Pow(pattern[i - 1].X - pattern[i].X, 2) + Math.Pow((pattern[i - 1].Y - pattern[i].Y), 2));
                }

                distances.Add(distance);
            }

            var answer = distances.Average();
            Console.WriteLine(answer);
        }

        public class Permutation {
            public IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items)
            {
                if (items.Count() == 1)
                {
                    yield return new T[] { items.First() };
                    yield break;
                }
                foreach (var item in items)
                {
                    var leftside = new T[] { item };
                    var unused = items.Except(leftside);
                    foreach (var rightside in Enumerate(unused))
                    {
                        yield return leftside.Concat(rightside).ToArray();
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 21976
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

s = np.cumsum(p)
# print(p, s)

m = []


def partsum(s, x):
    global K
    if x == K - 1:
        return s[x]
    return s[x] - s[x - K]


for i in range(K - 1, N):
    m.append(partsum(s, i))
# print(m)

idx = m.index(max(m))
# print(idx)

ans = 0
for j in range(idx, idx + K):
    ans += (p[j] + 1) / 2
print(ans)


Measured memory_bytes: 33988
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> a(N * 3);
  rep(i, 0, N * 3) { cin >> a[i]; }

  // first->sum, second->pq
  pair<int, priority_queue<int, vector<int>, greater<int>>> p;
  pair<int, priority_queue<int, vector<int>, less<int>>> q;

  vector<int> b(N + 1), c(N + 1);

  rep(i, 0, N) {
    p.first += a[i];
    p.second.push(a[i]);
  }
  b[0] = p.first;
  rep(i, 0, N) {
    p.first += a[N + i];
    p.second.push(a[N + i]);
    int x = p.second.top();
    p.second.pop();
    p.first -= x;
    b[i + 1] = p.first;
  }
  rep(i, 2 * N, 3 * N) {
    q.first += a[i];
    q.second.push(a[i]);
  }
  c[N] = q.first;
  rep(i, 0, N) {
    q.first += a[2 * N - 1 - i];
    q.second.push(a[2 * N - 1 - i]);
    int x = q.second.top();
    q.second.pop();
    q.first -= x;
    c[N - 1 - i] = q.first;
  }
  dump(b, c);
  int ans = -INF;
  rep(i, 0, N + 1) chmax(ans, b[i] - c[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6516