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

int main() {
    unsigned long long n;
    std :: cin >> n;
    std :: string str = "";

    while(n) {
        if(n <= 26) {
            str += 'a' + n - 1;
            break;
        }
        str += 'a' + ((n - 1) % 26);

        if(n % 26 == 0) n--;

        n /= 26;
    }

    std :: reverse(str.begin() , str.end());

    std :: cout << str << '\n';
}

Measured memory_bytes: 3124
/*  .　　∧_∧
   　（ ´・ω・)
   　//＼￣￣旦＼
   ／/ ※ ＼＿＿＿＼
   ＼＼ 　※ 　※ 　※ ヽ
   　 ＼ヽ-＿_＿--＿__ヽ*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//-------------------------------------------------------------------------------------------------------------------------------------------//

int main(){
	int n;
	cin>>n;
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc055/tasks/arc069_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M, t, cnt;
int main()
{
  cnt = 0;

  cin >> N >> M;

  t = min(N, M / 2);
  cnt += t;
  M -= 2 * t;
  cnt += M / 4;

  cout << cnt << '\n';

  return 0;
}


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

using namespace std;

int main()
{
    int n, a, b;
    
    cin >> n;
    cin >> a;
    cin >> b;
    
    int d = b-a;
    if(d%2 == 0){
        cout << "Alice";
    } else {
        cout << "Borys";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
using namespace std;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForIntInit(i, begin, n) for (int i = (begin); i < (n); ++i)
using int64 = long long;



int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    ForInt(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    // x_0
    int x_cur = sum;
    ForInt(i, n / 2)
    {
        x_cur -= 2 * a[2 * i + 1];
    }
    cout << x_cur;

    ForInt(i, n - 1)
    {
        int x_next = 2 * a[i] - x_cur;
        cout << " " << x_next;
        x_cur = x_next;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if ((a + b) % 2 == 0) {
            System.out.println(((a + b) / 2));
        } else {
            System.out.println(((a + b) / 2) + 1);
        }
	}
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>>w(m);
  for(int i=0; i<m; i++)cin >> w[i].first >> w[i].second;
  sort(w.begin(), w.end());
  int e=w[0].second, ret=0;
  for(int i=0; i<m; i++){
    if(w[i].first>=e){
      ret++;
      e=w[i].second;
    }
    else{
      e=min(e, w[i].second);
    }
  }
  cout << ++ret;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char argv[]){
    int input = 0;

    scanf("%d", &input);

    if(input >= 1 && input <= 999){
        printf("ABC\n");
    }
    if(input >=1000 && input <= 1998){
        printf("ABD\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll mod=1e9+7;
int main()
{
    io
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll k1,k2,k3,k4;
    k1=a*c;
    k2=a*d;
    k3=b*c;
    k4=b*d;
    ll ans=max(k1,max(k2,max(k3,k4)));
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;
double dp[301][301][301];
int tot;
double solve(int x,int y,int z)
{
  if(x==0&&y==0&&z==0)
  return 0;
  if(dp[x][y][z]>-0.9)
  return dp[x][y][z];
  double ans=(tot+(x>=1?(x*solve(x-1,y,z)):0)+(y>=1?(y*solve(x+1,y-1,z)):0)+(z>=1?(z*solve(x,y+1,z-1)):0));
  return dp[x][y][z]=(ans/(x+y+z));
} 
int main()
{
  memset(dp,-1.0,sizeof(dp));
  int n,one=0,two=0,three=0;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
     int x;
     cin>>x;
     x==1?one++:((x==2)?two++:three++);
  }
  tot=one+two+three;
  double ans=solve(one,two,three);
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 216864
N=int(input())
A=list(map(int,input().split()))
A.sort()
TF={a:True for a in A}
for i in range(N):
    if TF[A[i]]==True:
        if i > 0 and A[i - 1] == A[i]:
            TF[A[i]] = False
        m=A[N-1]//A[i]
        for j in range(2,m+1):
            s=A[i]*j
            if s in TF:
                TF[s]=False
print(len([1 for a in A if TF[a]==True]))

Measured memory_bytes: 35396
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defun euclidean-alg (m n)
  "Gibt die Verlaufsliste des euklidischen Algorithmus zurück."
  (multiple-value-bind (quot rem) (floor m n)
    (if (zerop rem)
	(list quot)
	(cons (/ (- m rem) n)
	      (euclidean-alg n rem)))))

(defun solve-bezout (m n)
  "Gibt eine ganzzahlige Lösung von mx+ny=gcd(m, n) zurück. M und N
müssen positiv sein."
  (loop for k in (if (>= m n)
		     (euclidean-alg m n)
		     (euclidean-alg n m))
        for x = 0 then u
        and y = 1 then v
        and u = 1 then (+ x (* (- k) u))
        and v = (- k) then (+ y (* (- k) v))
        finally (return (if (>= m n)
                            (values x y)
                            (values y x)))))


(defun get-minimum-factor (x alpha)
  "Gibt k in Z zurück, so dass x+k*alpha das kleinste nicht negative
Nummer ist."
  (funcall (if (plusp alpha)
               #'ceiling
               #' floor)
	   (/ (- x) alpha)))

(defun solve-bezout-nonnegative (m n d &optional (sup most-positive-fixnum))
  "Sucht eine ganzzahlige Lösung, so dass 
m*x+n*y=d, 0<=x, 0<=y, x+y<=sup."
  (let ((gcd-mn (gcd m n)))
    (if (/= (mod d gcd-mn) 0)
        nil
        (multiple-value-bind (init-x init-y) (solve-bezout m n)
          (let* ((factor (/ d gcd-mn))
                 (x0 (* init-x factor))
                 (y0 (* init-y factor))
                 (deltax (/ n gcd-mn))
                 (deltay (/ m gcd-mn))
                 (k-min1 (get-minimum-factor x0 deltax))
                 (k-min2 (get-minimum-factor y0 (- deltay)))
                 (x1 (+ x0 (* k-min1 deltax)))
                 (y1 (- y0 (* k-min1 deltay)))
                 (x2 (+ x0 (* k-min2 deltax)))
                 (y2 (- y0 (* k-min2 deltay))))
            (cond ((and (>= y1 0)
                        (<= (+ x1 y1) sup))
                   (cons x1 y1))
                  ((and (>= x2 0)
                        (<= (+ x2 y2) sup))
                   (cons x2 y2))
                  (t nil)))))))

(defun main ()
  (write-line
   (if (solve-bezout-nonnegative 4 7 (read))
       "Yes"
       "No")))

#-swank(main)



Measured memory_bytes: 16612
a, b, c = map(int, input().split())

if 4*a*b - (c - a - b) ** 2 < 0 and c-a-b > 0:
    print("Yes")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
else:
    print("No")
    # print("{}, {}".format(4*a*b, (c - a - b) ** 2))
    # 249999999 250000000 999999998


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

using namespace std;
#define lint long long
#define P pair<int, int>

int main() {
    int N;
    
    cin >> N;
    
    int A[N];
    
    lint cnt = 1;
    lint num = 1;
    
    for(int i = 0; i < N; ++i){
        num *= 3;
    }
    
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        if(A[i] % 2 == 0){
            cnt *= 2;
        }
    }
    
    cout << num - cnt << endl;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
LR = [tuple(map(int,input().split())) for _ in range(K)]
d = [0]*N
d[0] = 1
MOD = 998244353
for i in range(N-1):
    x = d[i]
    d[0] = 0
    for k in range(K):
        L, R = LR[k]
        if i+L < len(d):
            d[i+L] += x
            d[i+L] %= MOD
        if i+R+1 < len(d):
            d[i+R+1] -= x
            d[i+R+1] %= MOD
    d[i+1] += d[i]
    d[i+1] %= MOD
print(d[-1] % MOD)

Measured memory_bytes: 70032
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		int numK = nextInt();
		int numX = nextInt();
		int numY = nextInt();

		long res = 0;
		if (numN < numK) {
			res += numN * numX;
		} else {
			res += numK * numX + (numN - numK) * numY;
		}

		out.println(res);
	}

	private void solveA2() {
		int numN = nextInt();
		int numK = nextInt();
		int numX = nextInt();
		int numY = nextInt();

		long res = 0;
		for (int i = 1; i <= Math.min(numN, numK); i++) {
			res += numX;
		}
		for (int i = numK + 1; i <= numN; i++) {
			res += numY;
		}

		out.println(res);
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int n;
    cin >> n;

    int v = 100;

    int cnt = 0;
    while (v < n) {
      v += (int)(v * 0.01);
      ++cnt;
    }

    cout << cnt << endl;
  }
}

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

int main()
{
    int h1,m1,h2,m2,k,x,y,t;
    cin>>h1>>m1>>h2>>m2>>k;
    x = h1*60 + m1;
    y = h2*60 + m2;
    t = y-x;
    cout<<t-k;
}


Measured memory_bytes: 3652
#include <iostream>

void Range(int a, int b, int c);
int main(){
    int a, b, c;
    std::cin>> a >> b >> c;
    Range(a, b, c);
}

void Range(int a, int b, int c){
    if(c>b && b>a) std::cout<< "Yes\n";
    else std::cout<< "No\n";
}

Measured memory_bytes: 3072
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

const int maxN = 2e5 + 5;
const ll MOD = 998244353;
ll a[maxN], tree[4 * maxN];

void build(int left, int right, int node){
    if(left == right){
        tree[node] = a[left];
        return;
    }
    int mid = left + (right - left) / 2;
    build(left, mid, 2 * node);
    build(mid + 1, right, 2 * node + 1);
    tree[node] = (tree[2 * node] + tree[2 * node + 1]) % MOD;
    return;
}

void update(int left, int right, int node, int idx, int val){
    if(left == right){
        a[idx] = val;
        tree[node] = val;
        return;
    }
    int mid = left + (right - left) / 2;
    if(idx > mid){
        update(mid + 1, right, 2 * node + 1, idx, val);
    }
    else{
        update(left, mid, 2 * node, idx, val);
    }
    tree[node] = (tree[2 * node] + tree[2 * node + 1]) % MOD;
}

ll query(int left, int right, int node, int l_idx, int r_idx){
    if(left > r_idx || right < l_idx){
        return 0;
    }
    if(l_idx <= left && r_idx >= right){
        return tree[node];
    }
    int mid = left + (right - left) / 2;
    ll min1 = query(left, mid, 2 * node, l_idx, r_idx);
    ll min2 = query(mid + 1, right, 2 * node + 1, l_idx, r_idx);
    return (min1 + min2) % MOD;
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> x(k), y(k);
    for(int i = 0; i < k; i++){
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i <= n; i++){
        a[i] = 0;
    }
    a[1] = 1;
    build(1, n, 1);
    for(int i = 2; i <= n; i++){
        for(int p = 0; p < k; p++){
            int high = max(i - x[p], 0);
            int low = max(i - y[p], 0);
            // cout << low << " " << high << "\n";
            a[i] += query(1, n, 1, low, high);
            a[i] %= MOD;
            update(1, n, 1, i, a[i]);
        }
        // for(int i = 1; i <= n; i++){
        //     cout << a[i] << " ";
        // }
        // cout << "\n";
    }
    cout << a[n] << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int n,q;
vector<vector<int>> tree(200000, vector<int>());

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    if(b-a == c-b){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

using namespace std;

int main() {
    int D, G;
    cin >> D >> G;

    vector<int> p(D), c(D);
    for (int i = 0; i < D; ++i) {
        cin >> p[i] >> c[i];
    }

    int ans = 10000000;
    //ボーナスを貰える問題をbitmaskで抽出
    for (int bitmask = 0; bitmask < (1 << D); ++bitmask) {
        int sum = 0;
        int cnt = 0;
        for (int i = 0; i < D; ++i) {
            if (bitmask & (1 << i)) {
                sum += c[i] + p[i] * 100 * (i + 1);
                cnt += p[i];
            }
        }

        if (sum >= G) {
            ans = min(ans, cnt);
        } else {
            for (int i = D - 1; i >= 0; --i) {
                if (bitmask & (1 << i)) continue;
                for (int j = 0; j < p[i]; ++j) {
                    if (sum >= G) break;
                    sum += 100 * (i + 1);
                    ++cnt;
                }
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val (a , b , c , k) = readLine()!!.split(" ").map(String::toLong)
    var maxVal = 0L

    if(a < k) {
        maxVal += a * 1
        if(b < k - a){
            maxVal += (k - a - b) * -1
            print(maxVal)
            return
        }
            maxVal += (k - a) * 0
            print(maxVal)
            return
    }
    if(a > k){
        maxVal +=  (a - (a - k)) * 1
        print(maxVal)
        return
    }
    maxVal += a * 1
    print(maxVal)
    return

}

Measured memory_bytes: 36264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int a, b, d;
    cin >> a >> b;
    d=b-a;
    int ans;
    ans = d*(d+1)/2-b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<vector<int>> G(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<pair<int, int>> q;
	vector<int> c(N);
	q.push({ 0, 1 });
	q.push({ N - 1, 2 });
	c[0] = 1;
	c[N - 1] = 2;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();

		auto u = p.first;
		auto col = p.second;
		for (auto v : G[u])
		{
			if (c[v] > 0)
			{
				continue;
			}
			c[v] = col;
			q.push({ v, col });
		}
	}

	auto numF = 0;
	auto numS = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (c[i] == 1)
		{
			++numF;
		}
		else
		{
			++numS;
		}
	}

	if (numF > numS)
	{
		cout << "Fennec" << endl;
	}
	else
	{
		cout << "Snuke" << endl;
	}

	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

ll p[200000];
bool bol[200000];
ll counter[2000000];

int main(){
    ll n,m;cin>>n>>m;
    string s[m];
    rep(i,0,m-1){
        cin>>p[i];
        cin>>s[i];
    }
    ll ans=0,pen=0;
    rep(i,0,m-1){
        if(s[i]=="AC" && bol[p[i]]==false){
            ans++;
            pen+=counter[p[i]];
            bol[p[i]]=true;
        }else if(s[i]=="WA" && bol[p[i]]==false){
            counter[p[i]]++;
        }
    }
    cout<<ans<<' '<<pen<<endl;
    
    
    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};//p == 親, l == 左子,r == 右兄弟

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i,c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if( T[u].l == NIL ) cout << "leaf, ";
	else cout << "internal node, ";
	cout << "[";

	for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if ( T[u].r != NIL ) rec(T[u].r, p);
	if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main(){
	int i, j, d, v, c, l, r;
	cin >> n;
	for( i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for( i = 0; i < n; i++) {
		cin >> v >> d;
		for( j = 0; j < d; j++) {
			cin >> c;
			if ( j == 0 ) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for( i = 0; i < n; i++) {
		if (T[i].p == NIL) r = i;
	}
	rec(r,0);
	for( i = 0; i < n; i++) print(i);
	return 0;
}



Measured memory_bytes: 7704
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;

int howdividetwo(int n) {

	int sum = 0;

	while (n>0 && n % 2 == 0)
	{

		++sum;

		n /= 2;
	}

	return sum;

}

int main()
{
	int n;
	cin >> n;
	int a[200];

	int mi = 999999999;
	for (int i = 0; i < n; i++) {
		
		int buf;
		
		cin >> buf;

		mi=min(mi,howdividetwo(buf));
	}

	cout << mi << endl;


    return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

      int N = sc.nextInt();
      int X = sc.nextInt();

      int min_m = 1000;
      int sum_m = 0;
      int [] m = new int[ N ];
      for(int i = 0 ; i < N ; i ++){
        m[ i ] = sc.nextInt();
        sum_m += m[ i ];
        if(m[ i ] < min_m){
          min_m = m[ i ];
        }
      }

      System.out.println( N + (X - sum_m) / min_m );
  }

}


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

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

int main() {

    int n; cin >> n;
    // 桁あふれ処理めんどいので、+5くらい余計にとっておく
    vector<int> h(n+5, INT_MAX);
    rep(i, n) cin >> h[i];

    // 桁あふれ処理めんどいので、+5くらい余計にとっておく
    vector<int> dp(n+5, INT_MAX);

    // 最初だけ初期化
    dp[0] = 0;

    rep(i, n) {
        // i+1は2つの候補がある.
        dp[i+1] = min(dp[i] + abs(h[i]-h[i+1]), dp[i+1]);
        dp[i+2] = dp[i] + abs(h[i]-h[i+2]);
    }

    cout << dp[n-1] << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)

int N;
int A[1234];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //
    int s = 0,cur = 0;
    cin >> N;
    FOR(i,1,N){
        cin >> A[i];
        s += A[i] * cur;
        cur += A[i];
    }

    cout << s;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c; cin >> a >> b >> c;
    if(a == b && b == c) {
        if(a&2!=0) cout << 0 << endl;
        else cout << -1 << endl;
    }
    else {
        int ans = 0;
        while(true) {
            if(a%2!=0 || b%2!=0 || c%2!=0) {
                cout << ans << endl;
                return 0;
            }
            int a2 = b/2 + c/2;
            int b2 = a/2 + c/2;
            int c2 = a/2 + b/2;
            a = a2; b = b2; c = c2;
            ++ans;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		// ????????????1????????????????????????????????????????´?
		char[] strArray = str.toCharArray();

		for (int i = 0; i < strArray.length; i++) {

			// ??§???????????????
			if (Character.isUpperCase(strArray[i])) {

				// ?°????????????????
				strArray[i] = Character.toLowerCase(strArray[i]);

			// ?°????????????????
			} else if (Character.isLowerCase(strArray[i])) {

				// ??§???????????????
				strArray[i] = Character.toUpperCase(strArray[i]);

			

				

			}

		}

		for (int i = 0; i < strArray.length - 1; i++) {

			System.out.print(strArray[i]);

		}

		System.out.println(strArray[strArray.length - 1]);

	}
}

Measured memory_bytes: 24968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    ll cur = -1;
    REP (i,n) {
        ll cnt = 0;
        cin >> d[i];
        d[i] /= 2;
        ll tmp = d[i];
        while (tmp % 2 == 0) {
            tmp /= 2;
            cnt++;
        }
        if (cur == -1) cur = cnt;
        else {
            if (cur != cnt) return cout << 0 << endl,0;
        }
    }
    cur = 1;
    REP (i,n) {
        cur = cur / __gcd(cur,d[i]) * d[i];
    }
    ll ans = m / cur;
    ans = (ans+1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 4400
#include <iostream>
#include <vector>
using namespace std;
int N;
int b[100];
int query[100];
vector<int> arr;
int main() {
    cin >> N;
    for (int i=0; i<N; i++) cin >> b[i];

    for (int i=0; i<N; i++) arr.push_back(b[i]);

    for (int q=0; q<N; q++) {
        int found = -1;
        for (int i=arr.size()-1; i>=0; i--) {
            if (arr[i] == i+1) {
                found = i;
                break;
            }
        }
        if (found != -1) {
            query[q] = found+1;
            arr.erase(arr.begin() + found);
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i=N-1; i>=0; i--) {
        cout << query[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
//こだわり者いろはちゃん

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

set<int>t;
int n;
priority_queue<int,vector<int>,greater<int>>ans;

void dfs(string s){
    if(s.size()>6)return;
    for(auto i:t){
        string c=s;
        c.pb(i+'0');
        if(stoi(c)>=n)ans.push(stoi(c));
        else dfs(c);
    }
}

signed main (){
    int k;cin>>n>>k;
    vector<int>c(10,0);
    rep(i,0,k){
        int r;cin>>r;
        c[r]++;
    }
    rep(i,0,10)if(c[i]==0)t.insert(i);
    string s="";
    dfs(s);
    cout<<ans.top()<<nnn;
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    long int a,b,k;
    cin >> a >> b >> k;
    if (a >= k){
        cout << a-k << " " << b << endl;
    }
    else if (a < k && b >= k-a) {
        cout << 0 << " " << a+b-k << endl;
    }
    else {
        cout << "0" << " " << "0" << endl;
    }
}


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

using namespace std;

const int MOD=1000000007;
int N, M;
int dp[301][301][305];

void addmod(int& x, int v)
{
    x+=v;
    if(x>=MOD)
        x-=MOD;
}

int rec(int m, int n, int l)
{
    if(m==M)
        return n==N && l==N+1;
    int& ret=dp[m][n][l];
    if(ret!=-1)
        return ret;
    ret=0;
    // last town not visit, or something before that
    addmod(ret, 1LL*rec(m+1, n, n+1)*(l-1)%MOD);
    // nothing special
    addmod(ret, 1LL*rec(m+1, n, l)*(n-l+1)%MOD);
    // new explore
    if(n<N)
        addmod(ret, 1LL*rec(m+1, n+1, l)*(N-n)%MOD);
    return ret;
}

int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d%d", &N, &M);
    int ans=rec(0, 1, 2);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 108288
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
typedef long long ll;

int n;
 
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	cin >> n;
	if (n >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b) % 2 == 0) cout << (a+b) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

struct Proc{
  string name;
  int time;
};

class Queue{
private:
  Proc proc[100005];
  int head, tail;
public:
  Queue(){
    head = 0; tail = 0;
  }
  bool isEmpty();
  bool isFull();
  Proc dequeue();
  void enqueue(Proc p);
};

bool Queue::isEmpty(){
  return head == tail;
}

bool Queue::isFull(){
  return head == (tail + 1) % 100005;
}

Proc Queue::dequeue(){
  Proc p = proc[head];
  head = (head + 1) % 100005;
  return p;
}

void Queue::enqueue(Proc p){
  proc[tail] = p;
  tail = (tail + 1) % 100005;
}

int main(void){
  int n, q, time;
  string name;
  Queue que;

  cin >> n >> q;
  for(int i = 0; i < n; i++){
    cin >> name >> time;
    Proc p; p.name = name; p.time = time;
    que.enqueue(p);
  }

  time = 0;
  while(!que.isEmpty()){
    Proc p = que.dequeue();
    int t = p.time - q;
    if(t <= 0){
      time += p.time;
      cout << p.name << " " << time << endl;
    }else{
      p.time = t;
      que.enqueue(p);
      time += q;
    }
  }

  return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;



int main(){	
	long long A;
	scanf("%lld",&A);
	cout << 3*A*A << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M; 
long long X; 
pair<long long, pair<int, int>> E[2010]; 
vector<pair<long long, int>> MST[2010]; 
long long D[1010][1010]; 
long long total; 
int par[1010]; 
int depth[1010]; 
int siz[1010];  
long long pow2[2010]; 
long long mod = 1000000007;
vector<long long> extra; 
void init(){
	for(int i = 0; i < N; i++){
		par[i] = i; depth[i] = 0; siz[i] = 1; 
	}
}
int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]); 
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		siz[y] += siz[x]; 
	}else{
		par[y] = x; 
		siz[x] += siz[y];  
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int sz(int x){
	return siz[find(x)]; 
}
void dfs(int root, int v, int p){
	for(auto c : MST[v]){
		if(c.second == p) continue; 
		D[root][c.second] = max(D[root][v], c.first); 
		dfs(root, c.second, v); 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> M >> X; 
	pow2[0] = 1; 
	for(int i = 1; i < 2005; i++){
		pow2[i] = pow2[i-1] * 2 % mod; 
	}
	for(int i = 0; i < M; i++){
		int u, v; long long w; 
		cin >> u >> v >> w; 
		u--; v--;
		E[i].first = w; 
		E[i].second.first = u; 
		E[i].second.second = v; 
	}
	sort(E, E+M); 
	init(); 
	for(int i = 0; i < M; i++){
		int u = E[i].second.first;
		int v = E[i].second.second;
		long long w = E[i].first; 
		if(same(u, v)) continue;
		unite(u, v); 
		MST[u].emplace_back(w, v); 
		MST[v].emplace_back(w, u); 
		total += w;
	}
	if(X < total){
		cout << 0 << "\n"; return 0; 
	}
	for(int i = 0; i < N; i++) dfs(i, i, -1); 
	for(int i = 0; i < M; i++){
		int u = E[i].second.first;
		int v = E[i].second.second;
		long long w = E[i].first; 
		long long l = w - D[u][v]; 
		extra.emplace_back(l); 		
	}
	if(X == total){
		int cnt = 0; 
		for(long long a : extra){
			if(a == 0) cnt++;  
		}
		cout << (mod + pow2[M] - pow2[M - cnt + 1]) % mod << "\n"; 
	}else{
		int cnt1 = 0; int cnt2 = 0; 
		for(long long a : extra){
			if(a == X - total) cnt1 ++; 
			else if(a > X - total) cnt2 ++;
		}
		cout << (mod + pow2[cnt1 + cnt2 + 1] - pow2[cnt2 + 1]) % mod << "\n"; 
	}
}

Measured memory_bytes: 11784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define max_edge int(pow(10,6))
typedef pair<int,int>P;

vector<ll>ans(max_edge,0);
vector<ll> cost(max_edge,0);
vector<ll>previous_edge(max_edge);
vector<vector<ll>>next_edge(max_edge);

void dfs(ll edge){
    ans[edge] = ans[previous_edge[edge]] + cost[edge];
    for(int i=0;i<next_edge[edge].size();i++){
        dfs(next_edge[edge][i]);
    }
}

int main(void){
    int n,q; cin >> n >> q;
    for(int i=0;i<n-1;i++){
        ll a,b; cin >>a >> b;
        previous_edge[b]=a;
        next_edge[a].push_back(b);
    }


    for(int i=0;i<q;i++){
        ll p,x; cin >> p >> x;
        cost[p]+=x;
    }

    // for(int i=0;i<=n;i++) cout << cost[i] << ' ';cout << endl;
    dfs(1);
    for(int i=1;i<=n;i++){
        cout << ans[i];
        if(i!=n) cout << ' ';
    } 
    cout << endl;
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> cards;
  int input;
  for (int i=0;i<N;i++) {
      cin >> input;
      cards.push_back(input);
  }
  sort(cards.begin(), cards.end(), greater<int>());
  int diff = 0;
  for (int i=0; 2*i+1 < cards.size();i++) {
   diff += cards.at(2*i)-cards.at(2*i+1);
  }
  if (cards.size() % 2 == 1){
      diff += cards.at(N-1);
  }
  cout << diff << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

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

    cout <<(a>2*b ? a-2*b : 0) <<endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    bool inc = true;
    int a[200003];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
        if(i > 0 && a[i] <= a[i - 1]) inc = false;
    }
    if(inc){
        cout << 1 << endl;
        return 0;
    }
    int now = 131072;
    int mid = now / 2;
    while(mid > 0){
        map<int, int> mp;
        int s[200005] {0};
        int p = 0;
        for(int i = 0; i < n; i++){
            int insrt = lower_bound(s, s + p, a[i]) - s;
            if(insrt == p && (i == 0 || a[i] > a[i - 1])){
                s[p] = a[i];
                mp[a[i]] = 0;
                p++;
            }
            else if(insrt == p || s[insrt] != a[i]){
                s[insrt] = a[i];
                mp[a[i]] = 1;
                p = insrt + 1;
            }
            else{
                int l = a[i];
                while(true){
                    mp[l]++;
                    if(mp[l] != now){
                        s[insrt] = l;
                        p = insrt + 1;
                        break;
                    }
                    if(l == 0){
                        p = 1;
                        break;
                    }
                    if(insrt == 0 || s[insrt - 1] != l - 1){
                        mp[l - 1] = 0;
                    }
                    else{
                        insrt--;
                    }
                    l--;
                }
            }
        }
        if(mp[0] < now) now -= mid;
        else now += mid;
        mid /= 2;
    }
    if(now == 1){
        cout << 2 << endl;
        return 0;
    }
    map<int, int> mp;
    int s[200005] {0};
    int p = 0;
    for(int i = 0; i < n; i++){
        int insrt = lower_bound(s, s + p, a[i]) - s;
        if(insrt == p && (i == 0 || a[i] > a[i - 1])){
            s[p] = a[i];
            mp[a[i]] = 0;
            p++;
        }
        else if(insrt == p || s[insrt] != a[i]){
            s[insrt] = a[i];
            mp[a[i]] = 1;
            p = insrt + 1;
        }
        else{
            int l = a[i];
            while(true){
                mp[l]++;
                if(mp[l] != now){
                    s[insrt] = l;
                    p = insrt + 1;
                    break;
                }
                if(l == 0){
                    p = 1;
                    break;
                }
                if(insrt == 0 || s[insrt - 1] != l - 1){
                    mp[l - 1] = 0;
                }
                else{
                    insrt--;
                }
                l--;
            }
        }
    }
    if(mp[0] >= now) now++;
    cout << now << endl;
}

Measured memory_bytes: 13184
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		double ans=0;
		for(int i=0;i<a;i++) {
			double b=scan.nextInt();
			b=1/b;
			ans+=b;
		}
		System.out.println(1/ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string N;
    cin >> N;
    char c = N[N.size()-1];
    if(c == '3'){
        cout << "bon" << endl;
    } else if(c=='0'|| c=='1'||c=='6'|| c=='8'){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3624
n, m, x = gets.split(' ').map(&:to_i)

books = []

n.times do
  books << gets.split(' ').map(&:to_i)
end

min = Float::INFINITY
subsets = []

for i in 0..(books.length) do
  subsets = subsets + books.combination(i).to_a
end

subsets.each do |subset|
  result = Array.new(m + 1, 0)
  subset.each do |line|
    result = [result, line].transpose.map { |x| x.reduce(:+) }
  end

  correct = true  
  i = 1
  while i < m + 1
    if result[i] < x
      correct = false
      break
    end

    i += 1
  end

  min = [min, result[0]].min if correct
end

if min == Float::INFINITY
  puts "-1"
else
  puts min
end


Measured memory_bytes: 15044
#include <bits/stdc++.h>
using namespace std;
int n, can[100010];
char str[100010];
int main()
{
	scanf(" %s", str);
	n = strlen(str);
	for (int i = 1; i <= n; i++)
	{
		char a = str[i-1];
		if (a == '1') can[i] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		if (can[i] && !can[n-i])
		{
			printf("-1\n");
			return 0;
		}
	}
	if (!can[1])
	{
		printf("-1\n");
		return 0;
	}
	int upto = 0;
	int node = 0;
	int children = 0;
	for (int i = 2; i <= n/2; i++)
	{
		if (can[i])
		{
			++upto;
			if (node != 0)
			{
				printf("%d %d\n", node, upto);
				children++;
			}
			node = upto;
		//	printf("node %d\n", node);
			while (children < i-1)
			{
				upto++;
				printf("%d %d\n", node, upto);
				children++;
			}
		}
	}
	if (upto != n)
	{
		upto++;
		if (node != 0) printf("%d %d\n", upto, node);
		node = upto;
		while (upto < n) printf("%d %d\n", node, ++upto);
	}
}

Measured memory_bytes: 1920
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n; cin >> n;
  vector<ll> a(n+1); rep(i,n+1){cin >> a[i];}
  vector<ll> b(n); rep(i,n){cin >> b[i];}
  ll ans=0;

  for (int i=n; i>=1; i--){
    ll t=min(a[i],b[i-1]);
    a[i]-=t;b[i-1]-=t;ans+=t;
    t=min(a[i-1],b[i-1]);
    a[i-1]-=t;b[i-1]-=t;ans+=t;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
void factor(int n, vector<int> &x)
{
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            x.push_back(i);
            if (i * i != n)
                x.push_back(n / i);
        }
    }
}
int32_t main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a, b;
    factor(n, a);
    factor(m, b);
    set<int> s1;
    for (auto &i : a)
        s1.insert(i);
    set<int> s;
    for (auto &i : b)
        if (s1.count(i))
            s.insert(i);
    vector<int> x;
    for (auto &i : s)
        x.push_back(i);
    set<int> ans;
    for (auto &y : x)
    {
        if (y == 1)
        {
            ans.insert(y);
            continue;
        }
        for(int i = 1; i * i <= y; i++)
        {
            if(i==1)
                continue;
            if (y % i == 0)
            {
                if(ans.count(i))
                    goto lb;
                if (i * i != y)
                    if(ans.count(i))
                        goto lb;
            }
        }
        ans.insert(y);
        lb:;
    }
    cout << ans.size();
    return 0;
}
//16:33

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int x, y; cin >> x >> y;

    int ans = 0;

    if (x == 1) ans += 300000;
    if (x == 2) ans += 200000;
    if (x == 3) ans += 100000;

    if (y == 1) ans += 300000;
    if (y == 2) ans += 200000;
    if (y == 3) ans += 100000;

    if (x == 1 && y == 1) ans += 400000;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char** argv)
{
	int i, num, in, min, max;
	long total;


	scanf("%d", &num);
	for (i = 0; i < num; i++) {
		scanf("%d", &in);

		if (i == 0) {
			min = max = total = in;
		}
		else {
			if (min > in) {
				min = in;
			}
			if (max < in) {
				max = in;
			}
			total += in;
		}
	}
	printf("%d %d %ld\n", min, max, total);
	return 0;
}

Measured memory_bytes: 600