akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  int a = n / 2 + ((n % 2 == 0) ? 0 : 1);
  cout << (double)a / (double)n;


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <iostream>

int main () {
    
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    
    if ( (x - r) < 0 || W < (x + r) || (y - r) < 0 || H < (y + r) ) std::cout << "No" << std::endl;
    else std::cout << "Yes" << std::endl;
    
    return 0;
}


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

#define MAXN (1000000000)
#define MOD (1000000007)


ll gcd(ll a, ll b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}


int main(void)
{
    ll a,b,c,d;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    ll l = c*d/gcd(c,d);

    ll ans = b-a+1;
    ans -= (b/c)-((a-1)/c);
    ans -= (b/d)-((a-1)/d);
    ans += (b/l)-((a-1)/l);
    printf("%ld\n",ans);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int n,x,i,j,k,sum=0,count=0;
    while(scanf("%d %d",&n,&x)==2){
        if(n==0 && x==0) break;
        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                for(k=j+1;k<=n;k++){
                    sum=i+j+k;
                    if(sum==x) {
                    count++;}
                }
            }
        }
        printf("%d\n",count);
        count=0;
    }
    return 0;
}


Measured memory_bytes: 2112
#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
# ---- ここまで -----------------------
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

Measured memory_bytes: 3952
#include<stdio.h>

int main() {
	int n, x;
	int i, j, k;
	int cnt;

	while (1) {
		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0) {
			break;
		}

		cnt = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				if (i != j) {
					for (k = j + 1; k <= n; k++) {
						if (i != k && j != k) {
							if ((i + j + k) == x) {
								cnt++;
							}
						}
					}
				}
			}
		}
		printf("%d\n", cnt);
	}

	return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a,b,c,d;
		a = new int[N];
		b = new int[N];
		c = new int[M];
		d = new int[M];
		for (int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i=0; i<M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for (int i=0; i<N; i++) {
			long min = Long.MAX_VALUE;
			int ans = 0;
			for (int j=0; j<M; j++) {
				if (min > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])) {
					min = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
					ans = j + 1;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
   int n;
   cin >> n;
   for(int i = 1;i <= 9;i++){
       if(n % i == 0 && n / i <= 9){
           cout << "Yes" << endl;
           return 0;
       }
   }
   cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 500009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6];
ll power(ll x,ll n){
    if(x==0) return 0;
    if(n==0) return 1;
    /*while(n){
        if(n%2) x=(((x*x)%M)*x)%M; 
        else x=(x*x)%M;
        n/=2;
    }*/
    if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll n,m,ar[M5];
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,test,flag,ans; string s; 
    //cin>>test;
    test=1;
    while(test--){
    	cin>>n>>m;
    	cout<<(1900*m+(n-m)*100)*power(2,m);
    }
    return 0;
} 

Measured memory_bytes: 2304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b); g[b].emplace_back(a);
    }
    
    vector<int> p(n); p[0] = 1;
    vector<bool> seen(n, false);
    queue<int> que; que.emplace(0);
    
    while (!que.empty()) {
        int v = que.front(); que.pop();
        seen[v] = true;
        for (const auto& u : g[v]) if (!seen[u]) {
            p[u] = (p[v] == 1 ? 2 : 1);
            que.emplace(u);
        }
    }
    
    queue<int> v[3];
    for (int i = 1; i <= n; i++) v[i%3].emplace(i);
    
    auto f1 = [](int i) { return (i == 1); };
    auto f2 = [](int i) { return (i == 2); };
    int v1 = count_if(p.begin(), p.end(), f1);
    int v2 = count_if(p.begin(), p.end(), f2);
    if (v1 < v2) {
        swap(v1, v2);
        for (auto& e : p) e = (e == 1 ? 2 : 1);
    }
    
    if (v1 > n*2/3) {
        for (int i = 0; i < n; i++) {
            if (p[i] == 2) {
                p[i] = v[0].front(); v[0].pop();
            } else {
                if (!v[1].empty()) {
                    p[i] = v[1].front(); v[1].pop();
                } else if (!v[2].empty()) {
                    p[i] = v[2].front(); v[2].pop();
                } else {
                    p[i] = v[0].front(); v[0].pop();
                }
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            const int id = p[i];
            if (v[id].empty()) {
                p[i] = v[0].front(); v[0].pop();
            } else {
                p[i] = v[id].front(); v[id].pop();
            }
        }
    }
    
    for (auto ans : p) cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 20852
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, INF = 1000000000, ANS = INF;
	cin >> N;
	vector<vector<long long> > A(N, vector<long long>(2));
	for (int i = 0; i < N; i++) cin >> A[i][0];
	for (int i = 0; i < N; i++) cin >> A[i][1];
	vector<long long> V;
	for (int i = 0; i < N; i++) V.push_back(i % 2);
	sort(V.begin(), V.end());
	long long Even = (N + 1) / 2, Odd = N / 2;
	do {
		vector<pair<long long, long long> > E, O;
		for (int i = 0; i < N; i++) {
			if (V[i] == 0) E.push_back({ A[i][i % 2], i });
			else O.push_back({ A[i][(i + 1) % 2], i });
		}
		sort(E.begin(), E.end()), sort(O.begin(), O.end());
		bool check = true;
		vector<pair<long long, long long> > X;
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) X.push_back(E[i / 2]);
			else X.push_back(O[i / 2]);
		}
		for (int i = 0; i < N - 1; i++) {
			if (X[i].first > X[i + 1].first) check = false;
		}
		if (!check) continue;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (X[i].second > X[j].second) COUNT++;
			}
		}
		ANS = min(ANS, COUNT);
	} while (next_permutation(V.begin(), V.end()));
	cout << (ANS == INF ? -1 : ANS) << endl;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
lis = [0]*(n+1)
c = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    c[a].append(b)
    c[b].append(a)
    
que = deque([1])
check = [0 for i in range(n+1)]
check[1] = 1
while que:
    now = que.popleft()
    nx = c[now]
    for i in nx:
        if check[i] == 1:
            continue
        check[i] = 1
        lis[i] = now
        que.append(i)
if 0 in lis[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join(map(str, lis[2:])))


Measured memory_bytes: 42392
#include <iostream>

typedef unsigned long long ullong;

inline ullong SumFrom1( ullong N )
{
    return N * ( N+1 ) /2;
}

 
int main( void )
{
    ullong N;
    std::cin >> N;
    
    std::cout << ( SumFrom1(N) - SumFrom1(N/3)*3 - SumFrom1(N/5)*5 + SumFrom1(N/15)*15 ) << std::endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, j, k, ans = 1, bef = 0, num = 1, mnum = 1;
  char s[10010];
  scanf("%s", s);
  for(i = 0; i < strlen(s); ) {
    if(s[i] == 'e') {
      if(!i) {
        bef = 0;
        i += 3;
        continue;
      }
      if(bef == 1) {
        num++;
        bef = 0;
        if(mnum < num) mnum = num, ans = 0;
      } else {
        bef = 0;
        num = 1;
      }
      i += 3;
    } else {
      if(!i) {
        bef = 1;
        i += 7;
        continue;
      }
      if(bef == 0) {
        num++;
        bef = 1;
        if(mnum < num) mnum = num, ans = 1;
      } else {
        bef = 1;
        num = 1;
      }
      i += 7;
    }
  }
  if(ans == -1) ans = bef;
  if(ans) printf("chicken\n");
  else printf("egg\n");
  return 0;
}


Measured memory_bytes: 2624
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    vector<vector<LL>> g(n, vector<LL>(n));
    vector<vector<LL>> cnt(n, vector<LL>(n, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> g[i][j];
        }
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (g[i][j] > g[i][k] + g[k][j]) {
                    cout << -1 << endl;
                    return 0;
                } else if (g[i][j] == g[i][k] + g[k][j]) cnt[i][j]++;
            }
        }
    }

    LL ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (cnt[i][j] == 2) ans += g[i][j];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1664
//	-*- mode: C++ -*-
//	Insertion Sort
//		Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
//
//		for i = 1 to A.length-1
//		    key = A[i]
//		    /* insert A[i] into the sorted sequence A[0,...,j-1] */
//		    j = i - 1
//		    while j >= 0 and A[j] > key
//		        A[j+1] = A[j]
//		        j--
//		    A[j+1] = key
//		Note that, indices for array elements are based on 0-origin.
//
//		To illustrate the algorithms, your program should trace intermediate result for each step.
//
//	Input
//		The first line of the input includes an integer N, the number of elements in the sequence.
//
//		In the second line, N elements of the sequence are given separated by a single space.
//
//	Output
//		The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.
//
//	Constraints
//		1 ≤ N ≤ 100
//
//	Sample Input 1
//		6
//		5 2 4 6 1 3
//	Sample Output 1
//		5 2 4 6 1 3
//		2 5 4 6 1 3
//		2 4 5 6 1 3
//		2 4 5 6 1 3
//		1 2 4 5 6 3
//		1 2 3 4 5 6
//	Sample Input 2
//		3
//		1 2 3
//	Sample Output 2
//		1 2 3
//		1 2 3
//		1 2 3

#include <iostream>
#include <vector>

void	VPrint(unsigned int					N,
			   std::vector<unsigned int>&	V)
{
	unsigned int	count	{0};
	for(auto a : V){
		count++;
		std::cout << a;
		if(count < N){
			std::cout << ' ';
		}
		else{
			std::cout << '\n';
		}
	}
}

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	N	{0};
	std::cin >> N;

	std::vector<unsigned int>	V	{};
	V.resize(N, 0);

	for(unsigned int i = 0; i < N; i++){
		std::cin >> V[i];
	}

	for(unsigned int i = 1; i < N; i++){
		VPrint(N, V);
		unsigned int	key	= V[i];
		int				j	= i - 1;

		while(j >= 0 && V[j] > key){
			V[j + 1] = V[j];
			j--;
		}

		V[j + 1]	= key;
	}
	
	VPrint(N, V);

    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, k;
    cin >> n >> k;
    ll p[n];
    for (ll i = 0; i < n;i++)cin>>p[i];
    sort(p,p+n);
    ll ans=0;
    for (ll i = 0; i < k; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

ll p(ll n, ll k)
{
	if (k == 0)return 0;
	if (k == 1)return n;
	ll x = p(n, k / 2) % M;
	if (k & 1)return (((n * x) % M) * x) % M;
	else return (x * x) % M;
}
void solve()
{
	ll n;
	cin >> n;
	if (n == 1)cout << 0 << endl;
	else
	{
		cout << (p(10, n) - ((2 * p(9, n)) % M - p(8, n) + M) % M + M) % M << endl;
	}
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<vector<int>> table(70, vector<int>(n));
    for (int i = 0; i < n; i++)cin >> table[0][i], table[0][i]--;

    for (int i = 1; i < 70; i++) {
        for (int j = 0; j < n; j++) {
            table[i][j] = table[i - 1][table[i - 1][j]];
        }
    }

    int ret = 0;
    for (int i = 0; i < 70; i++) {
        if (k & 1) ret = table[i][ret];
        k >>= 1;
    }

    cout << ret + 1 << endl;
    return 0;
}

Measured memory_bytes: 58964
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int oo = 1E9;
const int MAX = 500000;
const int LOG = 19;

map<pii, int> name;
vector<pii> edj;

void Add(pii w){
  int t = sz(name);
  if(!name.count(w)) name[w] = t;
}

int r, c, n;
int _x1[100010], _y1[100010],
    _x2[100010], _y2[100010];

// Max / Min
int how[MAX];
pii arr[MAX][LOG]; // min, max

pii Get(int f, int t){
  int len = t - f + 1;
  int l = how[len];

  auto a = arr[f][l];
  auto b = arr[t - (1 << l) + 1][l];

  return mp(min(a.fi, b.fi),
            max(a.se, b.se));
}

set<int> r0, r1, c0, c1;
void Ver(int x, int y){
  if(x == 0) r0.insert(y);
  if(x == r) r1.insert(y);
  if(y == 0) c0.insert(x);
  if(y == c) c1.insert(x);
}

int main(){
  how[1] = 0;
  for(int i = 0;i < MAX;++i)
    if((1 << (how[i - 1] + 1)) <= i)
      how[i] = how[i - 1] + 1;
    else
      how[i] = how[i - 1];

  for(int i = 0;i < MAX;++i)
    arr[i][0].fi = oo,
    arr[i][0].se = -oo;

  scanf("%d%d%d", &r, &c, &n);
  //r = 1E8, c = 1E8, n = 100000;
  for(int i = 0;i < n;++i){
    scanf("%d%d%d%d", &_x1[i], &_y1[i], &_x2[i], &_y2[i]);
    //_x1[i] = 0, _y1[i] = rand();
    //_x2[i] = rand(), _y2[i] = c;
    Ver(_x1[i], _y1[i]);
    Ver(_x2[i], _y2[i]);
  }

  for(int j : r0)
    Add(mp(0, j));
  for(int i : c1)
    Add(mp(i, c));
  for(int j : vi(r1.rbegin(), r1.rend()))
    Add(mp(r, j));
  for(int i : vi(c0.rbegin(), c0.rend()))
    Add(mp(i, 0));
  //cout << "HERE\n";

  for(int i = 0;i < n;++i){
    int x1 = _x1[i], y1 = _y1[i],
        x2 = _x2[i], y2 = _y2[i];
    //scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if(name.count(mp(x1, y1)) && name.count(mp(x2, y2)))
      edj.pb(mp(name[mp(x1, y1)], name[mp(x2, y2)]));
  }

  for(int i = 0;i < sz(edj);++i)
    if(edj[i].fi > edj[i].se)
      swap(edj[i].fi, edj[i].se);

  for(int i = 0;i < sz(edj);++i){
    int a = edj[i].fi, b = edj[i].se;
    //cout << "?" << a << ' ' << b << endl;
    relaxMin(arr[a][0].fi, b);
    relaxMax(arr[a][0].se, b);
    relaxMin(arr[b][0].fi, a);
    relaxMax(arr[b][0].se, a);
  }

  for(int l = 1;l < LOG;++l){
    int mv = (1 << (l - 1));
    for(int i = 0;i < MAX;++i){
      arr[i][l] = arr[i][l - 1];
      if(i + mv < MAX){
        relaxMin(arr[i][l].fi, arr[i + mv][l - 1].fi);
        relaxMax(arr[i][l].se, arr[i + mv][l - 1].se);
      }
    }
  }

  bool ok = true;

  for(int i = 0;i < sz(edj);++i){
    int a = edj[i].fi;
    int b = edj[i].se;

    //cout << "!" << a << ' ' << b << endl;

    auto p = Get(a, b);
    //cout << p.fi << ' ' << p.se << endl;

    if(p.fi < a || p.se > b){
      ok = false;
      break;
    }
  }

  printf(ok ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 101180
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int f[110];
vector<II> a;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    FOR(i,2,n) {
        int g = i;
        FOR(j,2,100)
            while (g % j == 0) {
                g /= j;
                f[j]++;
            }
    }
    FOR(i,2,100)
        if (f[i]) a.emplace_back(II(i, f[i]));
    // FOR(i,0,SZ(a)-1) cout << a[i].FI << ' ' << a[i].SE << endl;
    // 74
    int res = 0;
    FOR(i,0,SZ(a)-1)
        if (a[i].SE >= 74) res++;
    // cout << res << endl;
    // 4 14
    FOR(i,0,SZ(a)-1)
        FOR(j,0,SZ(a)-1)
            if (a[i].SE >= 4 && a[j].SE >= 14 && i != j) res++;
    // cout << res << endl;
    // 2 24
    FOR(i,0,SZ(a)-1)
        FOR(j,0,SZ(a)-1)
            if (a[i].SE >= 2 && a[j].SE >= 24 && i != j) res++;
    // cout << res << endl;
    // 2 4 4
    FOR(i,0,SZ(a)-1)
        FOR(j,i+1,SZ(a)-1)
            if (a[i].SE >= 4 && a[j].SE >= 4)
                FOR(k,0,SZ(a)-1)
                    if (a[k].SE >= 2 && k != i && k != j) res++;
    cout << res;
    return 0;
}

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

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

    char b;
    cin >> b;

    switch (b) {
        case 'A':
            cout << 'T' << '\n';
            break;
        case 'T':
            cout << 'A' << '\n';
            break;
        case 'G':
            cout << 'C' << '\n';
            break;
        default:
            cout << 'G' << '\n';

    }

    return 0;
}


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

using namespace std;

int N;
vector< int > g[100000];
int dist[2][100000], id;

void dfs(int idx, int par = -1)
{
  if(~par) dist[id][idx] = dist[id][par] + 1;
  for(auto &to : g[idx]) if(to != par) dfs(to, idx);
}

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

  id = 0;
  dfs(0);
  id = 1;
  dfs(N - 1);

  int ret = 0;
  for(int i = 0; i < N; i++) {
    if(dist[0][i] <= dist[1][i]) ++ret;
  }
  if(ret >= (N + 2) / 2) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int64_t modPow(int a,int b,int d){
  bitset<40> bit(b);
  string s = bit.to_string();
  int64_t ret = 1;
  for(int i=0;i<s.length();++i){
    ret*=ret;
    if(s[i]-'0') ret*=a;
    ret%=d;
  }
  return ret;
}

typedef long long ll;

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = calc(a, b / 2, p);
        return (d * d) % p;
    } else {
        return (a * calc(a, b - 1, p)) % p;
    }
}

int main() {
    int64_t a, b, n, ans;
    cin >> n >> a >> b;
    ans = modPow(2, n, 1000000007);
    int64_t Na = 1, Nb = 1;
    for (int i = n - a + 1; i <= n; i++){
        Na *= i;
        Na %= 1000000007;
    }
    for (int i = n - b + 1; i <= n; i++){
        Nb *= i;
        Nb %= 1000000007;
    }
    int64_t c = 1, e = 1;
    for (int64_t i = 0; i < a; i++){
        c = c * calc(i + 1, 1000000005, 1000000007) % 1000000007;
    }

    for (int64_t i = 0; i < b; i++){
        e = e * calc(i + 1, 1000000005, 1000000007) % 1000000007;
    }

    ans -= (Na * c) % 1000000007 + (Nb * e % 1000000007);
    ans--;


    while(ans < 0){
        ans += 1000000007;
    }
    ans %= 1000000007;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char a[100010];
int n;
int vis[100010],ans[100010];
int main(){
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;i++) if(a[i]=='R'&&a[i+1]=='L') vis[i]=-1,vis[i+1]=1;
	for(int i=1,last=0;i<=n;i++){
		if(vis[i]==1) last=i;
		if(a[i]=='L'){
			ans[last-((i-last)&1)]++;
		}
	}
	for(int i=n,last=n+1;i>=1;i--){
		if(vis[i]==-1) last=i;
		if(a[i]=='R'){
			ans[last+((last-i)&1)]++;
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	printf("\n");
} 

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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> l(n);
	for(int i =0;i<n;i++)cin >> l[i];
	sort(l.begin(),l.end(),greater<int>());
	int ans = 0;
	for(int i = 0;i<k;i++)ans+=l[i];
	cout<<ans<<endl;
	return 0;
}




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


int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    for(auto&& a: A){
        int x, y;
        cin >> x >> y;
        a = make_pair(x, y);
    }

    map<pair<int, int>, int> cost;

    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j ){
            if( i !=j ){
                pair<int, int> p = make_pair(A[i].first - A[j].first, A[i].second - A[j].second);
                if(cost.find(p) != cost.end()){
                    cost[p] = cost[p] + 1;
                }else {
                    cost[p] = 1;
                }
            }
        }
    }

    int max_value = 0;
    for (auto itr = cost.begin(); itr != cost.end(); ++itr){
        max_value = max(max_value, itr->second);
    }

    cout << N - max_value << endl;

    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int x,y;
    int cur = 0;
    int flag = 0;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        if(x==y)
        {
            cur++;
            if(cur>=3) flag = 1;
        }
        else
        {
            cur = 0;
        }
    }
    if(flag)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3640
s = input()[::-1]

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    counts[num] += 1
    d *= 10
    d %= 2019

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2
    
print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  string str;
  int n;
  double m;
  long double ans = 0;
  cin >>n;
  FOR(i,n){
    cin >> m >> str;
    if(str=="BTC") ans+= m*380000;
    else ans+=m;
  }
  cout << ans fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

int main(){
    for(int i=1;;i++){
       int x,y;
       cin >> x >> y;
       if(x == 0&&y == 0)break;
       if(x>y){
         swap(x, y);
       }
       cout<< x << " " << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
	std::string S;
	long n = 0;
	long m = 0;

	std::cin >> S;

	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'B') {
			++m;
		} else {
			n += m;
		}
	}
	std::cout << n << "\n";
}

Measured memory_bytes: 640
n=int(input())
s=list(input())
num=list(range(10))
for i in range(10):
    num[i]=str(num[i])
ans=0
for i in range(n-2):
    if len(num)==0:
        break
    if s[i] in num:
        num2=[str(_) for _ in range(10)]
        num.remove(s[i])
        for j in range(i+1,n):
            if len(num2)==0:
                break
            if s[j] in num2:
                num2.remove(s[j])
                ans+=len(set(s[j+1:]))
print(ans)


Measured memory_bytes: 9356
/*
    coded by - PATHAKCODES ~~Revamped
    AIT PUNE , INDIA 
     
    "The Key is not will to win ......everybody has that "
    "It is will to prepare that is important"  
     
*/
     
#include <bits/stdc++.h>
 
using namespace std ;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
const ll n  = 1e6 +5;


int main ()
{
	IOS
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int d,t,s ;
    cin >> d >> t >> s ;

    if(((double)d/s) <= t)
        cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t,u;
  cin >> s >> t >> u;
  char turn = 'a';
  while (1) {
    switch (turn) {
      case 'a':
        if (s.empty()) {
          cout << "A" << endl;
          return 0;
        }
        turn = s.at(0);
        s.erase(0,1);
        break;
      case 'b':
        if (t.empty()) {
          cout << "B" << endl;
          return 0;
        }
        turn = t.at(0);
        t.erase(0,1);
        break;
      case 'c':
        if (u.empty()) {
          cout << "C" << endl;
          return 0;
        }
        turn = u.at(0);
        u.erase(0,1);
        break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll n,m;
	cin>>n>>m;
	unordered_map<int,bool> ans;
	vector<int> h(n);
	for(ll i=0;i<n;i++)
		cin>>h[i];
	for(ll i=0;i<m;i++) {
		ll a,b;
		cin>>a>>b;
		if(h[a-1]<h[b-1])
			ans[a] = true;
		else if(h[a-1]>h[b-1])
			ans[b] = true;
		else
		{
			ans[a] = true;
			ans[b] = true;
		}
	}
	cout<<n-ans.size()<<endl;
	return 0;
}

Measured memory_bytes: 6036
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int n;
	cin >> n;
	vi p(n);
	vi q(n);
	rep(i, n) cin >> p[i];

	q = p;
	sort(ASC(q));

	int cnt = 0;
	rep(i, n)
	{
		if (p[i] != q[i]) cnt++;
	}

	if (cnt >= 3)
	{
		ANS("NO");
	}
	else
	{
		ANS("YES");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int kaibun(string x){
  int ans=1;
  string x2;
  x2 = x;
  int l=x.size();
  reverse(x.begin(),x.end());
  for (int i=0;i<l;i++){
    if (x.at(i)!=x2.at(i)){
      ans=0;
      break;}
  }
  return ans;
}
  
int main(){
  string ans="Yes";
  string S;
  cin>>S;
  string S2((S.size())/2 , ' ');
  if (kaibun(S)==0){
    cout<<"No";
    return 0;} 
  for (int j=0;j<(S.size())/2;j++){
    S2.at(j)=S.at(j);
  }
  if (kaibun(S2)==0){
    ans="No";
  }
  cout<<ans;
}

Measured memory_bytes: 256
// http://koturn.hatenablog.com/entry/2016/02/04/050000#cpp
#include <cstdlib>
#include <iostream>
#include <memory>

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

  int N;
  cin >> N;

  int *H = nullptr;
  H = new int[N];
  for (int index = 0; index < N; index++)
  {
    cin >> H[index];
  }

  int count = 0;
  int highest = 0;
  for (int index = 0; index < N; index++)
  {
    if (H[index] < highest)
    {
      // pass
    }
    else
    {
      highest = H[index];
      count++;
    }
  }
  cout << count << endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5,INF = 0xfeeddeadbeef,inf = INF >> 1;
int n,a[N];
map<int,int> dp[N];
int DP(int i,int k) {
	if(k > (i+1>>1)) return -inf;
	if(i <= 0) return 0;
	if(dp[i][k]) return dp[i][k];
	return dp[i][k] = max(DP(i-2,k-1) + a[i],DP(i-1,k));
}
signed main() {
	cin >> n;
	for(int i = 1;i <= n;++i)	
		cin >> a[i];
	cout << DP(n,n>>1) << endl;
	return 0;
}


Measured memory_bytes: 44256
import Control.Applicative
import Control.Monad

solve :: Int -> Int -> Int -> [[Int]] -> [[Int]] -> [[Int]]
solve n m l matrix1 matrix2 = map (\r -> map (\c -> element r c) [0 .. l - 1]) [0 .. n - 1]
    where
        element r c = foldl (\a (x, y) -> a + x * y) 0 $ zip (row r) (column c)
        row r       = matrix1 !! r
        column c    = map (\r -> matrix2 !! r !! c) [0 .. m - 1]

main :: IO ()
main = do
    [n, m, l] <- map read . words <$> getLine
    matrix1   <- map (map read . words) <$> replicateM n getLine
    matrix2   <- map (map read . words) <$> replicateM m getLine
    putStr $ unlines $ map (unwords . map show) $ solve n m l matrix1 matrix2

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

#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(n) fori(somethingStupid,1,(n))

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

bool tests = false;
void solve(){
    ll n; cin >> n;
    vll a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    ll maxi = a[0]; ll ct = 0;
    for (int i=1; i<n; i++){
        ct += max(0ll, maxi - a[i]);
        maxi = max(maxi, a[i]);
    }cout << ct << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    rep(t) solve();
    return 0;
}


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

#define ll long long

int x,y;

const int MOD=1e9+7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t 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) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;


template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};


void solve(){
    cin>>x>>y;
    if((x+y)%3!=0 || (x*2<y || y*2<x)){
        cout<<0<<endl;
        return;
    }
    int n=(x+y)/3;
    int r=x-n;
    Combination<modint> Co(2000001);
    //cout<<n<<" "<<r<<endl;
    cout<<Co.C(n, r)<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 25728
import math
D, G = [int(x) for x in input().split()]
PC = [[int(x) for x in input().split()] for _ in range(D)]
ans = 100100
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if (i >> j) & 1:
            cnt += PC[j][0]
            point += 100 * (j+1) * PC[j][0] + PC[j][1]
    if (point < G):
        rest = G-point
        for j in range(D)[::-1]:
            if (i >> j) & 1 == 0:
                if (rest < 100*(j+1)*PC[j][0]):
                    # 200点問題3問で500点
                    cnt += math.ceil(rest / (100*(j+1)))
                    break 
                else:
                    cnt = 100100
                    break
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 41328
#include<stdio.h>
#include <cmath>
#include <set>
int main()
{
	int rows, cols;
	int n, m, k;
	int grid[100][100];
	
	while (scanf("%d%d%d", &rows, &cols, &n) != EOF)
	{
		memset(grid, 0, sizeof(grid));k = -1;
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &m);
			while (m--)
			{
				++k;
				grid[(k / rows) & 1 ? (rows - 1 - (k%rows)):k%rows][k / rows] = i;
			}
		}
		for (int i = 0; i<rows;++i)
			for (int j = 0; j<cols;++j)
				printf("%d%c",grid[i][j],j==cols-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 888
import math
a,b,h,m=map(int,input().split())
ah=30*h+m/2
am=6*m
the=max(ah,am)-min(ah,am)
if the>180:
    the=360-the
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(the))))

Measured memory_bytes: 9476
#include<stdio.h>

int main(void)

{

 int a,b;

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

 if(a==b){

    printf("a == b\n");

 }

   else{

    if(a<b){

       printf("a < b\n");

    }

    else{

       printf("a > b\n");

     }

    }

 return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

vector<int> divisor(int m)
{
    vector<int> d;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            d.push_back(i);
            if (i * i != m)d.push_back(m / i);
        }
    }
    return d;
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n, m;
        cin >> n >> m;
        vector<int> d(divisor(m));
        sort(d.begin(), d.end());

        int g = m / n;
        int cnt(0);
        while (cnt < (int)d.size() && d[cnt] <= g)
        {
            cnt++;
            //dbg2(cnt, d[cnt]);
        }
        cout << d[cnt - 1] << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
import heapq as hq

N = int(input())
c = []
for i in range(N):
  x, y = map(int, input().split())
  c.append((i, x, y))

cx = sorted(c, key=lambda x: x[1])
cy = sorted(c, key=lambda x: x[2])

edge = [set() for i in range(N)] # edge[from][to] = weight

for i in range(1, N):
  edge[cx[i-1][0]].add((cx[i][1]-cx[i-1][1], cx[i][0]))
  edge[cx[i][0]].add((cx[i][1]-cx[i-1][1], cx[i-1][0]))

  edge[cy[i-1][0]].add((cy[i][2]-cy[i-1][2], cy[i][0]))
  edge[cy[i][0]].add((cy[i][2]-cy[i-1][2], cy[i-1][0]))
  
for i in range(N-1):
  edge[cx[i][0]].add((cx[i+1][1]-cx[i][1], cx[i+1][0]))
  edge[cx[i+1][0]].add((cx[i+1][1]-cx[i][1], cx[i][0]))

  edge[cy[i][0]].add((cy[i+1][2]-cy[i][2], cy[i+1][0]))
  edge[cy[i+1][0]].add((cy[i+1][2]-cy[i][2], cy[i][0]))
  

q = [(0, 0)]
used = [False] * N
un = 0
r = 0

while q and un < N:
  w, prev = hq.heappop(q)

  if used[prev]: continue
  
  used[prev] = True
  un += 1
  r += w
  
  for w, to in edge[prev]:
    if not used[to]:
      hq.heappush(q, (w, to))
print(r)

Measured memory_bytes: 125912
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a;
	while (cin >> a) {
		int p[10] = {0};
		int count = a;
		int han;
		while (count != 0) {
			//hantei = 0;
			for (int i = 9; i >= 0; i--) {
				if (count >= (int)pow(2,i)) {
					count -= (int)pow(2,i);
					p[i] = 1;
					//hantei = 1;
					break;
				}
			}
		}
		for (int i = 0; i < 10; i++) {
			if (p[i] == 1) {
				cout << (int)pow(2,i);
				han = i+1;
				break;
			}
		}

		for (int i = han; i < 10; i++) {
			if (p[i] == 1) {
				cout << " " << (int)pow(2,i);
			}
		}

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int>> graph(h + 5, vector<int>(w + 5, 0));
    vector<vector<int>> dp(h + 5, vector<int>(w + 5, INF));
    dp[0][0] = 0;
    rep(i, h)rep(j, w){
        char s; cin >> s;
        if (s == '#') graph[i][j + 1] = 1;
    }
    rep(i, h)rep(j, w + 2){
        if (i != 0 and j == 0) continue;
        if (j == w + 1) continue;
        int dif_r = abs(graph[i][j + 1] - graph[i][j]);
        int dif_d = abs(graph[i + 1][j] - graph[i][j]);
        dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + dif_r);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + dif_d);
    }
    cout << dp[h - 1][w + 1] / 2 << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    Lint t1,t2; cin>>t1>>t2;
    Lint a1,a2,b1,b2; cin>>a1>>a2>>b1>>b2;

    if(a1*t1+a2*t2==b1*t1+b2*t2){
        cout<<"infinity"<<endl;
        return 0;
    }

    if(a1*t1+a2*t2<b1*t1+b2*t2){
        swap(a1,b1);
        swap(a2,b2);
    }

    a1*=t1; a2*=t2;
    b1*=t1; b2*=t2;

    if(a1>b1){
        cout<<0<<endl;
        return 0;
    }
    if(a1==b1){
        cout<<1<<endl;
        return 0;
    }
    Lint v1=a1-b1;
    Lint v2=a2-b2;
    Lint ans=(-v1)/(v1+v2)*2+((-v1)%(v1+v2)!=0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import collections
sys.setrecursionlimit(10 ** 7)


def main():
    N, K = map(int, input().split())
    c = collections.Counter(input().split())
    c = sorted(c.values())
    k = len(c) - K
    if k <= 0:
        print(0)
    else:
        print(sum(c[:k]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 35996