akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

void solve(){
	int n, l;
	scanf("%d%d", &n, &l);
	REP(i, 0, n){
		scanf("%d", &v[i]);
	}
	REP(i, 1, n){
		if (v[i - 1] + v[i] >= l){
			printf("Possible\n");
			REP(j, 0, i - 1){
				printf("%d\n", j + 1);
			}
			for(int j = n - 1; j >= i; j--){
				printf("%d\n", j);
			}
			return;
		}
	}
	printf("Impossible\n");
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

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

int main() {
  int N, K;
  cin >> N >> K;
 
  vector<int> aaa(N);
    
  for(int j = 0; j < K; j++){
  int d;
  cin >> d;
  
    for(int i = 0; i < d; i++){
    int a;
    cin >> a;
    aaa.at(a-1)++;
    }  
    
  }
  
   int u = 0;
      for(int i = 0; i < N; i++){
        if(aaa.at(i) == 0){
        u = u + 1;
        }else{
        continue;
        }
      }
    cout << u << endl;
 
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
inline int add(int a,int b) { a+=b; if(a>=mod) a-=mod; return a; }
inline int mul(int a,int b) { return 1ll*a*b%mod; }
inline int mul(int a,int b,int c) { return 1ll*a*b%mod*c%mod; }
int fac[maxn]; int inv[maxn];
inline int C(int n,int m) { return mul(fac[n],inv[m],inv[n-m]); }
int main(void)
{
	fac[0]=fac[1]=1; inv[0]=inv[1]=1;
	for(int i=2;i<=200000;i++) fac[i]=mul(i,fac[i-1]);
	for(int i=2;i<=200000;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=200000;i++) inv[i]=mul(inv[i],inv[i-1]);
	int n,k; scanf("%d%d",&n,&k);
	int res=0;
	if(k==1)
	{
		res=mul(C(n,1),n-1);
	}
	else
	{
		int top=min(n-1,k);
		for(int i=0;i<=top;i++)
		{
			int update=mul(C(n,i),C(n-i-1+i,n-i-1));
			res=add(res,update);
		}
	}
	printf("%d\n",res);
	return 0;	
} 

Measured memory_bytes: 2300
import collections
n = int(input())
arr = collections.Counter()
def factorize(num):
    while num % 2 == 0:
        arr[2] += 1
        num //= 2
    f = 3
    while f ** 2 <= n:
        if num % f == 0:
            arr[f] += 1
            num //= f
        else:
            f += 2
    if num != 1:
        arr[num] = 1

factorize(n)
varr = list(arr.values())
ans = 0
for i in varr:
    c = 0
    while c < i:
        ans += 1
        c += 1
        i -= c
print(ans)



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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }

    for(int i =  1 ; i <= n - k ; i++){
        if(a[i] < a[k+i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 4036
s = input()
N = int(s)
ans = 0
arr = [3, 5, 7]
for n in range(3, len(s)+1):
    for i in range(3**n):
        m = 0
        j = n - 1
        count = [0]*3
        for j in range(n):
            dig = (i % 3**(j+1)) // 3**j
            m += 10**j * arr[dig]
            count[dig] += 1
        if (not 0 in count) and m <= N:
            ans += 1
print(ans)

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

long long gcd(long long a,long long b){
    if(a < b)swap(a,b);
    if(b == 0)return a;
    if(a%b==0)return b;
    else return gcd(b, a % b);
}

vector<pair<long long,int>> pf(long long n) {
  vector<pair<long long,int>> res;
  for (long long i = 2; i*i <= n; i++) {
    if (n%i !=0) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n = n / i;
      res.back().second++;
    }
    //cout<<i<<endl;
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main(){
  long long A,B,temp,ans;
  cin>>A>>B;
  ans=0;
  temp=gcd(A,B); //A,Bの最大公約数を計算 
  //cout<<"gcd"<<temp<<endl;
  auto f=pf(temp);
  ans=f.size()+1;
  cout<<ans<<endl;
  //for(auto i=0;i<f.size();i++){
  //  cout<<f[i].first<<" "<<f[i].second<<endl;
  //}
      
  return 0;
}



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc067/tasks/arc078_a
//C - Splitting Pile
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll N;
vector<ll> a;

int main() {
    cin >> N;
    a.resize(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        scanf("%Ld", &a[i]);
        sum += a[i];
    }
    ll ans = 1e10;
    ll x = 0;
    for (int i = 0; i < N; i++) {
        x += a[i];
        if (i != N-1) ans = min(ans, abs(sum - 2*x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P  pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    ll ans = 0;
    for(auto m: mp) {
        if (m.second>=k) {
            ans = m.first;
            break;
        }
        else {
            k -= m.second;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7552
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    x = int(input())
    temp = (x // 500) * 1000
    x %= 500
    ans = temp + (x // 5) * 5
    print(ans)


    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc127/tasks/abc127_c

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int high = 100_000;
        int low = 0;
        for (int i=0;i<M;i++){
            int L = sc.nextInt();
            int R = sc.nextInt();
            if (L>low){
                low = L;
            }
            if (R<high){
                high = R;
            }
        }
        sc.close();
        if (high>=low){
            System.out.println(high-low+1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 67204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L;
int main() {
    cout << fixed << setprecision(20); 
    int a , b , h , m;
    cin >> a >> b >> h >> m;
    double t = ((h * 5) + (5.0 * m / 60.0) - m) * M_PI / 30.0;
    double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(t));
    cout << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
main()
{
    int t;
    scanf("%d",&t);
    int inp[t];
    int counte=0;
    int counta=0;
    for(int i=0;i<t;i++)
    {
        scanf("%d",&inp[i]);
        if(inp[i]%2==0)
           {

            counte++;
           if(inp[i]%3==0||inp[i]%5==0)
            counta++;

           }
        }





if(counta==counte)
    printf("APPROVED");
else
    printf("DENIED");



}


Measured memory_bytes: 128
function Main(input) {
	input = input.split("\n");
  	var inputValue = input[0];
  	var mostDivideCount = 0;
  	var mostValue = 0
  for (var i=0; i<=inputValue; i++)
  {
    var divideCount = 0;
    var t=i;
    while(t>=2 && t%2==0){
      divideCount+=1;
      t=t/2;
    }
    if(divideCount>=mostDivideCount){
      mostDivideCount = divideCount;
      mostValue = i;
    }
  }
	console.log('%d',mostValue);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	int k;
	cin >> n >> k;
	vvector<int> edges(n+1);
	vector<int> fast(n+1, -1);
	if(k==1){
		int ans = 0;
		rep(i, n){
			int d;
			cin >> d;
			if(d!=1)++ans;
		}
		cout << ans << endl;
		return 0;
	}

	int ans = 0;
	vector<int> ins(n+1, 0);
	vector<int> to(n+1, 0);
	vector<int> latest(n+1, 0);
	repa(i, n+1){
		int d;
		cin >> d;
		if(i==1){
			if(d!=1)++ans;
			to[1]=1;
			continue;
		}
		to[i] = d;
		++ins[d];
	}
	ins[1] += n * 2;
	queue<int> que;
	repa(i, n+1){
		if(ins[i]==0){
			que.push(i);
		}
	}
	while(que.size()){
		int d = que.front();
		que.pop();
		if(latest[d]==k-1&&to[d]!=1){
			++ans;
		}else{
			chmax(latest[to[d]], latest[d]+1);
		}
		--ins[to[d]];
		if(ins[to[d]]==0){
			que.push(to[d]);
		}
	}

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



Measured memory_bytes: 4608
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, a, b;
int cnt[3] = {};

int main() {
    cin >> n >> a >> b;
    forn(i, n) {
        int x;
        cin >> x;
        if (x <= a) {
            ++cnt[0];
        } else if (x <= b) {
            ++cnt[1];
        } else {
            ++cnt[2];
        }
    }
    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;
    return 0;
}


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

using LL = long long int;
constexpr LL MOD = 1e9 + 7;
pair<int, int> directions[] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

class Solution {
public:

};

void test() {
    Solution s;
}

void run() {
    Solution s;
}

int main() {
//    test();
//    run();
    using Status = bitset<26>;
    string s;
    while (cin >> s) {
        vector<int> dp(s.size() + 1);
        unordered_map<Status, int> pos;
        Status status;
        pos[status] = 0;
        for(int i = 0; i < s.size(); ++ i) {
            dp[i+1] = i+1; // init
            int index = s[i] - 'a';
            status.flip(index);
            if(pos.find(status) != pos.end()) { // all same
                dp[i+1] = min(dp[i+1], 1 + dp[pos[status]]);
            }
            for(int j = 0; j < 26; ++ j) { // one different
                status.flip(j);
                if(pos.find(status) != pos.end()) {
                    dp[i+1] = min(dp[i+1], 1 + dp[pos[status]]);
                }
                status.flip(j);
            }
            if(pos.find(status) == pos.end()) {
                pos[status] = i + 1;
            }
            else {
                int last = pos[status];
                if(dp[i+1] < dp[last]) {
                    pos[status] = i+1;
                }
            }
        }
        cout << dp.back() << endl;
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   

    vector<vector<int>> c(3, vector<int>(3));
    REP(i, 3)
        REP(j, 3)
            cin >> c[i][j];

    bool flag;

    REP(i, c[0][0]+1){

        vector<int> a(3);
        vector<int> b(3);

        a[0] = i;
        b[0] = c[0][0] - i;

        flag = true;

        for (int i = 1; i < 3; ++i) {
            a[i] = c[i][0] - b[0];
            if (a[i] < 0)   flag = false;
        }

        for (int j = 1; j < 3; ++j) {
            b[j] = c[0][j] - a[0];
            if (b[j] < 0)   flag = false;
        }

        for (int i = 1; i < 3; ++i){
            for (int j = 1; j < 3; ++j){
                if (c[i][j] != (a[i] + b[j]))
                    flag = false;
            }
        }

        if (flag)   break;
    }    

    if (flag) cout << "Yes" << endl;
    else      cout << "No"  << endl;
}

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

signed main() {
  const int mod = 1e9+7;
  int N, M;
  cin >> N >> M;
  
  vector<int> stair(N+1, 0);
  int A;
  for( int i = 0; i < M; i++ ){
    cin >> A;
    stair.at(A)++;
  }
  
  vector<int> dp(N+10, 0);
  dp.at(0) = 1;
  for( int i = 1; i <= N; i++ ){
    if( stair.at(i) == 0 ){
      dp.at(i) += dp.at(i-1);
      dp.at(i) %= mod;
    }if( i < N && stair.at(i+1) == 0 ){
      dp.at(i+1) += dp.at(i-1);
      dp.at(i+1) %= mod;
    }
  }
  
  cout << dp.at(N) << endl;
 
}




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

void getResult(const uint actCount, uint *cookie1, uint *cookie2){
  uint *first = cookie1;
  uint *second = cookie2;
  for(uint i = 0; i < actCount; i++){
    if(*first % 2 != 0){
      (*first)--;
    }
    uint half = *first / 2;
    *first = half;
    *second += half;
    
    uint *tmp = first;
    first = second;
    second = tmp;
  }
}

int main(){
  uint A, B, K;
  cin >> A >> B >> K;

  getResult(K, &A, &B);
  cout << A << " " << B;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string S, T; std::cin >> S >> T;
  int ans = 0;
  for(int i = 0; i < S.size(); ++i) if(S[i] != T[i]) ++ans;
  fin(ans);
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()


void solve(){
    int W,D;cin>>W>>D;
    if(W==0&&D==0)exit(0);
    vector<int>cnt(30);
    int ans = 0;
    REP(i,W){
        int x;cin>>x;
        ans+=x;
        cnt[x]++;
    }
    REP(i,D){
        int x;cin>>x;
        if(cnt[x])cnt[x]--;
        else ans+=x;
    }
    cout<<ans<<endl;
}
signed main(){
    while(true){
        solve();
    }
}


Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int N = 1001;

vector<int> v, parent, depth;

int find(int a){
  if(parent[a] == a) return a;
  else return parent[a] = find(parent[a]);
}

void merge(int a, int b){
  int pa = find(a), pb = find(b);
  if(pa == pb) return ;

  if(depth[pa] > depth[pb]) swap(pa, pb);
  if(depth[pa] == depth[pb]) ++depth[pa];
  parent[pb] = pa;
}

void init_union_find(int V){
  v = vector<int>(V);
  parent = vector<int>(V);
  depth = vector<int>(V, 1);
  REP(i, V) parent[i] = i;
}

int main() {
  int V, F[N];
  F[0] = 2; F[1] = 3;
  FOR(i, 2, N) F[i] = (F[i - 1] + F[i - 2]) % N;
  while(cin >>V){
    int D; cin >>D;
    vector<int> cnt(V, 0), L(V);
    REP(i, V) L[i] = F[i];
    init_union_find(V);
    REP(i, V) REP(j, V) if(abs(L[i] - L[j]) < D) merge(i, j);
    set<int> S;
    REP(i, V) S.insert(find(i));
    cout <<S.size() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	long long int a1=1,a2=2,n;
 	cin >> n;
 	long long int a3=a1;
 	for (int i = 0; i < n-1; i++){
 		a3=a1;
 		a1=a1+a2;
 		a2=a3;
 	}
 	if(n==1){
 		cout << 1 << endl;
 	}else{
 		cout << a1<< endl;
 	}
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int main()
{
	int n;
	while(cin>>n)
	{
		map<int,int> mp;
		int mn=1e6,mx=0;
		int cnt=0;//需要消去的个数 
		for(int i=1;i<=n;i++)
		{
			int x;
			scanf("%d",&x);
			mp[x]++;
			if(mp[x]>1)	
			{
				cnt++;
				mn=min(mn,x);
				mx=max(mx,x);
			}
		}
		//
		int k=cnt,ans;
		cnt=cnt%2;
		if(cnt==1)
		ans=n-k-1;
		else
		ans=n-k;
		
		cout<<ans<<endl; 
		
		
		
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string yn = "No";
  cin >> N;
  for(int i = 1;i<10;i++) {
    for(int j = 1;j<10;j++) {
      if(i*j==N) {
        yn = "Yes";
      };
    };
  };
  cout << yn << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string.h>
#include <set>
#include <math.h>
#include <numeric>
#include <assert.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <queue>
#include <random>
#include <chrono>
#include <limits.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define endl "\n"
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST;
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> OST_multiset;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const ll inf = 1e9 + 69;
const ld pi = 3.14159265358979323L;
const ld eps = 1e-15;

void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
int setIO_count = 0;
void setIO(string s = ""){
	if(!setIO_count){
		unsyncIO();
		setIO_count = 1;
	}
	if(s.size()){ //output only
		setIn(s + ".in");
		setOut(s + ".out");
	}
}

#define gc getchar//_unlocked //can't for window server
#define pc putchar//_unlocked //can't for window server
ll inp(){
	char c = gc(); bool neg = false;
	for(; c < '0'||'9' < c; c = gc())
		if(c == '-') neg=true;
	ll rs = c - '0'; c = gc();
	for(; '0' <= c && c <= '9'; c = gc())
		rs = (rs << 1) + (rs << 3) + (c - '0');
	if(neg) rs = -rs;
	return rs;
}
void pri(ll _n){
	ll N = _n, rev, count = 0;
	bool neg = false;
	if(N < 0){
		N = -N; neg = true;
	}
	rev = N;
	if(N == 0) {pc('0'); return;}
	if(neg) pc('-');
	while(rev % 10 == 0) {count ++; rev /= 10;}
	rev = 0;
	while(N != 0) {rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;}
	while(rev != 0) {pc(rev % 10 + '0'); rev /= 10;}
	while(count --) pc('0');
}

const ll mod = 1e9 + 7;
const int N = 2 * 100 * 1000 + 5;

int main(){
	setIO("");

	string s; cin >> s;
	if(s[s.size() - 1] == 's') s += "es";
	else s += 's';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main()
{
    int N, temp, count=0;
    scanf("%d", &N);
    
    for (int i = 0; i < N; i++){
        scanf("%d", &temp);
        if ( (i+1) % 2 == 1 && temp % 2 == 1) count++;
    }
    printf("%d", count);
}

Measured memory_bytes: 1732
N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    A[i], B[i] = map(int,input().split())
A.reverse()
B.reverse()
ans = 0
for i in range(N):
    A[i] += ans
    if A[i]%B[i] == 0:
        continue
    ans += (B[i]-A[i]%B[i])
print(ans)

Measured memory_bytes: 15016
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        long k = in.nextLong();
        String[] arr = s.split("");
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].equals("1")) {
                if (i + 1 == k) {
                    out.println(arr[i]);
                    return;
                }
            } else {
                out.println(arr[i]);
                return;
            }

        }
    }

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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }


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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }


}


Measured memory_bytes: 23124
delta = int(input())
tri_all = []
for i in range(delta):
	tri = list(map(int, input().split(' ')))
	tri.sort()
	tri_all.append(tri)

for i in range(len(tri_all)):
	if tri_all[i][0]**2 + tri_all[i][1]**2 == tri_all[i][2]**2:
		print('YES')
	else:
		print('NO')

Measured memory_bytes: 7808
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $b = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $c = array_map('intval', explode(" ", trim(fgets(STDIN))));
 
  sort($a);
  sort($b);
  sort($c);

  $ans=0;
  $ai=0;
  $bi=0;
  $ci=0;
  $ptn=0;
  for($ci=0;$ci<$n;$ci++){
    while($bi < $n && $c[$ci]>$b[$bi]){
      while($ai < $n && $b[$bi]>$a[$ai]){
        $ai++;
      }
      $bi++;
      $ptn+=$ai;
//      echo "PTN:".$ptn." ".$ai." ".$bi.PHP_EOL;
    }
//    echo "ANS:".$ptn." ".$ans.PHP_EOL;
    $ans+=$ptn;
  }
  echo $ans;

Measured memory_bytes: 33800
n = int(input())
v = list(map(int,input().split())) #input from array of integer like "1 2 3"
c = list(map(int,input().split())) #input from array of integer like "1 2 3"

ans = 0
for i in range(n):
  if v[i]>c[i]:
    ans += v[i]-c[i]

print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	static char s[1234567];
	scanf("%s", s);
	strcat(s, "J");

	int res = 0;
	int J, O, I;
	J = O = I = 0;
	for (int i = 0; s[i] != '\0'; ++i)
	{
		if (s[i] == 'J')
		{
			if (O | I)
				J = O = I = 0;
			++J;
		}
		else if (s[i] == 'O')
		{
			if (I)
				J = O = I = 0;
			++O;
		}
		else
			++I;

		if (min(J, I) >= O)
			max_swap(res, O);
	}
	printf("%d\n", res);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int t1=0, t2=0, a=0, b=0;
	for (int i=0; i<=1; i++) a=a*10+(s[i]-'0');
	for (int i=2; i<=3; i++) b=b*10+(s[i]-'0');
	if (a<=12&&a>=1) t2++;
	if (b<=12&&b>=1) t1++;
	if (t1==1&&t2==0) cout << "YYMM" << endl;
	if (t1==1&&t2==1) cout << "AMBIGUOUS" << endl;
	if (t1==0&&t2==0) cout << "NA" << endl;
	if (t1==0&&t2==1) cout << "MMYY" << endl;
	return 0;
} 

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

int partition(int a[],int p,int r){
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[i+1],a[r]);
	return i+1;
}

signed main(){
	int n,p;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];

	p=partition(a,0,n-1);

	r(i,n){
		if(i)cout<<' ';
		if(i==p)cout<<'['<<a[i]<<']';
		else cout<<a[i];
	}
	cout<<endl;
}


Measured memory_bytes: 3824
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Arrays;
import java.util.Queue;
import java.util.PriorityQueue;
import java.util.Comparator;

public class Main {
	public static class UnionFind {
		int[] parent;
		public UnionFind(int n) {
			this.parent = new int[n];
			Arrays.fill(parent, -1);
		}

		public boolean union(int a, int b) {
			if(isSame(a, b)) return false;
			parent[find(a)] = find(b);
			return true;
		}

		public int find(int a) {
			if(parent[a] < 0) return a;
			else {
				parent[a] = find(parent[a]);
				return parent[a];
			}
		}

		public boolean isSame(int a, int b) {
			return find(a) == find(b);
		}
	}

	public static class Vector {
		int s,t,w;
		public Vector(int s, int t, int w) {
			this.s = s;
			this.t = t;
			this.w = w;
		}
	}

	public static Comparator<Vector> vectorComparator = new Comparator<Vector>() {
		@Override
		public int compare(Vector v1, Vector v2) {
			return v1.w-v2.w;
		}
	};

	public static void main(String[] args) {
		FS r = new FS();
		int v = r.nextInt();
		int e = r.nextInt();
		UnionFind uf = new UnionFind(v);
		Queue<Vector> q = new PriorityQueue<Vector>(1, vectorComparator);
		for(int i=0; i<e; i++) {
			int s = r.nextInt();
			int t = r.nextInt();
			int w = r.nextInt();
			q.add(new Vector(s, t, w));
		}
		int c = 0;
		int sumW = 0;
		while(!q.isEmpty()) {
			if(c == v-1) break;
			Vector ve = q.poll();
			if(uf.union(ve.s, ve.t)) {
				c++;
				sumW += ve.w;
			}
		}
		System.out.println(sumW);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 32148
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> line(N, 0);
	vector<int> to(N);
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		int go = (i + a) % N;
		++line[go];
		to[i] = go;
	}
	queue<int> que;
	for (int i = 0; i < N; ++i) {
		if (line[i] == 0) {
			que.push(i);
		}
	}
	int res = 0;
	while (que.empty() == false) {
		int d = que.front();
		que.pop();
		++res;
		int go = to[d];
		if (--line[go] == 0) {
			que.push(go);
		}
	}
	cout << N - res << endl;
	return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
map<int,int> mmp;
int A[222222];
int main() {
	int N,K;
	scanf("%d%d",&N,&K);
	for(int i=1; i<=N; ++i) scanf("%d",A+i);
	for(int i=1; i<=N; ++i) A[i]=(A[i-1]+A[i]-1)%K;
	LL ans=0;
	mmp[0]++;
	for(int l=0,r=1; r<=N; ++r) {
		if(r-l==K) mmp[A[l++]]--;
		ans+=mmp[A[r]];
		mmp[A[r]]++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,n) for(ll i = 0; i <= n; ++i)

#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
using P = pair<int,int>;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここから書く

const int M = 1001001;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int L, R, d, count;
  cin >> L >> R >> d;
  
  count = R/d - (L-1)/d;
  cout << count << endl;

  return 0;
}




Measured memory_bytes: 3636
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

ll dp[1001][20001];
struct block{
  int w;
  int s;
  ll v;
};

bool comp(const block &x, const block &y){
  return x.s + x.w < y.s + y.w;
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<block> b(n);
  rep(i, n)cin >> b[i].w >> b[i].s >> b[i].v;
  sort(all(b), comp);
  rep(i, n){
    rep(j, b[i].w + b[i].s + 1){
      dp[i+1][j] = dp[i][j];
      if(0 <= j - b[i].w && j - b[i].w <= b[i].s)chmax(dp[i+1][j], dp[i][j-b[i].w] + b[i].v);
    }
  }
  ll res = 0;
  rep(i, b[n-1].w + b[n-1].s + 1){
    chmax(res, dp[n][i]);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 156544
n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
flg = True
while flg and cnt < k:
    res = [0 for _ in range(n)]
    for i in range(n):
        if i - a[i] < 0:
            res[0] += 1
        else:
            res[i-a[i]] += 1

        if i + a[i] + 1 < n:
            res[i+a[i]+1] -= 1

    for i in range(n-1):
        res[i+1] += res[i] 

    if all(res[i] == n for i in range(n)):
        flg = False

    cnt += 1
    a = res.copy()

print(*a)

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> ab(n);
  vector<pair<int, int>> cd(m);
  vector<pair<int, int>> dist(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;
  rep(i, m) cin >> cd[i].first >> cd[i].second;
  rep(i, n) {
    int min_dist = 1e9;
    rep(j, m) {
      if((abs(ab[i].first - cd[j].first)
         +abs(ab[i].second - cd[j].second)) < min_dist) {
        min_dist = abs(ab[i].first - cd[j].first)
                    + abs(ab[i].second - cd[j].second);
        dist[i].first = min_dist;
        dist[i].second = j;
      }
    }
  }
  rep(i, n) {
    cout << dist[i].second + 1 << endl;
  }
  return 0;
}
  

Measured memory_bytes: 3588
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()
ans = k

if n > 1:
    for i in range(n-1):
        ans *= k - 1

print(ans)


Measured memory_bytes: 65004
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll pref[211111];
ll x[211111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>pref[i];
	}
	for(int i=1;i<=n;i++)
	{
		pref[i]+=pref[i-1];
	}
	ll ans=0; ll mini=pref[0]-x[1];
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,pref[i]-x[i]-mini);
		if(i<n) mini=min(mini,pref[i]-x[i+1]);
	}
	cout<<ans<<'\n';
}	


Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll N=410000,mod=1e9+7;
ll n,m,T,cnt,a[N],fi[N],ne[N],la[N],siz[N],g[N],ans[N],x,y,z,k,aa,bb,cc;
ll qpow(ll x,ll p)
{
	ll ans=1,ret=x;
	for (;p;p/=2)
	{
		if (p%2==1) ans=(ans*ret)%mod;
		ret=(ret*ret)%mod;
	}
	return ans;
}
void add(ll x,ll y)
{
	a[++k]=y;
	if (!fi[x]) fi[x]=k; else ne[la[x]]=k;
	la[x]=k;
}
void dfs(int x,int fa)
{
	siz[x]=1;
	for (int i=fi[x];i;i=ne[i]) if (a[i]!=fa)
	{
		dfs(a[i],x);
		siz[x]+=siz[a[i]];
	}
}
void dfs2(int x,int fa)
{
	if (x!=1) 
	{
		ans[x]=ans[fa]*siz[x]%mod;
		ans[x]=ans[x]*qpow(n-siz[x],mod-2)%mod;
	}
	for (int i=fi[x];i;i=ne[i]) if (a[i]!=fa) dfs2(a[i],x);
	
}
int main() 
{
	scanf("%lld",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		add(x,y); add(y,x);
	}
	dfs(1,0);
	ans[1]=1;
	for (ll i=1;i<=n;i++) 
	{
		ans[1]=(ans[1]*i)%mod;
		ans[1]=(ans[1]*qpow(siz[i],mod-2))%mod;
	}
	dfs2(1,0);
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

int x,now = 100,ans;

signed main() {
    cin >> x;
    while(true) {
        now += now/100;
        ++ans;
        if (x <= now) {
            cout << ans << endl;
            return 0;
        }
    }
}




Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
const int N=205;
int n,v[N],a;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;++i)
		scanf("%d",&v[i]);
	std::sort(v+1,v+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		a+=v[i];
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
using namespace std;
#define INFTY (1<<21)
#define MAX 100
void floyd(int m, int C[MAX][MAX], int T[MAX][MAX]){
for(int k = 0;k<m;k++)
for(int i = 0;i<m;i++)
for(int j = 0;j<m;j++){
C[i][j] = min( C[i][j], C[i][k] + C[k][j] );
T[i][j] = min( T[i][j], T[i][k] + T[k][j] );
}
}
main(){
int n, m, a, b, c, t, k, q, C[MAX][MAX], T[MAX][MAX];
while( cin >> n >> m && !(n == 0 && m == 0) ){
for(int i = 0;i<m;i++)
for(int j = 0;j<m;j++) { C[i][j] = T[i][j] = INFTY; }
for(int i = 0;i<n;i++){
cin >> a >> b >> c >> t;
C[a-1][b-1] = C[b-1][a-1] = c;
T[a-1][b-1] = T[b-1][a-1] = t;
}
floyd(m, C, T);
cin >> k;
for(int i = 0;i<k;i++){
cin >> a >> b >> q;
if ( q ) cout << T[a-1][b-1] << endl;
else cout << C[a-1][b-1] << endl;
}
}
}

Measured memory_bytes: 940
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    const int m = n % 10;

    if (m == 3) {
        cout << "bon" << endl;
    } else if (m == 0 || m == 1 || m == 6 || m == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}


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

int xc2(int x){
	if(x<2)
		return 0;
	else return (x*(x-1))/2;
}

int main(){
	int n,m;
	cin>>n>>m;
	cout<<xc2(n)+xc2(m)<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
ans = []
ans.append(0)
ans.append(abs(a[1]-a[0]))
i = 2
while i<N:
  x = ans[i-2]+abs(a[i]-a[i-2])
  y = ans[i-1]+abs(a[i]-a[i-1])
  ans.append(min(x,y))
  i += 1
print(ans[N-1])

Measured memory_bytes: 13928
MOD = 10 ** 9 + 7
table_len = 2 * 10 ** 6 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
    
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD

def comb(a, b):
    return fac[a+b] * finv[a] * finv[b] % MOD


r1, c1, r2, c2 = map(int, input().split())
ans = (comb(r1, c1) + comb(r2+1, c2+1) - comb(r1, c2+1) - comb(r2+1, c1)) % MOD
print(ans)

Measured memory_bytes: 167184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  vector<int> d(n);

  rep(i, n){
    cin >> a[i];
    if(i) d[i] = a[i] - a[i-1];
  }
  d[0] = (k - a[n-1]) + a[0];
  sort(all(d));

  cout << k - d[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
n = int(input())
S = [int(i) for i in input().split()]
infty = 10**10
cnt = 0
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
#     L = [0] * (n1 + 1)
#     R = [0] * (n2 + 1)
#     for i in range(n1):
#         L[i] = A[left + i]
#     for i in range(n2):
#         R[i] = A[mid + i]
# #     L = [A[left + i] for i in range(n1)]
# #     R = [A[mid + i] for i in range(n2)]

#     L[n1] = infty 
#     R[n2] = infty
    
    L = A[left:mid] + [infty]
    R = A[mid:right] + [infty]

    
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        cnt += 1
        if(L[i] <= R[j]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            
def mergeSort(A, left, right):
    if (left + 1 < right):
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
mergeSort(S, 0, len(S))
print(" ".join([str(st) for st in S]))
print(cnt)


Measured memory_bytes: 66852
#include<stdio.h>
#include<stdlib.h>

struct node{
    int key;
    struct node *right, *left, *parent;
};

struct node *root, *NIL;

struct node * find(struct node *u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key){
            u=u->left;
        }
        else{
            u=u->right;
        }
    }

    return u;
}

void insert(int k){
    struct node *y = NIL;
    struct node *x = root;
    struct node *z;

    z = (struct node *)malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x != NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }

    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }
        else{
            y->right=z;
        }
    }
}

void inorder(struct node *u){
    if(u==NIL){
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(struct node *u){
    if(u==NIL){
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(void){
    int n, i, x;
    char com[10];
    scanf("%d", &n);

    for(int i=0; i<n; i++){
        scanf("%s", com);
        if(com[0]=='f'){
            scanf("%d", &x);
            struct node *t = find(root, x);
            if(t!=NIL){
                
                printf("yes\n");
            }
            else{
                printf("no\n");
            }
        }
         else if(com[0]=='i'){
            scanf("%d", &x);
            insert(x);
        }
        else if(com[0]=='p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
       
    }
    return 0;
}


Measured memory_bytes: 20548
<?php
// $n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];

if (($a < $c && $c < $b) || ($a > $c && $c > $b)) {
	echo 'Yes';
}else{
	echo 'No';
}

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

using namespace std;

typedef long long ll;

ll n,w,dp[10][100100],p[100100],a,b,c;

int main() {
	
	scanf("%lld",&n);
	
	for(int i = 0; i < n; i++) {
		
		scanf("%lld %lld %lld", &a, &b ,&c);
		
		if(!i) {
			dp[0][i] = a;
			dp[1][i] = b;
			dp[2][i] = c;
		}
		else {
			dp[0][i] = max(dp[1][i - 1] + a,dp[2][i - 1] + a);
			dp[1][i] = max(dp[0][i - 1] + b,dp[2][i - 1] + b);
			dp[2][i] = max(dp[0][i - 1] + c,dp[1][i - 1] + c);
		}
	}
	
	printf("%lld", max(dp[0][n - 1],max(dp[1][n - 1],dp[2][n - 1])));
	
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

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

    int a, b, c;

    cin >> a >> b >> c;

    if (a == b && b == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256