akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    ll x;
    cin >> x;
    ll yokin = 100;
    int cnt = 0;
    while(yokin < x)
    {
        ll rishi = (yokin / 100LL) * 101LL - (yokin / 100LL) * 100LL;
        yokin += rishi;
        cnt++;
        // debug(rishi << " " <<  yokin);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

// long long 用の pow (MAX ll 9,223,372,036,854,775,807 -> 19桁)
ll myLongLongPow(ll base, ll times) {
    ll acc = 1;
    rep(i, times) acc *= base;
    return acc;
}

// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

int main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i, S.size()) {
        if(S.at(i) != T.at(i)) {
            ans++;
        }
    }

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


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

int abs(int a,int b){
    if(a-b<0) return b-a;
    else return a-b;
}

int main() {
    int n;
    cin >> n;
    vector<int> time (n);
    vector<vector<int>> xy (n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> time.at(i) >> x >> y;
        xy.at(i).push_back(x);
        xy.at(i).push_back(y);
    }
    string ans = "Yes";
    int now = 0;
    int x=0;
    int y=0;
    for(int i=0; i<n; i++){
        if((time.at(i)-now)%2 != (abs(x,xy.at(i).at(0))+abs(y,xy.at(i).at(1)))%2) {
            ans = "No";
            break;
        }
        if(abs(x,xy.at(i).at(0))+abs(y,xy.at(i).at(1)) > time.at(i)-now){
            ans = "No";
            break;
        }
        now = time.at(i);
        x = xy.at(i).at(0);
        y = xy.at(i).at(1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
long long a[200010];
long long cost[200010];
long long n,k;
long long solve(long long n)
{
    long long i,j;
    if(n==1)
    {
        return 0;
    }
    else if(n == 2)
    {
        return abs(a[1] - a[2]);
    }
    else if(cost[n] != -1)
    {
        return cost[n];
    }
    else if(k == 1)
    {
        cost[n] = solve(n-1) + abs(a[n] - a[n-1]);
        return cost[n];
    }
    else if(n <= k)
    {
        cost[n] = 9223372036854775807;
        for(i=n-1;i>=1;i--)
        {
            cost[n] = min(solve(i) + abs(a[n] - a[i]),cost[n]);
        }
        return cost[n];
    }
    else 
    {
        cost[n] = 9223372036854775807;
        for(i=n-1;i>=n-k;i--)
        {
            cost[n] = min(solve(i) + abs(a[n] - a[i]),cost[n]);
        }
        return cost[n];
    }
    
}
int main()
{
    long long i;
    cin >> n >> k;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        cost[i] = -1;
    }
    cout << solve(n);
}





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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int j = a[0];
    for (int i = 1; i < n - 1; i++) {
        j ^= a[i];
    }
    if (a[n - 1] == j)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	long long a, b;
	cin >> a >> b;
	long long ans = 0ll;
	long long g = __gcd(a, b);
	for (long long i = 2; i * i <= g; ++i) { 
		if (g % i == 0){
			ans++;
			while (g % i == 0) {
				g /= i;
			}
		}
	}
	if (g > 1) ans++;
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  int n,k=0;
  cin>>n;
  vector<int> d(n);
  rep(i,n){cin>>d[i];}
  sort(all(d));
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 8 || b > 8) dump(":(");
  else dump("Yay!");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int a, b, c;
	int d = 0;
	scanf ("%d", &a);
	scanf ("%d", &b);
	scanf ("%d", &c);
	
	if (a > b) {
		d = a;
		a = b;
		b = d;
	} if (b > c) {
		d = b;
		b = c;
		c = d;
	} if (a > b) {
		d = a;
		a = b;
		b = d;
	}
	
	printf ("%d %d %d\n", a, b, c);
	
	return 0;
}


Measured memory_bytes: 2140
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())

R = math.ceil(math.sqrt(M))
div = []
for i in range(1,R+1):
    if M % i == 0:
        div.append(M//i)
        div.append(i)

ans = 1
for d in div:
    if M//d >= N:
        ans = max(ans,d)

print(ans)

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

// üÍ
int W, n;
int v[1001], w[1001];

int dp[1001][1001];
int ans_weight;

void solve(){
	// ¿lÌÅålðßé
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j <= W ; j++ ){
			if( j < w[i] ){
				dp[i+1][j] = dp[i][j];
			}else{
				dp[i+1][j] = max( dp[i][j] , dp[i][j-w[i]] + v[i] );
			}
		}
	}
	// ¿lÌÅåldp[n][W]ÆÈéÅ¬Ìd³Ìaðßé
	for(int j=0 ; j <= W ; j++ ){
		if( dp[n][j] == dp[n][W] ){
			ans_weight = j;
			break;
		}
	}
}

int main(){
	for(int t=1 ; scanf("%d", &W) , W ; t++ ){
		// zñÌú»
		for(int i=0 ; i < 1001 ; i++ ){
			for(int j=0 ; j < 1001 ; j++ ){
				dp[i][j] = 0;
			}
		}

		scanf("%d", &n);
		for(int i=0 ; i < n ; i++ ){
			scanf("%d,%d", &v[i], &w[i]);
		}
		solve();
		printf("Case %d:\n", t);
		printf("%d\n%d\n", dp[n][W], ans_weight );
	}
}

Measured memory_bytes: 0
// B - Small and Large Integers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B,K; cin>>A>>B>>K;
	set<int> S;
	for(int a=A,i=0; i<K && a<=B; ++i,++a) S.insert(a);
	for(int b=B,i=0; i<K && b>=A; ++i,--b) S.insert(b);
	for(auto s:S) cout<< s <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N,M,C,n=0,a=0;
  cin >>N >>M >>C;
  vector<int> B(M);
  vector<int> A(M);
  vector<int> X(M);
  for(int i=0;i<M;i++){
    cin >>B[i];
  }
  for(int i=0;i<N;i++){
    for(int i=0;i<M;i++){
      cin >> A.at(i);
    }
    for(int i=0;i<M;i++){
      X.at(i) =A.at(i)*B.at(i);
    }
    n=0;
    for(int i=0;i<M;i++){
      n += X.at(i);
    }
    if((n+C)>0){
      a++;
    }else{
    }
  }
  cout << a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
  while(true){
      int n,m;
      cin >> n >> m;
      if (n==0 && m==0) break;
      vector<int> a(n),b(n),c(m+1,0);
      rep(i,n) cin >> a[i] >> b[i];
      rep(i,n){
          c[a[i]]=max(c[a[i]],b[i]);
      }
      int ans=0;
      rep(i,m+1){
          ans+=c[i]; 
      }
      cout << ans << endl;
  }
}



Measured memory_bytes: 3088
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()

ans = 0
t = min(n, m // 2)
ans += t
m -= t * 2
ans += max(0, m // 4)
print(ans)

Measured memory_bytes: 3064
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,a,b,c;
	std::cin >> n >> a >> b >> c;
	std::vector<int> l(n);
	rep(i,n) std::cin >> l[i];
	int min = 1e9;
	for(int ai=1;ai<(1<<n);ai++) {
		for(int bi=1;bi<(1<<n);bi++) {
			for(int ci=1;ci<(1<<n);ci++) {
				if((ai&bi) || (ai&ci) || (bi&ci)) continue;
				int mp = -30;
				{
					int i = 0;
					int s = 0;
					while(ai>>i) {
						if(ai>>i&1) {
							mp+=10;
							s+=l[i];
						}
						i++;
					}
					mp+=std::abs(s-a);
				}
				{
					int i = 0;
					int s = 0;
					while(bi>>i) {
						if(bi>>i&1) {
							mp+=10;
							s+=l[i];
						}
						i++;
					}
					mp+=std::abs(s-b);
				}
				{
					int i = 0;
					int s = 0;
					while(ci>>i) {
						if(ci>>i&1) {
							mp+=10;
							s+=l[i];
						}
						i++;
					}
					mp+=std::abs(s-c);
				}
				min = std::min(min,mp);
			}
		}
	}
	print(min);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    for (int i = -1; i <= H; i++)
    {
        if ((i == -1) || (i == H))
        {
            for (int j = -1; j <= W; j++)
            {
                cout << "#";
            }
        }
        else
        {
            vector<char> tmp(W);
            for (int j = -1; j <= W; j++)
            {
                if ((j == -1) || (j == W))
                {
                    cout << "#";
                }
                else
                {
                    cin >> tmp[j];
                    cout << tmp[j];
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	ll x,y;
	cin >> x >> y;
	ll count=0,ans=x;
	while(1){
		if(ans>y)break;
		ans = ans*2;
		count++;
	}
	cout << count << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 998244353,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=0;;i++)
	{
		if(i%2)
		{
			a=max(0,a-d);
		}
		else
		{
			c=max(0,c-b);
		}
		//cout<<i<<" "<<a<<" "<<c<<endl;
		if(a==0)
		{
			cout<<"No"<<endl;
			break;
		}
		else if(c==0)
		{
			cout<<"Yes"<<endl;
			break;
		}
	}
}		

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M, Q;
	cin >> N >> M >> Q;
	ll S[N][M];
	REP(i, N){
		string T;
		cin >> T;
		REP(j, M){
			S[i][j] = (T[j]=='1'?1:0);
		}
	}

	ll yoko[N][M-1];
	ll tate[N-1][M];
	REP(i, N)REP(j, M-1) yoko[i][j] = (S[i][j]==1&&S[i][j+1]==1?1:0);
	REP(i, N-1)REP(j, M) tate[i][j] = (S[i][j]==1&&S[i+1][j]==1?1:0);


	ll yoko_sum[N+1][M];
	ll tate_sum[N][M+1];
	ll ao_sum[N+1][M+1];
	REP(i, N+1)REP(j, M) yoko_sum[i][j] = 0;
	REP(i, N)REP(j, M+1) tate_sum[i][j] = 0;
	REP(i, N+1)REP(j, M+1) ao_sum[i][j] = 0;
	REP(i, N)REP(j, M-1) yoko_sum[i+1][j+1] = yoko_sum[i+1][j] + yoko[i][j];
	REP(i, N)REP(j, M-1) yoko_sum[i+1][j+1] += yoko_sum[i][j+1];
	REP(i, N-1)REP(j, M) tate_sum[i+1][j+1] = tate_sum[i+1][j] + tate[i][j];
	REP(i, N-1)REP(j, M) tate_sum[i+1][j+1] += tate_sum[i][j+1];
	REP(i, N)REP(j, M) ao_sum[i+1][j+1] = ao_sum[i+1][j] + S[i][j];
	REP(i, N)REP(j, M) ao_sum[i+1][j+1] += ao_sum[i][j+1];


	REP(i, Q){
		ll x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--;y1--;x2--;y2--;
		ll yokohen = yoko_sum[x2+1][y2]-yoko_sum[x2+1][y1]-yoko_sum[x1][y2]+yoko_sum[x1][y1];
		ll tatehen = tate_sum[x2][y2+1]-tate_sum[x2][y1]-tate_sum[x1][y2+1]+tate_sum[x1][y1];
		ll ao = ao_sum[x2+1][y2+1] - ao_sum[x2+1][y1] - ao_sum[x1][y2+1] + ao_sum[x1][y1];
		cout << ao - yokohen - tatehen << endl;
	}
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, d;
int hi = 0;

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

  cin>>n>>d;
  int ans = 0;
  for (int i=1; i<=n; i++) {
    if (i > hi) {
      ans++;
      hi = i+d+d;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
solve :: [Int] -> Int -> Bool
solve [] _ = False
solve _ 0 = True
solve [x] m = x == m
solve (x:xs) m = solve xs m || solve xs (m-x)

getIntListFromLine :: IO [Int]
getIntListFromLine = do
    raw <- getLine
    let ans = map read (words raw) :: [Int]
    return ans

main = do
    n <- getLine
    a <- getIntListFromLine
    q <- getLine
    m <- getIntListFromLine
    let ans = map (solve a) m
    sequence $ map putStrLn (map (\x -> if x then "yes" else "no") ans)



Measured memory_bytes: 4680
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
s = [sum(a)] * (n + 1)
now = 0
for i in range(n + 1):
    now += a[i]
    s[i] -= now
ans = 0
now = 1
for ai, si in zip(a, s):
    ans += now
    now -= ai
    if now < 0:
        print(-1)
        exit()
    now = min(now * 2, si)
print(ans)


Measured memory_bytes: 20140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};


int main(){
    int x, y;
    cin >> x >> y;

    if(-x+2*y >=0 && (-x+2*y)%3==0 && 2*x-y>=0 && (2*x-y)%3==0){
        int a, b;
        a = (-x+2*y)/3;
        b = (2*x-y)/3;

        COMinit();
        cout << COM(a+b, b) << endl;
    }else{
        cout << 0 << endl;
    }
}


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

long calc(string s)
{
  if (s.size() == 1) return stoi(s);
  long a = 0; int i;
  for (i = 0; i < s.size()-1; i++)
    a += (s[0]-'0')*pow(10, i)*pow(2, s.size()-i-2);
  a += (s[0]-'0')*pow(10, i);
  return a+2*calc(s.substr(1));
}                                          

int main()
{
  string s; cin >> s;
  cout << calc(s) << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

// a^n (mod m)
fn mod_pow(a: i64, n_i64: i64, m: i64) -> i64 {
    let n = n_i64 as u32;

    if n == 0 {
        return 1;
    }

    if n == 1 {
        return a % m;
    }

    if n % 2 == 1 {
        let k = mod_pow(a, ((n - 1) / 2) as i64, m);
        let mut ans = (a * k) % m;
        ans = (ans * k) % m;
        return ans;
    } else {
        let k = mod_pow(a, (n / 2) as i64, m);
        let ans = (k * k) % m;
        return ans;
    }
}

fn comb_mod(n: i64, r: i64, fact_memo: &Vec<i64>, m: i64) -> i64 {
    let fact_r = fact_memo[r as usize];
    let fact_inv_r = mod_pow(fact_r, m - 2, m);

    let fact_n_r = fact_memo[(n - r) as usize];
    let fact_inv_n_r = mod_pow(fact_n_r, m - 2, m);

    let mut ans = (fact_memo[n as usize] * fact_inv_r) % m;
    ans = (ans * fact_inv_n_r) % m;

    return ans;
}

fn main() {
    input! {
        N: usize,
        K: usize,
    }

    const MOD: i64 = 1000_000_000 + 7;

    let mut fact_memo: Vec<i64> = vec![0; N + 1];
    fact_memo[0] = 1;
    fact_memo[1] = 1;
    for i in 2..N {
        fact_memo[i] = (i as i64 * fact_memo[i - 1]) % MOD;
    }

    for i in 1..=K {
        // K個の青いボールをiグループに分ける
        if N - K < i - 1 {
            println!("0");
            continue;
        }

        // 隣合っている必要があるので、青と赤を1セットで考える
        // R B R B R ... B R
        // B の残っている数 : K - i個
        // K-i個をi箇所に割り振る

        // Rの残っている数 : N - K - (i-1)個
        // N - K - (i-1)個を (i+1)箇所に割り振る

        // つまり、
        // ans = (K-i + i-1)C(i-1) * (N-K-(i-1)+i)C(i)
        // ans = (K-1)C(i-1) * (N-K+1)C(i)

        let r1 = comb_mod(K as i64 - 1, i as i64 - 1, &fact_memo, MOD);
        let r2 = comb_mod(N as i64 - K as i64 + 1, i as i64, &fact_memo, MOD);

        let ans = (r1 * r2) % MOD;
        println!("{}", ans);
    }
}


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

int main (int argc,char* argv[])
{
  int i=0;
  char s[200];
  gets(s);
  while(s[i]){
    if(i==0)
      printf("%c",s[i]);
    if(s[i] ==' ')
      printf("%c",s[i+1]);
    i++;
  }
  return 0;

}













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

bool isEvenString(string s) {
    int size = s.size();
    if (size % 2 != 0) return false;
    for (int i = 0; i < size/2; i++)
    {
        if (s[i] != s[size/2 + i]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s; cin >> s;
    while (1)
    {
        s.pop_back();
        if (isEvenString(s))
        {
            cout << s.size() << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

numOfA,numOfB,target = map(int, input().split())

timetoreadA = list(map(int,input().split()))
timetoreadB = list(map(int,input().split()))

timetoreadAacc = list(itertools.accumulate(timetoreadA))

booknumonlyA = 0
totaltime = 0
for time in timetoreadAacc:
	if target < time:
		break
	booknumonlyA += 1
	totaltime = time

bookreadA = booknumonlyA
bookread = [bookreadA]

for posB in range(numOfB):
	bookreadB = posB + 1
	newtime = totaltime + timetoreadB[posB]
	if newtime <= target:
		bookread.append(bookreadA + bookreadB)
		totaltime = newtime
	else:
		while newtime > target and bookreadA > 0:
			bookreadA -= 1
			newtime = newtime - timetoreadA[bookreadA]

		if newtime <= target:
			bookread.append(bookreadA + bookreadB)

		totaltime = newtime

print(max(bookread))

Measured memory_bytes: 41732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int t, d, l;
    while (cin >> t && t) {
        cin >> d >> l;
        int sum = 0;
        int wet = 1;
        rep(i, t) {
            int x; cin >> x;
            if (x < l || i == t - 1) continue;
            chmax(wet, i + 1);
            sum += max(0, min(t, d + (i + 1)) - wet);
            wet = d + (i + 1);
            //out(sum << " " << wet);
        }
        out(sum);
    }
}



Measured memory_bytes: 3092
using System;
 class Program{
    static void Main(){
    string[] str = Console.ReadLine().Split(' ');
    int a=int.Parse(str[0]);
    int b=int.Parse(str[1]);
    if(a>=1&&b<=100){
    Console.WriteLine("{0} {1}",a*b,a*2+b*2);}
}}



Measured memory_bytes: 17824
#include<stdio.h>

int N, ans;
char S[100000 + 1], pre;

int main(void) {
    scanf("%d", &N);
    scanf("%s", S);

    pre = -1;
    ans = 0;
    for(int i = 0;i < N;i++) {
        if (pre == -1 || pre != S[i]) {
            pre = S[i];
            ans++;
        }
    }

    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
//B-CollectingBalls
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x;
  int low = 0;
  int max = 0;
  cin >> N >> K;
  for(int i = 0; i<N; i++){
    cin >> x;
    if ( abs(K-x) < x ) {
      max += (abs(K-x))*2;
    } else {
      max += x*2;
    }
  }
  cout << max;
}

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

int main(){
    string s; cin >> s;
    if (s.at(2)==s.at(3) && s.at(4)==s.at(5)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

//chMIN
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

ll n;
ll active[100001][3];
ll dp[100001][3];

int main(){
    
    cin >> n;
    rep(i,n){
        rep(j,3){
            cin >> active[i][j];
            dp[i][j]=0;
        }
    }

// chmax(dp[i+1][k] , dp[i][j] + active[i][k]);　にしたい。
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j==k) continue;
                chmax(dp[i+1][k] , dp[i][j] + active[i][k]);
            }
        }
    }

    dunk(max(dp[n][2],max(dp[n][0],dp[n][1])));
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        int x;
        cin >> x;
    }
    int ans = 0;
    for(i = 1; i < n; i += k - 1) {
        ans++;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
       (lst (loop :repeat (1- n) :collect (read)))
       (lst-a (cons (car lst) lst))
       (lst-b (concatenate 'list lst (last lst)))
       (lst-t (concatenate 'list '(nil) (mapcar #'<= lst (cdr lst)) '(T))))
  (princ (reduce #'+ (mapcar (lambda (a b c)
                               (if a b c)) lst-t lst-a lst-b) )))

Measured memory_bytes: 15712
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <climits>
#include <numeric>

#define el '\n'
typedef long long ll;

using namespace std;



void sol(){
	
	ll n;
	cin >> n;
	ll sol = 0, k = 0;
	for (int i = 1; i < n; i++){
		sol += (n + i - 1) / i - 1;
	}
	cout << sol<<el;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t = 1;
	while(t--){
	//	cout << t<<el;
		sol();
	}
}

Measured memory_bytes: 3196
num = gets.to_i
p = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)

all = (1..num).to_a.permutation(num).to_a

p_num = all.find_index(p) + 1
x_num = all.find_index(x) + 1

puts (p_num - x_num).abs


Measured memory_bytes: 6780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    
    vector<pair<ll,ll>>  vp;
    vp.pb({h1,m1});
    vp.pb({h2,m2});
    sort(all(vp));
    ll m = -(h1*60 + m1) + (h2*60 + m2);
    cout<<m-k;
}


Measured memory_bytes: 3656
#include<iostream>
#include<sstream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b ;
  if (a == 1 and b != 1){
  cout << "Alice" << endl;
  }else if (b == 1 and a != 1){
  cout << "Bob" << endl;
  }else if (a < b){
  cout << "Bob" << endl;
  }else if (a > b){
  cout << "Alice" << endl;
  }else{
  cout <<"Draw" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main () 
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if(a==b)
{
    if(b!=c)
    {
        printf("Yes");
        return 0;
    }
}
if(a==c)
{
    if(b!=a)
    {
        printf("Yes");
        return 0;
    }
}
if(c==b)
{
    if(b!=a)
    {
        printf("Yes");
        return 0;
    }
}

printf("No");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;

int main() {
    ll A,B,C,X,sum,cnt=0; cin>>A>>B>>C>>X;
    for(ll i=0;i<=A;i++){
        for(ll j=0;j<=B;j++){
            for(ll k=0;k<=C;k++){
                sum=500*i+100*j+50*k;
                if(sum==X){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
}


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

long long inf = (1 << 30);
long long mod = 1e9;

int main(){

    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long long ans = ceil(1.0 * N / min(A, min(B, min(C, min(D, E))))) + 4;

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int minimum=9999999;
  
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    //odd number check
    if(A%2!=0){
      minimum=0;
      break;
    }
    int modCount=1; //at least,this number is a even number
    int delim=2;
    while(true){
      if(A%delim==0){
        //I don't know how to write power 
        modCount++;
        delim*=2;
      }else{
        break;
      }
    }
    if((modCount-1)<minimum){
      minimum=modCount-1;
    }
  }
  cout << minimum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 

set<int> ans;

int solve(){
	multiset<pair<int,int> > m;
	for(int i=1;i<10;i++) m.insert({1,i});
	while(ans.size()<=100000){
		auto f=*m.begin();
		ans.insert(f.ss);
		m.erase(m.begin());
		if(f.ss%10==0){
			m.insert({f.ff+1,f.ss*10});
			m.insert({f.ff+1,f.ss*10 + 1});
			continue;
		}
		if(f.ss%10==9){
			m.insert({f.ff+1,f.ss*10+9});
			m.insert({f.ff+1,f.ss*10+8});
			continue;
		}
		int z=f.ss%10;
		m.insert({f.ff+1,f.ss*10 +z });
		m.insert({f.ff+1,f.ss*10 + z+1});
		m.insert({f.ff+1,f.ss*10 + z-1});
		// trace(ans.size(),m.size());
	}
	vi z(all(ans));
	int k;cin>>k;
	cout<<z[k-1]<<endl;

	// for(auto i:ans) cout<<i<<",";




    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010); 
vector<ll> dist(100010);

int main(){
    ll h, w;
    cin >> h >> w;

    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }

    ll ans = min(h, w);

    ll w_1, w_2;
    if(w&1){
        w_1 = w/2;
        w_2 = w/2 + 1;
    }
    else {
        w_1 = w_2 = w/2;
    }

    rep(i, h+1){
        ll s_max = max(i*w, (h-i)*w_2);
        ll s_min = min(i*w, (h-i)*w_1);

        ans = min(ans, s_max-s_min);
    }

    ll h_1, h_2;
    if(h&1){
        h_1 = h/2;
        h_2 = h/2 + 1;
    }
    else {
        h_1 = h_2 = h/2;
    }

    rep(i, w+1){
        ll s_max = max(i*h, (w-i)*h_2);
        ll s_min = min(i*h, (w-i)*h_1);

        ans = min(ans, s_max-s_min);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

L = P[:x] + Q[:y] + R
L.sort(reverse=True)
print(sum(L[:x+y]))

Measured memory_bytes: 29420
//全国統一プログラミング王予選
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
struct UnionFind
{
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) {}
  bool unionSet(ll x, ll y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y)
  {
    return root(x) == root(y);
  }
  ll root(ll x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x)
  {
    return -data[root(x)];
  }
};
struct edge
{
  ll to,from;
  ll cost;
  bool ok=0;
  edge() {}
  edge(ll from , ll to, ll cost) : from(from),to(to), cost(cost){};
};
bool cmp(const edge &a, const edge &b){
  return a.cost < b.cost;
}
int main()
{
/* std::ifstream in("input");
std::cin.rdbuf(in.rdbuf()); */
ll n, m;
cin >> n >> m;
vector<ll> sum(n);
rep(i, n){
  cin >> sum[i];
}
vector<edge> g;
vector<vector<pair<ll,ll>>> gg(n);
rep(i, m)
{
  ll a, b, c;
  cin >> a >> b >> c;
  g.emplace_back(a-1,b - 1, c);
  gg[a-1].emplace_back(b-1,c);
  gg[b-1].emplace_back(a-1,c);
}
sort(g.begin(),g.end(),cmp);
UnionFind arr(n);
rep(i,m){
  if(arr.root(g[i].from)==arr.root(g[i].to)){
    if(sum[arr.root(g[i].from)]>=g[i].cost)g[i].ok=1;
  }
  else {
    ll sum1=sum[arr.root(g[i].from)];
    ll sum2=sum[arr.root(g[i].to)];
    arr.unionSet(g[i].from, g[i].to);
    sum[arr.root(g[i].from)]=sum1+sum2;
    if(sum[arr.root(g[i].from)]>=g[i].cost)g[i].ok=1;
  }
}
set<pair<ll,ll>> see;
rep(i,m){
  if(g[m-i-1].ok){
    if(see.find({min(g[m-i-1].to,g[m-i-1].from),max(g[m-i-1].to,g[m-i-1].from)})!=see.end())continue;
    queue<ll> q;
    ll co=g[m-i-1].cost;
    q.push(g[m-i-1].to);
    q.push(g[m-i-1].from);
    ans++;
    see.insert({min(g[m-i-1].to,g[m-i-1].from),max(g[m-i-1].to,g[m-i-1].from)});

    while(!q.empty()){
      ll p=q.front();
      q.pop();
      for(auto r:gg[p]){
        if(see.find({min(r.first,p),max(r.first,p)})!=see.end())continue;
        see.insert({min(r.first,p),max(r.first,p)});
        if(r.second<=co){
          ans++;
          q.push(r.first);
        }
      }
    }
  }
}
cout << m-ans << endl;
return 0;
}

Measured memory_bytes: 18796
n = gets.to_i
as = gets.split
  .each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }
  .select { |_, v| v >= 2 }

ans = 0
prev = 0

as.keys.sort.reverse.each do |k|
  v = as[k]
  s = prev * k

  if v >= 4
    s = s >= k ** 2 ? s : k ** 2
  end

  if s > ans
    ans = s
    break
  end

  prev = k
end

puts ans


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

int triangle(int N, vector<int> L){
    if (N < 3) return 0;

    int first, second, third, count = 0;
    for (int i = 0; i < L.size() - 2; i++){
        for (int j = i + 1; j < L.size() - 1; j++){
            for (int k = j + 1; k < L.size(); k++){
                first = L[i];
                second = L[j];
                third = L[k];
                if ((first != second && first != third) && second!= third){
                    if (first + second > third) count += 1;
                }
            }
        }
    }
    return count;
}


int main(){
    int N;
    cin >> N;
    int input;
    vector<int> L;
    while (cin >> input) {
      L.push_back(input);
    }
    sort(L.begin(), L.end());
    cout << triangle(N, L);

    return 0;
}


Measured memory_bytes: 3628
object Main extends App {
  import scala.io.StdIn._
  val Array(n, k, q) = readLine.trim.split(' ').map(_.toInt)
  val score = Array.fill(n){k - q}
  for (_ ← 0 until q) {
    val winner = readInt()
    score(winner - 1) += 1
  }
  println(score.map{
    case i if i > 0 ⇒ "Yes"
    case _ ⇒ "No"
  }.mkString("\n"))
}

Measured memory_bytes: 38400
score = []
until (t = gets.split(',').map(&:to_i))== [0,0]
    score << [t[0] , t[1], 0]
end

score.sort!{ |x, y| x[1] <=> y[1] }.reverse!
score.length.times do |i|
#    p score
    if i == 0
        score[i][2] = 1
    else
        if score[i-1][1] == score[i][1]
            score[i][2] = score[i-1][2]
        else
            score[i][2] = score[i-1][2] + 1
        end
    end
end

while gets
    puts score.assoc($_.to_i)[2]
end

Measured memory_bytes: 6108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

vector <P> px, py;

int dis(P a, P b) {
    return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        int x, y;
        scanf("%d %d\n", &x, &y);
        px.pb(P(x, y));
        py.pb(P(y, x));
    }
    sort(all(px));
    sort(all(py));
    int mini = INF;
    rep(N-1, i) mini = min(mini, dis(px[i], px[i+1]));
    rep(N-1, i) mini = min(mini, dis(py[i], py[i+1]));
    cout << mini << '\n';
}

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



Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long int j;
  cin>>j;
  long int ans=0;
  for(long int i=0;i<=j;i++){
    if(i%3!=0 && i%5!=0){
      ans+=i;
    }
    else{
      int unko=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
int n, dp[100001][3] = {}, abc[100000][3] = {};
void solve(void)
{
  int x[3];
  for(int i = 1; i != n + 1; i++){
    for(int j = 0; j != 3; j++){
      for(int k = 0; k != 3; k++){
        x[k] = j != k ? dp[i - 1][k] + abc[i - 1][j] : 0;
      }
      dp[i][j] = std::max(std::max(x[0], x[1]), x[2]);
    }
  }
}
int main(void)
{
  std::cin >> n;
  for(int i = 0; i != n; i++) std::cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
  solve();
  std::cout << std::max(std::max(dp[n][0], dp[n][1]), dp[n][2]) << std::endl;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
const int N = 222;
int f[2][N][N][N];
int n, m;
char mp[N][N];
int main(){
//	freopen("land.in", "r", stdin);
//	freopen("land.out", "w", stdout);
	cin>>n>>m;
//	memset(f, -1, sizeof(f));
	for(int i = 1;i <= n; i++){
		scanf("%s", mp[i] + 1);
	}
	for(int i = m;i >= 1; i--){
		for(int l = 1;l <= n; l++){
			for(int r = l;r <= n; r++){
				if(mp[l][i] != mp[r][i])break;
				f[0][l][r][i] = i;
				if(mp[l][i+1] == mp[l][i])f[0][l][r][i] = max(f[0][l][r][i+1], i);
			}
		}
	}
	int fl = 0;
	for(int ans = 0;ans <= 20; ans++){
		if(f[fl][1][n][1] == m){
			printf("%d\n", ans);
			return 0;
		}
		for(int i = 1;i <= m; i++){
			for(int l = 1;l <= n; l++){
//				printf("l=%d\n", l);
				int lst = n + 1;
				for(int r = n;r >= l; r--){
					if(f[fl][l][r][i] == m){
						f[fl^1][l][r][i] = m;
						continue;
					}
					int F = f[fl][l][r][i];
					F = max(F, f[fl][l][r][F+1]);
					int L = l, R = r - 1, res = l;
//					printf("r=%d\n", r);
//					for(int x = l;x < r; x++){
//						printf("x=%d f=%d\n", x, min(f[fl][l][x][i], f[fl][x+1][r][i]));
//					}
					while(L <= R){
						int mid = (L + R) >> 1;
						if(f[fl][l][mid][i] > f[fl][mid+1][r][i])L = mid + 1, res = mid;
						else R = mid - 1;
					}
//					printf("r=%d res=%d\n", r, res);
					if(res > lst){
						
						printf("ans=%d l=%d r=%d i=%d f=%d\n", ans, l, r, i, F);
						exit(0);
					}else lst = res;
					F = max(F, min(f[fl][l][res][i], f[fl][res+1][r][i]));
					if(res + 1 < r)++res, F = max(F, min(f[fl][l][res][i], f[fl][res+1][r][i]));
					f[fl^1][l][r][i] = F;
				}
			}
		}
		fl ^= 1;
	}
	return 0;
}

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

int main ()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int first = 0, second = 0, third = 0;
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if(t % 2 == 1) first++;
        else if(t % 4 == 0) third++;
        else second++;
    }
    if(second == 0) {
        if(first <= third + 1) cout << "Yes\n";
        else cout << "No\n";
    }
    else if(third == 0) {
        if(first == 0) cout << "Yes\n";
        else cout << "No\n";
    }
    else if(first == 0) {
        cout << "Yes\n";
    }
    else if(first <= third) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
import fractions
import itertools
k = int(input())

ans=k*(k+1)//2
for a in range(1,k+1):
    for b in range(a+1,k+1):
        t = fractions.gcd(a,b)
        for c in range(b,k+1):
            ans+=fractions.gcd(t,c)*6

print(ans)

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

int main() {
int N,c;
  c=0;
  cin>>N;
  string S;
  for (int i=0;i<N;i++){
    cin>>S;
    if(S=="Y"){
      c++;
  }
  }
  if(c>=1){
    cout<<"Four"<<endl;
  }
      else if(c==0){
        cout<<"Three"<<endl;
      }
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b; cin >> a >> b;
	cout << max({a+b, a-b, a*b});
}


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

int main(void){
      string S; cin >>S ;
      string X;
      int N,i=0;

      N=S.size();
      for(i=0;i<N;i++){
            X[N-(i+1)]=S[i];
      }
      X[i+1]='\0';
      S[i+1]='\0';

      for(int j=0;j<N;j++){
            if(S[j]!=X[j]){
                  cout << "No" << endl;
                  return 0;
            }
      }
     int x = ((N-1)/2);
      if(x == 2)x++;
      for(int k=0;k<x;k++){
//      cout << S[k] << ":" << k << "->" << X[(x-k)-1] << ":" << (x-k)-1 << endl; 
            if(S[k]!=X[(x-k)-1]){
                  cout << "No" << endl;
                  return 0;
            }
      }
      int l = ((N+3)/2);
      if(l == 4)l--;  
      for(int i=0;l<N;l++){
  //    cout << S[l] << ":" << l << "->" << X[(N-l)-1] << ":" << (N-l)-1 << endl; 
            if(S[l]!=X[(N-l)-1]){
                  cout << "No" << endl;
                  return 0;
            }
            i++;
      }
      cout << "Yes" << endl;
      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[105];

llint calc(llint p)
{
	llint ret = 0;
	for(int i = 1; i <= n; i++){
		ret += (a[i]-p)*(a[i]-p);
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ans = 1e9;
	for(int i = 1; i <= 100; i++) ans = min(ans, calc(i));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n, d; cin>>n>>d;
    cout<<n/(d*2 + 1) + bool( n%(d*2 + 1) )<<endl;
}


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

const int N=10000010;
int n;
int fac[N],inv[N],ci[N];
const long long mod=998244353;

long long ksm(long long x,long long t){
	long long tot=1;
	while(t){
		if(t&1) (tot*=x)%=mod;
		(x*=x)%=mod;
		t/=2;
	}
	return tot;
}

long long C(int x,int y){
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main(){
	scanf("%d",&n);
	long long tot=0;
	fac[0]=ci[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod,ci[i]=ci[i-1]*2%mod;
	inv[n]=ksm(fac[n],mod-2);for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=n/2+1;i<=n;i++) tot+=C(n,i)*ci[n-i]%mod;
	printf("%lld\n",(ksm(3,n)-tot*2%mod+mod)%mod);
}

Measured memory_bytes: 117376