akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll dp[101010][20];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll x;
	cin >> x;
	ll ans = 3 * x * x;
	cout << ans << endl;
	return 0;
}


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

int main(){
    string s;
    int m,x;
    while(true){
        cin >> s;
        if(s == "-"){
            break;
        };
        cin >> m;
        for(int i=0; i<m; i++){
            cin >> x;
            s = s.substr(x) + s.substr(0,x);
        };
        cout << s << endl;
    };
    return 0;
}


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

int main() {
  int n, t; cin>>n>>t;
  vector<long long> a(n);
  int ans = 0;
  for (int i = 0; i < n; i++) cin>>a[i];

  long long ma = 0, diff = 0;
  for (int i = n-1; i >= 0; i--) {
    ma = max(ma, a[i]);
    diff = max(diff, ma - a[i]);
  }

  ma = 0;
  for (int i = n-1; i >= 0; i--) {
    ma = max(ma, a[i]);
    if (ma - a[i] == diff) ++ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;
multiset<ll> st;
multiset<ll>::iterator med;

int main(void) {
  int Q;
  ll L = 0, R = 0, A = 0, B = 0;

  cin >> Q;
  rep(i, 0, Q) {
    int cmd;
    cin >> cmd;
    if (cmd==1) {
        ll a, b;
        cin >> a >> b;
        auto it = st.insert(a);
        //printf("%dに挿入\n", distance(st.bg, it));
        B += b;
        if (i==0) {
            med = st.bg;
        } else {
            ll x = *med;
            if ((sz(st)-1)%2==0) {
                if (a<x) {
                    // o x o o => o a x o o
                    A += x-a;
                    //printf("med:%d\n", *(med));
                    //printf("medは%dの位置\n", distance(st.bg, med));
                } else {
                    //　o x o o => o x z o o || o x z o a
                    ll z = *(++med);
                    A += L*(z-x);
                    A -= R*(z-x);
                    A += a-z;
                    A += z-x;
                    //printf("med:%d\n", *(med));
                    //printf("medは%dの位置\n", distance(st.bg, med));
                }
                L++;
            } else {
                if (a<x) {
                    // o o x o o => o a z x o o
                    ll z = *(--med);
                    A += R*(x-z);
                    A -= L*(x-z);
                    A += z-a;
                    A += x-z;
                    //printf("med:%d\n", *(med));
                    //printf("medは%dの位置\n", distance(st.bg, med));

                } else {
                    // o o x o o => o o x a o o
                    A += a-x;
                    //printf("med:%d\n", *(med));
                    //printf("medは%dの位置\n", distance(st.bg, med));
                    
                }
                R++;
            }

        }
    } else {
        printf("%lld %lld\n", *med, A+B);
    }
  
  }
    

    return 0;
}






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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> P[i];
    }
    ll ans = 0;
    FOR(i, N - 1, 1) {
        if (P[i - 1] < P[i] && P[i] < P[i + 1])
            ans++;
        if (P[i - 1] > P[i] && P[i] > P[i + 1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main() => Console.WriteLine(string.Join("\n", new int[int.Parse(Console.ReadLine())].Select(_ => Solve())));

	static long Solve()
	{
		var h = Read();
		V p0 = new V(h[0], h[1]), p1 = new V(h[2], h[3]), p2 = new V(h[4], h[5]), p3 = new V(h[6], h[7]);
		V s1 = p1 - p0, s2 = p3 - p2;

		Func<V, V, V, int> sign = (q0, q1, p) => Math.Sign((p.X - q0.X) * (q1.Y - q0.Y) - (q1.X - q0.X) * (p.Y - q0.Y));
		var d1 = sign(p0, p1, p2) * sign(p0, p1, p3);
		var d2 = sign(p2, p3, p0) * sign(p2, p3, p1);

		if (V.IsParallel(s1, s2))
		{
			// 同一直線上にない
			if (d1 != 0) return 0;

			if (p0.X == p1.X && p0.X == p2.X)
			{
				// y 軸に平行
				int m1 = Math.Min(p0.Y, p1.Y), M1 = Math.Max(p0.Y, p1.Y);
				int m2 = Math.Min(p2.Y, p3.Y), M2 = Math.Max(p2.Y, p3.Y);
				return (m1 < m2 ? m2 <= M1 : m1 <= M2) ? 1 : 0;
			}
			else
			{
				int m1 = Math.Min(p0.X, p1.X), M1 = Math.Max(p0.X, p1.X);
				int m2 = Math.Min(p2.X, p3.X), M2 = Math.Max(p2.X, p3.X);
				return (m1 < m2 ? m2 <= M1 : m1 <= M2) ? 1 : 0;
			}
		}
		else
		{
			return d1 <= 0 && d2 <= 0 ? 1 : 0;
		}
	}
}

struct V
{
	public int X, Y;
	public V(int x, int y) { X = x; Y = y; }

	public static V operator -(V v) => new V(-v.X, -v.Y);
	public static V operator +(V v1, V v2) => new V(v1.X + v2.X, v1.Y + v2.Y);
	public static V operator -(V v1, V v2) => new V(v1.X - v2.X, v1.Y - v2.Y);

	public static bool IsParallel(V v1, V v2) => v1.X * v2.Y == v2.X * v1.Y;
	public static bool IsOrthogonal(V v1, V v2) => v1.X * v2.X == -v1.Y * v2.Y;
}



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

public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String bl = "";
    while ((bl = br.readLine()) != null) {
      int n = Integer.parseInt(bl);
      int counter = 0;
      for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
          for (int c = 0; c < 10; c++) {
            for (int d = 0; d < 10; d++) {
              if ((a + b + c + d) == n) { counter++;}
            }
          }
        }
      }
      System.out.println(counter);
    }
  }
}

Measured memory_bytes: 24768
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
    int i,n,k,a[100000];
    memset(a,0,sizeof(a));

    cin >> n;
    for(i=0;i<n;i++){
        cin >> k;
        a[k-1]=i+1;
    }
    for(i=0;i<n;i++){
        cout << a[i] << " ";
    }
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = 0, A = 0, B = 0;
            K = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            A = int.Parse(str[0]);
            B = int.Parse(str[1]);
            bool flag = false;
            for (int i = 1; K * i <= B; i++)
            {
                if (i * K >= A) flag = true;
            }
            if (flag) Console.WriteLine("OK");
            else Console.WriteLine("NG");
        }            
    }
}


Measured memory_bytes: 27532
#define PI 3.14159265359
#define INF 2000000000
#define MAX 500000
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;

void LCS(string X,string Y){
 int c[1002][1002];
 int n=X.length(),m=Y.length();
 for(int i=0;i<=max(n,m);i++){
     c[i][0]=c[0][i]=0;
 }
 for(int i=1;i<=n;i++){
     for(int j=1;j<=m;j++){
         if(X[i-1]==Y[j-1])
           c[i][j]=c[i-1][j-1]+1;
         else{
           c[i][j]=max(c[i][j-1],c[i-1][j]);
         }
     }
 }
 cout<<c[n][m]<<endl;
}

int main(){
    int q;
    cin>>q;
    string X,Y;
    for(int i=0;i<q;i++){
        cin>>X>>Y;
        LCS(X,Y);
    }
}

Measured memory_bytes: 7028
n = int(input())
s = input()

s = list(s)
ans = 0
count = 0

for a in range(1, n):
    l1 = list(set(s[:a]))
    l2 = set(s[a:])

    length1 = len(l1)

    for x in range(length1):
        if l1[x] in l2:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)


Measured memory_bytes: 3060
import math
A, B ,X = map(int,input().split())
C =  2 * X / A / B
if C <= A:
    print(math.degrees(math.atan(B/C)))
else:
    C = 2*(A**2 * B - X) / (A**2)
    print(math.degrees(math.atan(C/A)))


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    string  S,flag="No";

    cin>>S;

    if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
        flag="Yes";
    }
    else if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]){
        flag="Yes";
    }
    else if(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
        flag="Yes";
    }

    cout<<flag<<endl;


    return 0;
}


Measured memory_bytes: 256
//与えられる座標は小さな整数だし、和集合求めるの面倒くさい。整数座標で圧縮して適当にやる。
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

const int TX = 20;

int r, n;
int xl, xr, y;
int data[50];	//data[x] = [x, x+1)の高さ	更新は[l,r)なので注意

int main() {
	while( cin >> r >> n ) {
		if (!r) break;
		int i, j;
		for( i = 0; i <41; i++ )
			data[i] = 0;
				
		for( i = 0; i < n; i++ ) {
			cin >> xl >> xr >> y;
			xl += TX;
			xr += TX;
			for( j = xl; j < xr; j++ ) {
				data[j] = max( data[j], y );
			}
		}
		
		double ans = 114514;
		for( i = TX - r; i < TX + r; i++ ) {
			double h1, h2, h, hit_h;
			//円が(x,y)と当たる時の座標を直接求めるのは難しそう…(扇形？いや違うなあ)
			//円が(x,0)と当たる時は？、三角関数やるだけ！
			h1 = -(double)r + sqrt( (double)r*r - (i-TX)*(i-TX) );
			h2 = -(double)r + sqrt( (double)r*r - (i+1-TX)*(i+1-TX) );
			//h1 = -(double)r + (double)r * cos( (double)(i - TX)/(double)r );
			//h2 = -(double)r + (double)r * cos( (double)(i + 1 - TX)/(double)r );
			h = max(h1, h2);
			//cout << "i = " << i-TX << " h1 = "<< h1 << " h2 = " << h2 << " h = " << h << " data = " << data[i] << endl;
			hit_h = (double)data[i] - h;
			
			ans = min(ans, hit_h);
		}
		printf("%.14f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S; cin >> S;
	int w; cin >> w;
	string ans = "";
	rep(i, S.length()) {
		if (i % w == 0) ans += S[i];
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int ans=1e9+7,n,k,tmp,a[100008],sum[100008],p;
bool flag;
int main()
{
    scanf("%d%d",&n,&k);
    p=n+1; flag=false;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>0&&!flag)flag=true,p=i;
    }
    for(int i=1;i<p;i++)
        sum[i]=-a[i];
    for(int i=p;i<=n;i++)
        sum[i]=a[i];
    for(int i=1;i<=n-k+1;i++)
    {
        tmp=sum[i];
        if(a[i+k-1]<=0){ans=min(ans,tmp); continue;}
        if(a[i]<0)
        {
            tmp+=sum[i+k-1];
            if(sum[i+k-1]<sum[i]) tmp+=sum[i+k-1]; else tmp+=sum[i];
            ans=min(ans,tmp);
        }
        else {tmp=sum[i+k-1]; ans=min(ans,tmp); continue;}
    }
    cout<<ans<<endl;
    return 0;
}


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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }

int main() {
	int T; cin >> T;
	while(T--) {
		long long a, b, c, d;
		cin >> a >> b >> c >> d;
		if(a < b) { cout << "No\n"; continue; }
		if(d < b) { cout << "No\n"; continue; }
		long long k = (a - c - 1) / b;
		a -= k * b;
		while(a > c) a -= b;
		if(a < 0) { cout << "No\n"; continue; }
		if(c >= b) { cout << "Yes\n"; continue; }
		a += d;
		long long e = gcd(b, d);
		b -= e;
		if(c >= b) cout << "Yes\n"; else cout << "No\n";
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

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

    int tmp;
    tmp = a;
    a = b;
    b = tmp;

    tmp = a;
    a = c;
    c=tmp;

    cout << a << " "<< b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
path = []

i = 0
while True:
    if s[i] == 'A':
        path.append(0)
        i += 1
    elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
        path.append(1)
        i += 2
    else:
        path.append(2)
        i += 1
    
    if i >= len(s):
        break


path.reverse()

ans = 0
c1 = 0
for i in range(len(path)):
    if path[i] == 1:
        c1 += 1
    elif path[i] == 2:
        c1 = 0
    else:
        ans += c1

print(ans)

Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

int n;
vector<int> arr;
vector<vector<int>> dp;


int solve(int l = 0, int r = n-1, int chance = 0) {
    // t(l, r, chance);
    if(dp[l][r] != -1e18) {
        return dp[l][r];
    }
    if(l == r) {
        if(!chance) {
            dp[l][r] = arr[l];
        }
        else {
            dp[l][r] = -arr[l];
        }
        return dp[l][r];
    }
    if(!chance) {
        dp[l][r] = max(arr[l]+solve(l+1, r, !chance), arr[r] + solve(l, r-1, !chance));
    }
    else {
        dp[l][r] = min(-arr[l] + solve(l+1, r, !chance), -arr[r] + solve(l, r-1, !chance));
    }
    return dp[l][r];
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    arr.assign(n, 0);
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    dp.assign(n+1, vector<int>(n+1, -1e18));
    int ans = solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 72960
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll p,q,a,n;
ll nums[7]={};
ll ans;
void Func(ll prod,ll sum,ll nums[],ll size){
    if(p*prod==q*sum){
        ans++;
        return;
    }
    if(size>=n)return;
    ll pre;
    if(size>0){
        pre=nums[size-1];
    }
    else{
        pre=a;
    }
    for(ll i=1;i<=min(a/prod,pre);i++){
        nums[size]=i;
        ll nextProd=prod*i;
        ll nextSum=sum*i+prod;
        if(p*nextProd>=q*nextSum){//目標(p/q)を上回っていなければ分数を増やす
            Func(nextProd,nextSum,nums,size+1);
        }
    }
}
int main(){
    while(cin>> p>>q>>a>>n,p!=0){
        ans=0;
        Func(1,0,nums,0);
        cout<<ans<<endl;
    }
    return 0;
}



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

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


//4-side
//int xx[] = {0,0,-1,1};
//int yy[] = {-1,1,0,0};
//6-side hexagonal
//int xx[] = {2,-2,1,1,-1,-1};
//int yy[] = {0,0,1,-1,1,-1};

#define popc(a) (__builtin_popcount(a))
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

#define MX 100005
#define inf 100000000

const double pi = acos(-1.0);
const ll mod = 1000000007ll;

char st[] = {'M', 'A', 'R', 'C', 'H'};
int cnt[MX];
char name[MX];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf(" %s", name);
        cnt[name[0]]++;
    }
    ll res = 0;
    for(int i = 0; i < (1<<5); i++)
    {
        if(__builtin_popcount(i) != 3)
            continue;
        ll tem = 1;
        for(int j = 0; j < 5; j++)
        {
            if((i>>j)&1)
                tem *= cnt[st[j]];
        }
        res += tem;
    }
    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 256
using System;

namespace AOJ.Volume0
{
    class Factorial
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            long ans = 1;
            for (int i = 2; i <= n; i++) { ans = ans * i; }
            Console.WriteLine(ans);
        }
    }
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  int dist_a = (x-a)*(x-a);
  int dist_b = (x-b)*(x-b);
  
  if(dist_a < dist_b) cout << "A" << endl;
  else cout << "B" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=8010;
const int X=8000;
int f[2][maxn*2];
int check(int tar,int n,int* x) {
	memset(f,0,sizeof(f));
	int cur=0,m=0;
	f[0][X]=1;
	rep(i,1,n) {
		cur^=1;memset(f[cur],0,sizeof(f[cur]));
		rep(j,-m,m) if(f[cur^1][j+X]) f[cur][j+X+x[i]]=f[cur][j+X-x[i]]=1;
		m+=x[i];
	}
	return f[cur][tar+X];
}
char s[maxn];
int x,y,n;
int mx,vx[maxn];
int my,vy[maxn];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	x=read();y=read();
	rep(i,1,n) {
		if(s[i]=='T') break;
		x--;
	}
	int cur=1;
	rep(i,1,n) {
		if(s[i]=='T') {
			int cnt=0;
			rep(j,i+1,n) {
				if(s[j]=='T') {i=j-1;break;}
				cnt++;
			}
			if(!cur) vx[++mx]=cnt;
			else vy[++my]=cnt;
 			cur^=1;
		}
	}
	printf("%s\n",(check(x,mx,vx)&&check(y,my,vy))?"Yes":"No");
	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int R, G;

void solve()
{
    cin >> R >> G;
    cout << 2 * G - R << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	ll l,r,x;
	scanf("%lld%lld%lld",&l,&r,&x);
	printf("%lld\n",r/x-(l-1)/x);
	return 0;
}

Measured memory_bytes: 3820
#include <iostream>

using namespace std;

int main(){
  string S;

  cin >> S;

  int ans = 0;
  int update = 0;

  for(int i = 0; S[i] != '\0'; i++){
    if(S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T'){
      update++;
    }
    else update = 0;
    ans = max(ans, update);
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,ans=0;
	cin>>n>>m;
	vl p(m);
	vvl v(m);
	rep(i,m){
		int k;
		cin>>k;
		rep(j,k){
			int in;
			cin>>in;
			v[i].push_back(in-1);
		}
	}
	rep(i,m)cin>>p[i];
	rep(i,(1<<n)){
		bool l=true;
		rep(j,m){
			int cnt=p[j];
			rep(k,v[j].size()){
				cnt+=(i&1<<v[j][k]?1:0);
			}
			l&=(cnt%2==0);
		}
		if(l)ans++;
	}
	cout<<ans<<endl;
}


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

#define int long long

signed main() {
	int N;
	cin >> N;
	vector<string> strings(N);
	for (int n = 0; n < N; ++n) {
		cin >> strings[n];
		sort(strings[n].begin(), strings[n].end());
	}
	sort(strings.begin(), strings.end());
	int previdx = 0;
	string prev = strings[0];
	long long ans = 0;
	for (int k = 0; k < N; ++k) {
		if (strings[k] != prev) {
			ans += (k-previdx)*(k-previdx-1)/2;
			prev = strings[k];
			previdx = k;
		}
	}
	ans += (N-previdx)*(N-previdx-1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;
    int ans = 0;
    rep(i, S.size()) {
        repd(j, i, S.size()) {
            string check = S.substr(i, j - i + 1);
            int res = 0;
            rep(k, check.size()) {
                if (check[k] != 'A' && check[k] != 'C' && check[k] != 'G' && check[k] != 'T') {
                    res = 0;
                    break;
                }
                res++;
            }
            chmax(ans, res);
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int h, w, d, n;
    cin >> h >> w >> d >> n;
    vector<string> grid(h);
    REP(y, h) cin >> grid[y];
    vector<int> r(d + 2);
    r[0] = -1; r[d + 1] = 1000;
    REP(i, d) cin >> r[i + 1];

    int cnt[50][50] = {};
    REP(i, n){
        int sx, sy, idx;
        cin >> sx >> sy >> idx;
        int lb = r[idx] + 1, ub = r[idx + 1];
        // [lb, ub]
        bool output[50][50] = {};
        REP(y, h) REP(x, w) if(grid[y][x] != '#') {
            int dist = max(abs(sx - x), abs(sy - y));
            if(lb <= dist && dist <= ub){
                cnt[y][x] ++;
                output[y][x] = true;
            }
        }
    }

    bool used[50][50] = {};
    queue<int> qx, qy;
    REP(y, h) REP(x, w) {
        if(grid[y][x] == 'D') {
            qx.push(x);
            qy.push(y);
            used[y][x] = true;
        }
    }

    while(!qx.empty()){
        int x = qx.front();
        int y = qy.front();
        qx.pop(); qy.pop();
        auto valid = [](int x, int w) -> bool { return 0 <= x && x < w; };
        int dx[] = {1, 0, -1, 0};
        int dy[] = {0, -1, 0, 1};
        REP(r, 4){
            int nx = x + dx[r];
            int ny = y + dy[r];
            if(valid(nx, w) && valid(ny, h) && grid[ny][nx] != '#' && !used[ny][nx]){
                used[ny][nx] = true;
                qx.push(nx);
                qy.push(ny);
            }
        }
    }


    int ok = 0, ng = 0;
    REP(y, h) REP(x, w) {
        if(cnt[y][x] == n){
            (used[y][x] ? ok : ng) += 1;
        }
    }
    if(ok > 0 && ng == 0){
        cout << "Yes" << endl;
    }else if(ok == 0 && ng > 0){
        cout << "No" << endl;
    }else if(ok > 0 && ng > 0){
        cout << "Unknown" << endl;
    }else{
        cout << "Broken" << endl;
    }


    return 0;
}

Measured memory_bytes: 1240
WHxyr = input()
WHxyr_list = WHxyr.split(" ")
W = int(WHxyr_list[0])
H = int(WHxyr_list[1])
x = int(WHxyr_list[2])
y = int(WHxyr_list[3])
r = int(WHxyr_list[4])

if (x - r >= 0 and y - r >= 0) and (x + r <= W and y + r <= H):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A.sort()
if sum(A)%10!=0:
    print(sum(A))
else:
    for i in range(N):
        if A[i]%10!=0:
            print(sum(A)-A[i])
            break
        if i==N-1:
            print("0")
            break

Measured memory_bytes: 3064
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	set<int> cpp;
	int q, com, o, r;
	scanf("%d", &q);

	while (q--)
	{
		
		scanf("%d%d", &com,&o);
		switch (com)
		{
		case 0:
			cpp.insert(o);
			printf("%d\n", cpp.size());
			break;

		case 1:
			printf("%d\n", cpp.count(o));
			break;
			
		case 2:
			cpp.erase(o);
			break;
		case 3:
				scanf("%d", &r);
				set<int>::iterator prev = cpp.lower_bound(o);
				set<int>::iterator next = cpp.upper_bound(r);
				while (prev != next)
				{
					printf("%d\n", *prev);
					prev++;
				}
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 12012
import sys
N,K=map(int,input().split())
A=sorted([int(i) for i in input().split()])
sa=sum(A)
def f(x):
    y=A[x]
    if y>=K:
        return True
    L=set()
    L.add(0)
    dp=[False]*(K-y)
    dp[0]=True
    t=0
    for i in range(N):
        if i==x:
            continue
        s=A[i]
        for k in range(t,-1,-1):
            if not dp[k]:
                continue
            if k+s>=K:
                continue
            if k+s+y>=K:
                return True
            dp[k+s]=True
        t=min(t+s,K-y-1)
    return False
ma=N-1
mi=0
if not f(N-1):
    print(N)
    sys.exit()
if f(0):
    print(0)
    sys.exit()
while ma-mi>1:
    #print(ma,mi)
    a=(ma+mi)//2
    if f(a):
        ma=a
    else:
        mi=a
print(ma)




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

int main() {
	int a, b;
	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		if (a > b)cout << b << " " << a << endl;
		else cout << a << " " << b << endl;
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int N; vll X;
void input()
{
    cin>>N;
    for(int i=0;i<N;++i){
        ll x; cin>>x; X.emplace_back(x);
    }
}

void solve()
{
    vll hp(101,0);
    for(ll i=1ll;i<101ll;++i){
        for(int j=0;j<N;++j){
            hp[i]+=(X[j]-i)*(X[j]-i);
        }
    }
    ll ans=1000000000000000000;
    for(ll i=1ll;i<101ll;++i){
        ans=min(ans,hp[i]);
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] date = sc.next().split("/");
        int year = Integer.valueOf(date[0]);
        int month = Integer.valueOf(date[1]);
        int day = Integer.valueOf(date[2]);

        System.out.println(month<=4 ? "Heisei" : "TBD");


    }
}

Measured memory_bytes: 22228
n = int(input())
h = list(map(int, input().split()))

cnt = [0] * n

for i in range(1, n):
  if h[i - 1] >= h[i]:
    cnt[i] = cnt[i - 1] + 1
  else:
    cnt[i] = 0
        
print(max(cnt))

Measured memory_bytes: 20208
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

H, M, H_2, M_2, K = map(int, input().split())

mae = H * 60 + M
ato = H_2 * 60 + M_2

print(ato - mae - K)




Measured memory_bytes: 9068
/*
Author: miitbh1
*/
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;
const int N=100001;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x, t;
    cin>>n>>x>>t;
    n=1ll*ceil(n/(x+0.0))*t;
    p(n);
    return 0;
}

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

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1){ }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

struct Edge
{
    int a, b, cost;

    bool operator<(const Edge& o) const{
        return cost < o.cost;
    }
};

struct Graph
{
    int n;
    vector<Edge> es;

    int kruskal(){
        sort(es.begin(), es.end());

        UnionFind uf(n);
        int min_cost = 0;

        for (int ei = 0; ei < es.size(); ei++)
        {
            Edge& e = es[ei];
            if(!uf.issame(e.a, e.b)){
                min_cost += e.cost;
                uf.merge(e.a, e.b);
            }
        }
        return min_cost;
    }
};

Graph input_graph(){
    Graph g;
    int m;
    cin >> g.n >> m;
    for (int i = 0; i < m; i++)
    {
        Edge e;
        cin >> e.a >> e.b >> e.cost;
        g.es.push_back(e);
    }
    return g;
}

int main() {
    Graph g = input_graph();
    cout << g.kruskal() << endl;
}


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


int main(void){
    int n;
    std::cin >> n;

    std::vector<int> a(n+1);
    for(int i = 0; i < n + 1; i++){
        std::cin >> a.at(i);
    }

    std::vector<int> b(n);
    for(int i = 0; i < n ; i++){
        std::cin >> b.at(i);
    }

    long long ans = 0;
    int temp = -1;

    for(int i = 0; i < n; i++){
        temp = std::min(a.at(i), b.at(i));
        ans += temp;
        a.at(i) -= temp;
        b.at(i) -= temp;

        temp = std::min(a.at(i+1), b.at(i));
        ans += temp;
        a.at(i+1) -= temp;
        b.at(i) -= temp;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int i;
    long n,t;
    long time[200000];
    long sum = 0;
    
    scanf("%ld %ld",&n,&t);
    for(i = 0; i < n; i++) scanf("%ld",&time[i]);
    
    for(i = 0; i < n-1; i++){
        if(time[i+1] - time[i] <= t){ //お湯が流れている間にスイッチが押される
            sum += time[i+1] - time[i];
           // printf("type 1 sum = %ld\n",sum);
        }else{
            sum += t;
           // printf("Type 2 sum = %ld\n",sum);
        }
    }
    sum += t; //最後の人
    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 1664
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
def main():
    n = int(input())
    uf = UnionFind(n)
    xs = [None]*n
    ys = [None]*n
    ps = [None]*n
    for i in range(n):
        x, y = map(int, input().split())
        ps[i] = [x, y]
        xs[i] = [x, i]
        ys[i] = [y, i]
    xs.sort()
    ys.sort()
    dist_xs = [None]*(n-1)
    dist_ys = [None]*(n-1)
    for i in range(n-1):
        dist_xs[i] = [xs[i+1][0] - xs[i][0], xs[i+1][1], xs[i][1]]
        dist_ys[i] = [ys[i+1][0] - ys[i][0], ys[i+1][1], ys[i][1]]
    dist_xs.sort()
    dist_ys.sort()
    x_i, y_i = 0, 0
    ans = 0
    while x_i < len(dist_xs) or y_i < len(dist_ys):
        if x_i < len(dist_xs) and y_i < len(dist_ys):
            if dist_xs[x_i][0] < dist_ys[y_i][0]:
                if not uf.same(dist_xs[x_i][1], dist_xs[x_i][2]):
                    uf.union(dist_xs[x_i][1], dist_xs[x_i][2])
                    ans += dist_xs[x_i][0]
                x_i += 1
            else:
                if not uf.same(dist_ys[y_i][1], dist_ys[y_i][2]):
                    uf.union(dist_ys[y_i][1], dist_ys[y_i][2])
                    ans += dist_ys[y_i][0]
                y_i += 1
        elif x_i < len(dist_xs):
            if not uf.same(dist_xs[x_i][1], dist_xs[x_i][2]):
                uf.union(dist_xs[x_i][1], dist_xs[x_i][2])
                ans += dist_xs[x_i][0]
            x_i += 1
        else:
            if not uf.same(dist_ys[y_i][1], dist_ys[y_i][2]):
                uf.union(dist_ys[y_i][1], dist_ys[y_i][2])
                ans += dist_ys[y_i][0]
            y_i += 1
    print(ans)

if __name__ == "__main__":
    main()

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
typedef vector<vm> vvm;
//

#define MOD (long)(1e9 + 7)

long long modPow(long long x, long long n){
  if(n == 0) return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x,n/2);
    return sqrtX * sqrtX % MOD ;
  }else{
    return x * modPow(x,n-1) % MOD;
  }
}

long long kaizyou(long long x){
  long long res = 1;
  for(int i = 1; i <= x; i++){
    res = (res * i) % MOD;
  }
  return res;
}

long long modCombi(long long a, long long b){
  if(b > a/2) return modCombi(a,a-b);
  return ((kaizyou(a) * modPow(kaizyou(b),MOD - 2)) % MOD)* modPow(kaizyou(a-b),MOD - 2) % MOD;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x ,y;
    cin >> x >> y;
    ll tmp = abs(x-y);
    ll mm = min(x-tmp,y-tmp);
    if(mm < 0){
      cout << 0 << endl;
      return 0;
    }

    if(mm % 3 != 0){
      cout << 0 << endl;
      return 0;
    }

    mm /= 3;
    mint ans = kaizyou(mm+mm+tmp) * modPow(kaizyou(mm),MOD-2);
    ans *= modPow(kaizyou(mm+tmp),MOD-2);

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
using namespace std;

int a[N];
int l[N], r[N];

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

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d", &l[i], &r[i]);

    sort(l, l + n);
    sort(r, r + n);
    if(n & 1)
    {
        x = l[n / 2];
        y = r[n / 2];
    }
    else
    {
        x = l[n / 2 - 1] + l[n / 2];
        y = r[n / 2 - 1] + r[n / 2];
    }
    printf("%d\n", y - x + 1);

    return 0;
}


Measured memory_bytes: 5392
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 1000005
#define mod 1000000007

ll all[maxN]= {};
int a,b,c,d;
void solve() {

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>a>>b>>c>>d;
	int win=0;
	int turn=0;
	while(1) {
		if(turn==0) {
			turn=1;
			c-=b;
			if(c<=0) {
				win = 1;
				break;
			}
			
		} else {
			turn=0;
			a-=d;
			if(a<=0) {
				win=2;
				break;
			}
			
		}
	}
	if(win==1) {
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  if(a+b>=a-b&&a+b>=a*b){
    cout << a+b;
  }else if(a-b>=a*b){
    cout << a-b;
  }else{
    cout << a*b;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
subordinate_dict = {emp_num: 0 for emp_num in range(1, N + 1)}

boss_nums = [int(boss_num) for boss_num in input().split()]

for boss_num in boss_nums:
  subordinate_dict[boss_num] += 1

for num in subordinate_dict.values():
  print(num)

Measured memory_bytes: 48892
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <iostream>
#include <set>
#include <map>

using namespace std;

int main() {
    int nodeCount, edgeCount;

    scanf("%d%d", &nodeCount, &edgeCount);

    vector< set<int> > to;
    vector< set<int> > to2;
    vector< set<int> > to3;
    vector< bool > v;
    vector< bool > v2;
    vector< bool > v3;
    to.resize(nodeCount);
    v.resize(nodeCount);
    v2.resize(nodeCount);
    v3.resize(nodeCount);

    for (int i = 0; i < nodeCount; ++i) {
        v[i] = false;
        v2[i] = false;
        v3[i] = false;
    }

    for (int i = 0; i < edgeCount; ++i) {
        int f, t;

        scanf("%d%d", &f, &t);

        to[f - 1].insert(t - 1);
    }

    int start, goal;

    scanf("%d%d", &start, &goal);

    queue<pair<int, int> > q;

    q.push(make_pair(start - 1, 0));
    v[start - 1] = true;

    while (!q.empty()) {
        auto p = q.front();
        q.pop();

        if (p.second % 3 == 0 && p.first == goal - 1) {
            printf("%d\n", p.second / 3);
            return 0;
        }

        for (const auto &item : to[p.first]) {
            if (p.second % 3 == 2 && !v[item]) {
                q.push(make_pair(item, p.second + 1));
                v[item] = true;
            }
            if (p.second % 3 == 0 && !v2[item]) {
                q.push(make_pair(item, p.second + 1));
                v2[item] = true;
            }
            if (p.second % 3 == 1 && !v3[item]) {
                q.push(make_pair(item, p.second + 1));
                v3[item] = true;
            }
        }
    }

    printf("-1\n");

    return 0;
}

Measured memory_bytes: 9600
import random

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(q, k=5):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q-1 and t & 1 == 0:
            return False
    return True

a, b = map(int, input().split())
comNum = list(set(make_divisors(a)) & set(make_divisors(b)))
ans = 1
for i in comNum:
    if is_prime(i):
        ans += 1
print(ans)

Measured memory_bytes: 5552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

namespace CF2016C_A
{
    class Program
    {
        static int N;
        static void Main(string[] args)
        {
            var t = ReadLine();
            bool c = false;
            bool f = false;
            for (int i = 0; i < t.Length; i++)
            {
                if (t[i] == 'C')
                {
                    c = true;
                }
                if (c && t[i] == 'F')
                {
                    f = true;
                }
            }
            if (c && f)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}


Measured memory_bytes: 2900
x, y = map(int, input().split())

a = (2 * x - y) // 3
b = (2 * y - x) // 3
rent_a = (2 * x - y) % 3
rent_b = (2 * y - x) % 3

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if a < 0 or b < 0:
    ans = 0
elif rent_a != 0 or rent_b != 0:
    ans = 0
else:
    n = a + b
    ans = combination(n, a)

print(ans)

Measured memory_bytes: 3188