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

int main(){
	int n,m;cin >> n >> m;
	vector<pair<long long int, long long  int>> vp;
	long long int ans = 0;
	for(int i = 0;i < n;i++){
		long long int a, b;cin >> a >> b;
		vp.push_back({a, b});
	}
	sort(vp.begin(), vp.end());
	for(int i = 0;i < n;i++){
		if(m > vp[i].second){
			m -= vp[i].second;
			ans += vp[i].second * vp[i].first;
		}
		else return cout << ans + m * vp[i].first, 0;
	}
}
// make pair, tuple
// make pair, tuple
// 
// __gcd(int, int);
// lcm = a * b / __gcd(a, b);
// 
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

// #binary exponentiation
// long long binpow(long long a, long long b) {
//     long long res = 1;
//     while (b > 0) {
//         if (b & 1)
//             res = res * a;
//         a = a * a;
//         b >>= 1;
//     }
//     return res;
// }


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

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }
};

template <typename M>
class node {
	using T = typename M::type;
public:
	T val, add;
	node<M> *l, *r;
	node() : val(), add(), l(nullptr), r(nullptr) {}
};

template <typename M>
class StarrySkyTree {
	using T = typename M::type;
	const ll n;
	node<M> *root;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1ll;
		return res;
	}
	T sub(ll l, ll r, node<M> *n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return M::id();
		if (!n) return T();
		if (l <= lb && ub <= r) return n->val + n->add;
		return M::op(sub(l, r, n->l, lb, (lb + ub) / 2), sub(l, r, n->r, (lb + ub) / 2, ub)) + n->add;
	}
	node<M>* suc(ll l, ll r, node<M> *n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return n;
		if (!n) n = new node<M>;
		if (l <= lb && ub <= r) {
			n->add += val;
			return n;
		}
		n->l = suc(l, r, n->l, lb, (lb + ub) / 2, val);
		n->r = suc(l, r, n->r, (lb + ub) / 2, ub, val);
		n->val = M::op(n->l ? n->l->val + n->l->add : T(), n->r ? n->r->val + n->r->add : T());
		return n;
	}
public:
	StarrySkyTree(ll n_) : n(size(n_)), root(nullptr) {}
	void add(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, b, i, s, t, x;
	cin >> n >> q;
	StarrySkyTree<RMQ> st(n);
	while (q--) {
		cin >> b;
		if (b) {
			cin >> i; i--;
			printf("%d\n", st.find(i, i));
		}
		else {
			cin >> s >> t >> x; s--, t--;
			st.add(s, t, x);
		}
	}
	return 0;
}

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


int main(){

  int a, b;
  double c, s, l, h;

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

  c=c*M_PI/180;

  s=a*b*sin(c)/2;
  l=a+b+sqrt(a*a+b*b-2*a*b*cos(c));
  h=b*sin(c);

  printf("%f\n%f\n%f\n", s, l, h);

  return 0;
}

Measured memory_bytes: 672
#include <iostream>
#include <vector>
#include <math.h>
#include <climits>

using namespace std;

int foo(vector<int>& h)
{
    int n = h.size();
    vector<int> dp(n);
    dp[n-1] = 0;
    for (int i=n-2;i>=0;--i)
    {
        int a = abs(h[i]-h[i+1]) + dp[i+1];
        int b = INT_MAX;
        if (i+2<n) b = abs(h[i]-h[i+2]) + dp[i+2];

        dp[i] = min(a,b);
    }

    return dp[0];
}

int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for (int i=0;i<n;++i) cin>>h[i];

    cout<<foo(h)<<endl;

    return 0;
}


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

int main() {
	int H[2], ans = 1e5;
	cin >> H[0] >> H[1];
	for (int i = 0; i < 2; i++) {
		if (H[i] % 3 == 0) {
			cout << 0 << endl;
			return 0;
		}
		ans = min(ans, H[1 - i]);
		int H1 = H[i] / 3;
		int smax = (H1 + 1) * H[1 - i];
		int smin = (H[i] - H1 - 1) * (H[1 - i] / 2);
		ans = min(ans, smax - smin);
		smin = H1 * H[1 - i]; smax = (H[i] - H1) * ((H[1 - i] + 1) / 2);
		ans = min(ans, smax - smin);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]); a[i] -= i;
    }
    sort(a.begin(), a.end());
    ll m = (n % 2? a[(n - 1) / 2] : (a[(n - 1) / 2] + a[(n - 1) / 2 + 1])/2);

    ll ans = 0;
    for (i = 0; i < n; i++) {
        ans += abs(a[i] - m);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n,k; cin>>n>>k;
  if (n >= 2*k-1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int k, a ,b;
    cin >> k;
    cin >> a >> b;
    for (int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}

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

int main() {
    
    long n; cin>>n;
    
    long d[200007],e[200007],tmp[n],sum=0;
    
    for(int i=0;i<200007;++i){
        d[i]=0;
        e[i]=0;
    }
    for(int i=0;i<n;++i){
        cin>>tmp[i];
        d[tmp[i]-1]+=1;
    }
    
    for(int i=0;i<200007;++i){
        if(d[i]>1) {
            e[i]=d[i]*(d[i]-1)/2;
            sum += e[i];
    }
    }
    
for(int i=0;i<n;++i){
    long ans=sum;
    if(e[tmp[i]-1]>0) ans =ans - e[tmp[i]-1]+(d[tmp[i]-1]-1)*(d[tmp[i]-1]-2)/2;
    
    cout<<ans<<endl;

    }
	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>

void max(int *,int);
void build(int *);
int n;  
int main(){
  int i,j,heap[500001];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }
  build(heap);
  for(i=1;i<=n;i++)
    printf(" %d",heap[i]);
  printf("\n");
  return 0;
}
void build(int *heap){
  int i;
  for(i=n/2;i>0;i--)
    max(heap,i);
}
void max(int *heap,int i){
  int l,r,largest,num;
  l = 2*i;
  r = 2*i+1;
  if(l<=n && heap[l] > heap[i])
    largest = l;
  else
    largest = i;
  if(r<=n && heap[r] > heap[largest])
    largest = r;
  if(largest!=i){
    num=heap[i];
    heap[i]=heap[largest];
    heap[largest]=num;
    max(heap,largest);
  }
}
  



Measured memory_bytes: 3684
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000

int G[100][100],n;

int prim(){
  int v,i,u,minv,d[100],p[100],color[100];

  for(i=0;i<n;i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(i = 0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] != INF){
        if(d[v] > G[u][v]){
        d[v] = G[u][v];
          p[v] = u;
        color[v] = GRAY;
      }
    }
  }
  }
  int sum=0;

  for(i=0;i<n;i++) if(p[i] != -1) sum += G[i][p[i]];

  return sum;

}

int main(){

  int i,j,x;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&x);
      if(x==-1) G[i][j] = INF;
      else G[i][j] = x;
    }
  }

  printf("%d\n",prim());

  return 0;

}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int modPow(LL x, LL y){
    LL r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}

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


int main() {
    LL S;cin >> S;

    COMinit();

    LL ans = 0;
    LL lim = S/3;
    for(LL i = lim;i >= 1;i--){
        LL tmp = S - 3*i;
        ans += COM(tmp+i-1,i-1);

        ans %= MOD;
    }

    cout << ans << endl;
    
}

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

int main() {	

	ll n; cin >> n;
	ll ans = 9223372036854775807LL;;
	for (ll a = 1; a * a <= n; a++) {
		if (n % a != 0) continue;
		else {
			ll b = n / a;
			ans = min(ans, a + b - 2LL);
		}
	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
pl = [-1]*(n+1)

for i in range(n):
    pl[a[i]-1] = i

a = 1
ma = 1
for i in range(n):
    if pl[i] < pl[i+1]:
        a += 1
    else:
        ma = max(a,ma)
        a = 1
        
print(n-ma)

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

int main() {
  int A = 0, B = 0;
  cin >> A >> B;
  
  for (double i = 0; i <= B * 20; i += 1) {
    if ((int)(i * 0.08) == A and (int)(i * 0.1) == B) {
      cout << (int)i << endl;
      return 0;
    }
  }
  
  cout << "-1" << endl;
  return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    set <char>s;
    for(int i=0;i<n;i++){
        char S;
        cin>>S;
        s.insert(S);
    }
    
    puts((s.size()==3?"Three":"Four"));

    return 0;
}




Measured memory_bytes: 256
import java.util.*;
class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Dice dice = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
		int a = stdIn.nextInt();
		for(int i = 0; i < a; i++) {
			int T = stdIn.nextInt();
			int S = stdIn.nextInt();
			Dice copy = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
			
			int ans = solv(T,S,copy,0); 
			System.out.println(ans);
		}
	}
	public static int solv(int a, int b, Dice dice,int count) {
		if(dice.Top == a && dice.S == b) return dice.E;
		if(count == 4) return -1;
		int ans = -1;
		Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnN();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnS();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnE();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnW();
		ans = Math.max(solv(a,b,tmp,count+1),ans);
		
		return ans;
	}
	
	
	
}

class Dice {
	int Top; //1
	int Bottom; //6
	int N; //   5
	int S; //   2
	int W; //左 4
	int E; //右 3
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}
	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}
	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}
	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}
	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
	
}

Measured memory_bytes: 18188
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    p = input().strip()

    len_s = len(s)
    len_p = len(p)

    for i in range(len_s):
        ok = True
        for j in range(len_p):
            if s[(i + j)%len_s] != p[j]:
                ok = False
                break
        if ok:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 5568
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    double win=0;
    double num_prob=(double)(1)/n;
    for(int i=1;i<=n;i++){
        if(i>=k){
            win+=(double)(1)/n;
        }
        else{
            int t=i;
            int cnt=0;
            while(t<k){
                t*=2;
                cnt++;
            }
            double steps=pow(2,cnt);
            double prob=(double)(1)/steps;
            win=win+(num_prob)*(prob);
        }
    }
    printf("%0.15f\n",win);
    return 0;
}


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

int pcnt(int x) {
  return __builtin_popcount(x);
}
int f(int x) {
  if (x == 0) return 0;
  return f(x%pcnt(x))+1;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  rep(i,n) x[i] = s[i]-'0';
  int pc = 0;
  rep(i,n) pc += x[i];
  vector<int> ans(n);
  rep(b,2) {
    int npc = pc;
    if (b == 0) npc++; else npc--;
    if (npc <= 0) continue;
    int r0 = 0;
    rep(i,n) {
      r0 = (r0*2)%npc;
      r0 += x[i];
    }
    int k = 1;
    for (int i = n-1; i >= 0; --i) {
      if (x[i] == b) {
        int r = r0;
        if (b == 0) r = (r+k)%npc;
        else r = (r-k+npc)%npc;
        ans[i] = f(r)+1;
      }
      k = (k*2)%npc;
    }
  }

  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5236
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), i;
		sc.close();
		if (N == 1) System.out.print(M);
		else if (M == 1) System.out.print(1);
		else {
			for (i = 2; i <= M / 2; ++i) {
				if (M % i == 0 && N <= i) break;
			}
			if (i == M / 2 + 1) System.out.print(1);
			else System.out.print(M / i);
		}
	}
}

Measured memory_bytes: 23636
# 30
# lack of understanding of Q !

n,m  = map(int, input().split())
L = 0
R = 500000
for i in range(m):
    l,r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)
    l = 0
    r = 0

if 0 >R-L:
    print(0)
else:
    print(R-L+1)


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

#define For(i, l, r) for (register int i = (l), i##end = int(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = int(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

template<typename T = int>
inline T read() {
	T x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 55;

int n; ll a[N], ans;

inline ll Div(ll a, ll b) {
	return (a + b - 1) / b;
}

int main () {

	File();

	For (i, 1, (n = read())) a[i] = read<ll>();

	for (;;) {
		int p = 0;
		For (i, 1, n) if (a[i] > a[p]) p = i;
		if (a[p] < n) break;
		ll cur = Div(a[p] - (n - 1), n); ans += cur;
		a[p] -= cur * n;
		For (i, 1, n) if (p != i) a[i] += cur;
	}

	printf ("%lld\n", ans);

	return 0;

}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int main(){

    int n, d, x;
    cin >> n >> d >> x;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0, consume = 0;
    rep(i,n){
        consume += 1 + (d-1)/a[i];
    }
    ans = consume + x;


    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 301;

bool vis[N][N][N];
LD dp[N][N][N];
int n;

LD solve(int x, int y, int z)
{
   // cout << x << " " << y << " " << z << endl;
	if (x == 0 && y == 0 && z == 0) return 0;
	if (vis[x][y][z]) return dp[x][y][z];
	vis[x][y][z] = true;
	LD den = (long double) x +  y + z;
	LD temp = (long double) n / (long double) den;
	dp[x][y][z] = temp;
	if (x)
		dp[x][y][z] += (((long double) x / den) * solve(x - 1, y, z));
	if (y)
		dp[x][y][z] += (((long double) y / den) * solve(x + 1, y - 1, z));
	if (z)
		dp[x][y][z] += (((long double) z / den) * solve(x , y + 1, z - 1));
 	return dp[x][y][z];
}

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

    cin >> n;

    int x = 0, y = 0, z = 0;
    for (int i = 0; i < n; i++){
    	int a; cin >> a;
    	if (a == 1) x++;
    	if (a == 2) y++;
    	if (a == 3) z++;
    }
    cout << fixed << setprecision(10) << solve(x, y, z) << endl;
	return 0;
}

Measured memory_bytes: 452992
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define ll long long

int main(void){

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

    cout<<(b%a==0?a+b:b-a)<<endl;

    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int total = 0;
    map <int,int> mp;
    while(k--){
        int d;
        cin>>d;
        vector <int> arr;

        for(int i=0;i<d;i++){
            int temp;
            cin>>temp;
            arr.push_back(temp);
        }
        for(int i=0;i<n;i++){
            mp.insert(make_pair(i+1,0));
        }
        for(int i=0;i<d;i++){
            if(mp.find(arr[i]) != mp.end()){
                mp[arr[i]]++;
            }
        }
    }
    for(auto it: mp){
            //cout<<it.first<<" "<<it.second<<"\n";
            if(it.second == 0){
                total++;
            }
        }
        cout<<total;
        return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
string s;
int i,j;
int main() {
	cin>>s;
	for (i=0;i<(int)s.size();i++){
		if(s[i]=='C'){
			for (j=i+1;j<(int)s.size();j++){
				if(s[j]=='F'){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
S = input() 
if(N==K):
 print(S[:K-1]+S[K-1].lower())
elif(K-1 == 0):
 print(S[0].lower()+S[1:])
else:
 print(S[:K-1]+S[K-1].lower()+S[K:])

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int D,N;
    cin >> D >> N;
    int ans=N;
    if(N==100) ans++;
    rep(i,D) ans*=100;
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

profit_max = 0
for i in range(2 ** n):
    value = 0
    cost = 0
    for j in range(n):
        if (i >> j) & 1:
            value += v[j]
            cost += c[j]
    profit_max = max(profit_max, value - cost)
print(profit_max)

Measured memory_bytes: 73536
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<Pll, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000];
string str;
bool f[210000];
char c[1100][1100];
void dfs(LL cur, LL par) {
	LL ret = 0;
	f[cur] = 1;
	rep(i, g[cur].size()) {
		LL v = g[cur][i];
		if (v == par)continue;
		if (f[v] == 0)
			dfs(v,cur);
		if (ma[Pll(cur, v)] == 0) {
			ma[Pll(cur, v)] = 1;
			ma[Pll(v, cur)] = 1;
			cout << cur + 1 << " " << v + 1 << endl;
			ret++;
		}
	}
	if (ret % 2 == 1) {
		ma[Pll(cur, par)] = 1;
		ma[Pll(par, cur)] = 1;
		cout << cur + 1 << " " << par + 1 << endl;
	}
}
int main() {
	cin >> n >> m;
	g.resize(n);
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	if (m % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}
	dfs(0, -1);
	return 0;
}

Measured memory_bytes: 33536
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k-1] << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n;
  cin >> s;
  int ans = n;
  int c = 0;
  rep(i, n-1) {
    if(s[i] == s[i+1]) c++;
    else {
      ans -= c;
      c = 0;
    }
  }
  out(ans - c);
  return 0;
}


Measured memory_bytes: 512
//Volume2-0219
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		final int      END  =  0,
		               KIND = 10;
		      int      n;
		      String[] cnt;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
    		if(n==END){break;}

    		//calculate
    		cnt = new String[KIND];
    		for(int i=0;i<10;i++){cnt[i] = "";}
    		while(n-- > 0){
    			cnt[sc.nextInt()] += "*";
    		}
    		//output
    		for(int i=0;i<KIND;i++){
    			System.out.println(cnt[i].equals("")?"-":cnt[i]);
    		}
    	}
	}
}

Measured memory_bytes: 83644
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>> s;
   int  a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
   if(a+b+c+d==7) {cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl; return 0;}
   if(a+b+c-d==7) {cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl; return 0;}
   if(a+b-c-d==7) {cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl; return 0;}
   if(a+b-c+d==7){ cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl; return 0;}
   if(a-b-c-d==7) {cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl; return 0;}
   if(a-b-c+d==7) {cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl; return 0;}
   if(a-b+c-d==7) {cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl; return 0;}
   if(a-b+c+d==7) {cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl; return 0;}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string str;
  while(getline(cin,str)){
    if(str == "END OF INPUT") break;
    int l=0;
    for(int i=0;i<str.size();i++){
      if(str[i] == ' '){
	cout << l;
	l = 0;
      }else{
	l++;
      }
    }
    if(l)cout << l;
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;


int accumulate(int* a,int n){
    return accumulate(a,a+n,0LL);
}

int accumulate(vector<int> a){
    return accumulate(a.begin(),a.end(),0LL);
}

pair<int,int> gcd(int cnt,int a,int b){
  if(b==0) return {cnt,a};
  cnt++;
  return gcd(cnt,b,a%b);
}

//これだとk<30までしか対応出来ないよん。ダメじゃねえか
//少し変えてみるよ
//意図せずフィボナッチを使っていたようだ
pair<int,int> rev_gcd(int k,int a,int b){
  if(k==0) return {a,b};
  if(b==0){
    return rev_gcd(k-1,a*2,a);
  }else{
    return rev_gcd(k-1,a+b,a);
  }
}

signed main(){ 
  int h,w,m; cin>>h>>w>>m;
  set<pair<int,int>> bombed;
  map<int,int> h_bombed;
  map<int,int> w_bombed;

  for(int i=0;i<m;i++){
    int hi,wi; cin>>hi>>wi;
    hi--;
    wi--;
    bombed.insert({hi,wi});
    h_bombed[hi]++;
    w_bombed[wi]++;
  }

  int h_max=0, w_max=0;
  vector<int> h_max_index;
  vector<int> w_max_index;
  for(int i=0;i<h;i++) h_max=max(h_max,h_bombed[i]);
  for(int i=0;i<w;i++) w_max=max(w_max,w_bombed[i]);
  for(int i=0;i<h;i++) if(h_max==h_bombed[i]) h_max_index.push_back(i);
  for(int i=0;i<w;i++) if(w_max==w_bombed[i]) w_max_index.push_back(i);

  bool closs = true;
  for(int hi=0;hi<h_max_index.size();hi++){
    for(int wi=0;wi<w_max_index.size();wi++){
      if(bombed.count({h_max_index[hi],w_max_index[wi]})==0){
        closs = false;
        break;
      }
    }
  }

  int res = h_max+w_max;
  if(closs) res--;
  cout << res << endl;
  

  
  /*
  int res=0;
  for(int i=0;i<m;i++){
    int hi=bombed[i].first;
    int wi=bombed[i].second;
    int cnt = h_bombed[hi]+w_bomed[wi]-1;
    res=max(res,cnt);
  }

  cout<<res<<endl;*/
}  

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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n; int k;
    cin >> n >> k;

    set <int> s;
    for (int i = 0; i < 10; i++)
        s.insert(i);
    
    for (int i = 0, x; i < k; i++)
        cin >> x, s.erase(x);
    
    for (int i = n; i <= 1e5; i++) {
        bool f = 1;
        for (int t = i, p = 1; t && f; t /= 10, p *= 10)
            if (s.find(t % 10) == s.end())
                f = 0;
        if (f) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

const int DEBUG = 0;

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<int, ll> PIL;

const int N = 110;
VI g[N];

void chmax_vi(VI &x, const VI &y) {
  while (x.size() < y.size()) x.push_back(0);
  REP(i, 0, y.size()) {
    x[i] = max(x[i], y[i]);
  }
}


VI flatten(int v, int par) {
  VI ma;
  REP(i, 0, g[v].size()) {
    int w = g[v][i];
    if (w == par) continue;
    VI res = flatten(w, v);
    chmax_vi(ma, res);
  }
  ma.insert(ma.begin(), g[v].size() - 1);
  return ma;
}



const ll inf = 1e18;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  REP(i, 0, n - 1) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  // pivot brute force
  PIL mi(1e8, -1);
  REP(i, 0, n) {
    VI ma;
    REP(j, 0, g[i].size()) {
      int w = g[i][j];
      VI fl = flatten(w, i);
      if (DEBUG) {
	cerr << "flatten(" << w << " " << i << "):" << endl;
	REP(i, 0, fl.size()) {
	  cerr << " " << fl[i];
	}
	cerr << endl;
      }
      while (ma.size() < fl.size()) ma.push_back(0);
      REP(i, 0, fl.size()) ma[i] = max(ma[i], fl[i]);
    }
    ll prod = g[i].size();
    REP(j, 0, ma.size() - 1) {
      ll lim = inf / ma[j] + 1;
      if (prod >= lim) {
	prod = inf;
      } else {
	prod *= ma[j];
      }
    }
    mi = min(mi, PIL(ma.size() + 1, prod));
  }
  // TODO edge-centric
  REP(i, 0, n) {
    REP(j, 0, g[i].size()) {
      int w = g[i][j];
      if (i > w) continue;
      VI f1 = flatten(w, i);
      VI f2 = flatten(i, w);
      if (DEBUG) {
	DEBUGP(i);
	DEBUGP(w);
	cerr << "f1:" << endl;
	REP(i, 0, f1.size()) cerr << " " << f1[i];
	cerr << endl;
	cerr << "f2:" << endl;
	REP(i, 0, f2.size()) cerr << " " << f2[i];
	cerr << endl;
      }
      chmax_vi(f1, f2);
      VI ma(f1);
      ll prod = 2;
      REP(j, 0, ma.size() - 1) {
	ll lim = inf / ma[j] + 1;
	if (prod >= lim) {
	  prod = inf;
	} else {
	  prod *= ma[j];
	}
      }
      mi = min(mi, PIL(ma.size(), prod));
    }
  }
  cout << mi.first << " " << mi.second << endl;
}


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

int main() {
	long int n,m,l,a[101][101],b[101][101],c[101][101];
	cin>>n>>m>>l;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin>>b[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			c[i][j]=0;
			for(int k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
				if(j!=0){
					cout<<" ";
				}
				cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}


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

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

    int n, x, t;
    cin >> n >> x >> t;

    int tmp = (n+x-1) / x;
    int ans = tmp*t;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	string in;
	while ( cin >> in )
	{
		replace( in.begin(), in.end(), ',', ' ' );
		istringstream is( in );
		vector <int> hands(5);
		for ( int i = 0; i < 5; i++ )
		{
			is >> hands[i];
		}

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

		bool straight = true;
		for ( int i = 0 ; straight && i < 4; i++ )
		{
			if ( i == 0 && hands[0] == 1 && hands[1] == 10 )
				continue;
			if ( hands[i+1] - hands[i] != 1 )
			{
				straight = false;
			}
		}

		if ( straight )
		{
			cout << "straight" << endl;
		}
		else
		{
			vector <int> cnt( 14, 0 );
			for ( int i = 0; i < 5; i++ )
			{
				cnt[ hands[i] ] ++;
			}

			sort( cnt.rbegin(), cnt.rend() );

			if ( cnt[0] == 4 )
			{
				cout << "four card" << endl;
			}
			else if ( cnt[0] == 3 && cnt[1] == 2 )
			{
				cout << "full house" << endl;
			}
			else if ( cnt[0] == 3 )
			{
				cout << "three card" << endl;
			}
			else if ( cnt[0] == 2 && cnt[1] == 2 )
			{
				cout << "two pair" << endl;
			}
			else if ( cnt[0] == 2 )
			{
				cout << "one pair" << endl;
			}
			else
			{
				cout << "null" << endl;
			}

		}

	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct Monoid{
	using T = pair<int, int>; //モノイドの台集合の型
	T operator()(const T &a, const T &b) {
		if(a.first == b.first){
			if(a.second < b.second) return a;
			else return b;
		}
		else if(a.first >= b.first) return a;
		else return b;
	} //二項演算
	static constexpr T identity() { return make_pair(0,-1); } //単位元
};

template<class Monoid>
class SegTree{ //SegTree<Monoid> seg(n);
	private:
		using T = typename Monoid::T; //台集合の型をエイリアス
		Monoid op; //演算の関数オブジェクト
		const int n; //列の長さ
		vector<T> t; //内部二分木

		void prop_to(int i) { //ノードiに伝搬
			t[i] = op(t[2 * i], t[2 * i + 1]);
		}

	public:
		SegTree(int n) : n(n), t(2 * n, op.identity()) {} //単位元で埋める初期化
		SegTree(const vector<T> &v) : n(v.size()), t(2 * n){ //配列を用いて初期化
			copy(begin(v), end(v), begin(t) + n);
			for(int i = n - 1; i > -0; i--) prop_to(i);
		}

		void set(int i, const T &x){
			t[i += n] = x; 
			while(i >>= 1) prop_to(i);
		}

		void add(int i, const int &x){
			pair<int, int> t = get(i);
			t.first += x;
			set(i, t);
		}

		T get(int i) { return t[i + n]; } //列のi番目を返す

		T query(int l, int r){
			T accl = op.identity(), accr = op.identity();
			for(l += n, r += n; l < r; l >>= 1, r >>= 1){
				if(l & 1) accl = op(accl, t[l++]);
				if(r & 1) accr = op(t[r-1], accr);
			}
			return op(accl, accr);
		}
};

int main(){
	int n, q;
	cin >> n >> q;

	vector<pair<int, int>> ini(n);
	rep(i,n) ini[i] = make_pair(0,i + 1);

	SegTree<Monoid> seg(ini);
	rep(i,q){
		int a, v;
		cin >> a >> v;
		a--;
		seg.add(a, v);

		pair<int, int> tmp = seg.query(0, n);
		cout << tmp.second << ' ' << tmp.first << endl;
	}
}



Measured memory_bytes: 26352
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



int n;
vector<int>v, ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	while (!v.empty()) {
		bool mon = 0;
		for (int i = v.size() - 1; i >= 0; --i) {
			if (v[i] == i + 1) {
				ans.push_back(v[i]);
				v.erase(v.begin() + i);
				mon = 1;
				break;
			}
		}
		if (!mon) { cout << -1 << endl; return 0; }
	}
	reverse(all(ans));
	for (auto i : ans) { cout << i << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N,M,R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    ll d[N][N];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
    for(int i = 0; i < R; i++){
        ll a;
        cin >> a;
        a--;
        r[i] = a;
    }
    for(int i = 0; i < M; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
        }
    }
    ll mincost = INF;
    sort(r.begin(),r.end());
    do{
        ll temp = 0;
        for(int i = 0; i < R - 1; i++){
            temp += d[r[i]][r[i+1]];
        }
        mincost = min(mincost,temp);
    }while(next_permutation(r.begin(),r.end()));
    cout << mincost << endl;
    return 0;
}


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

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

    bool a[200010];

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (t[i] == t[i + k])
        {
            a[i + k] = !a[i];
        }

        if (!a[i])
        {
            if (t[i] == 'r')
            {
                ans += p;
            }
            else if (t[i] == 's')
            {
                ans += r;
            }
            else
            {
                ans += s;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pll > 
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
set <pll> adj[200002];
set <lli> adj2[200002];
lli mod=1000000007;
int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
      lli n;
        cin>>n;
        lli a[n],b[n];
        for(lli i=0;i<n;i++)cin>>a[i];
        bool ans=true;
    	 for(lli i=0;i<n;i++)b[i]=a[i];
        for(lli i=0;i<n-1;i++)if(a[i+1]<a[i])ans=false;
        if(ans){
        	cout<<"YES";
        	return 0;
        }
        ans=false;
        for(lli i=0;i<n;i++){
        	for(lli j=i+1;j<n;j++){
        		swap(b[i],b[j]);
        		bool ani=true;
        		for(lli i=0;i<n-1;i++)if(b[i]>b[i+1])ani=false;
        		if(ani)ans=true;
        		for(lli i=0;i<n;i++)b[i]=a[i];
        	}

        }
        if(ans)cout<<"YES";
        else cout<<"NO";

        return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    int d = N % 10;
    N /= 10;
    int c = N % 10;
    N /= 10;
    int b = N % 10;
    N /= 10;
    int a = N % 10;

    if (a + b + c + d == 7) {
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    } else if (a - b + c + d == 7) {
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    } else if (a + b - c + d == 7) {
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    } else if (a - b - c + d == 7) {
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    } else if (a + b + c - d == 7) {
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    } else if (a - b + c - d == 7) {
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    } else if (a + b - c - d == 7) {
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    } else if (a - b - c - d == 7) {
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
    }
    return 0;
}


Measured memory_bytes: 256