akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	int c = -2,k = 2,e = N,w,r;
	if( N == 0){
		printf("0");
		return 0;
	}
	else printf("1");
	int h[100000];
	int count = 0,i;
	while(e!=0){
		r = e % c;
		w = e;
		e = e / c;
		if(r==-1) e++;
		r = w-c*e;
		h[count] = r;
		count++;
		
		if(e == 1) break;
	}
	
	for(i = count-1; i >= 0; i--)
	{
		printf("%d",h[i]);
	}
	//*/
	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

#define N 8

void Queen(int);

int n;
int bord[N][N];
int row[N];
int col[N];
int dpos[2*N-1];
int dneg[2*N-1];

int main()
{
  int i,x,y;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      //配列に２がはいっている場合、固定しているQが入っているようにする。

      scanf("%d%d",&x,&y);
      bord[x][y]=2;
      row[x]=2;
      col[y]=2;
      dpos[x+y]=2;
      dneg[x-y+N-1]=2;
    }
  
  Queen(0);

  for(x=0;x<N;x++)
    {
      for(y=0;y<N;y++)
	{
	  if(bord[x][y]==2||bord[x][y]==1)printf("Q");
	  else printf(".");
	}
      printf("\n");
    }
  
  return 0;
}

void Queen(int i)
{
  int j;
  static int hata;
  if(i==8)
    {
      hata=1;
      return;
    }

  for(j=0;j<8;j++)
    {
 
      if(bord[i][j]==2)//もし固定されたQがあったら
	{
	  Queen(i+1);
	}
      else//それ以外
	{
	  if(col[j]!=0 || dpos[i+j]!=0 || dneg[i-j+7]!=0 )
	    {
	      continue;
	    }
	  bord[i][j]=1;
	  
	  col[j]=1;
	  dpos[i+j]=1;
	  dneg[i-j+7]=1;
	  
	  Queen(i+1);

	  if(hata!=1)
	    {
	      col[j]=0;
	      dpos[i+j]=0;
	      dneg[i-j+7]=0;
	      bord[i][j]=0;
	    }
	}
      
    }
}



Measured memory_bytes: 2112
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var count = 0;
        for (int i = 0; i < h; i++)
            count += w - Console.ReadLine().Trim().Replace("#", "").Length;
        Console.WriteLine(count == h + w - 1 ? "Possible" : "Impossible");
    }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int in(){
    double t;
    scanf("%lf",&t);
    return t*(1ll<<50);
}

int K,L,R;
double P;
int E,T;

int w;
int sl,sr;

double dfs(double p,int k,int l,int r){
    if(k==K){
        int m=(l+r)/2;
        if(T-E<=m&&m<=T+E)return p;
        else return 0.0;
    }
    int tl=l+w,tr=r-w;
    if(tr<sl||sr<tl)return 0.0;
    if(sl<=tl&&tr<=sr)return p;
    int m=(l+r)/2;
    if(m>=T)return dfs(p*(1-P),k+1,l,m)+dfs(p*P,k+1,m,r);
    else return dfs(p*P,k+1,l,m)+dfs(p*(1-P),k+1,m,r);
}

signed main(){
    scanf("%lld",&K);
    L=in();R=in();
    scanf("%lf",&P);
    E=in();T=in();

    w=L-R;
    rep(i,K+1)w/=2;
    sl=T-E;
    sr=T+E;

    printf("%.20f\n",dfs(1.0,0,L,R));
    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N;
    cin >> N;

    string s;
    cin >> s;


    map<char, ll> mp;
    for (int i = 0; i < N; i++) {
        mp[s[i]]++;
    }

    ll ans = 1;
    ll rem = 1e9 + 7;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans = (ans * (itr->second + 1) ) % rem;
    }
    ans--;

    cout << ans << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

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

using ll = long long;

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

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

int main() {
  ll K;
  cin >> K;
  queue<ll> q;
  for(ll i = 0LL; i < 9LL; i++) {
    q.push(i+1LL);
  }
  ll ans;
  for(ll i = 0LL; i < K; i++) {
    ll t = q.front();
    if(i==K-1LL) ans=t;
    q.pop();
    ll s = t%10LL;
    if(s!=0LL)q.push(10LL*t+s-1LL);
    q.push(10LL*t+s);
    if(s!=9LL)q.push(10LL*t+s+1LL);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=(c=='-'),c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 20000
#define MOD 1000000007
int N,K;
int A[MAXN+5];

#define MAXA 2000
#define lowbit(x) (x&-x)
int Tree[MAXA+5];
void Update(int i,int d){
    while(i<=MAXA)
        Tree[i]+=d,i+=lowbit(i);
}
int GetSum(int i){
    int ret=0;
    while(i>0)
        ret+=Tree[i],i-=lowbit(i);
    return ret;
}

int main(){
    N=read(),K=read();
    for(int i=1;i<=N;i++)
        A[i]=read();
    int Sum=0;
    for(int i=1;i<=N;i++)
        Sum+=i-1-GetSum(A[i]),Update(A[i],1);
    Sum=(long long)Sum*K%MOD;
    for(int i=1;i<=N;i++){
        long long tmp=GetSum(A[i]-1);
        Sum=(Sum+(tmp*((long long)K*(K-1)/2%MOD)%MOD))%MOD;
    }
    printf("%d",Sum);
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int a = 0;
	int z = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = s.size(); i >= 0; i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}

	cout << z-a+1 << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    ll D, G; cin >> D >> G;
    vector<ll> p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];

    ll ans = accumulate(p.begin(), p.end(), 0);
    rep(bit, 1<<D){
        vector<bool> used(D, false);
        ll tmp_score = 0, tmp_prob = 0;
        rep(i, D) if(bit&1<<i) { used[i]=true; tmp_score += 100*(i+1)*p[i] + c[i]; tmp_prob += p[i]; }
        int cur = -1;
        rep(i, D) if(used[i]==false) cur = i;
        if(cur == -1) continue;

        
        ll add = (G-tmp_score+100*(cur+1)-1)/(100*(cur+1));
        chmax(add, 0LL);
        if(add >= p[cur]) continue;
        chmin(ans, tmp_prob+add);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
using namespace std;
int main()
{
    // 整数の入力
    int N, M;
    int result, checkpnum;
    cin >> N >> M;
    vector<pair<int, int>> vN, vM;

    for (int i = 0; i < N; i++) {
      	int n1, n2;
        cin >> n1 >> n2;
        vN.push_back(make_pair(n1, n2));
    }

    for (int i = 0; i < M; i++) {
      	int m1, m2;
        cin >> m1 >> m2;
        vM.push_back(make_pair(m1, m2));
    }

    for (auto n : vN) {
        result = pow(10, 9);
        checkpnum = 1;
        int resultcmp = 0;
        int checkpnumtmp = 0;
  	    for (auto m : vM) {
             resultcmp = std::abs(n.first - m.first) + std::abs(n.second - m.second);
             checkpnumtmp++;
             if (result > resultcmp) {
                 result = resultcmp;
                 checkpnum = checkpnumtmp;
                } 
        }
        cout << checkpnum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
let n=Int(readLine()!)!
let s=readLine()!

var ans = [Character]()

for c in s.unicodeScalars {
  if c.value >= 65 && c.value <= 90 {
    var x = Int(c.value) + n
    if x >= 91 {
      x = x - 91 + 65
    }
    let a = Character(UnicodeScalar(x))
    ans += [a]
  }
}

print(String(ans))

Measured memory_bytes: 4208
#include <stdio.h>
#define max(a, b) ((a)<(b) ? (b) : (a))
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)
int ans = 0;

void quick(int array[], int left, int right){
  int pl = left, pr = right, x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n;  scanf("%d", &n);
  int s[103] = {0};
  int not[104] = {0};
  for(int i=1; i<=n; i++){
    scanf("%d", &s[i]);
    ans += s[i];
    if(s[i] % 10)
      not[++not[0]] = s[i];
  }
  quick(not, 1, not[0]);
  if(ans % 10 == 0)
    if(not[0] > 0){
      ans -= not[1];
    }else{
      ans = 0;
    }
  
    
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    ll A, B;
    cin >> A >> B;
    vector<ll> X(n);
    rep(i, n) cin >> X[i];

    ll res = 0;
    rep(i, n - 1) {
        ll d = X[i+1] - X[i];
        ll c1 = d * A;
        ll c2 = B;
        res += min(c1, c2);
    }
    
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3976
#include <stdio.h>
int main(void)
{
    int i, n;
    long long num, min, maxv;

    min = 2000000000;
    maxv = 1 - min;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lld", &num);
        maxv = num - min > maxv ? num - min : maxv;
        min = num < min ? num : min;
    }
    printf("%lld\n", maxv);
    return 0;
}


Measured memory_bytes: 2108
import math


def solve_even(n):
    assert(n % 2 == 0)
    k = n // 2
    return leg(k)


def leg(k):
    return sum(k // 5 ** i for i in range(1, int(math.log(k) / math.log(5)) + 1))


n = int(input())

if n % 2 == 0:
    if n == 0:
        print(0)
    else:
        print(solve_even(n))
else:
    if n == 1:
        print(0)
    else:
        print(solve_even(n + 1) - leg(n // 2 + 1))

# (2k + 1)!! = (2k + 2)! / (2^(k+1)*(k+1)!)


Measured memory_bytes: 38384
from collections import deque


def bfs(start):
    Q = deque()
    Q.append(start)
    dist[start[1]][start[0]] = 0

    while Q:
        x, y = Q.popleft()

        for i in range(2):
            nx = x + dx[i]
            ny = y + dy[i]

            if not(0 <= nx < W and 0 <= ny < H):
                continue
            if G[ny][nx] == '.':
                continue
            if dist[ny][nx] != -1:
                continue

            Q.append((nx, ny))
            dist[ny][nx] = dist[y][x] + 1


H, W = map(int, input().split())
G = [[] for _ in range(H)]

n = 0
for i in range(H):
    G[i] = list(input())
    n += G[i].count('#')

dist = [[-1 for _ in range(W)] for _ in range(H)]
dx = [1, 0]  # 斜めも含むならその方向もプラス
dy = [0, 1]

bfs((0, 0))

if dist[H - 1][W - 1] + 1 == n:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define X real()
#define Y imag()
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
typedef complex<double> P;
typedef complex<double> point;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;
typedef vector<P> polygon;

struct C {
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};
//??????????????????
int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

int main(){
	int n;
	while(cin >> n && n > 0) {
		vector<P> ps;
		rep(i, n) {
			double x, y;
			cin >> x >> y;
			ps.pb({x, y});
		}
		double S = 0.0;
		rep(i, n) {
			int now = i, prv = (i - 1 + n) % n, nxt = (i + 1) % n;
			//S += cross(ps[nxt]-ps[now], ps[prv]-ps[now])/2.0;
			//S += cross(ps[nxt] - c, ps[now] - c)/2.0;
			S += (ps[now].X - ps[nxt].X)*(ps[now].Y +ps[nxt].Y);
		}
		G rect;
		double l = INF, r = -INF, u = -INF, d = INF;
		rep(i, 4) {
			double x, y;
			cin >> x >> y;
			rect.pb({x, y});
			l = min(l, x);
			r = max(r, x);
			u = max(u, y);
			d = min(d, y);
		}
		G pp;
		rep(i, n) {
			double x, y;
			if(ps[i].X > r) x = r;
			else if(ps[i].X < l) x = l;
			else x = ps[i].X;
			if(ps[i].Y > u) y = u;
			else if(ps[i].Y < d) y = d;
			else y = ps[i].Y;
			pp.pb({x, y});
		}
		double s = 0.0;
		rep(i, n) {
			int now = i, prv = (i - 1 + n) % n, nxt = (i + 1) % n;
			//s += cross(pp[nxt]-pp[now], pp[prv]-pp[now])/2.0;
			//s += cross(ps[nxt] - m, ps[now] -)/2.0;
			s += (pp[now].X - pp[nxt].X)*(pp[now].Y +pp[nxt].Y);
		}
		S /= 2.0;
		s /= 2.0;
		printf("%d\n", (int)(abs(S) - abs(s) + EPS));
		//cout << S <<" " << s << endl;
	}
}

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


int main() {
    string s;
    cin >>s;
    rep(i,3)if(s[i]==s[i+1]){
        cout << "Bad" <<endl;
        return 0;
    }
    cout << "Good" <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
const int N=100005;
vector<int>G[N];
LL ak[N];
void Init(int k) {
	LL zi=1,mu=1;
	ak[0]=1;
	for(int i=1;i<=k;i++)
		ak[i]=(ak[i-1]*(k-i+1))%MOD;
}
LL A(int a,int b) {
	if(b<0||b>a) return 0;
	LL ret=1;
	for(int i=a-b+1;i<=a;i++)
		ret=(ret*i)%MOD;
	return ret;
}
int n,k;
LL Dfs(int u,int fa) {
	int cnt=G[u].size()+1;
	if(cnt>k) return 0;
	LL ret=ak[cnt-2];
	for(int i=0;i<G[u].size();i++) {
		int v=G[u][i];
		if(v==fa) continue;
		ret=(ret*Dfs(v,u))%MOD;
	}
	return ret;
}
int main() {
	scanf("%d %d",&n,&k);
	Init(k-2);
	for(int i=1,u,v;i<n;i++) {
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	LL ans=A(k,G[1].size()+1);
	for(int i=0;i<G[1].size();i++)
		ans=(ans*Dfs(G[1][i],1))%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main()
{
	ll N, sum = 0; cin >> N;
  	vector<ll> A(N), B(N - 1);
  	for (int i = 0; i < N - 1; i++) {
    	cin >> B[i];
    }
  	A[0] = B[0];
  	for (int i = 1; i < N - 1; i++) {
    	A[i] = min(B[i - 1], B[i]);
    }
  	A[N - 1] = B[N - 2];
  	for (int i = 0; i < N; i++) {
    	sum += A[i];
    }
  	cout << sum << endl;
}

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

int main(){
string s1, s2, s3;
cin >> s1 >> s2 >> s3;
char C1, C2, C3;
C1 = toupper(s1.at(0));
C2 = toupper(s2.at(0));
C3 = toupper(s3.at(0));
cout << C1 << C2 << C3 << endl;
}

Measured memory_bytes: 256
person_num, shurui = map(int, input().split())
like_set = set(list(map(int, input().split()))[1:])
for i in range(person_num - 1):
    like_set_kari = set(list(map(int, input().split()))[1:])
    like_set &= like_set_kari
print(len(like_set))

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(){
    int n, d, x[10][10]={0}, ans=0;
    scanf("%d%d",&n,&d);
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            scanf("%d", &x[i][j]);
        }
    }

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            double calc=0;
            for(int k=0; k<d; k++){
                calc += ( (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]) );
            }
            if( (sqrt(calc) - (int)sqrt(calc)) == 0.0 ){ ans++; }
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> d(N);
    rep(i, N) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
    return 0;
}


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

using namespace std;

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

    int ret = n;
    for (int i = 0; i < n - 1; i++)
        if (s[i] == 'R' && s[i + 1] == 'L')ret -= 2;

    if (s[0] == 'L')ret--;
    if (s[n - 1] == 'R')ret--;

    cout << min(ret + 2 * k, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
template<ll mod = 1000000007ll>//no tests
struct umod{
    ll number;
    umod(): number(0LL){}
    umod(ll _number){ _number %= mod; if(_number < 0) _number += mod; number = _number;}
    umod& operator += (umod that){ number += that.number; if(number >= mod) number -= mod;return *this;}
    umod& operator -= (umod that){ number += mod - that.number; if(number >= mod) number -= mod;return *this;};
    umod& operator *= (umod that){ number = number*that.number%mod; return *this;}
    umod& operator /= (umod that){ return *this *= that.inverse();}
    umod operator + (umod that) const { return umod(*this) += that;}
    umod operator - (umod that) const { return umod(*this) -= that;}
    umod operator * (umod that) const { return umod(*this) *= that;}
    umod operator / (umod that) const { return umod(*this) /= that;}
    bool operator < (umod that) const { return number < that.number;}
    bool operator > (umod that) const { return number > that.number;}
    bool operator <= (umod that) const { return number <= that.number;}
    bool operator >= (umod that) const { return number >= that.number;}
    bool operator == (umod that) const { return number == that.number;}
    bool operator != (umod that) const { return number != that.number;}
    umod inverse() const {
        ll a = number, b = mod, u = 1, v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        if(u < 0) u += mod;
        return u;
    }
};
using big = umod<>;
const int maxn = 200200;
const ll mod = 1000000007ll;
ll pw(ll a, ll b){
    if(b == 0) return 1;
    if(b & 1) return (a*pw(a, b-1))%mod;
    ll mid = pw(a, b>>1);
    return (mid * mid)%mod;
}
big fat[maxn];
int posA, posB;
int arr[maxn];
int main(){
    fat[0] = 1;
    for(ll e = 1; e < maxn; e++)
        fat[e] = big(e)*fat[e-1];
    memset(arr, -1, sizeof(arr));
    int n;
    scanf("%d", &n); n++;
    for(int e = 0; e < n; e++){
        int x; scanf("%d", &x);
        if(arr[x] == -1) arr[x] = e;
        else {
            posA = arr[x];
            posB = e;
        }
    }
    // printf("%d %d\n", posA, posB);
    n--;
    for(int e = 1; e <= n; e++){
        big ans = fat[n]/(fat[n-e]*fat[e]);
        if(e >= 2){
            big cnt = fat[n-1]/(fat[n+1-e]*fat[e-2]);
            // printf("-- %lld\n", cnt.number);
            ans += cnt;
        }
        if(e >= 2){
            big add = fat[n-1]/(fat[n-1-(e - 1)]*fat[e-1]);
            big dec = 0;
            if(n - 1 - (posB - posA - 1) >= e-1)
                dec = fat[n - posB + posA]/(fat[(n - posB + posA)-(e-1)]*fat[e-1]);
            add -= dec;
            ans += add;
        }
        printf("%lld\n", ans.number);
    }
    printf("1\n");
    return 0;
}


Measured memory_bytes: 3584
"""
配列をソート
差を取って、最も大きいところから切っていく
K個塊になるまで切っていく
塊の端っこから端っこまでを足していく
"""
import numpy as np

N, M  = map(int,input().split())
A = input().split()
A = np.array([int(a) for a in A])

def count(A):
    A_sorted = np.sort(A)
    delta = np.abs(A_sorted[:-1] - A_sorted[1:])
    delta_ind = delta.argsort()[::-1]
    delta_ind_sort = np.sort(delta_ind[:N-1]) #昇順
    if len(delta_ind_sort) == 0:
        return 0 
    N_all = np.abs(A_sorted[0] - A_sorted[delta_ind_sort[0]]) #初期
    for i in range(len(delta_ind_sort)-1):
        # print(A_sorted[delta_ind_sort[i]+1],  A_sorted[delta_ind_sort[i+1]])
        N_all += np.abs(A_sorted[delta_ind_sort[i]+1] - A_sorted[delta_ind_sort[i+1]])
    
    N_all += np.abs(A_sorted[-1]-A_sorted[delta_ind_sort[-1]+1])
    return N_all


if N == 1:
    print(A.max()-A.min())
else:
    print(count(A))

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

using namespace std;

#define INF 999999999

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

int main(){
  int n=read(),t=read(),maxx=123456789;
  for(int i=1;i<=n;i++){
    int dis=read(),co=read();
    if (co<=t) maxx=min(maxx,dis);
  }
  if (maxx!=123456789) cout<<maxx;
  else cout<<"TLE";
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	double x, y;
	while (cin >> x >> y)
	{
		if (x <= EPS&& y <= EPS)break;
		printf("%.5f\n", x*x + 2 *x* sqrt(y*y + (x / 2)*(x / 2)));

	}
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    res = INF;
    for(auto a:A){
        ll T = 0;
        while(a%2 == 0){
            T++;
            a /= 2;
        }
        res = min(res,T);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		long N = reader.nextLong();
		long K = reader.nextLong();
		long[] A = new long[100010];
		for (int i=0; i<N; i++) {
		    int a = reader.nextInt();
		    long b = reader.nextLong();
		    A[a] += b;
		}
		solver(K, A);
	}
	
	public static void solver(long K, long[] A) {
		// write logic
		int i = 1;
		while(true) {
		    K -= A[i];
		    if (K <= 0) {
		        System.out.println(i);
		        return;
		    }
		    i++;
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 22108
#include<cstdio>
const int N=1e5+3,M=103;
int a[M],n,m,f[N];
signed main(){
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)scanf("%d",a+i);
	for(int i=0;i<=n;i++)
	  for(int j=1;j<=m;j++)
		if(i>=a[j])f[i]|=!f[i-a[j]];
	puts(f[n]?"First":"Second");
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		string s = GetString();

		List<char> buf = new List<char>(s.Length);
		for(int i = 0; i < s.Length; i++)
		{
			if(s[i] == 'B')
			{
				if(buf.Count == 0)
					continue;
				buf.RemoveAt(buf.Count - 1);
			}
			else
				buf.Add(s[i]);
		}
		Console.WriteLine(new String(buf.ToArray()));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a<=b&&b<=c){
        cout << a << " " << b << " " << c;
    }
        else if(a<=c&&c<=b){
        cout << a << " " << c << " " << b;
    }
        else if(b<=a&&a<=c){
        cout << b << " " << a << " " << c;
    }
        else if(b<=c&&c<=a){
        cout << b << " " << c << " " << a;
    }
        else if(c<=a&&a<=b){
        cout << c << " " << a << " " << b;
    }
        else{
        cout << c << " " << b << " " << a;
    }
    cout << endl;

}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

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

long long lcm(long long a, long long b) {
    return a / gcd(a,b) * b;
}


int main () {

    int T; cin >> T;

    REP(i,T) {
        ll A,B,C,D;
        cin >> A >> B >> C >> D;
        if (D < B) {
            cout << "No" << endl;
        } else if (A < B) {
            cout << "No" << endl;
        } else if (C >= B) {
            cout << "Yes" << endl;
        } else {
            ll l = A % B;
            if (l > C) {
                cout << "No" << endl;
            } else {
                if (D % B == 0) {
                    cout << "Yes" << endl;
                } else {
                    ll p = gcd(B, D);
                    if (C + p < B) {
                        cout << "No" << endl;
                    } else {
                        cout << "Yes" << endl;
                    }
                }
            }
        }
    }

    return 0;
}


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

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

    bool flag0 = true;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != '1' && i < K) {
            flag0 = false;
            break;
        }
    }

    if (!flag0) {
        for (int i = 0; i < S.size(); i++) {
            if (S[i] != '1') {
                cout << S[i] << endl;
                break;
            }
        }
    }

    if (flag0) {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char a;
    scanf("%c", &a);
    switch(a){
        case 'A':
        printf("T\n");
        break;
        case 'T':
        printf("A\n");
        break;
        case 'G':
        printf("C\n");
        break;
        case 'C':
        printf("G\n");
        break;
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int A,B,C; cin >> A >> B >> C;
    if (A==B){
        if(A==C){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else if(B==C){
        if(A==C){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else if(A==C){
        if(A==B){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=list(map(int,input().split()))
    flag=False
    cnt=1
    for i in range(N):
        if A[i]==cnt:
            cnt+=1
            flag=True
        else:
            continue
    if not flag:
        print(-1)
    else:
        print(N-cnt+1)





resolve()

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

int main(){
	int n,count;
	cin >> n;
	vector<int> dish(n);
	vector<int> plz(n);
	vector<int> plus(n-1);
	for(int i=0;i<n;i++){
		cin >> dish.at(i);
	}
	for(int i=0;i<n;i++){
		cin >> plz.at(i);
	}
	for(int i=0;i<n-1;i++){
		cin >> plus.at(i);
	}
	count=0;
	count += plz.at(dish.at(0)-1);
	for(int i=1;i<n;i++){
		count += plz.at(dish.at(i)-1);
		if(dish.at(i-1)==dish.at(i)-1){
			count += plus.at(dish.at(i-1)-1);
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  string S ;
  cin >> S ;
  int A = S.size() ;
  int counter = 0 ;
  rep(i,A)  if(S.at(i) == '1' ) counter++ ;
  int ans = min(counter,A - counter) ;
  cout << ans*2 << endl ;
}


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

vector<int> L;

int main() {
	int N = 0;

	cin >> N;

	int tmp;
	for (int i = 0; i < N; i++){
		cin >> tmp;
		L.push_back(tmp);
	}

	sort(L.begin(),L.end());
	int c = 0;

	for (int i = 0; i < N; i++)
		for (int j = i; j < N; j++)
			for (int k = j; k < N; k++){
				int len = L[i] + L[j] + L[k];
				int ma = max(L[i], max(L[j], L[k]));
				int rest = len - ma;

				if (ma < rest && L[i] != L[j] && L[j] != L[k] && L[k] != L[i])
					c++;

			}

	cout << c << endl;

}

Measured memory_bytes: 3652
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ a * a - b where [a, b] = fmap read (lines s) :: [Int]

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N,P;
  	cin >> N >> P;
  	vector<ll> A(N);
  	bool flag = true;
  	ll ans = 1;
  	for(ll i = 0; i < A.size(); ++i) cin >> A[i];
  	for(ll i = 0; i < A.size(); ++i){
      if(A[i] % 2 != 0) {
        flag = false;
        break;
      }
    }
  	if(flag){
      if(P == 1){
        cout << 0 << endl;
        return 0;
      }
      else{
        for(ll i = 0; i < A.size(); ++i) ans *= 2;
        cout << ans << endl;
        return 0;
      }
    }
  else{
    for(ll i = 0; i < A.size() - 1; ++i) ans *= 2;
    cout << ans << endl;
    return 0;
  }
  
}

Measured memory_bytes: 256
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
x=int(input())
ans=0
v=100
while v<x:
    v=math.floor(v*1.01)
    ans+=1

print(ans)



Measured memory_bytes: 27128
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
int main()
{
    jaldi
    #ifndef _DEBUG 
    //TakeInput
    #endif
    ll n,w,i,j,k;
    cin>>n>>w;
    ll a[n+1],v[n+1];
    fon(i,1,n+1){
        cin>>a[i]>>v[i];
        //cout<<a[i]<<" "<<v[i]<<endl;
    }
    ll dp[n+1][w+1];
    in0(dp);
    fon(i,1,n+1){
        fon(j,1,w+1){
            ll x;
            if(j-a[i]<0){
                x=-1;
            }
            else{
                x=dp[i-1][j-a[i]]+v[i];
            }

            dp[i][j]=max(dp[i-1][j],x);
            //cout<<x<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][w];

    
}
 
 








 

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (ull i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;
const long long INF = 1LL<<60;
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; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,x;		//0~n-1の範囲で全探索する。
	cin>>n>>m>>x;
	int c[15],a[15][15];
	ull sum[15],ans=INF;
	FOR(i,1,n+1){
		cin>>c[i];
		FOR(j,1,m+1){
			cin>>a[i][j];
		}
	}
	
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit)
    {
      FOR(i,0,m+1)	sum[i]=0;
        /* bit で表される集合の処理を書く */

        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
	
	for (int i = 0; i < (int)S.size(); ++i) {
		sum[0]+=c[S.at(i)+1];
		FOR(j,1,m+1)	sum[j]+=a[S.at(i)+1][j];
	}
      
	bool b=0;
	FOR(i,1,m+1)	if(x>sum[i])		b=1;
	if(b==0)		chmin(ans,sum[0]);
	}
  
  if(ans==INF)	cout<<"-1"<<endl;
  else cout<<ans<<endl;
  
    return 0;
}

Measured memory_bytes: 3656
n, b, a = gets.chomp.split.map(&:to_i)
 
times = n / (b + a)

if times == 0
  if n > b
    balls = b
  else
  balls = n
  end
elsif n - times * ((b + a)) >= b
  balls = times * b + b
else
  balls = times * b + n - times * ((b + a))
end
 
puts balls


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

string FILENAME = "template";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

ll dp[101][200000];

int main() {
    int N, W;
    cin >> N >> W;
    vi weight(N), value(N);
    forl(i, N) cin >> weight[i] >> value[i];
    forl(i, 101) fill_n(dp[i], 200000, 999999999999);
    dp[0][0] = 0;
    int ans = 0;
    forl(i, N) {
        forl(j, 200000) {
            if(dp[i][j] == 999999999999) continue;
            if(dp[i][j] + weight[i] <= W) setmin(dp[i+1][j+value[i]], dp[i][j]+weight[i]);
            setmin(dp[i+1][j], dp[i][j]);
        }
    }
    forl(i, 200000) {
        if(dp[N][i] != 999999999999) ans = i;
    }
    println(ans);
}

Measured memory_bytes: 158080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = ((int)b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(), c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

signed main() {
  string s;
  cin >> s;
  string wx = "";
  for (char x : s) {
    if (x != 'x') wx += x;
  }
  rep(i, 0, sz(wx) / 2) {
    if (wx[i] != wx[sz(wx) - 1 - i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  vector<int> a;
  a.push_back(0);
  rep(i, 0, sz(s)) {
    if (s[i] == 'x') {
      a.back()++;
    } else {
      a.push_back(0);
    }
  }
  
  int ans = 0;
  rep(i, 0, sz(a) / 2) {
    int l = a[i];
    int r = a[sz(a) - i - 1];
    ans += abs(l - r);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1724
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

path_list = [[] for _ in range(N)]

for i in range(M):
    edge = [int(i) - 1 for i in input().split()]
    path_list[edge[0]].append(edge[1])
    path_list[edge[1]].append(edge[0])
#%%
path_l = [set(i) for i in path_list]
    
ans = 0
for i, j in enumerate(path_l):
    for k in j:
        if H[i] <= H[k]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 55372
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)1000000007
// Big two primes 
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int int
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}

int main()
{
    fio;

    int a,b,c;
    cin>>a>>b>>c;

    multiset<int> m;
    m.insert(a);
    m.insert(b);
    m.insert(c);

    if(m.count(5) == 2 && m.count(7) == 1)
    cout<<"YES\n";

    else 
    cout<<"NO\n";    
    rr;
}

Measured memory_bytes: 256