akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

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

#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, x; in(N); in(x);

  if (x == 1 || x == 2 * N - 1) {
    out("No");
    return 0;
  }
  out("Yes");
  if (x <= N) {
    rep(i, N-1) {
      out(2*N-1-i);
    }
    out(x);
    rep(i, 1, N+1) {
      if (i == x)
        continue;
      out(i);
    }
  } else {
    rep(i, N, 2 * N) {
      if (i == x)
        continue;
      out(i);
    }
    out(x);
    rep(i, 1, N) {
      out(i);
    }
  }
  return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = INF;
    rep(i, N) {
        int Y = A[i];
        vector<vector<int>> seqs;
        vector<int> tmp;
        rep(j, N) {
            if (A[j] < Y) {
                if (tmp.size()) {
                    seqs.push_back(tmp);
                    tmp.clear();
                }
            } else {
                tmp.push_back(A[j]);
            }
        }
        if (tmp.size()) {
            seqs.push_back(tmp);
            tmp.clear();
        }

        priority_queue<int, vector<int>, greater<int>> P;
        for (auto seq : seqs) {
            sort(seq.begin(), seq.end());
            for (int j=0; j<(int)seq.size() - K + 1; j++) {
                P.push(seq[j]);
            }
        }

        if (P.size() < Q) continue;
        for (int j=0; j<Q-1; j++) P.pop();
        ans = min(ans, P.top() - Y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

class UnionFind:
    def __init__(self, n):
        # 負 : 根である．絶対値はランク
        # 正 : 根じゃない．値は親の番号
        self.root_table = [-1] * n
        # 自分の下に何個あるか(自分含む)
        self.count_table =  [1] * n
 
    def get_root(self, x):
        if self.root_table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.root_table[x] = self.get_root(self.root_table[x])
            return self.root_table[x]
 
    def find(self, x, y):
        return self.get_root(x) == self.get_root(y)
 
    def union(self, x, y):
        r1 = self.get_root(x)
        r2 = self.get_root(y)
        if r1 == r2:
            return

        # ランクの取得
        d1 = self.root_table[r1]
        d2 = self.root_table[r2]
        # 値が小さいほど深い木である(絶対値が大きい)
        if d1 <= d2:
            self.root_table[r2] = r1
            self.count_table[r1] += self.count_table[r2]
            # 深さが同じ時はランクが増える
            if d1 == d2:
                self.root_table[r1] -= 1
        else:
            self.root_table[r1] = r2
            self.count_table[r2] += self.count_table[r1]
        
    def count(self, x):
        return self.count_table[self.get_root(x)]


N, M, K = MI()
AB = LRI(M)
CD = LRI(K)

uf = UnionFind(N + 1)
friend = [0] * (N + 1)

for ab in AB:
    a, b = ab

    friend[a] -= 1
    friend[b] -= 1

    uf.union(a, b)

for cd in CD:
    c, d = cd

    if uf.find(c, d):
        friend[c] -= 1
        friend[d] -= 1

for i in range(1, N + 1):
    friend[i] += (uf.count(i) - 1)

print(*friend[1:])


Measured memory_bytes: 118748
#include <iostream>
#include <cstring>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1000000007LL
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define fir first
#define pb push_back
#define pi pair<int,int>
#define sec second
#define sz size()
#define vi vector<int>

int h,w,S,u[40][40],s[40][40];
pi dp[40][40][40][40];

int sum(int y1,int x1,int y2,int x2){
	return s[y2+1][x2+1]-s[y1][x2+1]-s[y2+1][x1]+s[y1][x1];
}

pi f(int y1,int x1,int y2,int x2){
	pi& res=dp[y1][x1][y2][x2];
	if(res.fir!=-1)return res;
	int mysum=0;//=sum(y1,x1,y2,x2);
	rep2(i,y1,y2+1)rep2(j,x1,x2+1)mysum+=u[i][j];
	if(mysum<S)return res=pi(-INF,0);
	res=pi(1,mysum-S);
	rep2(i,y1,y2){
		pi p=f(y1,x1,i,x2),q=f(i+1,x1,y2,x2);
		pi r=pi(p.fir+q.fir,min(p.sec,q.sec));
		res=max(res,r);
	}
	rep2(j,x1,x2){
		pi p=f(y1,x1,y2,j),q=f(y1,j+1,y2,x2);
		pi r=pi(p.fir+q.fir,min(p.sec,q.sec));
		res=max(res,r);
	}
	return res;
}

int main(){
	while(cin>>h>>w>>S && h){
		rep(i,h)rep(j,w)cin>>u[i][j];
		rep2(i,1,h+1)rep2(j,1,w+1){
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+u[i-1][j-1];
		}
		S=s[h][w]-S;
		rep(i,40)rep(j,40)rep(k,40)rep(l,40)dp[i][j][k][l]=pi(-1,0);
		pi ans=f(0,0,h-1,w-1);
		cout<<ans.fir<<" "<<ans.sec<<endl;
	}
}

Measured memory_bytes: 20000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );

		Scanner sc = new Scanner(System.in);

//		int n = Integer.parseInt(br.readLine());
		int n = sc.nextInt();

//		String[] A = br.readLine().split(" ");
		int[] A = new int[n];
		for (int i=0; i < n; i++) {
			A[i] = sc.nextInt();
		}

		sc.close();

//		int[] A = new int[n+1]; // 1 origin array
//		for (int i=1; i <= n ; i++) {
//			A[i] = Integer.parseInt(data[i-1]);
//		}

		int k = 10_000; // Constraints

		int[] B = new int[n+1];
//		countingsort(A, B, k);

		int[] C = new int[k+1];

		for (int j=0; j < n; j++) {
//			C[ Integer.parseInt(A[j]) ]++;
			C[ A[j] ]++;
		}

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

		for (int j = n-1; 0 <= j; j--) {
//			B[  C[ Integer.parseInt(A[j]) ]  ] = Integer.parseInt(A[j]);
			B[  C[ A[j] ]  ] = A[j];
//			C[ Integer.parseInt(A[j]) ]--;
			C[ A[j] ]--;
		}

		StringBuilder sb = new StringBuilder();
		for (int i=1; i <= n-1; i++) {
			sb.append(B[i] + " ");
		}
		sb.append(B[n]);
		System.out.println(sb);
	}

//	static void countingsort(int[] src, int[] dest, int range) {
//		int[] counter = new int[range+1];
////		for (int i=0; i <= range; i++) {
////			counter[i] = 0;
////		}
//
//		/** counter[i] ??? i ???????????°????¨?????????? */
//		for (int j=1; j < src.length; j++) {
//			counter[ src[j] ]++;
//		}
//
//		/** counter[i] ??? i ??\????????°???????????°????¨?????????? */
//		for (int i=1; i <= range; i++) {
//			counter[i] += counter[i-1];
//		}
//
//		for (int j = src.length - 1; 1 <= j; j--) {
//			dest[  counter[ src[j] ]  ] = src[j];
//			counter[ src[j] ]--;
//		}
//	}
}

Measured memory_bytes: 578248
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] ts = new int[N];
        for (int i = 0; i < N; i++) {
            ts[i] = sc.nextInt();
        }
        System.out.println( solve(N, T, ts) );
    }

    private static long solve(int N, int T, int[] ts) {
        long ans = 0;
        for (int i = 1; i < N; i++) {
            int prev = ts[i-1];
            int t = ts[i];

            ans += Math.min(T, t - prev);
        }

        ans += T;

        return ans;
    }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += i + 1;
  }
  cout << ans << '\n';
  return 0;
}

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


const int mod = 1e9 + 7;
int memo[10005][105];

int rec(int n, int su, int rem){
    if(memo[n][su] != -1) return memo[n][su];
    int ans = 0;
    if(not n){
        ans = (su%rem)?0:1;
    }
    else{
        for(int j = 0;j < 10;++j)
            ans = (ans + rec(n - 1, (su + j) % rem, rem)) % mod;
    }
    return memo[n][su] = ans;
}



signed main(){

    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    memset(memo, -1, sizeof(memo));
    

    string l;
    int d, n, curr = 0;
    cin >> l >> d;
    n = l.length();

    int ans = 0;
    for(int i = 0;i < n;++i){
        for(int j = 0;j < l[i] - '0';++j){
            ans = (ans + rec(n - i - 1, (curr + j) % d, d)) % mod;
        }

        curr = (curr + (l[i] - '0')) % d;
    }
    
    ans -= 1;
    if(curr % d == 0) ans += 1;

    cout << (ans + mod) % mod << endl;


}

Measured memory_bytes: 8560
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int c[N][N], a[N*N];

int main() {
	int h,w,n;cin>>h>>w>>n;
	rep(i,n) cin>>a[i];
	int cur=0;
	rep(k,h*w) {
		int i=k/w, j;
		if (i%2==0) j=k%w;
		else j=w-1-k%w;
		if(a[cur]==0) cur++;
		c[i][j]=cur+1;
		a[cur]--;
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j];
			if (j<w-1) cout << ' ';
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
N, M = map(int, input().split())
A = [-1] * N
valid = True
for i in range(M):
  s, c = map(int, input().split())
  if A[s - 1] < 0:
    A[s - 1] = c
  elif A[s - 1] != c:
    valid = False
if A[0] < 0:
  A[0] = 1 if 1 < len(A) else 0
if 1 < len(A) and A[0] < 1:
  valid = False
for i in range(1, N):
  if A[i] < 0:
    A[i] = 0
print(''.join([str(a) for a in A]) if valid else -1)

Measured memory_bytes: 3188
N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(N):
    for j in range(i + 1, N):
        dist_sq = sum((x - y) ** 2 for x, y in zip(X[i], X[j]))
        d = int(dist_sq ** 0.5)
        if dist_sq in (d ** 2, (d + 1) ** 2):
            count += 1
print(count)


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

using namespace std;

int x[4];
int main () {
    bool flag = true;
    for(int i=0; i<3; i++) {
        int a,b;
        cin >> a >> b;
        x[a]++;
        x[b]++;
        if( x[a] == 3 || x[b] == 3 ) flag = false;
    }
    cout << ( flag ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int H, W, D; cin >> H >> W >> D;
    vvi A(H+1, vi(W+1)); REPS(i, H) REPS(j, W) cin >> A[i][j];
    int Q; cin >> Q;
    vp query(Q); REP(i, Q) cin >> query[i].first >> query[i].second;
    vp pos(H*W+1); REPS(i, H) REPS(j, W) pos[A[i][j]] = make_pair(i, j);
    vi cost(H*W+1);
    REPS(i, D)
    {
        P p = pos[i];
        for(int j = i; j <= H*W; j += D)
        {
            cost[j] = cost[max(j-D, 0)] + abs(pos[j].first - p.first) + abs(pos[j].second - p.second);
            p = pos[j];
        }
    }
    REP(i, Q)
    {
        cout << cost[query[i].second] - cost[query[i].first] << endl;
    }
}

Measured memory_bytes: 3328
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include <cstring>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion

int dore(int a,int b,int c){
    
    if(a == max(a,max(b,c))) return 1;
    if(b == max(a,max(b,c))) return 2;
    if(c == max(a,max(b,c))) return 3;
}
int main(){
    int k,s;
    cin >> k >> s;

    int ans = 0;

    REP(i,k+1){
        REP(j,k+1){
            int z = s - i - j;
            if(z >= 0 && k >= z) ans++;
            
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
int main(){
	std::vector<int> cards(5);
	while(scanf("%d,%d,%d,%d,%d",&cards[0],&cards[1],&cards[2],&cards[3],&cards[4])!=EOF){
		int n=0;
		for(int i=0;i<4;i++){
			for(int j=i+1;j<5;j++){
				if(cards[i]==cards[j]){
					n++;
				}
			}
		}
		switch(n){
			case 1:
				std::cout<<"one pair"<<std::endl;
				break;

			case 2:
				std::cout<<"two pair"<<std::endl;
				break;

			case 3:
				std::cout<<"three card"<<std::endl;
				break;

			case 4:
				std::cout<<"full house"<<std::endl;
				break;

			case 6:
				std::cout<<"four card"<<std::endl;
				break;

			default:
				std::sort(cards.begin(),cards.end());
				if(cards[0]==cards[4]-4)std::cout<<"straight"<<std::endl;
				else if(cards[0]==1&&cards[1]==10&&cards[4]==13)std::cout<<"straight"<<std::endl;
				else std::cout<<"null"<<std::endl;
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
    int n;
    double ans;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++) {
        if(i != n -1) ans += s[i];
        else ans += s[i] / 2;
    }
    cout << (int)ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Min(a, b) ((a < b)? a : b)
#define Max(a, b) ((a > b)? a : b)
#define Abs(x) ((x>=0)? x : -x)/*Return the absolute value of x.*/
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i;
	char a[5];
	scanf("%s", a);
	rep(i,3){
		if(a[i] == a[i+1]){
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n;
	cin>>n;
	ll ch[200010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ans=0;
	for(ll i=1;i<n;i++){
		if(ch[i]<ch[i-1]){
			ans+=ch[i-1]-ch[i];
			ch[i]=ch[i-1];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5212
#include <stdio.h>
#define max 100
#define INF 2147483647
#define nil -1
#define true 1
#define white 2
#define gray 3
#define black 4
typedef struct{
  int degree; //出次数を表す。
  int Adj[max]; //隣接リスト(隣接する頂点の番号のリスト)。
  int color;
  int d; //Tに属する頂点とV-Tに属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録。
  int pi; //MST(最小全域木)におけるそれぞれのnodeの親を表す。
} node;
int prim(node *, int);
int n, A[max][max];

int main()
{
  //最小全域木のプログラム
  int i, j, k = 0;
  node node[max];
  
  for(i = 0 ; i < max ; i++) node[i].degree = 0;
  
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d",&A[i][j]); 
      if(A[i][j] != -1){
	node[i].degree++;
	node[i].Adj[k] = j;
	k++; }
    }
    k = 0;
  }
  
  printf("%d\n",prim(node, 0));

  return 0;
}

int prim(node *node, int r)
{
  int i, u, mincost, sum = 0;

  for(i = 0 ; i < n ; i++){ 
    node[i].d = INF;
    node[i].pi = nil;
    node[i].color = white; }

  node[r].d = 0;

  while(true){
    mincost = INF;
    for(i = 0 ; i < n ; i++){
      if(node[i].color != black && node[i].d < mincost){
	mincost = node[i].d;
	u = i; }
    }
    if(mincost == INF) break;
    node[u].color = black;
    for(i = 0 ; i < node[u].degree ; i++){
      if(node[node[u].Adj[i]].color != black && A[u][node[u].Adj[i]] < node[node[u].Adj[i]].d){
	node[node[u].Adj[i]].pi = u;
	node[node[u].Adj[i]].d = A[u][node[u].Adj[i]];
	node[node[u].Adj[i]].color = gray; }
    }
  }

  for(i = 0 ; i < n ; i++){
    if(node[i].pi != nil) sum += A[node[i].pi][i]; }
  
  return sum;
}


Measured memory_bytes: 2052
from collections import deque

def main():
    h, w = map(int, input().split())
    M = [list(input()) for _ in range(h)]
    D = [[10**10] * w for _ in range(h)]
    D[0][0] = 0

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((0, 0))
    while que:
        p = que.popleft()
        if p == (h-1, w-1):
            break
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]
            if 0 <= ny < h and 0 <= nx < w and M[ny][nx] != "#" and D[ny][nx] == 10**10:
                D[ny][nx] = D[p[0]][p[1]] + 1
                que.append((ny, nx))

    if D[h-1][w-1] == 10**10:
        print(-1)
        exit()

    n_white = 0
    for r in M:
        n_white += len([s for s in r if s == "."])
    print(n_white - D[h-1][w-1] - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
#include <stdio.h>

int main(void){
	
	int dataset[6];
	
	int count;
	
	count = 0;
	
	for(int i =1;i<=5;i++){
		
		scanf ("%d",&dataset[i]);
		
		if (dataset[i] == 0){
			
			break;
			
		}
		
		count++;
		
	}
	
	int syuturyoku[6];
	
	for(int k = 1;k<=count;k++){
		
		int l = 1000 - dataset[k];
		
		int m500 = l / 500;
		
		int m100 = (l -(500 * m500)) / 100;
		
		int m50 = (l - ((500 * m500) + (100 * m100))) / 50;
		
		int m10 = (l - ((500 * m500) + (100 * m100) + (50 * m50)))/ 10;
			
		int m5 = (l -  ((500 * m500) + (100 * m100) + (50 * m50) + (10 * m10))) / 5;
		
		int m1 = (l -  ((500 * m500) + (100 * m100) + (50 * m50) + (10 * m10) + (5 * m5))) / 1;
		
		syuturyoku[k] = m500 + m100 + m50 + m10 + m5 +m1;
		
	}
	
	for(int k = 1;k<=count;k++){
		
		printf ("%d\n",syuturyoku[k]);
		
	}
		
	return 0;
		
}


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

int main() {
	int k, s;
	cin >> k >> s;

	int count = 0;

	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if(z <= k && z >= 0){
				count++;
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define M 1000000
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }
 
int find(char str[]){
 
  long long key, i, h;
  key = getKey(str);
  for(i=0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
  }
 
  return 0;
 
}
 
int insert(char str[]){
 
  long long key, i, h;
  key = getKey(str);
 
  for(i=0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }    
  return 0;
 
}
 
int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
  scanf("%d", &n);
     
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
    printf("yes\n");
      } else {
    printf("no\n");
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 16352
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{

    static final FastReader in = new FastReader();
    static final FastWriter out = new FastWriter();

    public static void main(String[] args) throws IOException{
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        int ans = 0;
        for (int i = 0; i < n-2; i++){
            for (int j = i+1; j < n-1; j++){
                for (int k = j+1; k < n; k++){
                    if (a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[i]+a[k]>a[j])&&(i!=j&&j!=k&&i!=k)){
                        //out.pl(i + " " + j + " " + k);
                        ans++;
                    }
                }
            }
        }
        out.pl(ans);
        out.close();
    }
}
class FastReader{
    BufferedReader br;
    StringTokenizer st;
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    }
}
class FastWriter{
    PrintWriter out;
    FastWriter(){
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	out.flush();
    }
    void pl(Object o){
        out.write(o.toString());
	    out.write("\n");
        out.flush();
    }
    void pl(){
        out.write("\n");
    }
    void p(Object o){
        out.write(o.toString());
    }
    void close(){
        out.flush();
        out.close();
    }  
}


Measured memory_bytes: 33468
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	bool ok=true,tmp=false;
	for(int i=1;i<s.size();i++){
		if(!tmp&&s[i]=='C')
			tmp=true;
		else
			ok&=bool(islower(s[i]));
	}
	ok&=s[0]=='A'&&s[1]!='C'&&s[s.size()-1]!='C'&&tmp;
	cout<<(ok?"AC":"WA")<<endl;
}


Measured memory_bytes: 256
class FenwickTree:

    def __init__(self, size):
        self.size = size
        self.array = [0]*size

    def add(self, index, value):
        while index < self.size:
            self.array[index] += value
            index += index&(-index)

    def sum(self, index):
        answer = 0
        while index > 0:
            answer += self.array[index]
            index -= index&(-index)
        return answer

    def rangesum(self, start, end):
        return self.sum(end)-self.sum(start-1)


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().split(' ')))

def read_query():
    l, r = read_ints()
    return l-1, r-1

def solve():
    N, Q = read_ints()
    C = [c-1 for c in read_ints()]
    colour_to_index = [-1]*N
    queries = [read_query() for _ in range(Q)]
    answer = [-1]*Q
    queries_sorted_index = sorted(list(range(Q)), key=lambda i: queries[i][1])
    fenwick_tree = FenwickTree(N+1)
    last_r = -1
    for i in queries_sorted_index:
        l, r = queries[i]
        for j in range(last_r+1, r+1):
            colour = C[j]
            if colour_to_index[colour] != -1:
                fenwick_tree.add(colour_to_index[colour]+1, -1)
            colour_to_index[colour] = j
            fenwick_tree.add(colour_to_index[colour]+1, 1)
        answer[i] = fenwick_tree.rangesum(l+1, r+1)
        last_r = r
    print(*answer, sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 228748
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if j == W-1 and i == H-1:
                    print("#\n")
                elif j == W-1:
                    print("#")
                else:
                    print("#", end="")


Measured memory_bytes: 7044
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(str,input().split()))





N,M=input2()
ps=[]
for _ in range(M):
	ps.append(input_array())
ans_dict={i:False for i in range(N)}
ans_list=[0]*N
wa_list=[0]*N

wa=0


for x in ps:
	num=int(x[0])-1
	ans=x[1]
	if ans_dict[num] ==True:
		continue
	elif ans=="WA" and ans_dict[num]==False:
		wa_list[num]+=1
	elif ans=="AC" and ans_dict[num]==False:
		wa+=wa_list[num]
		ans_dict[num]=True
		ans_list[num]=1

print(sum(ans_list),wa)

Measured memory_bytes: 44296
import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                int cntA = scan.nextInt();
                int cntB = scan.nextInt();
                int cntC = scan.nextInt();
                int tmp = 0;

                tmp = cntB/cntA;

                if(cntC < tmp){
                        System.out.println(cntC);
                }else{
                        System.out.println(tmp);
                }
        }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define pp pair<int, int>
using namespace std;
int main(){
    int n, cnt=1;
    cin>>n;
    vector<pp > v;
    for(int i=0, x; i<n; ++i){
        cin>>x;
        v.push_back(pp(x, i));
    }
    
    sort(v.begin(), v.end());
    
    int tmp = v.begin()->second, ans=1;
    v.erase(v.begin());
    
    for(auto x: v){
        if(x.second>tmp) cnt++;
        else cnt=1;
        tmp=x.second;
        ans=max(ans, cnt);
    }
    
    cout<<n-ans;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll mini = min(x, y);
  ll maxi = max(x, y);
  ll ans1 = a * x + b * y;
  ll ans2=2 * c *maxi;
  ll ans3;
  if (x < y){
    ans3 = 2 * c * mini + b * (maxi - mini);
  }
  else{
    ans3 = 2 * c * mini + a * (maxi - mini);
  }
  ll ans = INF;
  chmin(ans, ans1);
  chmin(ans, ans2);
  chmin(ans, ans3);
  print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define M 1000000007
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef long long int lli; 
 
using namespace std;
 
bool sortbysec(const pair<char, lli> &a,const pair<char, lli> &b){
    return (a.second < b.second);
}
lli highest2(lli n){
    lli x=n;
    while(n){
        x=n;
        n=n&(n-1);
    }
    return x;
}
lli cache[3][100001];
lli a[100001],b[100001],c[100001];

lli dp(lli n,lli np){
    if(n==0){
        if(np==0)
        return cache[np][0]=a[0];
        else if(np==1)return cache[np][0]=b[0];
        else return cache[np][0]=c[0];
    }
    else{
        if(cache[np][n]!=-1)return cache[np][n];
        else{
            if(np==0){
                return cache[0][n]=a[n]+max(dp(n-1,1),dp(n-1,2));
            }
            else if(np==1)return cache[1][n]=b[n]+max(dp(n-1,0),dp(n-1,2));
            else return cache[2][n]=c[n]+max(dp(n-1,1),dp(n-1,0));
        }
    }
}
 
int main(){
    fast_io;
    lli m,k,t,row,col,n,g,i,p,j,p0,p1,mno,R,r,br,x,count=0;
    string s;
    cin>>n;
    forz(i,0,3){
        forz(j,0,n+1)cache[i][j]=-1;
    }
    forz(i,0,n)cin>>a[i]>>b[i]>>c[i];
    cout<<max(dp(n-1,0),max(dp(n-1,1),dp(n-1,2)));
    return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-

def main():
    s = str(input())

    if s == "RRR":
        print(3)
    elif s == "RRS" or s == "SRR":
        print(2)
    elif s == "SSS":
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61780
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, 0, n){
        int in;
        cin >> in;
        a[i]. first  = in;
        a[i]. second = i;
    }
    int ans = 0;
    sort(all(a));
    rep(i, 0, n){
        if(i % 2 != a[i]. second % 2) ans ++;
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 1792
x,y,a,b,c= list(map(int, input().split()))

A = sorted(list(map(int, input().split())), reverse=True)
A = A[:x]
B = sorted(list(map(int, input().split())), reverse=True)
B = B[:y]

C = sorted(list(map(int, input().split())), reverse=True)

ans = A + B + C
ans = sorted(ans, reverse=True)[:x+y]

print(sum(ans))


Measured memory_bytes: 21936
#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() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % 2019;
    d[i] = (d[i+1]+a) % 2019;
    ten *= 10; ten %= 2019;
  }
  vector<int> cnt(2019);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}


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

constexpr uint64_t MOD = 1000000007;

uint64_t fact(uint64_t N) {
    uint64_t tmp = 1;
    for(uint64_t i =1;i<=N;i++) {
        tmp = ((tmp * i) % MOD);
    }
    return tmp;
}

int main(void) {
    uint64_t N;
    cin >> N;

    cout << fact(N) << "\n";
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int,input().split()))
a = 0
b = []
for i in range(n):
    if i != n-1:
        if ls[i] >= ls[i+1]:
            a += 1
        else:
            b.append(a)
            a = 0
    elif i == n-1:
        b.append(a)
print(max(b))
        

Measured memory_bytes: 14252
#include <stdio.h>
 
int main(void)
{
    int n, x, i, j, k, count;
     
    while (1) {
        scanf("%d %d", &n, &x);
        if (n == 0 && x == 0) {
            break;
        }
         
        count = 0;
        for (i = 1; i <= n - 2; i++) {
            for (j = i + 1; j <= n - 1; j++) {
                for (k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
         
        printf("%d\n", count);
    }
     
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
  int A, B, K;
  scanf("%d%d%d", &A, &B, &K);

  int Min = (A > B) ? B : A;
  int Num = 0;
  for(int i = Min; i > 0; i--) {
    if((A % i == 0) && (B % i == 0)) {
      Num++;
      if(Num == K) {
	printf("%d\n", i);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>



int main(void) {

	int a,b,c;
	int i = 1;

	scanf("%d %d %d", &a,&b, &c);

	
	if ((a * 100 + b * 10 + c) % 4 == 0) { printf("YES"); }
	else { printf("NO"); }


	

	

	return 0;

}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}


void solve() {
  // main coding
  int n,m; cin>>n>>m;
  vector<vector<int>> E(n);
  vector<int> indeg(n);
  int x,y;
  rep(_,m) {
    cin>>x>>y;
    x--; y--;
    E[x].push_back(y);
    indeg[y]++;
  }
  queue<int> q;
  vector<int> dp(n);
  rep(i,n) if(indeg[i]==0) q.push(i);
  while(!q.empty()) {
    int u=q.front(); q.pop();
    for(int v: E[u]) { // u to v:
      dp[v]=max(dp[v],dp[u]+1);
      indeg[v]--;
      if(indeg[v]==0) q.push(v);
    }
  }
  cout<<*max_element(dp.begin(),dp.end())<<"\n";
}

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int g=0,p=0;
  for (int i=0;i<S.size();i++){
    if (S[i]=='g'){
      g++;
    }
    else {
      p++;
    }
  }
  cout << (g-p)/2 << endl;
}

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

int main()
{
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<long long, int>> apples(a+b+c);
    for(int i = 0; i < a; ++i)
    {
        long long t;
        cin >> t;
        apples[i] = make_pair(t,0);
    }
    for(int i = 0; i < b; ++i)
    {
        long long t;
        cin >> t;
        apples[a+i] = make_pair(t,1);
    }
    for(int i = 0; i < c; ++i)
    {
        long long t;
        cin >> t;
        apples[a+b+i] = make_pair(t,2);
    }
    sort(apples.begin(),apples.end(), greater<pair<long long,int>>());

    long long ascr = 0;
    long long bscr = 0;
    long long cscr = 0;
    int xCnt = 0;
    int yCnt = 0;
    int zCnt = 0;
    for(pair<long long, int> a : apples)
    {
        long long scr = a.first;
        int type = a.second;
        //cout << scr << " " << type << endl;
        if((type == 0 && xCnt >= x)
        || (type == 1 && yCnt >= y))
        {
            continue;
        }
        switch(type)
        {
            case 0:
                ascr += scr;
                xCnt += 1;
                break;
            case 1:
                bscr += scr;
                yCnt += 1;
                break;
            default:
                cscr += scr;
                zCnt += 1;
                break;
        }
        if(x+y <= xCnt+yCnt+zCnt)
        {
            break;
        }
    }
    cout << ascr+bscr+cscr << endl;
}

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

int main()
{
    int n,x;
    int a[100100];
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    int maximum=a[0]+a[1],c;
    for(int i=1;i<100005;i++){
        c=a[i]+a[i+1]+a[i-1];
        maximum=(maximum>c?maximum:c);
    }
    printf("%d\n",maximum);
    return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
q = list()
for i in range(m):
    q.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1, len(q[i])):
            w = q[i][j]
            if s >>(w-1) & 1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        ans += 1
print(ans)

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

int w, h, x, y, r;

int main() {
    cin >> w >> h >> x >> y >> r;
    int dx[4] = {r, 0, -r, 0};
    int dy[4] = {0, r, 0, -r};
    
    for (int i = 0; i < 4; i++) {
        int cx = x + dx[i], cy = y + dy[i];
        
        if (cx > w || cy > h || cx < 0 || cy < 0) {
            cout << "No" << endl;
            exit(0);
        }
    } 
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 3092
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	d := make([]int, n)
	
	for i := range d {
		fmt.Scan(&d[i])
	}
	
	sort.Ints(d)

	fmt.Println(max(d[n / 2] - d[n / 2 - 1], 0))
}

func max(num1, num2 int)int {
	if num1 > num2 {
		return num1
	}
	return num2
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, K; cin >> N >> K;
  int itr = 1 << N;
  int ans = INF;
  while (itr) {
    int n = 1;
    for (int i = 0; i < N; ++i) {
      if (itr & (1 << i)) {
        n *= 2;
      } else {
        n += K;
      }
    }
    chmin(ans, n);
    --itr;
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

int flag = 0;
char tem;

int main()
{
	while(cin>>tem) {
		if(tem == 'C') flag = 1;
		if(tem == 'F' && flag) {cout<<"Yes"; flag = 2; break;}
	}
	if(flag != 2) cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
#?????§?????????????????????

def draw_odd(n):
    a = ""
    for i in range(n/2):
        a += "#."
    if n % 2 != 0:
        a += "#"
    print a

def draw_even(n):
    a = ""
    for i in range(n/2):
        a += ".#"
    if n % 2 != 0:
        a += "."
    print a

while 1:
    HW = raw_input().split()
    H = int(HW[0])
    W = int(HW[1])

    if H == 0 and W == 0:
        break

    for i in range(H/2):
        draw_odd(W)
        draw_even(W)
    if H % 2 != 0:
        draw_odd(W)
    print ""

Measured memory_bytes: 6472
package main

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

func main() {
	n, m := readInt(), readInt()

	fmt.Println((n+m)*(n+m-1)/2 - n*m)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
use std::collections::HashMap;
use std::f64;

#[allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}

fn main() {
    input! {
        N:usize,
        v:[i32;N],
    }

    let mut counter = 0;

    for i in 0..N {
        if (i % 2 == 0) && (v[i] % 2 == 1) {
            counter += 1;
        }
    }
    print!("{}", counter);
}


Measured memory_bytes: 2156
x, k, d = [int(i) for i in input().split()]
if x == 0:
    if k % 2:
        print(d)
    else:
        print(0)
if x < 0:
    x = - x
if x > 0:
    if x - k * d >= 0:
        print(x-k * d)
    else:
        k1 = x // d
        if k1 % 2 == k % 2:
            print(x - k1 * d)
        else:
            print(abs(x - (k1+1)*d))

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

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

	ll n,p;
	cin >> n >> p;

	if(n == 1){
		cout << p << "\n";
		return 0;
	}
	ll ans=1,pp,num;
	int end=sqrt(p);
	for(ll i=2;i<=end;i++){
		pp = p;
		num=0;
		while(!(pp%i)){
			pp /= i;
			num++;
		}
		if(num >= n) ans = i;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256