akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main(){
	int m;
	while(cin>>m,m){
		vector<pii> M(m);
		REP(i,m){
			cin>>M[i].first>>M[i].second;
		}
		int n;
		cin>>n;
		vector<pii> N(n);
		set<pii> coords;
		REP(i,n){
			cin>>N[i].first>>N[i].second;
			coords.insert(N[i]);
		}
		pii ans;
		REP(i,n){
			bool ok=true;
			REP(j,m){
				pii p(N[i].first+(M[j].first-M[0].first),N[i].second+(M[j].second-M[0].second));
				if(!EXIST(coords,p)){
					ok=false;
					break;
				}
			}
			if(ok){
				ans=make_pair(N[i].first-M[0].first,N[i].second-M[0].second);
				break;
			}
		}
		cout<<ans.first<<" "<<ans.second<<endl;
	}
}

Measured memory_bytes: 1252
N, M = map(int, input().split())
is_ac = [False] * N
was = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if is_ac[p]:
        continue
    if s == 'AC':
        is_ac[p] = True
    else:
        was[p] += 1
ac = sum([1 for ac in is_ac if ac])
wa = 0
for i in range(N):
    if is_ac[i]:
        wa += was[i]
print(ac, wa)


Measured memory_bytes: 5528
#include<stdio.h>
#include<algorithm>

using namespace std;

int a[100010];
int n;

int main(void) {
    int t, ncnt, cnt=0;
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", a+i);
    sort(a, a+n);
    t = a[0];
    ncnt = 1;
    for(int i=1; i<n; i++) {
        if(a[i]==t) ncnt++;
        else {
            cnt += (ncnt>=t ? ncnt-t : ncnt);
            t = a[i];
            ncnt = 1;
        }
    }
    if(ncnt==1) {
        if(t>ncnt) cnt++;
    }
    else {
        cnt += (ncnt>=t ? ncnt-t : ncnt);
    }
    
    printf("%d", cnt);
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


#define NITEM(arr) (sizeof(arr)/sizeof(arr[0]))
#define MODU 1000000007LL

#define N_MAX 200000


typedef long long ll;

typedef struct
{
	int c, w;
}ball_t;


ball_t ball[N_MAX+1];
int c_num[N_MAX+1];
int movable[N_MAX+1];
ll factrial[N_MAX+1];

ll gcd(ll a, ll b)
{
	ll c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


int cmp(const void *pa, const void *pb)
{
	const ball_t *a, *b;

	a=pa;
	b=pb;
	if(a->w<b->w) return -1;
	return (a->w>b->w);
}


int cmp2(const void *pa, const void *pb)
{
	const ball_t *a, *b;

	a=pa;
	b=pb;
	if(a->c<b->c) return -1;
	if(a->c>b->c) return 1;

	if(a->w<b->w) return -1;
	return (a->w>b->w);
}


ll mod_inv(ll a, ll b)
{
	ll n, ret=1LL;

	for(n=b-2;n>0;n>>=1)
	{
		if(n&1) ret=(ret*a)%b;
		a=(a*a)%b;
	}
	return ret;
}


ll calc(int c_num[], int n)
{
	int i, j;
	ll u, l;

	if(factrial[0]==0)
	{
		factrial[0]=1;
		for(i=1;i<=N_MAX;i++)
		{
			factrial[i]=(factrial[i-1]*i)%MODU;
		}
	}

	l=u=1;
	for(i=j=0;i<n;i++)
	{
		if(c_num[i]==0) continue;

		l=(l*factrial[c_num[i]])%MODU;
		j+=c_num[i];
	}
	u=factrial[j];
	return (u*mod_inv(l, MODU))%MODU;
}


int main(void)
{
	int N, X, Y;
	int i, second, light;

if(0)
{
	ll x=123;
	printf("%lld\n", (x*mod_inv(x, MODU))%MODU);
	return 1;
}


	while(scanf("%d%d%d", &N,&X,&Y)==3)
	{
		for(i=0;i<N;i++)
		{
			scanf("%d%d", &ball[i].c, &ball[i].w);
		}

		qsort(ball, N, sizeof(ball[0]), cmp2);
		light=0;
		for(i=1;i<N;i++)
		{
			if(ball[light].c==ball[i].c)
			{
				if(ball[light].w+ball[i].w<=X)
				{
					ball[i].w=ball[light].w;
				}
			}
			else
			{
				light=i;
			}
		}

		qsort(ball, N, sizeof(ball[0]), cmp);

		for(second=1;second<N;second++)
		{
			if(ball[second].c!=ball[0].c) break;
		}

		if(second>=N)
		{
			printf("1\n");
			continue;
		}

		memset(movable, 0, sizeof(movable));
		for(i=0;i<N;i++)
		{
			if(ball[0].c!=ball[i].c)
			{
				if(ball[0].w+ball[i].w<=Y) movable[i]=1;
			}
			if(ball[second].c!=ball[i].c)
			{
				if(ball[second].w+ball[i].w<=Y) movable[i]=2;
			}
		}

		memset(c_num, 0, sizeof(c_num));
		for(i=0;i<N;i++)
		{
			if(movable[i]) c_num[ball[i].c]++;
		}
		printf("%d\n", (int)calc(c_num+1, N));
	}
	return 0;
}


Measured memory_bytes: 6416
#include<stdio.h>
#include<math.h>
 
int main (void)
{
    int kazu;
    double x[100],y[100];
    int i;
    double A=0,B,C,D=0,E,F,G,H=0,I,sa[100];
     
 
    scanf("%d",&kazu);
 
    for(i=0;i<100;i++)
    {
        x[i]=0;
        y[i]=0;
        sa[i]=0;
    }
 
    for(i=0;i<kazu;i++)
    {
        scanf("%lf",&x[i]);
    }
    for(i=0;i<kazu;i++)
    {
        scanf("%lf",&y[i]);
    }
     
 
    for(i=0;i<kazu;i++)
    {
        B= x[i]-y[i];
        if(B<0)
        {
            B=-1*B;
        }
 
        A=A+B;
         
    }
 
    for(i=0;i<kazu;i++)
    {
        D=(x[i]-y[i])*(x[i]-y[i])+D;
        C=sqrt(D);
    }
 
    for(i=0;i<kazu;i++)
    {
		F=x[i] - y[i];
        if(F< 0)
        {
            F= -1*F;
        }
 
        G=pow(F,3);
		H=H+G;
    }
        E=pow(H,1.0/3.0);
 
 
      
 
      
    for(i=0;i<kazu;i++)
    {
        sa[i]=x[i]-y[i];
         
        if(sa[i]<0)
        {
            sa[i]=-1*sa[i];
        }
         
    }
         
    I = sa[0];
    for(i=0;i<kazu;i++)
    {
         
        if(I<sa[i])
        {
            I=sa[i];
        }
        else
        {
            I=I;
        }
     }
     
    printf("%f %f %f %f\n",A,C,E,I);
 
    return 0;
}

Measured memory_bytes: 716
/*
 * src.cpp
 *
 *  Created on: 2016/09/24
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int AC='z'-'a'+1;

string S;
int K;

int main(){
	cin>>S;
	cin>>K;
	REP(i,(int)S.length()){
		char c=S[i];
		if (c=='a') continue;
		int a='z'-c+1;
		if (K>=a){
			K-=a;
			S[i]='a';
		}
	}
	K%=AC;
	while(K){
		S.back()++;
		if (S.back()>'z'){
			S.back()='a';
		}
		K--;
	}
	cout<<S<<endl;
	return 0;
}




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

int main() {

    int a,b,p,N,M;
    cin>>N>>M;
    if(N<2 && M<2)
    {
        p=0;
        cout<<'0';
    }
   
    if(N+M>2)
    {
     a=(N*(N-1))/2;
     b=(M*(M-1))/2;
    
    if(N>2 && M>2)
    {
     p=a+b;
     cout<<p;
    }
     if(N<2)
    {
      cout<<b;
    }
    if(M<2)
    {
      cout<<a;
    }
    }

	return 0;
}


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

int main(void){
    int w,h;
    while(cin >> h >> w,h){
        int sq = h*h+w*w;
        int ansh = 1000, answ = 1000, anssq = 1000000;
        // i <-> h , j <-> w
        for(int i=1; i<151;i++){
            for(int j=i+1; j<151; j++){
                int tempd = i*i+j*j;
                if(tempd > sq){
                    if(tempd < anssq){
                        ansh = i;
                        answ = j;
                        anssq = tempd;
                    }
                    else if(tempd == anssq && i < ansh){
                        ansh = i; answ = j;
                    }
                }
                else if(tempd == sq){
                    if(i > h && anssq != tempd){
                        ansh = i; answ = j; anssq = tempd;
                    }
                }
            }
        }
        cout << ansh << " " << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,N;
  cin >> H >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int sum = 0;
  rep(i,N) {
    sum += A[i];
  }
  if(sum >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

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

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()



int main() {
	ll n,m,d;
	cin >> n >> m >> d;
	printf("%.8f", double(m - 1) / n / n*(n*(d == 0) + 2*(n - d)*(d != 0)));


}



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

using namespace std;

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

  long long ans = 0, stk = 0;
  for (char i : s) {
    if (i == 'B') ++stk;
    else ans += stk;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num):>, lower_bound(A, A+N, num):>=
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>	// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>		// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>	// push(x), front(), pop()
#include <deque>
#include <stack>	// push(x), top(), pop()
#include <map>		// M[key],  insert(key, val), erase(key), find(key), 
#include <set>		// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

void solve() {
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll d = a * x + b * y;
	ll e = c * 2 * max(x, y);
	ll f = c * 2 * min(x, y);
	if (x > y) f += (x - y)*a;
	else f += (y - x)*b;
	ll ans = min(min(d, e), f);
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	n int
	a []int
)

func main() {
	fmt.Scan(&n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var q int
	fmt.Scan(&q)
	ms := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&ms[i])
	}

	//回答
	for i := 0; i < q; i++ {
		res := solve(0, ms[i])
		if res {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}

}

func solve(i, m int) bool {
	if m == 0 {
		return true
	}

	if i >= n {
		return false
	}

	res := solve(i+1, m) || solve(i+1, m-a[i])
	return res
}



Measured memory_bytes: 1128
from operator import itemgetter
N=int(input()) 
s = [input().split() for i in range(N)]
for i in range(N):
    s[i][1] = s[i][1].zfill(3)
    s[i].append(i)
s.sort(key=itemgetter(1),reverse=True)
s.sort(key=itemgetter(0))
[print(s[i][-1]+1) for i in range(N)]

Measured memory_bytes: 38384
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		SortedArrays solver = new SortedArrays();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}


	static class SortedArrays {

		private int n;
		private int a[];

		private Scanner scanner;
		private int output;

		public SortedArrays() {
			scanner = new Scanner(System.in);
			output = 1;
		}

		public void readInput() {
			int buff;
			n = Integer.parseInt(scanner.next());
			a = new int[n];

			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(scanner.next());
			}

		}

		public void solve() {
			int slope=0;
			for(int i=1; i<n; i++) {

				if(slope == 0) {
					if(a[i-1]<a[i]) {
						slope = 1;
					} if(a[i-1]>a[i]) {
						slope = -1;
					}
				} else if(slope == 1) {
					if(a[i-1]>a[i]) {
						slope = 0;
						output++;
					}
				} else if(slope == -1) {
					if(a[i-1]<a[i]) {
						slope = 0;
						output++;
					}
				}
			}

		}
		public void writeOutput() {
			System.out.println(output);
		}
	}

}


Measured memory_bytes: 48908
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

//const int mod = (int) (1e9 + 7);
const int mod = 998244353;
template<int mod>
class ModInt {
    int x;
public:
    ModInt() : x(0) {}
    ModInt(long long int y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt& p)
    {
        if ((x += p.x) >= mod)
        {
            x -= mod;
        }
        return *this;
    }
    ModInt &operator-=(const ModInt& p)
    {
        if ((x += mod - p.x) >= mod)
        {
            x -= mod;
        }
        return *this;
    }
    ModInt &operator*=(const ModInt& p)
    {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt& p)
    {
        *this *= p.Inverse();
        return *this;
    }
    ModInt operator-() const
    {
        return ModInt(-x);
    }
    ModInt operator+(const ModInt& p)
    {
        return ModInt(*this) += p;
    }
    ModInt operator-(const ModInt& p)
    {
        return ModInt(*this) -= p;
    }
    ModInt operator*(const ModInt& p)
    {
        return ModInt(*this) *= p;
    }
    ModInt operator/(const ModInt& p)
    {
        return ModInt(*this) /= p;
    }
    bool operator==(const ModInt& p)
    {
        return x == p.x;
    }
    bool operator!=(const ModInt& p)
    {
        return x!= p.x;
    }
    ModInt Inverse() const
    {
        int a = x, m = mod, u = 1, v = 0, t;
        while (m > 0)
        {
            t = a / m;
            std::swap(a -= t * m, m);
            std::swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& p)
    {
        return os << p.x;
    }
    friend std::istream& operator>>(std::istream& is, ModInt& a)
    {
        long long t;
        is >> t;
        a = ModInt<mod>(t);
        return is;
    }
};

using mint = ModInt<mod>;

void DLeapingTak(std::istream& in, std::ostream& out) {
    int n, k;
    in >> n >> k;
    struct p
    {
        int l, r;
    };
    vector<p> s(k);
    for (int i = 0; i < k; ++i) {
        in >> s[i].l >> s[i].r;
    }
    vector<mint> dp(n + 1);
    vector<mint> sum_dp(n + 1);
    sum_dp[1] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 0; j < k; ++j) {
            // i-s[i].l~
            if (i - s[j].l >= 1) {
                dp[i] += sum_dp[i - s[j].l] - sum_dp[max(0, i - s[j].r - 1)];
            }
        }
        sum_dp[i] = sum_dp[i - 1] + dp[i];
    }
    out << dp[n] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    DLeapingTak(in, out);
    return 0;
}

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

int main(){
  ll n,k,array[100000],ans=1e15,sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array,array+n);
  for(int i=0;i<n-k+1;i++){
    if(array[i+k-1]-array[i]<ans){
      ans=array[i+k-1]-array[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main() {
	int N, i, a, b, c;
	const char *result;
	scanf(" %d", &N);
	while (N--) {
		result = "YES";
		b = c = 0;
		for (i = 0; i < 10; i++) {
			scanf(" %d", &a);
			if (b < a)
				b = a;
			else if (c < a)
				c = a;
			else
				result = "NO";
		}
		puts(result);
	}
	return 0;
}

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

#define ll long long

int main(void){
    string s;
    cin >> s;
    int sn = 0;
    for(int i=0;i<s.length();i++){
        sn += s[i]-'0';
    }
    if(stoi(s)%sn==0){
        cout << "Yes" << endl;
     }else{
         cout << "No"<<endl;
     }
     return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t c = n/(a+b) ;
  int64_t d = n%(a+b) ;
  if ( d<=a){
    cout << a*c + d << endl;
  }else {
    cout << a*(c+1) << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  int a[n];
  ll sum=0;
  rep(i,0,n){
    cin>>a[i];
    sum+= (a[i]-1);
  }
  cout<<sum<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3620
N,T = map(int,input().split(" "))
A = list(map(int,input().split(" ")))

minA = [(-1,-1)] * (N)
maxA = [(-1,-1)] * (N)

maxA[N-1] = (A[-1],1)
minA[0] = (A[0],1)
for i in range(1,N):
	if A[i] == minA[i-1][0]:
		minA[i] = (A[i],minA[i-1][1]+1)
	else:
		minA[i] = (min(minA[i-1][0],A[i]),1)

	if A[N-i-1] == minA[N-i][0]:
		minA[N-i-1] = (A[N-i-1],minA[N-i][1] + 1)
	else:
		maxA[N-i-1] = (max(maxA[N-i][0],A[N-i-1]),1)

pair = {}
prev = maxA[1][0] - minA[0][0]
for i in range(N-1):
	if prev < (maxA[i+1][0] - minA[i][0]):
		pair = {(maxA[i+1][0],minA[i][0]) : min(maxA[i+1][1],minA[i][1])}
		prev = (maxA[i+1][0] - minA[i][0])
	elif prev == (maxA[i+1][0] - minA[i][0]):
		if (maxA[i+1][0],minA[i][0]) in pair:
			pair[(maxA[i+1][0],minA[i][0])] = max(pair[(maxA[i+1][0],minA[i][0])],min(maxA[i+1][1],minA[i][1]))
		else:
			pair[(maxA[i+1][0],minA[i][0])] = min(maxA[i+1][1],minA[i][1])

print(sum(pair.values()))

Measured memory_bytes: 28532
import heapq

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for _ in range(m):
    tmp = heapq.heappop(A)
    tmp = int((-tmp / 2) // 1)
    heapq.heappush(A, -tmp)
print(-sum(A))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int front=INF,rest=-INF;
	string S;
	cin>>S;

	REP(i,(int)S.length()){
		switch(S[i]){
		case 'C':
			chmin(front,i);
			break;
		case 'F':
			chmax(rest,i);
			break;
		}
	}
	if(front<rest) print("Yes");
	else print("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <regex>
#include <cmath>
#include <bitset>
#include <array>
#include <deque>
#include <list>
#include <stack>
#include <iterator>
#include <random>
#include <cctype>

#define DEBUG_OUTPUT 0

#if DEBUG_OUTPUT
#define debug(...) debug_output(__VA_ARGS__)
#define debug_output_matrix(...) debug_output_matrix_impl(__VA_ARGS__)
#else
#define debug(...)
#define debug_output_matrix(...)
#endif

using namespace std;

using s32 = int32_t;
using u32 = uint32_t;
using s64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

// ==== I/O
const char newline = '\n';

template<class T>
void input(T& val) {
    cin >> val;
}

template<class Head, class... Args>
void input(Head& val, Args&... args){
    input(val);
    input(args...);
}

template<class T>
T input() {
    T val;
    input(val);
    return val;
}

template<class T>
std::vector<T> input_vector(int n) {
    std::vector<T> res;
    for(int i=0;i<n;i++){
        res.emplace_back(input<T>());
    }
    return res;
}

template<class T>
void output(const T& val){
    cout << val;
}
template<class T1,class T2>
void output(const T1& val, const T2& val2){
    output(val);
    if(val2 != newline)
        output(' ');
    output(val2);
}

template<class T1, class T2, class... Args>
void output(const T1& val, const T2& val2, Args&&... args){
    output(val);
    output(' ');
    output(val2, args...);
}

#if DEBUG_OUTPUT
template<class T>
void debug_output(const T& val){
    cerr << val;
}
template<class T1,class T2>
void debug_output(const T1& val, const T2& val2){
    debug_output(val);
    if(val2 != newline)
        output(' ');
    debug_output(val2);
}

template<class T1, class T2, class... Args>
void debug_output(const T1& val, const T2& val2, Args&&... args){
    debug_output(val);
    debug_output(' ');
    debug_output(val2, args...);
}
#endif

template<class T>
vector<vector<T>> make_matrix2(T val, int a, int b){
    return vector<vector<T>>(
        a, vector<T>(b, val)
    );
}

template<class T>
void debug_output_matrix_impl(const vector<vector<T>>& v) {
    cerr << "========" << endl;
    for(const auto& a: v){
        for(const auto& b : a){
            cerr << b << " ";
        }
        cerr << endl;
    }
    cerr << endl;
}

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

// =======================

int main(){
    for(int i=0;i<5;i++){
        if(input<s32>() == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N, K;
    cin >> N >> K;
    if (2*K-N-1 > 0) {
        cout << "-1\n";
        return 0;
    }

    vector<vector<ll>> ans(3, vector<ll>(N, 0));
    Rep (i, N) {
        if (i < (N+1)/2) {
            ans[0][i] = K+2*i;
        } else {
            ans[0][i] = K+1+2*(i-(N+1)/2);
        }
    }

    Rep (i, N) {
        if (i < (N+1)/2) {
            ans[1][i] = K+N+(N+1)/2-i-1;
        } else {
            ans[1][i] = K+2*N-1-i+(N+1)/2;
        }
    }

    Rep (i, N) {
        ans[2][i] = K+2*N+i;
    }

    Rep (i, N) {
        cout << ans[0][i] << " " << ans[1][i] << " " << ans[2][i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4600
#include<stdio.h>
#include <limits.h>
 
#define N 101

#define White 0
#define Gray  1
#define Black 2
 
 
int n=0;
int G[N][N];
int d[N];
int color[N];
int que[N];
int head=0;
int tail=0;
 
void Enqueue(int);
int Dequeue();
void BFS(int);

int main()
{
  int i,j,s,v,r;
  int p=1;

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
    for(j=1; j<=n;j++)
      {
	G[i][j] = 0;
      }
    }
  //loop
  for(i=1;i<=n;i++){
    scanf("%d%d", &v,&r);
    for(j=1;j<=r;j++){
      scanf("%d",&s);
      G[i][s] = 1;
    }
  }

  //BFS work
  BFS(p);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}

void Enqueue(int s)
{
  que[tail]=s;
  tail+=1;
}

int Dequeue()
{
  int sugiyama;
  sugiyama = que[head];
  head+=1;
  return sugiyama;
} 

void BFS(int s)
{
  int sugi,yama;
  for(sugi=1;sugi<=n;sugi++){
    color[sugi] = White;
    d[sugi] = -1;
  }
  color[s] = Gray;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    sugi = Dequeue();
    for(yama=1;yama<=n;yama++){
      if(color[yama] == White && G[sugi][yama] == 1){
        color[yama] = Gray;
        d[yama] = d[sugi] + 1;
        Enqueue(yama);
      }
    }
    color[sugi] = Black;
  }
}

Measured memory_bytes: 636
#include<stdio.h>
int main(void){
  int x,y,s,a=0,b,h1=0,h2=0,sum=0,hh1,hh2;
  while(1){
  scanf("%d %d %d",&x,&y,&s);
  if(x==0&&y==0&&s==0)
    break;
  for(a=1;a<s;a++){
    b=s-a;
    if((100*a)%(100+x)!=0){
    h1=a*100/(100+x)+1;
    }
    else
    h1=a*100/(100+x);
    if((b*100)%(100+x)!=0)
    h2=b*100/(100+x)+1;
    else
    h2=b*100/(100+x);
    hh1=h1*(100+x)/100;
    hh2=h2*(100+x)/100;
    if(hh1!=a){
      h1=0;
      h2=0;
    }
    if(hh2!=b){
      h1=0;
      h2=0;
    }
    h1=h1*(100+y)/100;
    h2=h2*(100+y)/100;
    if(sum<h1+h2){
      sum=h1+h2;
    }
  }
  printf("%d\n",sum);
  sum=0;
  }
  return(0);
}

Measured memory_bytes: 600
#include <iostream> 

int main(){
	int a,b,x=0;
	int gh[50];	
	while(std::cin>>a>>b){
		if(a==0&&b==0){
			for(int gf=1;gf<=x;gf++){
		std::cout<<gh[gf]<<std::endl;
	}return 0;
		}
		int d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0,d9=0;
		int o=0;
		x++;
		for(int d=0;d<10;d++){
			if(a>1&&d<=10-a){
				for(d2=d+1;d2<10;d2++){
			if(a>2&&d2<=10-a+1){
				for(d3=d2+1;d3<10;d3++){
			if(a>3&&d3<=10-a+2){
				for(d4=d3+1;d4<10;d4++){
			if(a>4&&d4<=10-a+3){
				for(d5=d4+1;d5<10;d5++){
			if(a>5&&d5<=10-a+4){
			for(d6=d5+1;d6<10;d6++){
			if(a>6&&d6<=10-a+5){
			for(d7=d6+1;d7<10;d7++){
			if(a>7&&d7<=10-a+6){
				for(d8=d7+1;d8<10;d8++){
			if(a>8&&d8<=10-a+7){
				for(d9=d8+1;d9<10;d9++){
		if(a==9&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==8&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==7&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==6&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==5&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==4&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==3&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==2&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
		}
		
			}if(a==1&&b==d){
			o++;
		}
		}
		gh[x]=o;
	}
	
	return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
int a;
cin>>a;
cout<<a+pow(a,2)+pow(a,3)<<endl;
    return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<(int)(n);i++)
#define endl '\n'
typedef pair<int,int> P;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    d*=d;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
   ll n,p;
   string s;
   cin >> n >> p;
   map<ll,ll> mp;
   for (ll i = 2;i*i <= p;i++){
      while(p%i == 0){
         mp[i]++;
         p/=i;
      }
   }
   if (p != 1) mp[p]++;
   ll ans = 1LL;
   for (auto q:mp){
      //cout << q.first << " " << q.second << endl;
      if (q.second >= n){
         rep(j,q.second/n){
            ans *= q.first;
         }
      }
   }
   cout << ans << endl;

 
   return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

int N;
vi G[200010];
int ans[200010];

signed main()
{
	cin>>N;
	
	rep(i, N-1) {
		int a;cin>>a;
		--a;
		G[a].PB(i+1);
	}

	rep(i, N) printf("%lld\n", (int)G[i].size());
}




Measured memory_bytes: 14604
// B - ABC
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;

	long long ans = 0;
	for (int i = s.size() - 1, c = 0; i >= 0; i--)
		if (s[i] == 'A') ans += c;
		else if (s[i] == 'C' && i - 1 >= 0 && s[i - 1] == 'B') c++, i--;
		else c = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 100;
int pref[N][26];
int mn[N][26];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0;i < n;i++){
	    for(int j = 0;j < 26;j++){
	        pref[i][j] = pref[i - 1][j];
	    }
	    pref[i][(s[i] - 'a')]++;
	}
	for(int j = 0;j < 26;j++){
	    mn[0][j] = 2 * pref[0][j];
	}
	for(int i = 1;i < n;++i){
	    for(int j = 0;j < 26;j++){
	        mn[i][j] = min(mn[i - 1][j], 2 * pref[i][j] - i);
	    }
	}
	if(s[0] == s[1]){
	    cout << 1 << " " << 2;
	    exit(0);
	}
	for(int i = 2;i < n;i++){
	    for(int j = 0;j < 26;j++){
	        if(2 * pref[i][j] - i > mn[i - 2][j]){
	        for(int r = 0;r < i;r++){
	            if(pref[i][j] - ((r)? (pref[r - 1][j]): 0) > ((i - r + 1) / 2)){
	                cout << r + 1 << " " << i + 1;
	                break;
	            }
	        }
	        exit(0);
	        }
	    }
	}
	cout << -1 << " " << -1;
	return 0;
} 

Measured memory_bytes: 24200
#include<bits/stdc++.h>
#define mod 1000000007
#define N 309
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int n,m,fst[N],pnt[N],len[N],nxt[N],dp[N][N][N]; bool bo[N][N][N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k,l,x,y;
	for (i=1; i<=m; i++){
		scanf("%d%d",&x,&y);
		pnt[i]=x; nxt[i]=fst[y]; fst[y]=i;
		scanf("%d",&len[i]);
	}
	for (i=0; i<=n; i++)
		for (j=0; j<=n; j++)
			for (k=0; k<=n; k++){
				x=max(max(i,j),k);
				for (l=fst[x]; l; l=nxt[l]){
					y=pnt[l];
					if ((i>=y)+(j>=y)+(k>=y)!=len[l]) break;
				}
				bo[i][j][k]=(!l);
			}
	dp[0][0][0]=1;
	for (i=0; i<n; i++)
		for (j=0; j<n; j++)
			for (k=0; k<n; k++) if (dp[i][j][k] && bo[i][j][k]){
				x=max(max(i,j),k);
				ad(dp[x+1][j][k],dp[i][j][k]);
				ad(dp[i][x+1][k],dp[i][j][k]);
				ad(dp[i][j][x+1],dp[i][j][k]);
			}
	int ans=0;
	for (i=0; i<=n; i++)
		for (j=0; j<=n; j++)
			for (k=0; k<=n; k++) if (i==n || j==n || k==n)
				if (bo[i][j][k]) ad(ans,dp[i][j][k]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 140544
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int X;
    cin >> X;
    
    if(X==3 || X==5 || X==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int N, M;
    cin >> N >> M;
    vpl v;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        v.push_back(pair<ll, ll>(a, b));
    }

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

    ll ans = 0;
    ll now = 0;
    for (int i = 0; i < N; ++i) {
        if (v[i].second < (M - now)) {
            ans += v[i].first * v[i].second;
            now += v[i].second;
        } else {
            ans += v[i].first * (M - now);
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

bool lcmp(const pair<int, int>& a, const pair<int, int>& b) {
  return a.first < b.first;
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, Q;
  cin >> N >> Q;
  vector<pair<int, int>> as(N * 2);
  F0R(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    as[i * 2] = { s - x, x };
    as[i * 2 + 1] = { t - x, x };
  }
  sort(rng(as), lcmp);
  as.emplace_back(INT32_MAX, 0);
  int ai = 0;
  set<int> ws;
  F0R(i, Q) {
    int d;
    cin >> d;
    while (as[ai].first <= d) {
      auto it = ws.find(as[ai].second);
      if (it == ws.end()) {
        ws.insert(as[ai].second); // 通行止めに
      }
      else {
        ws.erase(it); // 通行止め解除
      }
      ai++;
    }
    if (ws.size()) {
      cout << *ws.begin() << newl;
    }
    else {
      cout << -1 << newl;
    }
  }
}
#endif


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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

string a;

int main(){
	cin>>a;
	if(a[2]==a[3] && a[4]==a[5]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

	//system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int a;
	int b;
	int c;
	cin>>a;
	cin>>b;
	cin>>c;
	int k;
	cin>>k;
	while(k>0)
	{
	    if(b<=a)
	    {
	        b=b*2;
	        k--;
	    }
	    else
	        break;
	}
	while(k>0)
	{
	    if(c<=b)
	    {
	        c=c*2;
	        k--;
	    }
	    else
	        break;
	}
	if(b>a && c>b)
	    cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
}


Measured memory_bytes: 3608
import collections
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
m = [input() for _ in range(m)]
dd = collections.defaultdict(int)
for i in s:
    dd[i]+=1
for i in m:
    dd[i]-=1
print(max(0,max(dd.values())))


Measured memory_bytes: 9348
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: usize,
    }
    println!("{}", r * r);
}


Measured memory_bytes: 4476
S = input()
op = ["+", "-"]
for a in op:
    for b in op:
        for c in op:
            f = S[0] + a + S[1] + b + S[2] + c + S[3]
            if eval(f) == 7:
                print(f + "=7")
                break
        else:
            continue
        break
    else:
        continue
    break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int mod = 1000000007;
const int modx = 998244353;
#define ll long long
#define readi(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define readl(x) scanf("%I64d", &x)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = b; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bpc(x) __builtin_popcount(x)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<double, double>
#define pic pair<int, char>
#define ddouble long double
#define PI 3.1415926535
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define prod(x, y) ((x % mod) * (y % mod)) % mod
#define add(x, y) ((x % mod) + (y % mod)) % mod
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define pqs priority_queue<int, vector<int>, greater<int>>
#define pqb priority_queue<int>
#define mii map<int, int>
#define mll map<ll, ll>
using namespace std;
//using namespace __gnu_pbds;
/*ll power(ll x, ll y)
{
    ll r = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            r = (r*x) % mod;

        y = y>>1;
        x = (x*x) % mod;
    }
    return r;
}*/
const int N = 300;
int n;
ddouble dp[N + 1][N + 1][N + 1] = {}, vis[N + 1][N + 1][N + 1] = {};
ddouble rec(int x, int y, int z)
{
    if (x < 0 || y < 0 || z < 0)
        return 0;
    if (x == 0 && y == 0 && z == 0)
        return 0;
    if (vis[x][y][z])
        return dp[x][y][z];
    vis[x][y][z] = 1;
    ddouble ans = x * rec(x - 1, y, z) * 1.0 + y * rec(x + 1, y - 1, z) * 1.0 + 1.0 * z * rec(x, y + 1, z - 1) + n * 1.0;
    ans = ans / (x + y + z) * 1.0;
    dp[x][y][z] = ans;
    return ans;
}
void thunder()
{
    cin >> n;
    int i;
    int x = 0, y = 0, z = 0;
    rep(i, n)
    {
        int p;
        cin >> p;
        if (p == 1)
            x++;
        else if (p == 2)
            y++;
        else
            z++;
    }
    ddouble ans = rec(x, y, z);
    cout << fixed << setprecision(9) << ans << endl;
    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif*/
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q = 1;
    //cin >> t;
    while (q--)
        thunder();
}


Measured memory_bytes: 422176
import kotlin.math.abs

fun main() {
    class Permutation<T:Comparable<T>> (private var li: List<T>){

        val size_li:Int
        val size_e:Int
        val sortedList: List<List<T>>
        val invMap: Map<List<T>, Int>
        private var is_setting:Boolean =false
        var now: List<T>
            set(value){
                if (is_setting){
                    field=value
                }else{
                    this.setting(value = value)
                }
            }
        var ind:Int
            set(value){
                if (is_setting){
                    field=value
                }else{
                    this.setting(index = value)
                }

            }

        init {
            this.is_setting=true
            this.now= listOf<T>()
            this.ind=-1
            this.size_li=this.fact(li.size)
            this.size_e=li.size
            this.sortedList=this.getList(li.sorted()).toList()
            this.invMap= this.getMap().toMap()
            this.setting(value = li)
        }

        private fun setting(index:Int?=null, value:List<T>?=null){
            this.is_setting=true
            if (index!==null) {this.ind= index; this.now=this.sortedList[index]}
            if (value!==null) {this.now= value; this.ind= this.invMap[value] ?: error("out of map")}
            this.is_setting=false
        }
        fun next():Boolean{
            this.ind =(this.ind+1)%this.size_li
            this.now=this.sortedList[this.ind]
            return this.ind != 0
        }
        fun prev():Boolean{
            this.ind=(this.ind-1+this.size_li)%this.size_li
            this.now=this.sortedList[this.ind]
            return this.ind!=this.size_li-1
        }
        private fun getList(li_before: List<T>, li_after: List<T> =listOf<T>(), tmp_ans: MutableList<List<T>> =mutableListOf<List<T>>()): MutableList<List<T>>{
            var ans:MutableList<List<T>> =mutableListOf<List<T>>()
            if (li_before.size<=1){
                tmp_ans.add(li_after+li_before)
                ans= tmp_ans
            }else{
                for (i in li_before.indices){
                    ans= this.getList(li_before.take(i)+li_before.takeLast(li_before.size-1-i), li_after+li_before[i],tmp_ans)
                }
            }
            return ans
        }
        private fun getMap():MutableMap<List<T>, Int>{
            var ans= mutableMapOf<List<T>, Int>()
            this.sortedList.forEachIndexed { index, e -> ans[e]=index }
            return ans
        }
        private fun fact(n:Int): Int{
            return if (n==0) 1 else n*this.fact(n-1)
        }
    }
    readLine()
    var p= readLine()!!.split(" ").map { it.toInt() }
    var q= readLine()!!.split(" ").map { it.toInt() }
    var perm=Permutation(p)
    var tmp=perm.ind
    perm.now=q
    println(abs(tmp-perm.ind))

}

Measured memory_bytes: 71816