akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <limits.h>
#define min(rhs, lhs) ((rhs) < (lhs) ? (rhs) : (lhs))

typedef struct{
    long f, s;
    long long t;
} three;

static inline void swap(three *rhs, three *lhs){
    three tmp = *rhs;
    *rhs = *lhs;
    *lhs = tmp;
}

three pq[1000000];

static inline void pqinsert(three elem) {
    pq[0].f++;
    pq[pq[0].f] = elem;
    long i = pq[0].f;
    while(i / 2){
        if(pq[i].t < pq[i / 2].t)swap(&pq[i], &pq[i / 2]);
        i /= 2;
    }
}

static inline three pqpop() {
    three ret = pq[1];
    pq[1].t = LLONG_MAX;
    swap(&pq[1], &pq[pq[0].f]);
    pq[0].f--;
    long mi, i = 1;

    while(i * 2 + 1 <= pq[0].f + 1) {
        mi = pq[i * 2].t > pq[i * 2 + 1].t ? i * 2 + 1 : i * 2; 
        if(pq[mi].t < pq[i].t)
        swap(&pq[mi], &pq[i]);
        i = mi;
    }
    return ret;
}

int main(void) {
    register long i, j;
    int n, m, tu, tv;
    long s, ta, tb;
    scanf("%d%d%ld",&n, &m, &s);
    static three train[50][49];
    static int trarp[50];
    for(i = 0; i < m; i++) {
        scanf("%d%d%ld%ld",&tu ,&tv ,&ta ,&tb);
        tu--;
        tv--;
        train[tu][trarp[tu]] = (three){tv, ta, tb};
        train[tv][trarp[tv]] = (three){tu, ta, tb};
        trarp[tu]++;
        trarp[tv]++;
    }
    static long excm[50], exct[50];
    for(i = 0; i < n; i++)
    scanf("%ld%ld",&excm[i], &exct[i]);
    static long long dp[50][2501];

    for(i = 0; i < 50; i++)
    for(j = 0; j <= 2500; j++)
    dp[i][j] = LLONG_MAX;
    for(i = 1; i < 100000; i++)
    pq[i] = (three){0, 0, LLONG_MAX};
    s = min(s, 2500);
    pqinsert((three){0, s, 0});

    while(pq[0].f) {
        three cur = pqpop();
        if(dp[cur.f][cur.s] <= cur.t)
        continue;
        dp[cur.f][cur.s] = cur.t;

        for(i = 0; i < trarp[cur.f]; i++)
        if(train[cur.f][i].s <= cur.s)
            pqinsert((three){train[cur.f][i].f, cur.s - train[cur.f][i].s, cur.t + train[cur.f][i].t});
            
            if(cur.s == 2500)
            continue;
            pqinsert((three){cur.f, min(cur.s + excm[cur.f], 2500), cur.t + exct[cur.f]});
    }
    static long long mins[50];
    for(i = 0; i < n; i++)
    mins[i] = LLONG_MAX;
    for(i = 1; i < n; i++)
    for(j = 0; j < 2501; j++)
    mins[i] = min(dp[i][j], mins[i]);
    for(i = 1; i < n; i++)
    printf("%lld\n",mins[i]);
}


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

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


int main(){
  int n; 
  cin >> n;
  vector<int> a(22),b(22),c(22);
  rep(i,n){ cin >> a[i+1]; }
  rep(i,n){ cin >> b[i+1]; }
  rep(i,n){ cin >> c[i+1]; }
  a[0]=-111;

  int ans=0;
  for(int i=1; i<=n; i++){
    ans += b[a[i]];
    if(a[i-1]+1==a[i]){ ans += c[a[i-1]]; }    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int w, h;
int r[31][31], u[31][31];
int a[31][31];
deque<pair<int, int> > Q;
pair<int, int> x, y;
int main()
{
	while(cin >> w >> h && w>0)
	{
		for(int i=0; i<h; i++)
		{
			for(int j=0; j<w; j++)
			{
				a[i][j]=-1;
			}
		}
		for(int i=0; i<h-1; i++)
		{
			for(int j=0; j<w-1; j++)
			{
				cin >> r[i][j];
			}
			for(int j=0; j<w; j++)
			{
				cin >> u[i][j];
			}
		}
		for(int j=0; j<w-1; j++)
		{
			cin >> r[h-1][j];
		}
		Q.clear();
		x=make_pair(0, 0);
		Q.push_back(x);
		a[0][0]=1;
		while(!Q.empty())
		{
			x=Q.front();
			Q.pop_front();
			if(x.first!=0)
			{
				if((u[x.first-1][x.second]==0)&&(a[x.first-1][x.second]==-1))
				{
					y=make_pair(x.first-1, x.second);
					Q.push_back(y);
					a[x.first-1][x.second]=a[x.first][x.second]+1;
				}
			}
			if(x.second!=0)
			{
				if((r[x.first][x.second-1]==0)&&(a[x.first][x.second-1]==-1))
				{
					y=make_pair(x.first, x.second-1);
					Q.push_back(y);
					a[x.first][x.second-1]=a[x.first][x.second]+1;
				}
			}
			if(x.first!=h-1)
			{
				if((u[x.first][x.second]==0)&&(a[x.first+1][x.second]==-1))
				{
					y=make_pair(x.first+1, x.second);
					Q.push_back(y);
					a[x.first+1][x.second]=a[x.first][x.second]+1;
				}
			}
			if(x.second!=w-1)
			{
				if((r[x.first][x.second]==0)&&(a[x.first][x.second+1]==-1))
				{
					y=make_pair(x.first, x.second+1);
					Q.push_back(y);
					a[x.first][x.second+1]=a[x.first][x.second]+1;
				}
			}
		}
		if(a[h-1][w-1]==-1)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << a[h-1][w-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
def solve(a_s) -> int:
  # def get_ret_from_xs(xs) -> int:
  #   # 繰り上がり処理ありバージョン
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * (x % 2)
  #     ret %= 10**9 + 7
  #   return ret
  #
  # def get_ret_from_xs2(xs) -> int:
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * x
  #     ret %= 10**9 + 7
  #   return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60

  ret = 0
  for i in range(60):
    ones = sum([(a >> i) & 0b1 for a in a_s])
    ret += 2**i * (ones * (len(a_s) - ones))
    ret %= 10**9 + 7
  return ret

  # for a in a_s:
  #   for i in range(len(zeros)):
  #     # a_bin = format(a, '060b')
  #     # a_i_digit_from_right = a_bin[60 - i - 1]
  #     # if a_i_digit_from_right == '0':
  #     #   zeros[i] += 1
  #     # else:
  #     #   ones[i] += 1
  #
  #     a_i_digit_from_right = (a >> i) & 0b1
  #     if a_i_digit_from_right == 0:
  #       zeros[i] += 1
  #
  # # 繰り上がり処理しないでも、各桁で収めてもいいんだ！
  # xs = [zeros[i] * (len(a_s) - zeros[i]) for i in range(60)]
  # return get_ret_from_xs2(xs)
  #
  #
  # # # 繰り上がりのせいで、xsの要素数は60を超えることがあるので注意
  # # xs = []
  # # i = 0
  # # while True:
  # #   x_i = 0
  # #   if i <= 59:
  # #     x_i = (zeros[i] * ones[i])
  # #   if i >= 1:
  # #     x_i += xs[i - 1] // 2
  # #   xs.append(x_i)
  # #
  # #   if i >= 60 and x_i // 2 == 0:
  # #     break
  # #
  # #   i += 1
  #
  # #xs = [2, 3, 1]
  # #return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    int sum = 0;
    vector<int> t(n);
    for(int i=0;i<n;i++){
        cin >> t[i];
        sum += t[i];
    }
    int m;cin >> m;
    for(int i=0;i<m;i++){
        int p, x;cin >> p >> x;p--;
        cout << sum+x-t[p] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 1000000000;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
struct LazySegmentTree {
private:
  int n;
  vector<int> node, lazy;
  vector<bool> lazyFlag;
public:
  LazySegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1);
    lazy.resize(2*n-1, INF);
    lazyFlag.resize(2*n-1, false);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
  }
  void lazyEvaluate(int k, int l, int r) {
    if(lazyFlag[k]) {
      node[k] = lazy[k];
      if(r - l > 1) {
        lazy[k*2+1] = lazy[k*2+2] = lazy[k];
        lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
      }
      lazyFlag[k] = false;
    }
  }
  void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    lazyEvaluate(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      lazyFlag[k] = true;
      lazyEvaluate(k, l, r);
    }
    else {
      update(a, b, x, 2*k+1, l, (l+r)/2);
      update(a, b, x, 2*k+2, (l+r)/2, r);
      node[k] = min(node[2*k+1], node[2*k+2]);
    }
  }
  int find(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    lazyEvaluate(k, l, r);
    if(b <= l || r <= a) return INF;
    if(a <= l && r <= b) return node[k];
    int vl = find(a, b, 2*k+1, l, (l+r)/2);
    int vr = find(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int H, W;
  cin >> H >> W;
  vector<int> A(H);
  vector<int> B(H);
  REP(i, H) cin >> A[i] >> B[i];
  REP(i, H) {
    A[i]--; B[i]--;
  }
  vector<int> t1(W);
  vector<int> t2(W);
  REP(i, W) t1[i] = W-i;
  LazySegmentTree l1(t1);
  LazySegmentTree l2(t2);
  
  REP(i, H) {
    if(B[i] != W-1) {
      int mi = l1.find(0, B[i]+2);
      l1.update(B[i]+1, B[i]+2, mi);
      int move = mi - (W-(B[i]+1));
      if(mi == INF) move = INF;
      l2.update(B[i]+1, B[i]+2, move);
      //cout << mi << " " << move << endl;
    }
    l1.update(A[i], B[i]+1, INF);
    l2.update(A[i], B[i]+1, INF);
    int ans = l2.find(0, W);
    if(ans == INF) cout << -1 << "\n";
    else cout << ans + (i+1) << "\n";
  }
}

Measured memory_bytes: 15384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n,m,k;
 cin>>n>>m>>k;
 vector<ll> d(m);
 vector<ll> rev(n,-1);
 for(ll i=0;i<m;i++)cin>>d[i],d[i]--,rev[d[i]] = i;
 vector< vector<ll> > v(n,vector<ll>(k,0) );
 set<ll> dd;
 for(ll i=0;i<n;i++){
  for(ll j=0;j<k;j++) cin>>v[i][j],v[i][j]--;
 }
 vector<ll> dp( 1<<m , inf );
 dp[ (1<<m)-1 ] = 0;
 queue<mp> q;
 q.push(  mp( (1<<m)-1 , 0 ) );
 while(!q.empty() ){
  mp now = q.front();
  q.pop();
 // if( dp[now.first] != inf ) continue;
  //dp[nn] = cost;
  ll nn = now.first;
  if( nn == 0 ) break;
  ll cost = now.second;
  for(ll i=0;i<k;i++){
   ll next = 0;
   for(ll j=0;j<m;j++){
    if( (nn>>j)&1 ){
     if( rev[ v[ d[j] ][i] ] != -1 ){
      next |= 1<<rev[ v[d[j]][i] ];
     }
    }
   }

   if( dp[next] != inf ) continue;
   dp[next] = cost + 1;
   q.push( mp( next , cost+1) );
  }
 }
 cout<<dp[0]<<endl;

    return 0;
}



Measured memory_bytes: 4100
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	const ll MOD = 998244353;

	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(begin(a), end(a));

	ll t = a[0];
	for (ll i = 1; i < n; i++) {
		(t *= gcd(a[i], i) % MOD) %= MOD;
	}

	cout << t << endl;
	return 0;
}


Measured memory_bytes: 1024
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

int n;
int ans;

vector<int> w,r;
vector<pi> b;
int B;

const int N = 9;
int res[N][N];

void dfs(int d){
    if(d==B){
        rep(i,n)if(w[i]!=n/2) return;
        ++ans;
        return;
    }

    int x = b[d].fi, y = b[d].se;
    if(res[x][y]==0){
        rep(i,2){
            ++w[x];
            --r[x];
            --r[y];

            bool valid = true;
            for(int j:{x,y}){
                if(w[j]+r[j]<n/2 || w[j]>n/2) valid = false;
            }
            if(valid) dfs(d+1);

            --w[x];
            ++r[x];
            ++r[y];
            swap(x,y);
        }
    }
    else dfs(d+1);
}

int main(){
    while(cin >>n,n){
        memset(res,0,sizeof(res));
        w = vector<int>(n);
        r = vector<int>(n,n-1);

        int m;
        cin >>m;
        rep(i,m){
            int x,y;
            cin >>x >>y;
            --x;
            --y;

            res[x][y] = 1;
            res[y][x] = -1;

            ++w[x];
            --r[x];
            --r[y];
        }

        ans = 0;
        b.clear();
        rep(i,n)for(int j=i+1; j<n; ++j) b.pb({i,j});
        B = b.size();
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}



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

using ll = long long;

const ll MOD = 1e9+7;

int main() {
   int H, W, K;
   cin >> H >> W >> K;
   --K;

   ll dp[H+1][W];
   fill(dp[0], dp[H+1], 0);
   dp[0][0] = 1;

   for (int h = 0; h < H; h++) {
      for (int b = 0; b < (1<<(W-1)); ++b) {
         bool judge = true;
         for (int i = 0; i < W-2; ++i) {
            if ((b >> i) % 4 == 3) judge = false;
         }

         if (!judge) continue;

         int perm[W];
         for (int i = 0; i < W; ++i) perm[i] = i;

         for (int i = 0; i < W-1; ++i) {
            if ((b >> i) & 1) swap(perm[i], perm[i+1]);
         }

         for (int i = 0; i < W; ++i) {
            dp[h+1][perm[i]] += dp[h][i];
            dp[h+1][perm[i]] %= MOD;
         }
      }
   }

   cout << dp[H][K] << endl;

   return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		FibonacciNumber fn = new FibonacciNumber(scan.nextInt());
		fn.show();
	}
}
class FibonacciNumber{
	int n=1;
	int target;
	int ans=1;
	public FibonacciNumber(int t){
		target=t;
	}
	void calc(int a, int b){
		if(target<2)
			return;
		ans=a+b;
		if(++n==target)
			return;
		calc(b,ans);
	}
	public void show(){
		calc(1,1);
		System.out.printf("%d\n",ans);
	}
}
class BubbleSort{
	int[] seq;
	int SwapCount;
	public BubbleSort(int length){
		seq=new int[length];
		SwapCount=0;
	}
	public void Load(int i,int num){
		seq[i]=num;
	}
	void Swap(int x, int y){
		int tmp=seq[x];
		seq[x]=seq[y];
		seq[y]=tmp;
		SwapCount++;
	}
	void Sort(){
		for(int i=0; i<seq.length;i++)
			for(int j=seq.length-1; j>i;j--)
				if(seq[j]<seq[j-1])
					Swap(j,j-1);
	}
	public void show(){
		Sort();
		for(int i=0;i<seq.length;i++)
			System.out.printf("%d ",seq[i]);
		System.out.printf("\n%d\n",SwapCount);
	}
}

Measured memory_bytes: 17320
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> c(n), d(n);
    for(int i=0;i<n;i++){
    	cin >> c[i] >> d[i];

    }
    sort(be(c));
    sort(be(d));
    ll mi, ma;
    if(n&1){
    	mi = c[n/2];
    	ma = d[n/2];
    	cout << ma - mi + 1 << endl;
    }else{
    	bool maki = false, niko = false;
    	if((c[n/2] - c[n/2 - 1]) % 2 == 0){
    		mi = (c[n/2] + c[n/2 - 1]) / 2;
    	}else{
    		mi = (c[n/2] + c[n/2 - 1]) / 2 + 1;
    		maki = true;
    	}
    	if((d[n/2] - d[n/2 - 1]) % 2 == 0){
    		ma = (d[n/2] + d[n/2 - 1]) / 2;
    	}else{
    		ma = (d[n/2] + d[n/2 - 1]) / 2;
    		niko = true;
    	}
    	ll ans = (ma - mi) * 2LL + 1;
    	if(maki) ans++;
    	if(niko) ans++;
    	cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6372
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int main() {
	int n,t=0,x=0,y=0;
	bool can=true;
	cin>>n;
	int pt,px,py;
	rep(i,0,n){
		pt=t,px=x,py=y;
		cin>>t>>x>>y;
		int dt=t-pt,dx=abs(x-px),dy=abs(y-py);
		if(dx+dy>dt||dt%2!=(dx+dy)%2)can=false;
		if(!can)break;
	}
	if(!can)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main () {
	int n;
	cin >> n;
	set<string> registed;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		registed.insert(str);
	}
	bool state = false;
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		string str;
		cin >> str;
		if (registed.find(str) == registed.end()) {
			cout << "Unknown " << str << endl;
		}
		else {
			if (state) {
				cout << "Closed by " << str << endl;
			}
			else {
				cout << "Opened by " << str << endl;
			}
			state = !state;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i,j,v[n];
	for(i=0;i<n;i++)
		cin>>v[i];
	sort(v,v+n,greater<ll>());
	ll ans=0;
	ans+=v[0];
	i=1;
	j=2;
	for(;j<n;){
		ans+=v[i];
		if(j+1<n)
		ans+=v[i];
	i++;
		j+=2;

	}
	cout<<ans<<endl;

	return 0;
} 

Measured memory_bytes: 5204
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    a, b = mi()
    print(100, 100)
    ans = [[] for i in range(100)]
    for i in range(50):
        for j in range(100):
            ans[i].append('#')
    for i in range(50, 100):
        for j in range(100):
            ans[i].append('.')

    for i in range(a - 1):
        ans[2 * (i // 50)][2 * (i % 50)] = '.'
    for i in range(b - 1):
        ans[99 - 2 * (i // 50)][2 * (i % 50)] = '#'

    for i in range(100):
        print(''.join(ans[i]))


main()


Measured memory_bytes: 10060
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>

using namespace std;

int N, cor = 0, av;
double a = 0;

int main()
{
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> N;
	vector<int> v(N);
	
	for (int i = 0; i < N; ++i)
	{
		cin >> v[i];
		a += v[i];
	}
	a /= N;
	av = round(a);
	for (int i = 0; i < N; ++i)
		cor += pow((av-v[i]), 2);
	cout << cor << '\n';
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String T = sc.next();
        String[] t = T.split("");
        
        long count = 0;
        for(int i=0; i<t.length; i++) {
            if(t[i].equals("?")) System.out.print("D");
            else System.out.print(t[i]);
        }
        
        
    }   
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}

const int INF=1001001001001001001ll;

int N,M;
int X[1111],Y[1111],Z[1111];

int dp[1111];

int solve(){
    fill_n(dp,M+1,-INF);
    dp[0]=0;
    rep(i,N){
        for(int j=M-1;j>=0;j--){
            chmax(dp[j+1],dp[j]+X[i]+Y[i]+Z[i]);
        }
    }
    return dp[M];
}

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>X[i]>>Y[i]>>Z[i];

    int ans=0;
    rep(i,8){
        rep(j,N){
            if(i>>0&1)X[j]*=-1;
            if(i>>1&1)Y[j]*=-1;
            if(i>>2&1)Z[j]*=-1;
        }
        chmax(ans,solve());
        rep(j,N){
            if(i>>0&1)X[j]*=-1;
            if(i>>1&1)Y[j]*=-1;
            if(i>>2&1)Z[j]*=-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    lint A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K > A + B) {
        lint rem = K - A - B;
        cout << A - rem << endl;
    }
    else {
        cout << min(A, K) << endl;
    }
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
    }
    ll max = 0, submax = 0;
    for(auto e: mp){
        if(e.second >= 4){
            if(max < e.first){
                max = submax = e.first;
            }else if(submax < e.first){
                submax = e.first;
            }
        }else if(e.second >= 2){
            if(max < e.first){
                submax = max;
                max = e.first;
            }else if(submax < e.first){
                submax = e.first;
            }
        }
    }
    cout << max * submax << endl;
}

Measured memory_bytes: 5376
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = long.Parse(Console.ReadLine());

            var ub = (int)Math.Floor(Math.Sqrt(N));
            for (int i = ub; i > 0; i--)
            {
                if (N % i == 0)
                {
                    var l = i;
                    var r = N / i;
                    Console.WriteLine(l + r - 2);
                    break;
                }
            }
        }
    }
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int ans;
    if(a<10 and b<10) ans = a*b;
    else ans = -1;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

template<int N>
struct UF {
    int ig[N];
    vector<int> gi[N];
    int gn;
    void init(int n = N) {
        for (int i = 0; i < n; i++) {
            ig[i] = i;
            gi[i] = {i};
        }
        gn = n;
    }
    void merge(int a, int b) {
        if (same(a, b)) return;
        gn--;
        int x = ig[a], y = ig[b];
        if ((int)gi[x].size() < (int)gi[y].size()) swap(x, y);
        for (int j: gi[y]) {
            ig[j] = x;
        }
        gi[x].insert(gi[x].begin(), gi[y].begin(), gi[y].end());
        gi[y].clear();
    }
    bool same(int a, int b) {
        return ig[a] == ig[b];
    }
};
const int MN = 1010;
UF<MN> uf;

int main() {
    int n, m;
    cin >> n >> m;
    uf.init(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    int A = 0, B = 0;
    for (int i = 0; i < n; i++) {
        if (uf.gi[i].size() == 0) continue;
        if (uf.gi[i].size() == 1) B++;
        else A++;
    }
    printf("%d\n", abs(A-B));
}

Measured memory_bytes: 3324
/*---Author:HenryHuang---*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+5;
int n,p;
int ksm(int a,int b,int p){
	int ans=1;
	while(b){
		if(b&1) ans=1ll*ans*a%p;
		b>>=1,a=1ll*a*a%p;
	}
	return ans;
}
int C[maxn][maxn],S[maxn][maxn];
void init(){
	C[0][0]=S[0][0]=1;
	for(int i=1;i<=n+1;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j){
			S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j]%p)%p;
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>p;init();
	int ans=0;
	for(int i=0;i<=n;++i){
		int tmp=1ll*ksm(2,ksm(2,n-i,p-1),p)*C[n][i]%p,owo=0;
		if(i&1) tmp=p-tmp;
		for(int j=0;j<=i;++j){
			owo=(owo+1ll*S[i+1][j+1]*ksm(2,1ll*(n-i)*j%(p-1),p)%p)%p;
		}
		(ans+=1ll*tmp*owo%p)%=p;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 58736
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let n: usize = io.read();
    let mut s = io.chars();

    let mut ans = 0;
    for i in 0..n {
        let sl = &s[i..];
        let z2 = zalgo(sl);
        // io.debug(&z2);
        let ln = z2.len();
        for j in 1..ln {
            if j >= z2[j] {
                ans = max(ans, z2[j]);
            }
        }
    }
    // let z = zalgo(&s);
    io.writeln(ans);
}
fn zalgo(s: &[char]) -> Vec<usize> {
    let n = s.len();
    let mut a = vec![0usize; n];
    let mut from = 0;
    let mut last = 0;
    a[0] = n;
    for i in 1..n {
        let mut same = a[i];
        if from != 0 {
            same = min(a[i - from], if last > i { last - i } else { 0 });
        }
        while i + same < n && s[same] == s[same + i] {
            same += 1;
        }
        if last < i + same {
            last = i + same;
            from = i;
        }
        a[i] = same;
    }
    return a;
}

static MOD: i64 = 1000000007;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4476
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

S=one_str()

count=0
max_count=0
for s in S:
    if s in ["A","G","C","T"]:
        count+=1
    else:
        if max_count < count:
            max_count = count
        count=0
if max_count < count:
    max_count=count
print(max_count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (1000000007)


//グラフ
#define MAXV (MAXN*3)
int Gv;
typedef struct edge
{
    int to;
    ll cost;
    struct edge* next;
}edge;


void Gadd(edge** es,int v, int to, ll cost)
{
    edge* e = malloc(sizeof(edge));
    e->to = to;
    e->cost = cost;
    e->next = es[v];
    es[v] = e;
}

// Que
typedef struct Que
{
    ll val;
    struct Que* next;
}Que;

void QuePush(Que** qr,ll val)
{
    Que* q = malloc(sizeof(Que));
    q->val = val;
    q->next = *qr;
    *qr = q;
}

//NULLチェックは外側で
ll QuePop(Que** qr)
{
    ll r = (*qr)->val;
    Que* f = *qr;
    *qr = (*qr)->next;
    free(f);
    return r;
}

edge* Ge[MAXV]; //vから出てる有向辺

//vからの最短距離
int GSP[MAXV];
void GShortestPath(int v)
{
    Que *q=NULL,*nq=NULL;
    QuePush(&q,v);
    GSP[v] = 0;
    while(q!=NULL)
    {
        while(q!=NULL)
        {
            ll v = QuePop(&q);
            edge* e = Ge[v];
            while(e!=NULL)
            {
                if(GSP[e->to]==0)
                {
                    GSP[e->to] = GSP[v]+1;
                    QuePush(&nq,e->to);
                }
                e = e->next;
            }
        }
        q = nq;
        nq = NULL;
    }
}

int main(void)
{
    int n,m;
    int s,t;
    scanf("%d %d",&n,&m);

    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        u--;v--;
        Gadd(Ge,u,v+MAXN,0);
        Gadd(Ge,u+MAXN,v+MAXN+MAXN,0);
        Gadd(Ge,u+MAXN+MAXN,v,0);
    }
    scanf("%d %d",&s,&t);
    s--;t--;
    GShortestPath(s);

    printf("%d\n",GSP[t]==0?-1:GSP[t]/3);

    return 0;
}


Measured memory_bytes: 13056
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int a;
	int b;
	int s;
	int[] sa = new int[7];
	
	public void kei(){
		for(s=0;s<sa.length;s++){
			a = sc.nextInt();
			b = sc.nextInt();
			sa[s] = a - b;
			
		}
	}
	
	public void hyouji(){
		for(s=0;s<sa.length;s++){
			System.out.println(sa[s]);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main go = new Main();
		go.kei();
		go.hyouji();

	}

}

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

using namespace std;
//using ll = long long;

int main() {
    int N = 9;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    bool ans =1;
    for (size_t i = 0; i < 2; i++)
    {
        for (size_t j = 0; j < 2; j++)
        {
            if (A.at(3*i+j+1)-A.at(3*i+j) != A.at(3*i+j+4)-A.at(3*i+j+3))
            {
                ans = 0;
                break;
            }
            
        }
        for (size_t j = 0; j < 2; j++)
        {
            if (A.at(3*i+j+3)-A.at(3*i+j) != A.at(3*i+j+4)-A.at(3*i+j+1))
            {
                ans = 0;
                break;
            }
            
        }
        
    }
    if(ans) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <complex>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vst;
typedef pair<int,int> pint;
typedef long long ll;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(),(s).end()
#define each(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define debug(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl
template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}
template<class T> void print(T P[], int n) {cout<<"{ ";for(int i=0;i<n;++i){if(i>0)cout<<", ";cout<<P[i];}cout<<" }"<<'\n';}
template<class T> void print(T P[][30], int n, int m) {for(int i=0;i<n;++i){cout<<i<<" : ";print(P[i],m);}}



int n;
vst str;

bool d[30][30];

string solve() {
    map<char,int> ma;
    for (int i = 0; i < 26; ++i) ma[(char)('a'+i)] = i;

    memset(d, 0, sizeof(d));
    for (int i = 1; i < str.size(); ++i) {
        string s1 = str[i-1];
        string s2 = str[i];
        
        for (int j = 0; j < min((int)s1.size(), (int)s2.size()); ++j) {
            if (s1[j] != s2[j]) {
                d[ma[s1[j]]][ma[s2[j]]] = true;
                break;
            }
            else if (j == min((int)s1.size(), (int)s2.size())-1 && s1.size() > s2.size()) {
                return "no";
            }
        }
    }
    
    bool ok = true;
    for (int k = 0; k < 26; ++k) {
        for (int i = 0; i < 26; ++i) {
            for (int j = 0; j < 26; ++j) {
                d[i][j] |= d[i][k] & d[k][j];
            }
        }
    }
    
    for (int i = 0; i < 26; ++i) {
        if (d[i][i]) ok = false;
    }
    
    //print(d, 26, 26);
    
    return ok ? "yes" : "no";
}

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/JAG Practice Asia 2012 A - Dictionary.in", "r", stdin );
    
    while (cin >> n) {
        if (n == 0) break;
        str.clear();
        for (int i = 0; i < n; ++i) {
            string temp;
            cin >> temp;
            str.pb(temp);
        }
        cout << solve() << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1264
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm> 
using namespace std;

#define ls st<<1
#define rs st<<1|1
#define LL long long 
#define CLR(a,b) memset(a,(b),sizeof(a))

const int MAXN = 1e3+11;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f; 

/* ------------------------基本函数-------------------------*/
long long read()
{
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
bool prime(int x) {
	if(x==2 || x==3) 
		return true;
	if(x%2==0 || x%3==0 || x==1)
		return false;
	int k = sqrt(x)+1;
	for(int i = 5; i < k; i++) {
		if(x%i==0 || x%(i+2)==0)
			return false;
	}
	return true;
} 

LL pow_mod(int a, int b, int c) {
	LL ans = 1;
	while(b) {
		if(b&1)
			ans = (ans*1) % c;
		a = (a*a) % c;
		b /= 2;
	}
	return ans;
}
int gcd(int a, int b) {
	if(!b) 
		return a;
	return gcd(b,a%b);
}
/*-------------------------------------------------------*/


int main() {
	LL x,y,a,b;
	while(cin >> x) {
	string s;
	cin >> s >> y;
	if(s =="-") cout << x-y << endl;
	else cout << x+y << endl;
	}
	
return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    final int n = scanner.nextInt();
    final int l = scanner.nextInt();
    scanner.nextLine();
    String[] s = new String[n];
    for (int i = 0; i < n; i++) {
      s[i] = scanner.nextLine();
    }

    System.out.println(Arrays.stream(s).sorted().collect(Collectors.joining()));
  }
}

Measured memory_bytes: 27732
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    ll z = 1, f[200005] = {1}, g[200005] = {};
    g[200000] = 750007460;
    for (int i = 1; i <= 200000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 199999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    cin >> n >> m;
    for (int i = 2; i <= 32800; i++) if (m % i == 0) {
        int c = 0;
        while (m % i == 0) m /= i, c++;
        z = z * f[n + c - 1] % mod * g[c] % mod * g[n - 1] % mod;
    }
    if (m > 1) z = z * n % mod;
    cout << z;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,max=0,i,sum=0;
  cin>>n;
  int l[n];
  for(i=0;i<n;++i){
    cin>>l[i];
  }
  for(i=0;i<n;++i){
    if(l[i]>max) {max = l[i];}
    sum+=l[i];
  }
  if(sum-max>max){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
S = list(input())
stack = [""]
cnt = 0
was_same = False
for s in S:

    if was_same:
        stack.append(temp+s)
        was_same = False
        cnt += 1
    elif s != stack[-1]:
        stack.append(s)
        was_same = False
        cnt += 1
    elif s == stack[-1]:
        temp = s
        was_same = True
print(cnt)
#print(stack)

Measured memory_bytes: 9404
program takaku
  implicit none
  integer :: N,i,suml,yn
  integer,allocatable :: L(:)
  read(*,*) N
  allocate(L(N))
  read(*,*) L
  suml=sum(L)
  yn=0
  do i=1,N
     if(L(i).lt.(suml-L(i))) then

     else
        yn=1
     endif
  enddo
  if(yn.eq.1) then
     write(*,'(a)') 'No'
  else
     write(*,'(a)') 'Yes'
  endif

  deallocate(L)



end program takaku


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


int main() {
    int h,a;
    cin >> h >> a;
    int count = 0;
    int hp = h;
    while(hp > 0){
        hp -= a;
        count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

ll powmod (int x, int n){
    ll res = 1;
    rep(i,n){
        res = res * x % mod;
}
    return res;
}

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

    ll ans = powmod(10,n) - (powmod(9,n) * 2) + powmod(8,n);
    ans %= mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int n, ma, mb, dp[41][401][401], INF=1e4;
int main(void){
    cin>>n>>ma>>mb;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=1;i<=n;i++){
        int a, b, c;
        cin>>a>>b>>c;
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                dp[i][j][k]=dp[i-1][j][k];
                if(j>=a&&k>=b)dp[i][j][k]=min(dp[i][j][k], dp[i-1][j-a][k-b]+c);
            }
        }
    }
    int m=INF;
    for(int i=1;i<=400;i++){
        int a=ma*i, b=mb*i;
        if(a<=400&&b<=400)m=min(m, dp[n][a][b]);
    }
    if(m>=INF){
        cout<<-1<<endl;
    }else{
        cout<<m<<endl;
    }
}


Measured memory_bytes: 25984
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s,t = input().split()
a,b = nm()
u = input()

if u == s:
  a-=1
if u == t:
  b-=1

print(a)
print(b)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int D = NextInt();
        int N = NextInt();
        Console.WriteLine(Math.Pow(100, D) * (N == 100 ? 101 : N));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	REP(i, S.size()) S[i] = 'x';
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m),sum1(n+1,0),sum2(m+1,0);
    rep(i,n){
        cin>>a[i];
        sum1[i+1]=sum1[i]+a[i];
    }
    rep(i,m){
        cin>>b[i];
        sum2[i+1]=sum2[i]+b[i];
    }
    ll ans=0;
    rep(i,n+1){
        ll now=i;
        ll ret=k-sum1[i];
        if(ret<0){
            continue;
        }
        auto itr=upper_bound(begin(sum2),end(sum2),ret);
        itr--;
        now+=itr-begin(sum2);
        chmax(ans,now);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9528
using System;

public class TogglingCases
{
    //????????????????????????????°?????????¨??§???????????\????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        string beforeComment;
        char[] changeCommnet;
        string afterComment;
        /*---??£?¨???¨---*/

        /*??\?????¨*/
        beforeComment = Console.ReadLine();

        /*??????*/
        changeCommnet = beforeComment.ToCharArray();

        for (int i = 0; i < changeCommnet.Length; i++)
        {
            if (char.IsUpper(changeCommnet[i]))
            {
                changeCommnet[i] = char.ToLower(changeCommnet[i]);
            }
            else
            {
                changeCommnet[i] = char.ToUpper(changeCommnet[i]);
            }
        }

        afterComment = new string(changeCommnet);

        Console.WriteLine(afterComment);
    }
}

Measured memory_bytes: 9100
from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import unittest
from io import StringIO
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:  # 平方数の場合n**0.5を1つだけにしてる
                    divisors.append(n//i)

        divisors.sort(reverse=True)  # ソートしたけりゃして
        return divisors

    M = make_divisors(sum(A))

    def main():
        for i in M:
            AA = [0]*N
            age = 0
            # delete = 0
            for j in range(N):
                AA[j] = A[j] % i
                #if AA[j] == 0:
                    # delete += 1
                    # age -= i
                age += i-AA[j]
            AA.sort()

            times = 10**9
            sage = 0
            for j in range(0,N-1):
                sage += AA[j]
                age -= i-AA[j]
                if sage % i == age % i:
                    times = min(max(sage, age), times)
            if times <= K:
                return i
    print(main())

resolve()

Measured memory_bytes: 5712