akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
        int n;

        scanf("%d",&n);

        switch ( n % 10){
                case 0:
                case 1:
                case 6:
                case 8:
                        printf("pon");
                        break;
                case 3:
                        printf("bon");
                        break;

                default :
                        printf("hon");
                        break;
        }
        return 0;

}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define  ll long long
using namespace std;
int main()
{
 ll a,b;
 cin>>a>>b;
 ll k=min(a,b);
 ll j=max(a,b);
 int m=j;
 if(k!=0&&j!=0)
 {
 while(j%k !=0)
 {
     j = j+m;
 }
 cout<<j;
 }
 if(k==0)
 {
     cout<<j;
 }
}


Measured memory_bytes: 256
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

int L;

int recur(int n)
{
    stringstream ss;
    ss << setw(L) << setfill('0') <<  n;

    string str = ss.str();
    string str2 = string(str);

    sort(str.begin(), str.end());
    sort(str2.rbegin(), str2.rend());


    return stoi(str2) - stoi(str);
}

void solve()
{
    int a;
    while(cin >> a >> L, a||L) {
        vector<int> v;
        v.push_back(a);
        for(int i = 1; i<= 20; i++) {
            int r = recur(v[i-1]);
            auto it = find(all(v), r);
            if (it != v.end()) {
                auto dist = distance(v.begin(), it);
                cout << dist << " " << *it << " " << i - dist <<endl;
                break;
            }
            v.push_back(r);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

Measured memory_bytes: 3172
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++)cin>>c[i];

	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int lb=lower_bound(a,a+n,b[i])-a;
		int ub=upper_bound(c,c+n,b[i])-c;	
		ans+=(lb)*(n-ub);
		
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 5980
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	int a,b;

	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string p = to_string(i);
		bool r = 1;
		for (int k = 0; k < p.size() / 2; k++) {
			if (p[k] != p[p.size() - 1 - k])r = 0;
		}
		if (r)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    B = A+[A[i] + K for i in range(N)]
    answer = 10**9
    for i in range(N):
        answer = min(answer,B[i+N-1]-B[i])
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 37236
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
#define rep(i, n) for(ll i = 0LL; i < (n); i++)
using Graph = vector<vector<int>>;
ll mod = 1000000007LL;
vector<ll> y;

ll modpow(ll x, int p = mod - 2) {
	if (p == 0) return 1;
	ll temp = modpow(x, p / 2);
	temp = temp * temp % mod;
	if (p % 2) temp = temp * x % mod;
	return temp;
}

int main(void) {
	ll n;
	cin >> n;
	vector<ll> x(n), dif(n), inv(n), inv_sum(n, 0), fact(n, 1);
	rep(i, n) {
		cin >> x[i];
	}
	
	rep(i, n - 1) {
		dif[i + 1] = x[i + 1] - x[i];
	}

	rep(i, n - 1) {
		inv[i + 1] = modpow(i + 1);
		inv_sum[i + 1] = (inv_sum[i] + inv[i + 1]) % mod;		
	}

	rep(i, n - 1) {
		fact[i + 1] = fact[i] * (i + 1) % mod;
	}

	ll ans = 0;
	rep(i, n - 1) {
		ll temp = (inv_sum[i + 1] * dif[i + 1]) % mod;
		ans += temp;
		ans %= mod;
	}
	ans = ans * fact[n - 1] % mod;

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

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e3 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;



void solve(){
    ll a , b , c , k;
    cin >> a >> b >> c >> k;
    while(k && a >= b){
        b *= 2;
        -- k;
    }
    while(k && b >= c){
        -- k;
        c *= 2;
    }
    if(a < b && b < c){
        cout << "Yes\n";
    }
    else{
        cout << "No";
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3652
import math
import bisect

X = int(input())

N = 100100
primes = [i for i in range(X + 100)]
primes[1] = 0

for prime in primes:
    if prime > math.sqrt(N):
        break
    if prime == 0:
        continue
    for non_prime in range(2 * prime, X + 100, prime):
        primes[non_prime] = 0
    
lpm = [prime for prime in primes if prime != 0]
i = bisect.bisect_left(lpm, X)
print(lpm[i])

Measured memory_bytes: 44784
n,m=map(int,input().split())
r=[[] for x in range(n)]
for c in range(m):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
s=[-1]*n
u=[0]
v=[]
k=1
while k<n:
    for d in u:
        for e in r[d]:
            if s[e]==-1:
                s[e]=d
                k+=1
                v.append(e)
    u=v
print('Yes')
for c in range(n-1):
    print(s[c+1]+1)

Measured memory_bytes: 34584
S = input()
L = ['A', 'T', 'G', 'C']
N = len(S)
num = 0
ans = 0
for i in range(N):
    if S[i] in L:
        num += 1
    else:
        ans = max(num, ans)
        num = 0
ans = max(num, ans)
print(ans)


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

#define _GLIBCXX_DEBUG
#define rep(i, V) for (int i = 0; i < V; i++)
#define repr(i, V) for (int i = V-1; i >= 0; i--)
#define repval(i, a, V) for (int i = a; i < V ; i++)
#define all(x) x.begin(), x.end()
#define ld long double
#define eps 0.0000000001
#define mod 1000000007
#define inf 1e9
#define vec vector
#define each(i, mp) for(auto& i:mp)
int N, M, R;
int res;
bool used[8];
vec<vec<int>> dist(201, vec<int>(201, inf));
vec<int> r(8);

void dfs(int c, int las, ll d){
    if (c == R){
        if (res > d){
        	res = d;
        }
        return;
    }
    rep(i, R)if(!used[i])
    {
        used[i] = true;
        if (las == -1){
        	dfs(c+1, i, 0);
        }else{
         	dfs(c+1, i, d+dist[r[las]][r[i]]);
        }
        used[i] = false;
    }
}

int main(){
    cin >> N >> M >> R;
    rep(i, R){
    	cin >> r[i];
      	r[i]--;
    }
    rep(i, N) dist[i][i] = 0;

    int a, b, c;
    rep(i, M){
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        if (dist[i][j] > dist[i][k] + dist[k][j]){
            dist[i][j] = dist[i][k] + dist[k][j];
        }
    }
    
    res = inf;
    dfs(0,-1,0);
    cout << res << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
int one[64];
int main() {
	int N; cin >> N;
	vector<ll> a(N); rep(i, N) cin >> a[i];
	rep(i, N) {
		rep(j, 60) {
			if (a[i] >> j & 1) one[j]++;
		}
	}
	ll ans = 0;
	rep(i, 60) {
		ll x = 0;
		rep(j, N) {
			if (a[j]>>i & 1) x++;
		}
		ll temp = x * (N-x) % MOD;
		rep(j, i) temp = temp * 2 % MOD;
		ans += temp;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5556
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    string T;cin >> T;
    string R = "";
    for(int i = 0;i<T.size()-1;i++){
        R += T.at(i);
    }
    if(S == R){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,W;
    cin >> N>>W;
    int W1[100],V[100];
    for(int i=0;i<N;i++){
        cin>>W1[i]>>V[i];
    }
    long long dp[101][100001];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<100001;j++){
            if(i==0){
                if(j==0){
                    dp[i][j]=0;
                }
                else{
                dp[i][j]=2000000000;
                }
            }
            else{
                int w=W1[i-1],v=V[i-1];
                int index=j-v;
                if(index<0){
                    dp[i][j]=dp[i-1][j];
                }
                else{
                    long long tmp=dp[i-1][j],tmp1=dp[i-1][index]+w;
                    if(tmp<tmp1){
                        dp[i][j]=tmp;
                    }
                    else{
                        dp[i][j]=tmp1;
                    }
                }
            }
        }
    }
    int max_v=0;
    for(int i=0;i<100001;i++){
        if(dp[N][i]<=W && max_v<i){
            max_v=i;
        }
    }
    cout<<max_v<<endl;
    return 0;
}

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

blue = 0

if n <= (a+b):
  if n > a:
    blue = a
  else:
    blue = n
else:
  blue = (n // (a+b))*a

  if (n % (a+b)) > a:
      blue += a
  else:
      blue += n %(a+b)
print(blue)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll f(ll x) {
  ll res = ((x+1) / 2) % 2;
  return x%2 == 0 ? res^x : res;
}

int main() {
  ll a,b; cin >> a >> b;
  ll ans = 0;

  COUT(f(a-1) ^ f(b));
  return 0;
}

Measured memory_bytes: 256
s = input()
len_s = len(s)
s = '+'.join(s)
#print(s)

ans = 0
for i in range(2**(len_s-1)):
    tmp_s = list(s)
    for j in range(len_s-1):
        if ((i>>j)&1):
            tmp_s[2*j+1] = ''
    tmp_s = ''.join(tmp_s)
    #print(tmp_s)
    ans += eval(tmp_s)
    #print(ans)

print(ans)


Measured memory_bytes: 3188
n, m = gets.split(" ").map(&:to_i)
h = gets.split(" ").map(&:to_i)
ary = []
m.times {ary << gets.split(" ").map(&:to_i)}

ary_flag = Array.new(n, 1)
ary.each {|x|
  if h[x[0]-1] == h[x[1]-1]
    ary_flag[x[0]-1] = 0
    ary_flag[x[1]-1] = 0
  elsif h[x[0]-1] > h[x[1]-1]
    ary_flag[x[1]-1] = 0
  elsif h[x[0]-1] < h[x[1]-1]
    ary_flag[x[0]-1] = 0
  end
}

puts ary_flag.count(1)


Measured memory_bytes: 29440
#include <iostream>
#include <map>
#include <queue>
using namespace std;
int d[10000000]={0};
int main(){
  priority_queue< pair<int,int> >q;
  int a,b;
  pair<int,int>p;
  int n,m;
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> a >> b;
    d[a] += b;
    q.push(make_pair(d[a],-a));
    while(1){
      p = q.top();
      if(p.first == d[-p.second]){
	cout << -p.second << " " << p. first<< endl;
	break;
      }
      q.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 6188
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N (1000*100)
#define MOD (ll(1E9+7))
int N;
string S;

int W,B;

ll kai[MAX_N+5];

ll kaijo(int n)
{
	DOUT<<"---- kaijo("<<n<<") ----"<<endl;
	if(kai[n]!=0) {
		return kai[n];
	}
	ll i=n;
	for(;i>=1; i--) {
		if (kai[i]!=0) {
			break;
		}
	}
	ll ret = kai[i];
	for(;i<n;i++) {
		DOUT<<"(i+1)* kai[i]=="<<((i+1)* kai[i])<<endl;
		kai[i+1] = ((i+1)* kai[i])%MOD;
	}
	return (kai[n])%MOD;
}

int main(int argc, char *argv[])
{
	kai[0]=1;
	kai[1]=1;
	ios::sync_with_stdio(false);
	cin >> N;
	cin >> S;
	FOR(n,2*N) {
		DOUT << "S["<<n<<"]=="<<S[n]<<endl;
		DOUT << "(2*N-n)%2=="<<(2*N-n)%2<<endl;
		if((2*N-n)%2==0) {
			if(S[n]=='B') { S[n]='W'; }
			else if(S[n]=='W') { S[n]='B'; }
		}
		DOUT << "S["<<n<<"]=="<<S[n]<<endl;
	}
	W=0;
	B=0;
	FOR(n,2*N) {
		DOUT << "S["<<n<<"]=="<<S[n]<<endl;
		if(S[n]=='B') { B++; }
		else if(S[n]=='W') { W++; }
	}
	if(B!=W) {
		cout << 0 << endl;
		return 0;
	}

	int count = 0;
	ll ans = 1;
	count = 0;
	FOR(n,2*N) {
		DOUT << "S["<<n<<"]=="<<S[n]<<", ans="<<ans<<", count=="<<count<<endl;
		if(S[n]=='B') {
			DOUT<<"ans*count="<<(ans*count)%MOD<<endl;
			ans = ans*count%MOD;
			count--;
		}
		else {
			count++;
		}
		DOUT << "ans=="<<ans<<", count=="<<count<<endl;
	}

	cout << ans*kaijo(N)%MOD << endl;

	DOUT << kaijo(1000*100) << endl;

	return 0;
}




Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

ll N, M, S;
struct Edge {
	ll u, a, b;
};
vector<Edge> edges[60];
const ll INF = 1e18;
ll C[60], D[60];
ll dp[60][20000];
typedef pair<ll, pair<ll, ll>> P;

signed main() {
	cin >> N >> M >> S;
	S = min(S, 19000ll);
	rep(i, M) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		edges[u].push_back({v, a, b});
		edges[v].push_back({u, a, b});
	}
	for (int i=1; i<=N; i++) {
		cin >> C[i] >> D[i];
	}
	rep(i, 60) rep(j, 20000) dp[i][j] = INF;
	priority_queue<P, vector<P>, std::greater<P>> q; // {time, {vertex, money}}
	q.push({0ll, {1ll, S}});
	while (!q.empty()) {
		auto g = q.top();
		q.pop();
		ll t = g.first, i = g.second.first, j = g.second.second;
		if (dp[i][j] <= t)
			continue;
		dp[i][j] = t;
		// printf("i=%lld j=%lld t=%lld dp[i][j]=%lld\n", i, j, t, dp[i][j]);
		// exchange
		if (j + C[i] < 20000)
			q.push({t + D[i], {i, j + C[i]}});
		// move
		for (auto e: edges[i]) {
			ll u = e.u, a = e.a, b = e.b;
			if (j-a >= 0)
				q.push({t+b, {u, j-a}});
		}
	}
	for (int i=2; i<=N; i++) {
		ll ans = INF;
		rep(j, 20000)
			ans = min(ans, dp[i][j]);
		cout << ans << endl;
	}
	return 0;
}


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

long long Li(int N,vector<vector<long long>>&M){
  if (N==0){
    return 2;
  }
  if (N==1){
    return 1;
  }
  for (int i=0;i<M.size();i++){
    if (N==M.at(i).at(0)){
      return M.at(i).at(1);
    }
  }
  long long l;
  l = Li(N-1,M) + Li(N-2,M);
  M.push_back({N,l});
  return l;
}

int main(){
  int N;
  cin >> N;
  vector<vector<long long>>M(0,vector<long long>(0));
  cout << Li(N,M) << endl;
}

Measured memory_bytes: 256
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
#define lll long long
lll f[2][100005];
lll n,m;
int main()
{
	lll w,v;
	scanf("%lld%lld",&n,&m);
	lll mx=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w,&v);
		for(int j=0;j<w;j++)
		{
			f[i%2][j]=f[(i+1)%2][j];
			mx=max(mx,f[i%2][j]);
		}
		for(int j=w;j<=m;j++)
		{
			f[i%2][j]=max(f[(i+1)%2][j],f[(i+1)%2][j-w]+v);
			mx=max(mx,f[i%2][j]);
		}
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {

    int n, m; cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    // print(G);
    queue<int> que;
    que.push(0);
    vector<P> dist(n, P(-1, -1));
    dist[0] = P(0, -1);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for (int nv: G[v]) {
            if (dist[nv].fi!=-1) continue;
            int d = dist[v].fi+1;
            dist[nv] = P(d, v);
            que.push(nv);
        }
    }

    bool ok = true;
    rep(i, n) {
        if (dist[i].fi == -1) ok = false;
    }
    if (!ok) puts("No");
    else {
        puts("Yes");
        FOR(i, 1, n) {
            cout << dist[i].se+1 << endl;
        }
    }
}

Measured memory_bytes: 10608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdint-intn.h>
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    string s; cin >> s;
    if(s == "ABC") {
        println("ARC");
    } else {
        println("ABC");
    }

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[11][11];
int main(){
	long long n,a,b,c,d;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n--;
	for(int i=0;i<=n;i++){
		long long LM=a-d*i+c*(n-i);
		if(LM<=b&&b<=LM+n*(d-c)){
			printf("YES\n");return 0;
		}
	}
	printf("NO\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;

int solve(int day,int flag)
{
    if(day==n)
    return 0;
    if(dp[day][flag]!=-1)
    return dp[day][flag];
    int maxi = 0;
    if(flag==0)
    {
        maxi = max(maxi,a[day][1]+solve(day+1,1));
        maxi = max(maxi,a[day][2]+solve(day+1,2));
        maxi = max(maxi,a[day][3]+solve(day+1,3));
    }
    else if(flag==1)
    {
        maxi = max(maxi,a[day][2]+solve(day+1,2));
        maxi = max(maxi,a[day][3]+solve(day+1,3));
    }
    else if(flag==2)
    {
        maxi = max(maxi,a[day][1]+solve(day+1,1));
        maxi = max(maxi,a[day][3]+solve(day+1,3));
    }
    else
    {
        maxi = max(maxi,a[day][1]+solve(day+1,1));
        maxi = max(maxi,a[day][2]+solve(day+1,2));
    }
    return dp[day][flag] = maxi;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=3;j++)
        cin>>a[i][j];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
    return 0;
}

Measured memory_bytes: 9600
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()
print(2**len("{:b}".format(H))-1)


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


int main(){

    int ans = 0;
    int K,S = 0;
    cin >> K >> S;
    int Z;


    for(int X =0; X<=K; X++){
        for(int Y=0; Y<=K; Y++){
            Z = S - (X + Y);
            if(0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

const int MAXN = 200100;
int n, k, p[MAXN];

long long dp[MAXN];

int main() {
	scanf("%d",&n);
	scanf("%d",&k);
	for (int i = 0; i < n; i++) scanf("%d",&p[i]);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = (1LL << 40);
		for (int j = i - 1; j >= max(0, i - k); j--) {
			dp[i] = min(dp[i], dp[j] + max(p[i] - p[j], p[j] - p[i]));
		}
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}

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


using namespace std;
using ll = long long;

int main() {
	char komoji[] = { 'a',

	'b',
	'c',
	'd',
	'e',
	'f',
	'g',
	'h',
	'i',
	'j',
	'k',
	'l',
	'm',
		'n',
		'o',
		'p',
		'q',
		'r',
		's',
		't',

		'u',
		'v',
		'w',
		'x',
		'y',

		'z' };

	char x;
	cin >> x;
	for (int i = 0;i < 26;i++) {
		if (x == komoji[i]) {
			cout << "a\n";
			return 0;
		}
	}
	cout << "A\n";

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,in[N],rem[N];
vector <int> e[N];
int dfs(int x,int pre){
	int s=0;
	for (auto y : e[x])
		if (y!=pre){
			if (dfs(y,x))
				return 1;
			s+=rem[y];
		}
	if (s>1)
		return 1;
	rem[x]=!s;
	return 0;
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int a=read(),b=read();
		e[a].push_back(b);
		e[b].push_back(a);
		in[a]++,in[b]++;
	}
	if (n==2)
		return puts("Second"),0;
	int rt=0;
	for (int i=1;i<=n;i++)
		if (in[i]>1)
			rt=i;
	puts(dfs(rt,0)?"First":"Second");
	return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;

int main()
{
     int N,K;
     cin >> N >> K;
     int res;
     int m;
     for(int i=0 ; i<N ;i++){
         cin>>m;
         res+=2*min(m,K-m);
     }  
     cout << res;
} 


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

int main() {
  int n;cin>>n;
  int ans=0,a=1;
  for(int i=1;i<=n;i++){
    int t=i,cnt=0;
    while(t>0){
      if(t%2==0)cnt++;
      t/=2;
    }
    if(ans<cnt){
      ans=cnt;
      a=i;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3612
import math
def comb(n, k):
    if n < 0 or k < 0 or n < k: return 0
    return math.factorial(n) // math.factorial(n-k) // math.factorial(k)



n,k = map(int, input().split())
MOD = 10 ** 9 + 7
print(comb(k, n) % MOD)



Measured memory_bytes: 5668
t = list(str(input()).split(" "))
n = int(t[0])
m = int(t[1])

x = [list() for i in range(n)]
lst = list()

for i in range(m):
    t = list(str(input()).split(" "))
    a = int(t[0])
    b = int(t[1])
    x[a-1].append(b-1)
    x[b-1].append(a-1)

def depth(p):

    if(len(lst) == n-1):
        global c
        c = c+1

    else:
        for i in x[p]:
            if(i not in lst):
                lst.append(p)
                depth(i)
                lst.remove(p)

c = 0
depth(0)
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,m,dp[3005][3005][2],mod=1e9+7,ans;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++) dp[0][i][0]=1;
    dp[0][0][1]=1;
    for(int i=1;i<=m;i++){
        for(int j=0;j<=n;j++){
            if(j>1){
                dp[i][j][0]+=dp[i-1][j][0]+dp[i-1][j-1][0];
                if(n-j) dp[i][j][0]+=dp[i-1][j][0]+dp[i-1][j+1][0];
                dp[i][j][1]+=dp[i-1][j][1]+dp[i-1][j-1][1];
                if(n-j) dp[i][j][1]+=dp[i-1][j][1]+dp[i-1][j+1][1];
            }
            else if(j==1){
                dp[i][j][0]+=dp[i-1][j-1][0];
                if(n-j) dp[i][j][0]+=dp[i-1][j][0]+dp[i-1][j+1][0];
                dp[i][j][1]+=dp[i-1][j][1]+dp[i-1][j-1][1]+dp[i-1][j][0];
                if(n-j) dp[i][j][1]+=dp[i-1][j][1]+dp[i-1][j+1][1];
            }
            else{
                dp[i][j][1]+=dp[i-1][j+1][0]+dp[i-1][j][1]+dp[i-1][j+1][1];
            }
            dp[i][j][0]%=mod;
            dp[i][j][1]%=mod;
            //cout << dp[i][j][0] << ' ' << dp[i][j][1] << '\n';
        }
    }
    for(int i=0;i<=n;i++){
        ans+=dp[m][i][1];
    }
    cout << ans%mod;
}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

int d[2505];
bool from1[2505];
bool toN[2505];
bool root[2505];
vector<vector<int>> TO(2505);
vector<vector<int>> OT(2505);

void dfs(int v){
    if(from1[v])return;
    from1[v]=true;
    for(int u:TO.at(v)){
        dfs(u);
    }
}
void rdfs(int v){
    if(toN[v])return;
    toN[v]=true;
    for(int u:OT.at(v)){
        rdfs(u);
    }
}

int main() {
    int N,M,P;
    cin>>N>>M>>P;
    vector<edge> edges;
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        c-=P;
        c=-c;
        struct edge add;
        add.from=a;
        add.to=b;
        add.cost=c;
        edges.push_back(add);
        TO.at(a).pb(b);
        OT.at(b).pb(a);
    }

    rep(i,N)d[i]=1001001001;
    d[0]=0;

    rep(i,N)from1[i]=false;
    dfs(0);
    rep(i,N)toN[i]=false;
    rdfs(N-1);
    rep(i,N)root[i]=from1[i] & toN[i];

    rep(i,N){
        rep(j,sz(edges)){
            struct edge e=edges[j];
            if(d[e.to]>d[e.from]+e.cost){
                if(!root[e.to])continue;
                d[e.to]=d[e.from]+e.cost;
                if(i==N-1){
                    cout<<-1<<endl;return 0;
                }
            }
        }
    }

    int ans=-d[N-1];
    cout<<max(ans,0)<<endl;

/*rep(i,N)cout<<from1[i]<<" ";
cout<<endl;
rep(i,N)cout<<toN[i]<<" ";
cout<<endl;
rep(i,N)cout<<root[i]<<" ";

rep(i,N){
    cout<<"{";
    rep(j,TO.at(i).size()){
        cout<<TO.at(i).at(j)<<" ";
    }
    cout<<"}";
}
rep(i,N){
    cout<<"{";
    rep(j,OT.at(i).size()){
        cout<<OT.at(i).at(j)<<" ";
    }
    cout<<"}";
}*/

    return 0;
}


Measured memory_bytes: 640
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
MOD = 10**9+7

grid = []
grid.append("#"*(w+2))
for _ in range(h):
    grid.append("#" + ns() + "#")
grid.append("#"*(w+2))

ans = [[0]*(w+2) for _ in range(h+2)]
ans[1][1] = 1
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j] == "." and (i,j) != (1,1):
            ans[i][j] = ans[i-1][j] + ans[i][j-1]
            ans[i][j] %= MOD
            
print(ans[h][w])

Measured memory_bytes: 52720
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S,T;
  cin>>S>>T;
  int flag=1;
  for(int i=0;i<S.size();i++)if(S[i]!=T[i]){flag=0;break;}
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;
const int INF = (int) (1e9) + 5;
int main(){
  FASTER;
  int n;
  cin >> n;
  vector<int>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  vector<int> dp(n, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j <= i + 2; j++){
      if (j < n){
        dp[j] = min(dp[j], dp[i] + abs(ar[i] - ar[j]));
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    
    print((N+1) // 2)
    
    return


if __name__ == '__main__':
    main()


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

int main() {
    int K, S, ans = 0;
    cin >> K >> S;
    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            if (x + y > S) break;
            else if (S - x - y <= K) ++ans;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
const int MAX = 500000;

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

int main()
{
	int n;
	cin >> n;
	map<ll, ll> _map;
	vecll a(n);
	rep(i, n)
	{
		cin >> a[i];
		_map[a[i]]++;
	}
	ll sum = 0;
	for (auto x : _map)
	{
		sum += x.second * (x.second - 1) / 2;
	}
	for (auto i = 0; i < n; i++)
	{
		cout << sum - _map[a[i]] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 12728
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int w = scan.nextInt(),
        h = scan.nextInt(),
        x = scan.nextInt(),
        y = scan.nextInt(),
        r = scan.nextInt();
    if ((r <= x && x <= w - r) && (r <= y && y <= h - r)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

int main()
{
    int X;
    cin >> X;
    if (X >= 400 && X <= 599)
    {
        cout << "8" << endl;
    }
    else if (X >= 600 && X <= 799)
    {
        cout << "7" << endl;
    }
    else if (X >= 800 && X <= 999)
    {
        cout << "6" << endl;
    }
    else if (X >= 1000 && X <= 1199)
    {
        cout << "5" << endl;
    }
    else if (X >= 1200 && X <= 1399)
    {
        cout << "4" << endl;
    }
    else if (X >= 1400 && X <= 1599)
    {
        cout << "3" << endl;
    }
    else if (X >= 1600 && X <= 1799)
    {
        cout << "2" << endl;
    }
    else if (X >= 1800 && X <= 1999)
    {
        cout << "1" << endl;
    }
    return 0;
}

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

int N, M;
bool path[10][10];
bool used[10];
int ans = 0;

void dfs(int n) {
  bool all_used = true;
  for (int i=0; i<N; i++) {
    if (!used[i]) all_used = false;
  }
  if (all_used) ans++;

  for (int i=1; i<N; i++) {
    if (!path[n][i]) continue;  // 辺がなければcontinue
    if (used[i]) continue;      // 訪問済みであればcontinue
    used[i] = true;
    dfs(i);
    used[i] = false;
  }
}

int main() {
  cin >> N >> M;
  int a, b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    path[a-1][b-1] = path[b-1][a-1] = true;
  }
  used[0] = true;
  dfs(0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void)
{
unsigned long H,W;
  
  scanf("%ld %ld", &H, &W);
  if (H ==1 || W == 1) {
    printf("1\n");
  } else if (H*W % 2 == 0) {
    printf("%ld\n", H*W/2);
  } else {
    printf("%ld\n", (H*W)/2 + 1);
  }
  
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
}


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

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

    string S;
    cin >> S;
    string ans;
    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else ans = "Sunny";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <math.h>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i,n){
    cin >> h[i];
  }
  bool ans = true;
  h[0] -=1;
  for(int j=1;j<n-1;j++){
    if(h[j] <= h[j+1] && h[j] > h[j-1]){
      h[j] -= 1;
    }
    if(h[j] > h[j+1]){
      h[j] -=1;
    }
    if(h[j] < h[j-1]){
      ans = false;
    }
  }
  if(h[n-2] > h[n-1]){
    ans = false;
  }
  if(ans){
    cout << "Yes";
  } else {
    cout << "No";
  }
      
  
 
 return 0;
}

Measured memory_bytes: 640
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

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

const int INF = 1e9;

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

  vi a(3);

  rep(i,3)
    cin >> a[i];

  rvsort(a);

  cout << a[0] * 10 + a[1] + a[2];


  return 0;
}

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

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

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


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  int i,j,k,l,m,n,flag=0;
  char str[101];
  cin>>str;
  n = strlen(str);
  j=n-1;
  for(i=0;i<n/2;i++)
  {if(str[i]!=str[j])
  {
    flag++;
  }
    j--;
  }
  cout<<flag;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N; string S; cin >> N >> S;
    for (int i=0; i<S.length(); i++) {
        if (S[i]+N > 'Z')
            cout << (char)(S[i]+N-26);
        else
            cout << (char)(S[i]+N);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
submits = []
m.times do
  task, result = gets.split
  submits << [task.to_i, result]
end

ac = 0
acs = Hash.new {0}
tmp_penalties = Hash.new {0}
penalty = 0
now_task = 0


submits.each do |task, result|
  if result == 'AC'
    if acs[task.to_s.to_sym].zero?
      ac += 1
      acs[task.to_s.to_sym] = 1
      penalty += tmp_penalties[task.to_s.to_sym]
    end
  else
    tmp_penalties[task.to_s.to_sym] += 1
  end
end

puts "#{ac} #{penalty}"


Measured memory_bytes: 51196
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int L, R,   d;
    cin >> L >> R >> d;

    int ans = 0;
    for (int i = L; i <= R; i++){
        if (i % d == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620