akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
int s[3006][3006];
int main(){
	register int n, i, k, k2, x, y, ans;
	register char c;
	scanf("%d %d", &n, &k);
	k2 = k << 1;
	for (i = 1; i <= n; ++i) {
		scanf("%d %d %c", &x, &y, &c);
		if (c == 'B') x += k;
		x %= k2, y %= k2;
		if (x >= k && y >= k) x -= k, y -= k;
		else if (x < k && y >= k) x += k, y -= k;
		++s[x][y], ++s[x + k][y + k], ++s[x][y + k2];
		if (x >= k && y < k) ++s[x - k][y + k];
		//printf("%d %d\n", x, y) ;
	}
	for (x = k * 3 - 1; x >= 0; --x) {
		for (y = k * 3 - 1; y >= 0; --y) {
			s[x][y] += s[x][y + 1];
			//printf("%d %d %d\n", x, y, s[x][y]);
		}
	}
	for (x = k * 3 - 1; x >= 0; --x) {
		for (y = k * 3 - 1; y >= 0; --y) {
			s[x][y] += s[x + 1][y];
			//printf("%d %d %d\n", x, y, s[x][y]);
		}
	}
	ans = 0;
	for (x = 0; x < k2; ++x) {
		for (y = 0; y < k2; ++y) {
			cmax(ans, s[x][y] + s[x + k][y + k] - s[x + k][y] - s[x][y + k]);
			//printf("%d %d %d %d %d %d\n", x, y, s[x][y], s[x + k][y + k], s[x + k][y], s[x][y + k]);
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 35328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;
int R, N, M;
int main(){
	cin >> R >> N >> M;
	if (R + N >= M) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int ans = 0;

  for(int i = 0; i <= A; i++) {
    for(int j = 0; j <= B; j++) {
      for(int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

bool checker[2000000];

string str_rev(string str){
	string s, dum;
	s = "";
	for(int i = 0; i < str.size(); i++){
		dum = "D";
		dum[0] = str[i];
		s = dum + s;
	}
	return s;
}

string str_make(string str1, string str2, int i, int j, int k){
	if(i == 1){
		str1 = str_rev(str1);
	}
	if(j == 1){
		str2 = str_rev(str2);
	}
	if(k == 0){
		return str1 + str2;
	}
	return str2 + str1;
}

int main(){
	int n;
	cin >> n;
	for(int loop = 1; loop <= n; loop++){
		string str, str1, str2, str_add;
		string str_list[1000];
		int index = 0;
		cin >> str;
		for(int num = 1; num < str.size(); num++){
			str1 = str.substr(0, num);
			str2 = str.substr(num);
			for(int i = 0; i <= 1; i++){
				for(int j = 0; j <= 1; j++){
					for(int k = 0; k <= 1; k++){
						str_add = str_make(str1, str2, i, j, k);
						bool checker = true;
						for(int ID = 0; ID < index; ID++){
							if(str_add == str_list[ID]){
								checker = false;
								break;
							}
						}
						if(checker){
							str_list[index] = str_add;
							index++;
						}
					}
				}
			}
		}
		printf("%d\n", index);
	}
	return 0;
}

Measured memory_bytes: 1288
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                             //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

int gcd(int a, int b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    cin>>n>>m;
    k=n*(n-1);
    k/=2;
    k+=(m*(m-1))/2;

    cout<<k<<el;


  }


  return 0;
}


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

using namespace std;

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n);
    for(auto &x: a) cin >> x;
    for(int i=0; i<n; i++) a[i] -= i+1;
    sort(a.begin(), a.end());
    long b = a[n/2];

    long r = 0;
    for(auto &x: a)
        r += abs(x - b);
    cout << r << endl;
}


Measured memory_bytes: 1792
def nyu():
    N, M = map(int, input().split())
    X = list(map(int,input().split()))
    X.sort()
    return N,M,X


def kansu(N,M,X):

    x_abs = [X[m+1] -X[m] for m in range(M-1)]    
#    print(x_abs)

    
    x_abs.sort()

    koma_max = 0
    for m in range(M-N):
        koma_max += x_abs[m]

    print(koma_max)


N,M,X = nyu()
#print(X)

if M == 1:
    print(0)
else:
    kansu(N,M,X)

#print(S)



Measured memory_bytes: 13968
N,M = map( int, input().split() )
break_list = []
for i in range(M):
    break_list.append( int( input() ) )

break_list.append(-10)
t = 0
fib = [0] * (N + 1)
if break_list[0] == 1:
    fib[1] = 0
    t += 1
else:
    fib[1] = 1
    
fib[0] = 1

for i in range(N - 1):
    if ( i + 2 ) ==  break_list[t]:
        fib[i + 2] = 0
        t += 1
    else:
        fib[i + 2] = fib[i] + fib[i + 1]
 
if N == 1:
    print( fib[1] )
else:
    print( fib[i+2] %  1000000007 )

Measured memory_bytes: 460020
#include <cstdio>
#include <cstdlib>
using namespace std;

int ExGCD(int a, int b, int &x, int &y){
    int d=a;
    x=1; y=0;
    if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
    return d;
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int a,b;
        scanf("%d%d", &a, &b);
        int x,y,d;
        d = ExGCD(a, b, x, y);
        if(d <= 50000){
            printf("3\n0 0\n%d %d\n%d %d\n", a, b, abs(y), abs(x));
        }else{
            printf("4\n0 0\n%d %d\n%d %d\n%d %d\n", a-1, b, a/d, b/d, a, b-1);
        }
    }
    return 0;
}



Measured memory_bytes: 2740
/*
 * Name        : d
 * Creat       : Fri Jul 12 10:29:59 CST 2019
 * Accept      : Fri Jul 12 10:36:16 CST 2019
 * Author      : landcold7
 * Motivation  : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll x = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i % 2 == 0) {
      x += a[i];
    }
    else {
      x -= a[i];
    }
  }
  trace(x);
  vector<ll> ans(n);
  ans[0] = x;
  for (int i = 1; i < n; ++i) {
    ans[i] = 2 * a[i - 1] - ans[i - 1];
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << (i == n - 1 ? "\n" : " ");
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 2944
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
pairs = [list(map(int, input().split())) for i in range(q)]
ans = 0

for combo in combinations_with_replacement(range(1, m+1), n):
    tmp = 0
    for pair in pairs:
        if combo[pair[1]-1] - combo[pair[0]-1] == pair[2]:
            tmp += pair[3]
    ans = max(tmp, ans)

print(ans)


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

/*
2つの整数K,Sが与えられます。
3つの変数X,Y,Zがあり、0≦X,Y,Z≦Kを満たす整数の値を取ります。
X+Y+Z=Sを満たすX,Y,Zへの値の割り当ては何通りありますか。
*/

int main() {
  int K, S, count = 0;
  cin >> K >> S;

  for (int x = 0; x <= K; x++) {
    // if(x > S) { break; }
    for (int y = 0; y <= K; y++) {
      if ((x + y) <= S && (x + y + K) >= S ) {
        count++;
      }
    }
  }

  cout << count << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S; cin >> S;
  while (S.size() >= 2 && S[0] == 'h' && S[1] == 'i') {
    S = S.substr(2);
  }
  if (S.size() == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)
	var answer int
	for a := x; ; a++ {
		if isPrime(a) {
			answer = a
			break
		}
	}
	fmt.Println(answer)
}

func isPrime(x int) bool {
	var upperBound int
	upperBound = int(math.Sqrt(float64(x)) + 1)
	for divider := 2; divider < upperBound; divider++ {
		if x%divider == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 512
#include <iostream>
using namespace std; 
int main(){
    int a,b,c;
    int k,count;
    cin >> a >> b >> c;
    k = a;
    count = 0;
    while(k <= b){
        if(c%k == 0){
            count++;
        }
        k++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <iomanip>
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ld s;
	cin>>s;
	
	ld length = s / 3.0; 

	s -= length; 

	ld breadth = s / 2.0; 

	ld height = s - breadth;
	
	cout<< fixed << setprecision(12) << length*breadth*height<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
//#define v vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：コッホ曲線
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_5_C
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n;

void printVert(ld x, ld y) { cout << x << " " << y << endl; }

void koch(ld x0, ld x1, ld y0, ld y1, ll n) {
  if (n == 0) {
    printVert(x0, y0);
  } else {
    // 中間点の座標を計算
    ld c1x = (2 * x0 + x1) / 3.0;
    ld c1y = (2 * y0 + y1) / 3.0;
    ld c2x = (x0 + 2 * x1) / 3.0;
    ld c2y = (y0 + 2 * y1) / 3.0;
    ld c3x = (x0 + x1) / 2.0 + sqrt(3) * (y0 - y1) / 6.0;
    ld c3y = (y0 + y1) / 2.0 + sqrt(3) * (x1 - x0) / 6.0;

    koch(x0, c1x, y0, c1y, n - 1);
    koch(c1x, c3x, c1y, c3y, n - 1);
    koch(c3x, c2x, c3y, c2y, n - 1);
    koch(c2x, x1, c2y, y1, n - 1);
  }
}

void solve() {
  koch(0, 100, 0, 0, n);
  printVert(100, 0);
}

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  solve();

  return 0;
}



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

typedef long long ll;

int main(){
  ll x, y, z, k;
  cin >> x >> y >> z >> k;

  vector<ll> v, vx(x), vy(y), vz(z);
  
  for(ll i=0; i<x; i++)
    cin >> vx[i];
  
  for(ll i=0; i<y; i++)
    cin >> vy[i];
  
  for(ll i=0; i<z; i++)
    cin >> vz[i];
  
  sort(vx.begin(), vx.end(), greater<ll>());
  sort(vy.begin(), vy.end(), greater<ll>());
  sort(vz.begin(), vz.end(), greater<ll>());

    for(ll i = 0; i<x; i++){
        for(ll j = 0; j < y; j++){
            if ((i+1) * (j+1) > k) break;
            for( ll m = 0; m < z; m++){
                if( (i+1) * (j+1) * (m+1) > k) break;
                v.push_back(vx[i] + vy[j] + vz[m]);
            }
        }
    }

    sort(v.begin(), v.end(), greater<ll>());

    for(ll i=0; i<k; i++)
        cout << v[i] << endl;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	/**
	 * 三角形の面積、周の長さ、高さを求める
	 * @param args0
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double angle = scan.nextDouble();
		
//		double a = Double.parseDouble(args[0]);
//		double b = Double.parseDouble(args[1]);
//		double angle = Double.parseDouble(args[2]);

		double S =0, L =0,h = 0;

		S = (a * b * Math.sin( angle * (Math.PI / 180) ) ) /2;
//		System.out.println(Math.sin(angle));
		L = a + b + Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2 * a * b * Math.cos(angle * (Math.PI/180)));
		h = S * 2 / a;

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);





	}

}



Measured memory_bytes: 28084
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[3010][3010];

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int x=a+1;x<=c;x++){
        dp[x][b]=dp[x-1][b]*b;
        dp[x][b]%=MOD;
    }
    for(int y=b+1;y<=d;y++){
        dp[a][y]=dp[a][y-1]*a;
        dp[a][y]%=MOD;
    }
    for(int x=a+1;x<=c;x++){
        for(int y=b+1;y<=d;y++){
            dp[x][y]=dp[x-1][y]*y;
            dp[x][y]%=MOD;
            dp[x][y]+=dp[x][y-1]*x;
            dp[x][y]%=MOD;
            dp[x][y]-=dp[x-1][y-1]*(x-1)*(y-1);
            dp[x][y]%=MOD;
            if(dp[x][y]<0) dp[x][y]+=MOD;
        }
    }
    cout<<dp[c][d]<<endl;
}

Measured memory_bytes: 73960
/*
 * B.cpp
 *
 *  Created on: 2020/06/07
 *      Author: admin
 */


#include <iostream>
#include <math.h>

using namespace std;


int main(){
	int N;
	long long A[100010];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	};

	int zero = 0;
	for (int i=0; i<N; i++){
		if(A[i] == 0) zero++;
	}
	if(zero>0){
		cout << 0;
		return 0;
	}

	long long prod= 1;
	for(int i=0; i<N; i++){
		if (A[i] <= 1000000000000000000/prod){
			prod *= A[i];
		}else{
			cout << "-1";
			return 0;
		}
	}
	cout << prod;
	return 0;
}


Measured memory_bytes: 4416
from sys import *

input = stdin.readline
maxn = 10 ** 5 + 5

Sum = [0] * maxn
Cnt = [0] * maxn

n = int(input())
arr = list(map(int, input().split()))
ans = 0
for x in arr:
	ans += x
	Sum[x] += x
	Cnt[x] += 1 
q = int(input())
for i in range(q):
	x, y = map(int, input().split())
	ans -= Sum[x]
	ans += y * Cnt[x]
	Sum[y] += y * Cnt[x]
	Cnt[y] += Cnt[x]
	Sum[x] = 0
	Cnt[x] = 0
	print(ans)


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

using namespace std;

int main()
{
  int N, A, B, C, D[101];
  cin >> N;
  cin >> A >> B >> C;
  for(int i = 0; i < N; i++) cin >> D[i];
  sort(D, D + N, greater<int>());
  for(int i = 1; i < N; i++) D[i] += D[i-1];
  int maxical = C / A;
  for(int i = 0; i < N; i++) maxical = max(maxical, (C + D[i])/(A + (i+1)*B));
  cout << maxical << endl;
  return 0;
}

Measured memory_bytes: 1176
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

left, right = 0, max(A)
while right - left > 1:
    mid = (left + right) // 2
    res = 0
    for i in range(N):
        res = res + math.ceil(A[i]/mid) - 1
    if res <= K:
        right = mid
    else:
        left = mid
print(right)

Measured memory_bytes: 31072
import sys
# import pdb
input = sys.stdin.readline

N, K = map(int, input().split())
hs = list(map(int, input().split()))

inf = 1e10

dp_list = [inf for _ in range(N)]
dp_list[0] = 0

# import heapq

sys.setrecursionlimit(1000000)
def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  costs = []
  # heapq.heapify(costs)
  if K <= p:
    for i in range(1,K+1):
        # heapq.heappush(costs, dp_memo(p-i) + abs(hs[p] - hs[p-i]))
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  else:
    for i in range(1,p+1):
        # heapq.heappush(costs, dp_memo(p-i) + abs(hs[p] - hs[p-i]))
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  result = min(costs)
  # result = heapq.heappop(costs)
  dp_list[p] = result
  return result


def dp_recur(N):
  for i in range(1, N):
    for j in range(1,K+1):
      if i-j < 0:
        break
      dp_list[i] = min(dp_list[i], dp_list[i-j] + abs(hs[i] - hs[i-j]))
  return dp_list[N-1]

print(dp_recur(N))
# print(dp_memo(N-1))


Measured memory_bytes: 58896
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf = 1e9+9;
const int mod = 1e9+7;
#define maxn 2010
const int MX = 4e6;
ll fac[4000100], invfac[4000100];

ll potmod(ll a, ll b)
{
	ll res = 1;
	while (b > 0)
	{
		if (b & 1) res = (res * a ) % mod;
		a = (a * a)%mod;
		b /= 2;
	}
	return res;
}

inline ll binom(int n, int k)
{
	return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
}

int dp[2010][2010];

int main()
{
	fac[0] = invfac[0] = 1;
	FOR(i, 1, MX) 
	{
		fac[i] = fac[i-1] * i % mod;
	}
	invfac[MX] = potmod(fac[MX], mod - 2);
	for (int i=MX-1; i>0; --i) invfac[i] = (invfac[i + 1] * (i + 1))%mod;
	int n , k;
	cin >> n >> k;
	if (n == 1) OUT(1);
	if (k == 1) OUT(1);
	
	dp[0][0] = 1;
	for (int j=1; j<=n; ++j)
	{
		dp[0][j] = binom(j * (k - 1) - 1, k - 2) * dp[0][j-1] % mod;
	}
	
	for (int i=1; i<=n; ++i)
	{
		for (int j=i; j<=n; ++j)
		{
			if (i == j) dp[i][j] = dp[i-1][j];
			else
			{
				dp[i][j] = dp[i-1][j];
				ll res = binom(i + j * (k - 1) - 1, k - 2);
				res %= mod;
				res *= dp[i][j-1]; res %= mod;
				dp[i][j] += res;
				while (dp[i][j] >= mod) dp[i][j] -= mod;
			}
			//if (dp[i][j] > 0) cout << "i, j: " << i << ' ' << j << " res : " << dp[i][j] << endl;
		}
	}
		
	cout << (ll)dp[n][n] * fac[n] % mod;
}


Measured memory_bytes: 78592
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n,m,k,q,p;
  
    while(cin>>n>>p){
        map<int,int>m;
        for(int i=0;i<n;i++){
            cin>>k;
            for(int j=0;j<k;j++){
                cin>>q;
                if(m.find(q)==m.end()){
                    m.insert({q,1});
                }else{
                    m[q]++;
                }
            }
        }
        int ans=0;
        for(auto i : m){
            if(i.second==n)
                ans++;
        }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "zabcdefghijklmnopqrstuvwxyz";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}
int main(){
	int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll to =0;
    rep(i,n)to =to^a[i];
    rep(i,n-1){
        ll ans = to^a[i];
        cout<<ans<<' ';
    }
    ll ans =to^a[n-1];
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int a,b,ap,bp;
    cin>>a>>b;
    for(int i=1;i<10000;i++)
    {
        if((i*8)/100==a && (i*10)/100==b)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> s(M), c(M), rec(N+1, -1);
    
    if(N == 1 && M == 0){
        cout << 0 << endl;
        return 0;
    }
    
    rep(i, 0, M){
        cin >> s[i] >> c[i];
        if(s[i] == 1 && c[i] == 0 && N != 1){
            cout << -1 << endl;
            return 0;
        }
        if(rec[s[i]] != -1 && rec[s[i]] != c[i]){
            cout << -1 << endl;
            return 0;
        }
        rec[s[i]] = c[i];
    }
    
    if(rec[1] != -1) cout << rec[1];
    else cout << 1;
    rep(i, 2, N+1){
        if(rec[i] != -1) cout << rec[i];
        else cout << 0;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(void){
  int i,n,tm,c[N]={0},t[N]={0},min=1000,ct=0;
  scanf("%d %d",&n,&tm);
  for(i=0;i<n;i++){
    scanf("%d %d",&c[i],&t[i]);
  }
  for(i=0;i<n;i++){
    if(t[i]<=tm){
      if(c[i]<min){
        min=c[i];
      }
    }else{
      ct++;
    }
  }
  if(ct!=n){
    printf("%d\n",min);
  }else{
    printf("TLE\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

#define N 600000
#define NIL -1

//array
int key[N];
int parent[N];
int leftc[N];
int rightc[N];

//root
int root=NIL;

//function insert
void insert(int z){
  int x,y;
  
  y=NIL;
  x=root;

  while(x!=NIL){
    y=x;
    if(key[z]<key[x]) x=leftc[x];
    else x=rightc[x];
  }  
  
  parent[z]=y;

  if(y==NIL) root=z;
    
  else if(key[z]<key[y]) leftc[y]=z;
 
  else rightc[y]=z;
  
  
}

//print
void inorderprint(int now){
  if(now!=NIL){
    inorderprint(leftc[now]);
    printf(" %d",key[now]);
    inorderprint(rightc[now]);
  }
}

void preorderprint(int now){
  if(now!=NIL){
    printf(" %d",key[now]);
    preorderprint(leftc[now]);
    preorderprint(rightc[now]);
  }
}



int main(){

  int n,i,j,data;
  int z=0;
  char str[10];
  //initialize array
  for(i=0;i<N;i++){
    parent[i]=NIL;
    key[i]=NIL;
    rightc[i]=NIL;
    leftc[i]=NIL;
  }
  //load numbaer
  scanf("%d",&n);

  //load command
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      key[z]=data;
      insert(z);
      z++;
    }
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }

  return 0;
}

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

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


Measured memory_bytes: 3084
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        int[] h = ReadLine().Split(' ').Select(int.Parse).ToArray();
        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            if(h[i] >= K)
            {
                ans++;
            }
        }
        WriteLine(ans);
    }
}

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

using namespace std;

int main(void)
{
	int n = 0, k = 0, num = 0, cnt =0, sum=0,a = 0;
	int bnum;
	vector<int> vec;
	vector<int> mem;
	mem.push_back(0);
	cin >> n; //個数
	cin >> k; //種類

	for (int i = 0; i < n; i++)
	{
		cin >> num;
		vec.push_back(num);
	}

	sort(vec.begin(), vec.end());
	bnum = vec[0];
	for (int i = 0; i < n; i++)
	{
		if (vec[i] != bnum)
		{
			bnum = vec[i];
			cnt++;
			mem.push_back(1);
		}
		else
		{
			mem[cnt] ++;
		}
	}

	//どの数値が何個あるか迄完成
	sort(mem.begin(), mem.end());
	while (a <(int)mem.size() - k)
	{
		sum += mem[a];
		a++;
	}

	cout << sum  <<endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

map<Pii, int> dp;

int f(int s, int x) {
    if (dp.count(Pii(s, x))) {
        return dp[Pii(s, x)];
    }
    int ret = 0;
    (ret += f(s / 2, x / 2)) %= mod;
    if (s >= 1 && x >= 1) (ret += f((s - 1) / 2, (x - 1) / 2)) %= mod;
    if (s >= 2) (ret += f((s - 2) / 2, x)) %= mod;
    return dp[Pii(s, x)] = ret;
}

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

    int n;
    cin >> n;
    dp[Pii(0, 0)] = 1;
    cout << f(n, n) << endl;
}


Measured memory_bytes: 896
#include <iostream>
#define s true
using namespace std;
int abs(int i,int j){
	int f=i-j;
	if(f<0){
		i*=-1;
	}
	return f;
}

int main(){
	int a,b;
	cin>>a>>b;
	int c=a*2;
	a*=4;
	if(b%2==0&&a>=b&&c<=b){
		cout<<"Yes";
	}
	else cout<<"No";
return 0;
}

Measured memory_bytes: 3132
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> pre(n), ino(n);
    for(int& x : pre) cin >> x, --x;
    for(int& x : ino) cin >> x, --x;
    vector<int> find(n, 0);
    for(int i : in(n)) find[ino[i]] = i;
    vector<int> ans;
    function<void(int, int, int, int)>
      dfs = [&](int pl, int pr, int il, int ir) { // [pl, pr)
          if(pl >= pr) return;
          int root = pre[pl];
          int mid = find[root];
          int bound = pl + 1 + mid - il;
          dfs(pl + 1, bound, il, mid);
          dfs(bound, pr, mid + 1, ir);
          ans.emplace_back(root);
    };
    dfs(0, n, 0, n);
    for(int i : in(n))
      cout << ans[i] + 1 << (i == n - 1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 3172
# https://atcoder.jp/contests/abc106/tasks/abc106_d
# どうやったら高速に区間[p,q]に完全に入っている区間の数を取得できるか？
# p,qを二次元座標として捉えると電車1本の線は二次元平面上の1点として表せる
# このときp,qの区間に完全に入っている電車の本数というのは、x軸、y軸の両方において[p,q]となる四角形内にある電車の本数
# queryに高速に答えるために二次元累積和を構築する
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


import numpy as np

N, M, Q = read_ints()
LR = read_tuple(M)
pq = read_tuple(Q)

# numpy使わずに再実装 #入れるときはpythonのほうが速いので
LR2d = [[0] * (N + 1) for _ in range(N + 1)]
for L, R in LR:
    LR2d[L][R] += 1
LR2d = np.array(LR2d, np.int64)

LR2d_accum = np.zeros((N + 2, N + 2), np.int64)
LR2d_accum[1:, 1:] = LR2d.cumsum(axis=0).cumsum(axis=1)  # 1次元累積和同様半開区間で考える
# つまりインデックスi,jとはもとの配列においてi,jを含まない四角形の領域の合計を出す

# queryに答えていく
for p, q in pq:
    print(LR2d_accum[q + 1, q + 1] - LR2d_accum[q + 1, p] -
          LR2d_accum[p, q + 1] + LR2d_accum[p, p])


Measured memory_bytes: 48896
#include <stdio.h>

int search(int A[],int n, int key)
{
  int i = 0;
  A[n] = key;
  while( A[i] !=key )i++;
  return i != n;
}
int main()
{
  int i,n,A[10000+1],q,key,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++)
  {
    scanf("%d", &key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}



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

using namespace std;
typedef unsigned int ui;

int main(){
  int n;
  while(cin >> n && n){
    ui sum=0, pi;
    vector<ui> jo(n-1);
    for(int i=0; i<n; ++i) cin >> pi, sum+=pi;
    for(int i=0; i<n-1; ++i) cin >> jo[i];
    sort(jo.begin(), jo.end());
    ui ans=sum*(ui)n;
    for(int i=jo.size(); i>0; --i){
      sum+=jo[i-1];
      ans=max(ans, sum*(ui)i);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1464
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long doublea
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b;char c;
    cin>>a>>c>>b;
    if(c=='-')cout<<a-b<<endl;
    else cout<<a+b<<endl;
}

Measured memory_bytes: 256
//  [amitdu6ey]
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#include <bits/stdc++.h>
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

void solve(){
    ll n;
    cin>>n;
    vll a(n);
    loop(i,0,n) cin>>a[i];
    vll dp(n);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    loop(i,2,n){
        dp[i]=min( abs(a[i]-a[i-1])+dp[i-1], abs(a[i]-a[i-2])+dp[i-2] );
    }
    cout<<dp[n-1]<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
      solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define fi first
#define se second
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

ii3(k, a, b);
yn(a <= b/k*k, "OK", "NG");

return 0;
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

int main(int argc, char* argv[])
{
  ll n,t;
  std::cin >> n >> t;

  std::vector< ll > vt(n, 0);
  std::vector< ll >::iterator it;

  for (ll i = 0; i < n; i++) {
    ll tmp;
    std::cin >> tmp;
    vt[i] = tmp;
  }

  ll sum = 0;
  for (it = vt.begin(); it != vt.end(); it++) {
    if (it+1 != vt.end()) {
      sum += std::min(it[+1] - *it, t);
    } else {
      sum += t;
    }
  }

  std::cout << sum << std::endl;
  return 0;
}


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

typedef long long int LLI;

int Q;
LLI A, B;

LLI Sqrt(LLI x) {
  LLI low = -1;
  LLI high = 1e9 + 7;
  while (high - low > 1) {
    LLI mid =(high+low)/2;
    if (mid*mid <= x) low = mid;
    else high = mid;
  }
  return low;
}

int main() {
  scanf("%d", &Q);
  for (int i=0; i<Q; i++) {
    scanf("%lld%lld", &A, &B);
    LLI k = Sqrt(A*B-1);
    LLI ans = k*2;
    LLI t = A*B-1;
    if (t/A != 0 && t/(t/A) == A) ans--;
    if (t/B != 0 && t/(t/B) == B) ans--;
    if (k != 0 && t/k != 0 && t/k == k) ans--;
    printf("%lld\n", ans);
  }
}


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

using namespace std;

int main()
{
	int N;
    long long K;
    int a[200005];
    int index[200005];
    int loop_checker[200005];
    int res = 0;
    int p, q;

	cin >> N >> K;

    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 1; i <= N; i++){
        res = a[res]-1;
        loop_checker[i] = res;
    }

    for(int i = 1; i <= N; i++){
        if(index[loop_checker[i]] != -1){
            index[loop_checker[i]] = -1;
        }
        else{
            for(int j = 1; j < i; j++){
                if(loop_checker[i] == loop_checker[j]){
                    p = i-j;
                    q = j;
                    if(K < q){
                        cout << loop_checker[K]+1 << endl;
                    }else{
                        K = (K-q)%p+q;
                        cout << loop_checker[K]+1 << endl;
                    }
                    
                    return 0;
                }
            }
        }
    }
	return 0;
}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

//nコからkコを取り出す。
//for(int bit = (1<<k)-1; bit < (1<<n); bit=next_combination(bit)){}
int next_combination(int sub) {
int x = sub & -sub, y = sub + x;
return (((sub & ~y) / x) >> 1) | y;
}

ll join(ll x, ll y){
    int dig = 1;
    ll div = 10;
    while(y/div != 0){
        dig++;
        div *= 10;
    }

    x *= div;
    return x+y;
}

int main()
{
    int n, k; 
    while(cin >> n >> k){
    if(n==0 && k==0) break;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    set<int> s;
    int w = 1;
    rep(i, k) w*=(i+1);

    for(int bit = (1<<k)-1; bit < (1<<n); bit=next_combination(bit)){
        vector<int> p(k);
        rep(i, k) p[i] = i;
        vector<int> b;
        rep(i, n){
            if(bit >> i & 1) {
                b.push_back(a[i]);
            }
        }
        // prvec(b);
        rep(wi, w){
            ll num = join(b[p[0]], b[p[1]]);
            FOR(i, 2, k) num = join(num, b[p[i]]);
            // pr(num);
            s.insert(num);
            next_permutation(ALL(p));
        }
    }

    pr(s.size());
    }
    return 0;}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));

    constexpr int Amax = 1e6;
    vector<bool> isDiv(Amax + 1);

    int ans = 0;
    for (int i = 0, j; i < N; i = j) {
        for (j = i + 1; j < N; ++j) {
            if (A[j] != A[i]) break;
        }
        if (isDiv[A[i]]) continue;
        else {
            if (j - i == 1) ans++;
            for (int n = A[i]; n <= Amax; n += A[i]) {
                isDiv[n] = true;
            }
        }
    }

    write(ans);
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int x;
  cin>>x;
  if(x>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a * b <= c * d) cout << c * d << endl;
    else cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#define max 100000
#define null -1

typedef struct{
  int parent,left,right;
}node;

node tree[max];
int num,depth[max];
/*
int Depth(int deep){
    d=0;
    while(tree[deep].parent!=-1){
        deep=tree[deep].parent
        d++;
    }
    return d;
    } */

void record(int a,int p){
  depth[a]=p;
  if(tree[a].right!=null){
    record(tree[a].right,p);
  }
  if(tree[a].left!=null){
    record(tree[a].left,p+1);
  }
}

void pri(int result){
  int i,child;

  printf("node %d: ",result);
  printf("parent = %d, ",tree[result].parent);
  printf("depth = %d, ",depth[result]);

  if(tree[result].parent==null){
    printf("root, ");
  }else if(tree[result].left==null){
    printf("leaf, ");
  }else{
    printf("internal node, ");
  }

  printf("[");

  for(i=0,child=tree[result].left; child!=null; i++,child=tree[child].right){
    if(i){
      printf(", ");
    }
    printf("%d",child);
  }
  printf("]\n");
}

int main(){
  int i,j;
  int v,dep,child,left,right;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    tree[i].parent=null;
    tree[i].left=null;
    tree[i].right=null;
  }

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

    for(j=0;j<dep;j++){
      scanf("%d",&child);
      if(j==0){
	tree[v].left=child;
      }else{
	tree[left].right=child;
      }
      left=child;
      tree[child].parent=v;
    }
  }
  for(i=0;i<num;i++){
    if(tree[i].parent==null){
      right=i;
    }
  }

  record(right,0);

  for(i=0;i<num;i++){
    pri(i);
  }
  return 0;
}



Measured memory_bytes: 6388
import collections

n = int(input())
v = [int(i) for i in input().split()]
o = collections.Counter(v[0::2])
e = collections.Counter(v[1::2])
o_count = o.most_common()[:2]
e_count = e.most_common()[:2]

ans = None
if o_count[0] != e_count[0]:
    ans = n - o_count[0][1] - e_count[0][1]
elif len(o_count) == 1 and len(e_count) == 1:
    ans = n // 2
elif len(o_count) == 1:
    ans = n//2 - e_count[1][1]
elif len(e_count) == 1:
    ans = n//2 - o_count[1][1]
else:
    ans = min(
        n - o_count[0][1] - e_count[1][1],
        n - e_count[0][1] - o_count[1][1]
    )
print(ans)


Measured memory_bytes: 64108
n, a, b = map(int, input().split())
S = input()

cnt = 0
oversea = 1
for s in S:
    #print(s)
    if s == "a":
        if cnt < a+b:
            print("Yes")
            cnt += 1
        else:
            print("No")
    if s == "b":
        if cnt < a+b and oversea <= b:
            print("Yes")
            cnt += 1
            oversea += 1
        else:
            print("No")
    if s == "c":
        print("No")

Measured memory_bytes: 9300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;

long long toLL(string s) {
    stringstream ss(s);
    long long ret;
    ss >> ret;
    return ret;
}

int main() {
    int n; string t;
    cin >> n;
    while (n--) {
        cin >> t;
        string l, s;
        sort(t.begin(), t.end());
        s = t;
        sort(t.begin(), t.end(), greater<char>());
        l = t;
        cout << abs(toLL(s) - toLL(l)) << endl;;
    }
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e3+5,mod=1e9+9;
ll hs[N],f[N],invf[N];
int n;
char s[N];
int get_hs(int l,int r)
{
    return (hs[r]-hs[l-1]+mod)%mod*invf[l-1]%mod;
}
map<int,int>vis;
bool judge(int m)
{
    if(m==0) return true;
    vis.clear();
    for(int i=n-m+1;i>=1;i--)
        vis[get_hs(i,i+m-1)]++;
    int pos=1;
    for(int i=1;i<=n-m+1;i++)
    {
        while(pos<=i+m-1&&pos<=n-m+1)
        {
            vis[get_hs(pos,pos+m-1)]--;pos++;
        }
        if(pos>n-m+1) return false;
        if(vis[get_hs(i,i+m-1)]) return true;
    }
    return false;
}
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    f[0]=invf[0]=1;
    for(int i=1;i<N;i++)
        f[i]=f[i-1]*13331%mod,invf[i]=qpow(f[i],mod-2);
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
        hs[i]=(hs[i-1]+(s[i]-'a')*f[i])%mod;
    int l=0,r=n/2,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(judge(m)) ans=m,l=m+1;
        else r=m-1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;
int main(void){
  int n;
  vector< P > points;
  set< int > xs;
  set< int > ys;
  cin >> n;
  for(int i = 0;i < n;++i){
    int x,y;
    cin >> x >> y;
    points.push_back(P(x,y));
  }
    
  for(int i = 1;i < n;++i){
    int x1 = (int)abs(points[0].first);
    int y1 = (int)abs(points[0].second);
    int x2 = (int)abs(points[i].first);
    int y2 = (int)abs(points[i].second);
    if((x1 + y1) % 2 != (x2 + y2) % 2){
      puts("-1");
      return 0;
    }
  }

  if((points[0].first + points[0].second) % 2 == 0){
    cout << 32 << endl;
    cout << "1 ";
  }else{
    cout << 31 << endl;
  }
  cout << "1";
  for(int i = 1;i < 31;++i){
    cout << " " << (1 << i);
  }
  cout << endl;
  for(P point : points){
    int x,y;
    tie(x,y) = point;
    if((x+y) % 2 == 0){
      cout << "R";
      --x;
    }
    int bitu = (x + y + (1 << 31) - 1) / 2;
    int bitv = (x - y + (1 << 31) - 1) / 2;
    int resx = 0,resy = 0;
    for(int i = 0;i < 31;++i){
      if(bitu & (1 << i)){
        if(bitv & (1 << i)){
          cout << "R";
          resx += (1 << i);
        }else{
          cout << "U";
          resy += (1 << i);
        }
      }else{
        if(bitv & (1 << i)){
          cout << "D";
          resy -= (1 << i);
        }else{
          cout << "L";
          resx -= (1 << i);
        }
      }
    }
    cout << endl;
    //cout << resx << " " << resy << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,i,count=0;
    cin>>n;
    int a[n+1];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if((i+1)%2!=0)
        {
            if(a[i]%2!=0)
                count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

#define ll long long

int main() {
  ll N;
  string S;
  cin >> N >> S;

  int arr[26];
  for (int i=0; i<26; i++) arr[i] = 1;
  for (int i=0; i<S.size(); i++) {
    char c = S[i];
    int j = (int)(c - 97);
    arr[j]++;
  }

  ll ans = 1;
  for (int i=0; i<26; i++) {
    ans *= arr[i];
    ans %= 1000000007;
  }

  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 512
x,y = map(int,input().split())
ans = 0
if x == 1 and y == 1:
    ans += 400000

def q(x,ans):
    if x == 1:
        ans += 300000
    elif x == 2:
        ans += 200000
    elif x == 3:
        ans += 100000
    return ans
ans = q(x,ans)
ans = q(y,ans)
print(ans)

Measured memory_bytes: 3064