akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(){}
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int n):n(n){}

  void init(int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

struct Point{
  int x,y,idx,idy;
  Point(){}
  Point(int x,int y,int idx):x(x),y(y),idx(idx),idy(-1){}
  bool operator<(const Point &a)const{
    if(y!=a.y) return y>a.y;
    return x<a.x;
  }
};

const int MAX = 114514;
Point ps[MAX],bk[MAX];
int xs[MAX],ys[MAX];

void chk(int idx,int j){
  if(idx<0) return;
  int &idy=ps[j].idy;
  if(idy<0||xs[idy]<xs[idx]) idy=idx;
}

void upd(int &idx,int i){
  if(idx<0||xs[idx]<ps[i].x) idx=ps[i].idx;
}

void dfs(int l,int r){
  if(l+1==r) return;
  int m=(l+r)>>1;
  dfs(l,m);dfs(m,r);
  
  {
    int i=l,j=m,idx=-1;
    while(i<m||j<r){
      if(i==m||j==r){
        if(i==m) chk(idx,j++);
        if(j==r) upd(idx,i++);
        continue;
      }      
      ps[i].x+ps[i].y<=ps[j].x+ps[j].y?upd(idx,i++):chk(idx,j++);
    }
  }

  {
    int i=l,j=m,k=l;
    for(int i=l;i<r;i++) bk[i]=ps[i];
    while(i<m||j<r){
      if(i==m||j==r) ps[k++]=bk[(j==r?i:j)++];
      else ps[k++]=bk[(bk[i].x+bk[i].y<=bk[j].x+bk[j].y?i:j)++];
    }
  }
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  using P = pair<int, int>;
  vector<P> es;

  for(int b=0;b<4;b++){
    for(int i=0;i<n;i++){
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      ps[i]=Point(xs[i],ys[i],i);
    }
    
    sort(ps,ps+n);
    dfs(0,n);

    for(int i=0;i<n;i++){   
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      
      if(ps[i].idy<0) continue;
      int u=ps[i].idx,v=ps[i].idy;
      if(u>v) swap(u,v);
      es.emplace_back(u,v);      
    }
  }
  
  Kruskal<Int> ks(n);
  for(P e:es){
    int u,v;
    tie(u,v)=e;
    int c=max(abs(xs[u]-xs[v]),abs(ys[u]-ys[v]));
    ks.add_edge(u,v,c);
  }

  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 25108
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <sstream>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	int n;string s;
	cin >> n >> s;

	int ans = 0;

	for(int i = 0;i < n - 2;i++){
		if(s[i] == 'A'&&s[i+1] == 'B'&&s[i+2] == 'C'){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!int).array;

    auto dp = new bool[][](N+1, 10001);
    dp[0][0] = true;

    foreach (i; 0..N) {
        foreach (j; 0..10001) {
            if (dp[i][j]) {
                dp[i+1][j] = true;
                if (j + A[i] <= 10000) {
                    dp[i+1][j+A[i]] = true;
                }
            }
        }
    }


    int ans = 0;
    foreach (i; 0..10001) {
        if (i % 10 > 0 && dp[N][i])
            ans = i;
    }

    ans.writeln;
}


Measured memory_bytes: 3324
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&c<48)c=getchar();if(c=='-')f=-1,c=getchar();while(c>47)x=x*10+(c^48),c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;


int fa[maxn], sz[maxn];

int find(int a) { return fa[a]==a?a:fa[a]=find(fa[a]); }

int main() {
    int n=read(), m=read();
    for(int i=1; i<=n; ++i) fa[i]=i, sz[i]=1;
    for(int i=1; i<=m; ++i) {
        int u=read(), v=read();
        int x=find(u), y=find(v);
        if(x!=y) {
            fa[x]=y;
            sz[y]+=sz[x];
        }
    }
    int mx=0;
    for(int i=1; i<=n; ++i) mx=max(mx,sz[i]);
    printf("%d\n", mx);
}

Measured memory_bytes: 5324
using System;
namespace kozaiyApp
{
    public class CrestedIbisVsMonster
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]); // モンスター体力
            int N = int.Parse(input[1]); // まほう種類
            int[][] AB = new int[N][]; // A奪う体力 B奪われる体力


            for (int i = 0; i < N; i++)
            {
                AB[i] = new int[2];
                string[] inputMagic = Console.ReadLine().Split(' ');
                AB[i] = Array.ConvertAll(inputMagic, int.Parse);
            }

            // Aの低い順にソート
            Array.Sort(AB, (a, b) => a[0] - b[0]);
            // Bの低い順にソート
            Array.Sort(AB, (a, b) => a[1] - b[1]);

            int[,] DP = new int[N, H + 1];
            for (int i = 0; i < N; i++) // まほうの種類
            {
                for (int j = 0; j <= H; j++) // モンスター体力
                {
                    if (j == 0)
                    {
                        DP[i, j] = 0;
                        continue;
                    }

                    if (i == 0)
                    {
                        if (j <= AB[i][0])
                        {
                            DP[i, j] = AB[i][1];
                            continue;
                        }
                        double r = (double)j / AB[i][0];
                        int R = Convert.ToInt32(Math.Ceiling(r));
                        DP[i, j] = R * AB[i][1];
                        continue;
                    }

                    // 前行の値
                    int p = DP[i - 1, j];
                    // j>A の場合は B+残りスペース(今の行のj-A) ※同じまほうが複数回使えるため前行ではなく今の行を見る
                    int q = j > AB[i][0] ? AB[i][1] + DP[i, j - AB[i][0]] : AB[i][1];
                    // pとq小さい方
                    DP[i, j] = Math.Min(p, q);
                }
            }

            Console.WriteLine(DP[N - 1, H]);
        }
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int k, n;
  cin >> n >> k;
  arr(p,n);

  sortall(p);
  int ans=0;
  rep(i,k){
    ans+=p[i];
  }
  prt(ans);
}


Measured memory_bytes: 3624
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pii pair<int,int>
#define add(a,b) ((int) (((ll) (a) + (b))%MOD))
#define mul(a,b) ((int) (((ll) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, S, a;
int dp [3000][3001] = {{0}};

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> S;
    F0R(i,N) {
        cin >> a;
        if (a <= S) dp[i][a] = i+1;
        if (!i) continue;
        FOR(j,1,S+1) {
            if (j-a > 0) dp[i][j] = add(dp[i][j], dp[i-1][j-a]);
            if (j != S) dp[i][j] = add(dp[i][j], dp[i-1][j]);
        }
    }
    int ans = 0;
    RF0(i,N) ans = add(ans,mul(dp[i][S], N-i));
    cout << ans << '\n';
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

int main() {
	make3(n, a, b);
	(b-a+1) %2 ? puts("Alice") : puts("Borys");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}


int main(){
    int n;cin>>n;
    vector<ll> a(n);

    rep(i,n){
        ll num;cin >> num;
        a[i] = num-(i+1);
    }
    sort(a.begin(),a.end());

    ll ans=0;
    rep(i,n){
        ans += abs(a[i]-a[n/2]);
    }
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    
    int b;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(a[i] < a[j]){
                b = a[i];
                a[i] = a[j];
                a[j] = b;
            }
        }
    }

    int point_A = 0;
    int point_B = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            point_A += a[i];
        }
        if(i % 2 == 1){
            point_B += a[i];
        }
    }
    printf("%d\n",point_A - point_B);

    return 0;
}

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



int main(void){
	string a,b;
	cin >> a; 
	cin >> b;
	int i = 0, j = 0;
	while(true){
		if(i == a.length()){
			break;
		}else{
			cout << a[i++];
		}
		if(j == b.length()){
			break;
		}else{
			cout << b[j++];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=B.interact$B.pack.f.map(fst.fromJust.B.readInt).B.words
f(_:as)=g 2 2.reverse$as
g x y(a:as)
  |z>y="-1"
  |otherwise=g z(y`div`a*a+a-1)as
  where z=(x+a-1)`div`a*a
g x y _=unwords.map show$[x,y]

Measured memory_bytes: 15740
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

count = 0
can_kill = 0

for i in range(N+1):
  target = max(A[i] - can_kill,0)
  if i != N:
    if target <= B[i]:
      count += A[i]
      can_kill = B[i] - target
    else:
      count += B[i]+can_kill
      can_kill = 0
  else:
    if A[i] > can_kill:
      count += can_kill
    else:
      count += A[i]
print(count)

Measured memory_bytes: 19116
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct query {
    int a, b, c, d;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll A, B, N;
    cin >> A >> B >> N;
    output(A * min(N, (B - 1)) / B);
    
    
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A.at(i);
    for(int i=0; i<N; ++i) A.at(i) -= 1;

    int ans = 0;

    for(int i=0; i<N; ++i){
        if(i == A.at(A.at(i))) ans++;
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	if n == 1 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 1772
//g++ -Wshadow -Wall -O2 -Wno-unused-result -Wno-psabi
#include "bits/stdc++.h"
#define f first
#define s second
#define inf 1e18
#define ll long long
#define mod 1000000007
#define pb emplace_back
#define vll vector<long long int>
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) ((long long int)(x).size())
#define mll map<long long int, long long int>
#define pll pair<long long int, long long int>
using namespace std;

ll n;
const ll nax = 10e6+5;
ll cnt[nax] = {0};

void input(){
	cin >> n;
}

void solve(){
	ll ans = 0;
	for (ll i = 1; i <= n; i++) for (ll j = i; j <= n; j += i) cnt[j]++;
	for (ll i = 1; i < n; i++) ans += cnt[i];
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(20);
	ll t = 1;
	//cin >> t;
	while(t--){
		input();
		solve();
        cout<<endl;
	}
	cin.get();
	return 0;
}

Measured memory_bytes: 11424
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 100009;
const int INF = 1e9;
const double EPS = 1e-2;

int n, A, B, h[N];

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

inline bool judge(int x) {
	LL cnt = 0;
	for (int i = 1; i <= n; i++) {
		LL tmp = h[i] - (LL)x * B;
		if (tmp > 0) {
			cnt += ceil((double)tmp / (A - B)) + EPS;
		}
	}
	return cnt <= x;
}

int main() {
	n = read();
	A = read(); B = read();
	for (int i = 1; i <= n; i++) {
		h[i] = read();
	}
	int l = 1, r = INF, mid, ret;
	while (l <= r) {
		mid = l + r >> 1;
		if (judge(mid)) {
			r = mid - 1;
			ret = mid;
		} else {
			l = mid + 1;
		}
	}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

string base = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

    int N, M, Q;
    while (cin >> N >> M >> Q, N) {
        vector<string> S(Q + 1), B(Q + 1);
        S[0] = string(N, '0');
        B[0] = string(M, '0');
        rep(i, Q) {
            cin >> S[i + 1] >> B[i + 1];
        }

        vector<vector<bool>> a(N, vector<bool>(M, true));
        rep2(q, 1, Q + 1) {
            rep(i, N) {
                rep(j, M) {
                    if ((S[q][i] == '0') ^ (B[q][j] == B[q - 1][j])) {
                        a[i][j] = false;
                    }
                }
            }
        }

        rep(j, M) {
            int cnt = 0;
            int ans = -1;
            rep(i, N) {
                if (a[i][j]) {
                    cnt++;
                    ans = i;
                }
            }
            cout << (cnt == 1 ? base[ans] : '?');
        }
        cout << endl;

    }
}

Measured memory_bytes: 4272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n), c;
    rep(i, n) cin >> a[i] >> b[i];
    sort(ALL(a));
    int maxa = a.back();
    //cout << maxa << endl;
    rep(i, n)
    {
        if (b[i] >= maxa)
            c.push_back(b[i]);
    }
    sort(ALL(c), greater<int>());
    int ans = 0;
    rep(i, c.size())
    {
        h -= c[i];
        ans++;
        //cout << c[i] << endl;
        if (h <= 0)
        {
            cout << ans << endl;
            return 0;
        }
    }
    while (h > 0)
    {
        ans++;
        h -= maxa;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1660
#include<stdio.h>
int main(){
  int n,i,j,min,mi;
  char s[101];
  while(scanf("%d",&n),n){
    int b[12]={0};
    scanf("%s",s);
    for(i=0;s[i];i++){
      if(s[i]=='M')b[i%n]++;
      if(s[i]=='S'){
	b[n]+=b[i%n]+1;
	b[i%n]=0;
      }
      if(s[i]=='L'){
	b[i%n]+=b[n]+1;
	b[n]=0;
      }
    }
    for(i=0;i<n;i++){
      min=101;
      for(j=i;j<n;j++){
	if(min>b[j])min=b[mi=j];
      }
      printf("%d ",min);
      b[mi]=b[i];
    }	
    printf("%d\n",b[n]);
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define LL long long

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

int n, m, fac[N] = { 1 }, inv[N] = { 1 };
LL ans;

int mul(int ta, int tb) {
	int ret;
	__asm__ __volatile__ ("\tmull %%ebx\n\tdivl %%ecx\n":"=d"(ret):"a"(ta), "b"(tb), "c"(mod));
	return ret;
}

int qpow(int bas, int po) {
	int res = 1;
	while(po) {
		if(po & 1)
			res = mul(res, bas);
		bas = mul(bas, bas);
		po >>= 1;
	}
	return res;
}

int C(int tn, int tm) {
	return mul(fac[tn], mul(inv[tm], inv[tn - tm]));
}

int A(int tn, int tm) {
	return mul(fac[tn], inv[tn - tm]);
}

int32_t main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i)
		fac[i] = mul(fac[i - 1], i);
	inv[m] = qpow(fac[m], mod - 2);
	for(int i = m; i >= 2; --i)
		inv[i - 1] = mul(inv[i], i);
	for(int i = 0; i <= n; ++i) {
		int flg = (i & 1) ? -1 : 1;
		int tmp = mul(C(n, i), mul(A(m, i), qpow(A(m - i, n - i), 2)));
		ans += flg * tmp;
		ans %= mod, (ans += mod) %= mod;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 7608
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int, vector<int>, greater<int>> que;
    int tmp;
    rep(i, N) {
        cin >> tmp;
        que.push(tmp); 
    }

#if 0
    rep(i, N) {
        cout << que.top() << ", ";
        que.pop();
    }
    cout << endl;
#endif

    vector<pair<int, int>> cb(M);
    int B, C;
    rep(i, M) {
        cin >> B >> C;
        cb[i] = {C, B};
    }

    sort(cb.rbegin(), cb.rend());
    rep(i, M) {
        C = cb[i].first;
        B = cb[i].second;
        rep(j, B) {
            int top = que.top();
            if(top < C) {
                que.pop();
                que.push(C);
            } else {
                break;
            }
        }
    }
    uint64_t ret = 0;
    rep(i, N) {
        ret += que.top();
        que.pop();
    }
    cout << ret << endl;

    return 0;
}



Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

const int INF=2500*100000*4;

int main(){
  int N,M,P;
  cin >> N >> M >> P;
  vector<pair<pair<int,int>, int> > E(M);
  for(int i=0;i<M;i++){
    cin >> E[i].first.first >> E[i].first.second >> E[i].second;
    E[i].first.first--; E[i].first.second--;
    E[i].second*=-1;
    E[i].second+=P;
  }

  vector<pair<int,int>> v(N,make_pair(0,INF));
  v[0].second=0;
  for(int i=1;i<N;i++){
    for(auto ei:E){
      if((v[ei.first.second].second>v[ei.first.first].second+ei.second) && v[ei.first.first].second!=INF){
        v[ei.first.second].second=v[ei.first.first].second+ei.second;
        v[ei.first.second].first=ei.first.first;
      }
    }
    //for(auto vi:v) cout << vi.second << " "; cout << endl;
  }

  vector<int> f(N);
  for(auto ei:E){
    if(v[ei.first.first].second+ei.second<v[ei.first.second].second){
      f[ei.first.second]=-1;
      f[ei.first.first]=-1;
    }
  }

  int ans=0;
  if(v[N-1].second==INF) ans=-1;
  else{
    vector<int> r(N,0);
    r[N-1]=1;
    for(int i=0;i<N;i++){
      for(auto ei:E){
        if(r[ei.first.second]==1) r[ei.first.first]=1;
      }
    }

    for(int i=0;i<N;i++){
      if((r[i]==1) && (f[i]==-1) && (v[i].second!=INF)) ans=-1;
    }
    if(ans!=-1) ans=max(0,-v[N-1].second);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
  long long *A = (long long *)a;
  long long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main(){
    long long n,a[5],m,i;
    scanf("%lld",&n);
	for(i=0;i<5;i++)scanf("%lld",&a[i]);
    qsort(a,5,sizeof(long long),cmp);
    m=n/a[0]+1;
    if(n%a[0]==0)m-=1;
   printf("%lld",4+m);
}


Measured memory_bytes: 128
# frozen_string_literal: true

n = gets.to_i
list = []
n.times do
  query = gets.split(' ')
  case query[0]
  when 'insert'
    list.unshift(query[1])
  when 'delete'
    if (k = list.index(query[1]))
      list.delete_at(k)
    end
  when 'deleteFirst'
    list.shift
  when 'deleteLast'
    list.pop
  end
end
puts list.join(' ')



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

#define ll long long

using namespace std;

int a[30];
int b[30];
int c[30];

int main()
{
    int n,res = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++)
    {
        cin >> b[i];
    }
    for(int i = 1; i <= n - 1; i++)
    {
        cin >> c[i];
    }
    int prev = -2;
    for(int i = 1; i <= n; i++)
    {
        res += b[a[i]];
        if(a[i] == prev + 1) res += c[prev];
        prev = a[i];
    }
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi fisrt
#define se second

using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f3f3f3f;

vector<int> vec[N];

int n,m,k,ans;
int a[N];
int num[N];

int ksm(int xx,int yy,int zz)
{
	int ret;
	while (yy)
	{
		if (yy&1) ret=(ret*xx) % zz;
		xx=(xx*xx)%zz;
		yy>>=1;
	}
	return ret;
}

signed main()
{
	cin>>n>>m>>k;
	if (m*k>=n) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 5968
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

int n, m;
vector <string> a, b;

bool check(int x, int y){
    if(x + m > n) return false;
    int k = 0;
    for(int i = x; i < x + m; i++){
        string s = a[i].substr(y, m);
        if(s != b[k++]) return false;
    }
    
    return true;
}

void solve(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        a.push_back(s);
    }
    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        b.push_back(s);
    }
    if(n * m == 1){
        cout << ((a[0] == b[0]) ? "Yes" : "No");
        return;
    }
    for(int i = 0; i < n - m; i++){
        for(int j = 0; j < n - m; j++){
            if(check(i, j)){
                cout << "Yes";
                return;
            }
        }
    }
    cout << "No";
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
import sys
Sa = input()
Sb = input()
Sc = input()
Na = len(Sa)
Nb = len(Sb)
Nc = len(Sc)
ia, ib, ic = 0, 0, 0
t = 'a'
while True:
    if t == 'a':
        while ia < Na and Sa[ia] == 'a':
            ia += 1
        if ia >= Na:
            print('A')
            sys.exit()
        t = Sa[ia]
        ia += 1
    if t == 'b':
        while ib < Nb and Sb[ib] == 'b':
            ib += 1
        if ib >= Nb:
            print('B')
            sys.exit()
        t = Sb[ib]
        ib += 1
    if t == 'c':
        while ic < Nc and Sc[ic] == 'c':
            ic += 1
        if ic >= Nc:
            print('C')
            sys.exit()
        t = Sc[ic]
        ic += 1


Measured memory_bytes: 9048
#include<stdio.h>
int main(){
	int a[3],n=0,i,j,t;
	while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF){
		for(i=0;i<3;i++){
			for(j=i;j<3;j++){
				if(a[i]>a[j]){
					t=a[i];a[i]=a[j];a[j]=t;
				}
			}
		}
		printf("%d\n",a[2]-a[0]);
	}	
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

int main()
{
    long X;
    std::cin >> X;

    long double tmp = 100;
    auto i = 0;
    for (;tmp < X; i++) {
        tmp = std::floor(tmp * 1.01);
    }

    std::cout << i << std::endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    int A[N];
    int sum_votes = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum_votes += A[i];
    }
    sort(A, A + N);
    if (A[N - M] >= sum_votes * (1.0 / (4 * M)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;
typedef long long ll;

const int nc = 26;
int D;
ll c[40], t[400];
ll s[400][40];

ll scoring(){
	vector<int> last(nc+10, -1);

	long long sat = 0;

	for(ll d = 0; d < D; d++){
		last[t[d]] = d;

		for(int i = 0; i < nc; i++){
			sat -= c[i] * (d - last[i]);
		}
		sat += s[d][t[d]];
		//cout << sat << endl;
	}

	return sat;
}

double elapsed_time(chrono::system_clock::time_point start){
  auto now_time = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast<std::chrono::milliseconds>(now_time - start).count();
  //cout << elapsed << endl;
  return elapsed;
}

int main(){
	random_device rnd;
	mt19937 mt(rnd());
	
	cin >> D;

	for(int i = 0; i < nc; i++){
		cin >> c[i];
	}

	for(int i = 0; i < D; i++){
		for(int j = 0; j < nc; j++){
			cin >> s[i][j];
		}
	}

	ll score = scoring();

	for(int i = 0; i < D; i++){
		t[i] = mt() % nc; //初期解をrandで生成
	}

  auto start = chrono::system_clock::now();
	int cnt = 0;    
	while(cnt < 100000){
		cnt++;
		//if(elapsed_time(start) > 1.9) break;
		int d, q, old;

		d = mt() % D;
		q = mt() % nc;
		old = t[d];
		t[d] = q;

		ll new_score = scoring();
		//cout << new_score << endl;
		if(score > new_score){
			t[d] = old;
		}else{
			score = new_score;
		}
	}

  //cout << score << endl;
	for(int i = 0; i < D; i++){
		cout << ++t[i] << endl;
	}
	return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,v[20],c,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=0;i<n;i++){
		cin>>c;
		if(v[i]>c)
			ans+=v[i]-c;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# import numpy as np
# import copy

def main():

    k,x = [int(i) for i in input().split(' ')]
    # ishi = 2000001
    # mn = -1000000
    # mx = 1000000

    saisyo = x - k 

    saidai = x + k -1

    res = []
    while True:
        if saisyo >= saidai:
            break
        saisyo = saisyo + 1
        res.append(saisyo)

    res = [str(i) for i in res]
    print(' '.join(res))


    

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
fun main(args: Array<String>) {

    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)

    var coin = 0
    var day = 0
    while (coin < c) {
        day++
        coin += a
        if (day % 7 == 0) coin += b
    }
    println(day)
}


Measured memory_bytes: 33840
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

a,b,c = map(int,F.readline().split())

if a == b:
    if b == c:
        print('No')
        sys.exit()
    print('Yes')
    sys.exit()

if a == c or b == c:
    print('Yes')
    sys.exit()
print('No')
sys.exit()


Measured memory_bytes: 5764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSumOfDivisors solver = new DSumOfDivisors();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSumOfDivisors {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long answer = 0;
            for (int i = 1; i <= n; i++) {
                long first = i;
                long last = (n / i) * i;
                long count = n / i;

                long sum = (first + last) * count / 2;
                answer += sum;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 25860
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printve(vector<T>& v) {int n = sz(v); REP(i, n) cerr << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vl a(n);
    vl b(n + 1);
    ll sum = 0;
    REP(i, n) {
        cin >> a[i];
        b[a[i]]++;
    }
    REP(i, n + 1) {
        if (b[i] > 1) sum += (b[i] * (b[i] - 1)) / 2;
    }
    REP(i, n) {
        if (b[a[i]] == 2) cout << sum - 1 << endl;
        else if (b[a[i]] > 2) cout << sum - (b[a[i]] * (b[a[i]] - 1)) / 2 + ((b[a[i]] - 1) * (b[a[i]] - 2)) / 2 << endl;
        else cout << sum << endl;
    }
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int k;
    cin >> k;
    if(k%2){
        cout << k/2*(k/2+1) << endl;
    }
    else cout << k/2*(k/2) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            // LINQを使った別解
            var N = cin.ReadInt;
            var ans = cin.ReadIntArray(N).Min(x =>
            {
                var c = 0;
                while (x % 2 == 0 && x != 0)
                {
                    x /= 2;
                    c += 1;
                }
                return c;
            });
            WriteLine(ans);
            
            //var N = cin.ReadInt;
            //int  maxdiv2 = 33;
            //for (int i=0; i < N; ++i)
            //{
            //    var a = cin.ReadInt;
            //    var cnt = 0;
            //    while (a % 2 == 0)
            //    {
            //        a /= 2;
            //        cnt += 1;
            //    }
            //    maxdiv2 = Min(cnt, maxdiv2);
            //}
            //WriteLine(maxdiv2);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K ;
  cin >> N >> K;
  int ans =1 ;
  int i=0 ;
  while(ans < K && i<N){
    ans *= 2 ;
    i ++;
  }
  while(i<N){
    ans += K ;
    i ++;
  }
  cout << ans << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin >> a[i];
    vector<bool> H(h,false);
    vector<bool> W(w,false);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                H[i]=true;
                W[j]=true;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(H[i]&&W[j]){
                cout << a[i][j];
            }
        }
        if(H[i]) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll n,m,dp[1111][1111];
ll solve(vector<ll> a,vector<ll> b,vector<ll> c) {
  rep(i,n+1)rep(j,m+1) dp[i][j]=-MAXL;
  dp[0][0]=0;
  rep(i,n) {
    rep(j,m+1) {
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+a[i]+b[i]+c[i]);
    }
  }
  return dp[n][m];
}
void Main() {
  cin >> n >> m;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  ll ans=-MAXL;
  rep(t,1<<3) {
    vector<ll> aa=a,bb=b,cc=c;
    if(t&(1<<0)) rep(i,n) aa[i]*=-1;
    if(t&(1<<1)) rep(i,n) bb[i]*=-1;
    if(t&(1<<2)) rep(i,n) cc[i]*=-1;
    ans=max(ans,solve(aa,bb,cc));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include "iostream"
#include "vector"
#include "algorithm"

int main(void) {
	long long n, k;
	std::cin >> n;
	std::cin >> k;
	std::vector<long long> h(n);
	for (long long i = 0; i < n; ++i)
		std::cin >> h[i];

	std::sort(h.begin(), h.end());

	long long ans = 0;
	for (long long i = 0; i < n - k; ++i)
		ans += h[i];

	std::cout << ans;
}

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

int main(){
	int x, y;
	cin >> x >> y;
	
	if( 2*x<=y && y<=4*x && (4*x-y)%2==0 && (y-2*x)%2==0 )	cout << "Yes" << endl;
	else	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  while(n--){
  	cout<<"ACL";
  }
   return 0; 
}
 

Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
int main(){
    while(1){
        int m,n;
        char cha[100000],con[100000],a[100000];
        cin>>m;
        if(m==0)break;
        for(int i=0;i<m;i++){
            cin>>cha[i]>>con[i];
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
            for(int j=0;j<m;j++){
                if(a[i]==cha[j]){
                    a[i]=con[j];
                    break;
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i];
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i=0,j=0,N;
    scanf("%d", &N);
    char s[N+1], ans[N+1];
    scanf("%s",s);
    
    for(i=0;i<N;i++){
        if(s[i] != s[i+1]){
            ans[j] = s[i];
            j+=1;
        }
    }
    printf("%d\n", j);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int N,K;
	cin >> N >> K;

	if(N == 1) {
		cout << K << endl;
		return 0;
	}

	ll ans = 1;
	for(int i = 0; i < N - 1; i++) ans *= (K - 1);
	ans *= K;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
N = int(input())
pri_cnt = {}
n = N
i = 2

while i ** 2 <= N:
  while n % i == 0:
    if i not in pri_cnt:
      pri_cnt[i] = 1
    else:
      pri_cnt[i] += 1
    n = n / i
  if (i == 2):
    i += 1
  else:
    i += 2

if n > 1:
  pri_cnt[int(n)] = 1

ans = 0
for pri, cnt in pri_cnt.items():
  count = 1
  remain = cnt
  while remain >= count:
    ans += 1
    remain -= count
    count += 1
print(ans)

Measured memory_bytes: 9284
<?php

$input = intval(fgets(STDIN));

$list = array(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);

echo $list[$input - 1];


?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 1000000007
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int t, n;

int main() {
    //scanf("%d", &t);
    t = 1;
    while(t--) {
        scanf("%d", &n);  
        printf("%d\n", !n);
    }
	return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
#define s second
#define f first
using namespace std;
int main(){
  int n,m;
  while(cin>>n,n){
    pair<int,int>a[n];
    r(i,n)cin>>a[i].f>>a[i].s;
    cin>>m;
    pair<int,int>b[m];
    r(i,m)cin>>b[i].f>>b[i].s;
    set<pair<int,int> >se;
    r(i,m)se.insert(b[i]);
    r(i,m){
      int c=0,x,y;
      x=a[0].f-b[i].f;
      y=a[0].s-b[i].s;
      r(j,n)if(!se.count(mk(a[j].f-x,a[j].s-y)))c++;
      if(!c){
        cout<<-x<<' '<<-y<<endl;
        goto L;
      }
    }L:;
  }
}

Measured memory_bytes: 3128