akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

//5で割った余りが１の素数をn個出力する
int n;
vector<int>prime;
//primeに素数をぶち込む
void MakePrime(int n) {
	prime.emplace_back(2);
	for (int i = 3; i <= n; i += 2) {
		bool a = false;
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
}
int main() {
	cin >> n;
	MakePrime(55555);
	int cnt = 0;
	int pos = 0;
	while (cnt < n) {
		if (prime[pos] % 5 == 1) {
			if (cnt)cout << " ";
			cout << prime[pos];
			cnt++;
		}
		pos++;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int dp[214514];

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

  int ans = 0;
  rep(i, N) {
    int p;
    scanf("%d", &p);
    assert(dp[p] == 0);
    dp[p] = dp[p-1] + 1;
    ans = max(dp[p], ans);
  }
  printf("%d\n", N - ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ll fact[MAXN], invfact[MAXN];
ll expo( ll base, ll exp, ll m = MOD )
{
    ll res = 1;
    while( exp > 0 )
    {
        if( exp&1 )
        {
            res *= base;
            res = mod(res,m);
        }
        base *= base;
        base = mod(base,m);
        exp /= 2;
    }
    res = mod(res,m);
    return res;
}
ll modinv( ll base, ll m = MOD )
{
    return expo( base, m-2, m );
}
ll choose( ll n, ll k )
{
    if( k < 0 || k > n )
        return 0;
    ll ans = fact[n];
    ans = mod( ans * invfact[n-k] );
    ans = mod( ans * invfact[k] );
    return ans;
}
void add( ll &x, ll y )
{
    x += y;
    if( x >= MOD )
        x -= MOD;
}

int main() 
{
    fastio();

    fact[0] = invfact[0] = 1;
    for(int i=1;i<MAXN;i++)
    {
        fact[i] = mod( i * fact[i-1] );
        invfact[i] = modinv( fact[i] );
    }

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

    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        ll now = mod( choose(i,k-1) - choose(n-1-i,k-1) );
        now = mod( now * a[i] );
        add( ans, now );
    }
    cout<<ans,nl;


    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int main(){
    int x,y;

    cin >> x >> y;

    while ( x != 0 || y != 0){
        if (x > y){
            cout << y << " " << x << endl;
        } else {
            cout << x << " " << y << endl;
        }
        cin >> x >> y;
    }

    return 0;
}

Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int):
    return A * B - A - B + 1


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    result = solve(A, B)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;


uint32_t grundy(int n, int k)
{
	if (n < k) { return 0; }
	if (n%k == 0) { return n / k; }
	//return grundy(n - n / k - 1, k);
	auto rem = n % k;
	auto diff = n / k + 1;
	auto next = n;
	next -= ((rem+ diff-1) / diff)*diff;
	return grundy(next, k);

	//if (dp[n][k] != -1) { return dp[n][k]; }
	//std::bitset<1000> S;

	////Sに追加;
	//for (size_t i = 1; i <= n/k; i++)
	//{
	//	S[grundy(n - i, k)] = true;
	//}

	//for (int32_t i = 0; i < 1000; i++) {
	//	if (!S[i]) { return dp[n][k]= i; }
	//}
	//return 0;
}


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
int main()
{
	//fill_all(dp, -1);

	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	//for (size_t j = 1; j <= 50; j++)
	//{
	//		for (size_t i = 0; i < 50; i++)
	//	{
	//		out << grundy(i, j) << ' ';
	//	}
	//	out << endl;
	//}
	in >> N;
	uint32_t tmp = 0;
	for (int32_t i = 0; i < N; i++)
	{
		int32_t n, k;
		in >> n >> k;
		tmp ^= grundy(n, k);
	}
	if (tmp) {
		out << "Takahashi" << endl;
	}
	else {
		out << "Aoki" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 384
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

P = [K-Q for _ in range(N)]

for i in range(Q):
    P[A[i]-1] += 1

for i in P:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 57176
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    ll t[100010],a[100010];
    rep(i,n){
        cin>>t[i]>>a[i];
    }
    ll T=t[0],A=a[0];
    rep2(i,1,n){
        if(T<=t[i]&&A<=a[i]){
            T=t[i],A=a[i];
        }
        else{
            ll x[2],y[2];
            x[0]=(T/t[i]+(T%t[i]!=0))*t[i];
            y[0]=x[0]/t[i]*a[i];
            y[1]=(A/a[i]+(A%a[i]!=0))*a[i];
            x[1]=y[1]/a[i]*t[i];
            if(x[0]<T||y[0]<A){
                T=x[1],A=y[1];
            } else if(x[1]<T||y[1]<A){
                T=x[0],A=y[0];
            } else if(x[0]+y[0]<x[1]+y[1]){
                T=x[0],A=y[0];
            } else{
                T=x[1],A=y[1];
            }
        }
    }
    cout<<T+A<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long fact[2000015], invfact[2000015];
long long mod = 1e9 + 7;
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
long long inverse(long long a){
    return bigmod(a, mod - 2);
}
void precalc(){
    fact[0] = 1;
    invfact[0] = inverse(fact[0]);
    for(long long i = 1; i <= 2000005; i++){
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = inverse(fact[i]);
    }
}
long long nCr(long long n, long long m){
    long long ans = (fact[n] * invfact[m]) % mod;
    return (ans * invfact[n - m]) % mod;
}
int main(){
    precalc();
    long long n, k;
    cin >> n >> k;
    if(k >= n){
        k = n - 1;
    }
    long long ans = 0;
    for(long long i = 0; i <= k; i++){
        ans = (ans + nCr(n, i) * nCr(n - 1, i)) % mod;
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list.at(i);
  }
  for (int j = K; j < N; j++) {
    if (list.at(j - K) < list.at(j)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

int main() {
  char b;
  cin >> b;
  
  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  } else if (b == 'G') {
    cout << 'C' << endl;
  } else if (b == 'T') {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    string S;
    cin>>S;
    int N=S.size();
    //...RL...に人が集中する
    vector<int> count(N,0);
    int Rcount=0;
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            Rcount++;
        }else{
            count[i]+=Rcount/2;
            count[i-1]+=Rcount/2+(Rcount%2);
            Rcount=0;
        }
    }
    for(int i=N-1;i>=0;i--){
        if(S[i]=='L'){
            Rcount++;
        }else{
            count[i]+=Rcount/2;
            count[i+1]+=Rcount/2+(Rcount%2);
            Rcount=0;
        }
    }
    for(int i=0;i<N;i++){
        cout<<count[i];
        if(i==N-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    vector<vector<int>> matrix(n,vector<int>(m));
    vector<int> costs(n);

    for(int i=0;i<n;i++) {
        int c;
        cin>>c;
        costs[i]=c;
        for(int j=0;j<m;j++) {
            int num;
            cin>>num;
            matrix[i][j]=num;
        }
    }

    int all=1<<n;
    int ans=123456789;

    for(int mask=0;mask<all;mask++) {
        vector<int> levels(m);
        int total_cost=0;
        for(int i=0;i<n;i++) {
            if((mask>>i)&1) {
                total_cost+=costs[i];
                for(int j=0;j<m;j++) {
                    levels[j]+=matrix[i][j];
                }
            }
        }
        bool ok=true;
        for(int i=0;i<m;i++) {
            if(levels[i]<x) {
                ok=false;
            }
        }

        if(ok) {
            ans=min(ans, total_cost);
        }
    }
    if(ans==123456789) {
        cout<<-1<<endl;
    }
    else {
        cout<<ans<<endl;
    }

    

}




Measured memory_bytes: 3656
mod = 10 ** 9 + 7

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

A = [0] + [pow(K // x, N, mod) for x in range(1, K + 1)]
for x in reversed(range(1, K + 1)):
    for i in range(2, K // x + 1):
        A[x] -= A[i * x]

print(sum(i * a for i, a in enumerate(A)) % mod)

Measured memory_bytes: 12156
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;


const ll mod = 1000000007;


long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return pow_mod(a, mod - 2, mod);
}

int nikou(ll n, ll k){
    ll ans = 1;
    for(int kk = 1; kk <= k; kk++){
        ans *= (((n - kk + 1) % mod) * modinv(kk,mod)) % mod;
        ans %= mod;
    }
    return ans % mod;
}

int main()
{
    ll n,a,b;
    std::cin >> n >> a >> b;
    ll ans = pow_mod(2,n,mod);
    ans--;
    ans -= nikou(n,std::min(n - b,b));
    if(ans < 0)ans += mod;
    //std::cout << nikou(n,std::min(n - a,a)) << std::endl;
    ans -= nikou(n,std::min(n - a,a));
    if(ans < 0)ans += mod;
    std::cout << ans <<std::endl;



}


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

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;

    int n = s.size();
    string ans = "No";
    for (int i = 0; i < n; i++){
        rotate(s.begin(), s.begin() + 1, s.end());
        if (s == t){
            ans = "Yes";
            break;
        }
    }

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

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

const int MAXV = 100010;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a;
    cin >> a;
    
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    
    
    return 0;
}


Measured memory_bytes: 4172
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp;
    int s;
    foreach (c; N) s += (c - '0').to!int;
    writeln(s%9 == 0 ? "Yes" : "No");
}

Measured memory_bytes: 3012
#include<iostream>
using namespace std;
int main(){
    int r,c;
    cin >> r >> c;
    int a,b;
    int s=0;
    int t[r+1][c+1];
    int l,k;
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            t[i][j]=0;
        }
    }
    for(k=0;k<r;k++){
        for(l=0;l<c;l++){
            cin >> t[k][l];
            a = a + t[k][l];
            cout << t[k][l] << " "; 
        }
        cout << a << endl;
        
        a=0;
    }
    for(k=0;k<c;k++){
        for(l=0;l<r;l++){
            b=b+t[l][k];
        }cout << b << " ";
        s+=b;
        b=0;
    }
    
    cout << s << endl;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <stdbool.h>
#define PI 3.141592653589
#define N_MAX 100

int main()
{
  int m, f, r, s;
  while(1)
    {
      scanf("%d %d %d", &m, &f, &r);
      if(m == -1 && f == -1 && r == -1) break;
      s = m + f;
      if(m == -1 || f == -1) printf("F\n");
      else if(s >= 80) printf("A\n");
      else if(s >= 65) printf("B\n");
      else if(s >= 50 ||(s >= 30 && r >= 50)) printf("C\n");
      else if(s >= 30) printf("D\n");
      else printf("F\n");
    }
  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<random>

//#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define ALL(v) (v).begin() , (v).end()
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long
const int mod = 1e9 + 7;
void solve(){

	int n , k;
	cin>>n>>k;
	int a[n];
	for(int i = 0 ;  i < n ; ++i)
		cin>> a[i] ;

	int dp[k+2];
	memset(dp , 0 , sizeof dp);
	dp[0] = 1;
	for(int i = 0 ; i < n ; ++i){

		int x = a[i];
		int tmp[k+2];
		memset(tmp , 0 , sizeof tmp);
		for(int j = k ; j >= 0 ; --j){

			int val = dp[j];
			int left = j + 1;
			int right = j + x;
			right = min(right , k);

			tmp[left] += val;
			tmp[right + 1]-=val;
		}

		for(int j = 1 ; j <= k ; ++j){

			tmp[j] += tmp[j-1];
			dp[j] += tmp[j];
			dp[j]%=mod;
		}
	}

	cout<<dp[k]<<endl;
}

signed main(){

    fast;
    //freopen("output.txt" , "w" , stdout);
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 1920
#include<cstdio>
#include<vector>
#include<algorithm>
#define MN 2100001
using namespace std;
 
int n,m,a[MN],x,y,fa[MN],s[MN],d[MN]; 
vector<int> v[MN];
void dfs(int x,int f){
fa[x]=f;s[x]=1;
    for (int i=0;i<v[x].size();i++)
    if (v[x][i]!=f){
        d[v[x][i]]=d[x]+1;
        dfs(v[x][i],x);
        s[x]+=s[v[x][i]];
    }
}
int main(){
    scanf("%d",&n);
    for (int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        v[x].push_back(y);v[y].push_back(x);
    }
    dfs(1,0);
    x=n;y=d[x]-(d[x]-1>>1);
    while (d[x]!=y) x=fa[x];
    if (n-s[x]>s[x]) puts("Fennec");else puts("Snuke");
}

Measured memory_bytes: 66944
main = do
    fs <- getLine
    ss <- getContents
    let ls = lines ss
    let initBlds = replicate 4 initBld
    let finBlds = visitBlds initBlds ls
    printBlds finBlds

printBlds [] = return ()
printBlds [x] = printBld x
printBlds (x:xs) = do
    printBld x
    putStrLn "####################"
    printBlds xs

printBld bld = mapM_ putStrLn $ showBld bld

visitBlds :: [Bld] -> [String] -> [Bld]
visitBlds blds [] = blds
visitBlds blds (x:xs) = visitBlds (visitBldLine blds x) xs

visitBldLine :: [Bld] -> String -> [Bld]
visitBldLine blds line = visitBld blds b f r v
  where
    ns = map (\x -> read x :: Int) $ words line
    b = ns!!0
    f = ns!!1
    r = ns!!2
    v = ns!!3

visitBld :: [Bld] -> Int -> Int -> Int -> Int -> [Bld]
visitBld blds b f r v = map (\(bldNo, bld) -> if bldNo == b then visitFloor bld f r v else bld) $ zip [1..] blds
  where
    visitFloor floors f r v = map (\(lv, floor) -> if lv == f then visitRoom floor r v else floor) $ zip [1..] floors
    visitRoom rooms r v = map (\(roomNo, room) -> if roomNo == r then room+v else room) $ zip [1..] rooms


type Bld = [[Int]]

initBld :: Bld
initBld = replicate 3 $ replicate 10 0

showBld :: Bld -> [String]
showBld = map concat . map (map (\n -> ' ':show n))



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

int main(){
  int n;
  cin>>n;
  cout<<2*n-1<<endl;
  int a[55];
  int ma=0,ma_i=0;
  rep(i,n){
    cin>>a[i];
    if(abs(a[i])>abs(ma)){
      ma=a[i];
      ma_i=i;
    }
  }
  rep(i,n){
    a[i]+=ma;
    cout<<ma_i+1<<' '<<i+1<<endl;
  }
  if(ma>=0)
    rep(i,n){
      if(i>0){
	a[i]+=a[i-1];
	cout<<i<<' '<<i+1<<endl;
      }
    }
  else
    for(int i=n-1;i>=0;i--){
      if(i<n-1){
	a[i]+=a[i+1];
	cout<<i+2<<' '<<i+1<<endl;
      }
    }
  return 0;
}




Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split(' '))))
# print(A)
a_max = A[-1]
dp = [True]*(a_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[p] == True:
        # print(math.sqrt(p))
        for q in range(a_max//p+1):
            # print(p*q)
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[A[-1]]:
    ans += 1
print(ans)


Measured memory_bytes: 32196
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

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

ll lcm(ll a, ll b) {
    ll temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main(void)
{
    ll N;
    cin >> N;
    ll ret = 1;
    REP(n,N) {
        ll a;
        cin >> a;
        ret = lcm(ret, a);
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, h;
    cin >> n >> h;
    int maxe = 0;
    vector<int> b(n);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a >> b[i];
        chmax(maxe, a);
    }
    sort(b.begin(), b.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] <= maxe)    break;
        h -= b[i];
        ++ans;
        if(h <= 0){
            cout << ans << endl;
            return 0;
        }
    }
    ans += ceil((double)h / maxe);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	string ans = "No";
	for (int i = 0; i <= N; i++) {
		if (i * 2 + (N - i) * 4 == M)
			ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    ll a, b, c;
    while(cin>>a>>b>>c){
        ll ans=0;
        ll tmp1=c-a-b;
        ll tmp2=4*a*b;
        if(tmp1<0){
        	printf("No\n");
        }
        else{
        	tmp1*=tmp1;
        	// cout<<tmp1<<" "<<tmp2<<endl;
        	if(tmp2<tmp1){
        		printf("Yes\n");
        	}
        	else{
        		printf("No\n");
        	}
        }
    }
  return 0;
}




Measured memory_bytes: 256
n,k = map(int,input().split())

t = list(map(int,input().split()))

memo = [0]*(n+1)

for i in range(n):
    memo[i+1] = t[i]

move = 1

count = 0

check = [0]*(n+1)

while check[move] == 0 and count < k-1:
    check[move] += 1
    move=memo[move]
    count += 1

if k == count:
    print(memo[move])
else:
    count2 = 0
    check = [0]*(n+1)
    move_log = []
    while check[move] == 0:
        move_log.append(move)
        check[move] += 1
        move=memo[move]
        count2 += 1
    print(move_log[(k-count)%count2])

Measured memory_bytes: 96724
from math import factorial
import itertools
n,d =map(int,input().split())
x=[]
cnt=0
n_lis = [i for i in range(n)]
n_list = list(itertools.combinations(n_lis, 2))
for i in range(n):
    tmp = list(map(int,input().split()))
    x.append(tmp)
    
for index1, index2 in n_list:
    if d != 1:
        dist = 0
        for ind in range(d):
            dist += (x[index1][ind]-x[index2][ind])**2
        if int(dist **(1/2)) == dist **(1/2):
            cnt+=1
    if d == 1:
        cnt = int(factorial(n) / factorial(2) / factorial(n - 2))

print(cnt)

Measured memory_bytes: 3064
s = input()
k = int(input())
m = 0
j = 0
if len(set(list(s))) == 1:
    print((len(s) * k) // 2)
    exit()
for i in range(len(s)):
    if len(s) <= j + 1:
        a = m * k
        if s[0] == s[-1] == s[len(s) // 3]:
            print(a + k - 1)
        else:
            print(a)
        break
    if s[j] == s[j + 1]:
        m += 1
        j += 1
    j += 1

Measured memory_bytes: 3064
// 2019/07/10
// AtCoder Beginner Contest 087 - A

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // Input
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans;

        // Calc
       ans = (x - a) % b;
       
       // Output
       System.out.println(ans);
    }
}

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

int main() {
	string s, t;
	cin >> s >> t;
	string ans = "Yes";
	if(t.substr(0, s.size()) != s) ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int nn = n;
  int sum = 0;
  while(nn){
    sum += nn % 10;
    nn /= 10;
  }
  if(n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>

using namespace std;

const int inf = 1e9;

struct edge{int to,cost;};
typedef pair<int,int> P;

int V;
vector<edge> g[100000];
int d[100000];

int main(){
	int e,r;
	cin >> V >> e >> r;
	for(int i = 0;i < e;i++){
		int f;
		edge te;
		cin >> f >> te.to >> te.cost;
		g[f].push_back(te);
	}

	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d + V,inf);
	d[r] = 0;
	que.push(P(0,r));
	
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < g[v].size();i++){
			edge e = g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}

	for(int i = 0;i < V;i++){
		if(d[i] == inf) cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 13072
K = int(input())
A = list(map(int, input().split()))

mx = 2
mi = 2

for a in A[:: -1]:
    mx = (-(-(mx + 1) // a)) * a - 1
    mi = (-(-mi // a)) * a

def isOk(x):
    for a in A:
        x = (x // a) * a
    return x == 2

if isOk(mi) and isOk(mx):
    print(mi, mx)
else:
    print(-1)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
ll n, q;
vector<vector<ll>> to(n);
vector<bool> seen(n);
vector<ll> score(n);
vector<ll> ans(n);

void dfs(ll node, ll num){
    seen[node] = true;
    ans[node] = num;

    for(ll next : to[node]){
        if(seen[next]){
            continue;
        }else{
            dfs(next, num + score[next]);
        }
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    cin >> n >> q;
    to.resize(n);
    rep(i, n-1){
        ll a, b; cin >> a >> b; a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    score.resize(n);
    rep(i, q){
        ll p, x; cin >> p >> x; p--;
        score[p] += x;
    }

    seen.resize(n);
    ans.resize(n);
    dfs(0, score[0]);

    rep(i, ans.size()){
        cout << ans[i] << " ";
    }
    br;


}

Measured memory_bytes: 26672
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

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())


n = ni()
a = list(li())
lst = []
for i in range(n):
    lst.append((i, a[i]))

lst.sort(key=lambda x: x[1])

ans = []
for i, _ in lst:
    ans.append(i+1)

print(*ans)

Measured memory_bytes: 24040
#include<stdio.h>

int main(void){
    int i, j, k;

    int score = 0;//満足度

    int d;//何日開催するのか
    scanf("%d", &d);

    int c[26];//各コンテストのペナルティ値
    for(i=0;i<26;i++) scanf("%d", &c[i]);

    int s[d][26];//コンテストiをD日目に開催したときの得点
    for(i=0;i<d;i++) for(j=0;j<26;j++) scanf("%d", &s[i][j]);

    int last[26];//各コンテストを最後に開催したのは何日目か
    for(i=0;i<26;i++) last[i] = 0;

    int holding[d];//D日目にコンテストiを開催する
    //初期解
    int max_i, max_sum, tmp;
    for(i=0;i<d;i++){//今日=i、今日の終わり=i+1
        max_i = 0;
        max_sum = 0;
        for(j=0;j<26;j++){
            tmp = s[i][j] - c[j] * ( i+1 - last[j] );
            if( max_sum < tmp ){
                max_sum = tmp;
                max_i = j;
            }
        }
        last[max_i] = i+1;
        holding[i] = max_i + 1;
        //score += s[i][max_i];
        //for(j=0;j<26;j++) score -= c[j] * ( i+1 - last[j] );
    }

    //局所探索法

    //出力
    for(i=0;i<d;i++) printf("%d\n", holding[i]);
    //printf("%d\n", score);

    return 0;
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    
    const int M = 1e5 + 1;
    vi hist(M);
    for(auto& e : a) hist[e]++;

    int res = 0;
    rep(i, 1, M-1){
        chmax(res, hist[i-1] + hist[i] + hist[i+1]);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
class P
{
    static int n;
    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        int m = int.Parse(Console.ReadLine());
        int[][] k = new int[n][];
        for (int i = 0; i < n; i++)
        {
            k[i] = new int[n];
            for (int j = 0; j < n; j++)
            {
                if (i == j)
                {
                    k[i][j] = 0;
                    continue;
                }
                k[i][j] = int.MaxValue / 50;
            }
        }
        string[] str;
        for (int i = 0; i < m; i++)
        {
            str = Console.ReadLine().Split(',');
            int a, b, c, d;
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);
            d = int.Parse(str[3]);
            k[a - 1][b - 1] = c;
            k[b - 1][a - 1] = d;
        }
        str = Console.ReadLine().Split(',');
        int s, g, v, p;
        s = int.Parse(str[0]);
        g = int.Parse(str[1]);
        v = int.Parse(str[2]);
        p = int.Parse(str[3]);
        FloydWarshall(ref k);
        Console.WriteLine(v - p - k[s - 1][g - 1] - k[g - 1][s - 1]);
    }
    static void FloydWarshall(ref int[][] K)
    {
        for (int k = 0; k < n; k++)
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (K[i][j] > K[i][k] + K[k][j])
                        K[i][j] = K[i][k] + K[k][j];
    }
}


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

int main(){
  ll H,cnt=0,ans=0;
  cin >> H;
  while(H>1){
    H=H/2;
    cnt++;
  }
  
  cout << ll(pow(2,cnt+1)-1) << endl;
  return 0; 
}

Measured memory_bytes: 4112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll x, y, z, k, a[1010], b[1010], c[1010];
vector<ll> vec, G;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < y; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < z; i++)
	{
		cin >> c[i];
	}
	sort(a, a + x), reverse(a, a + x);
	sort(b, b + y), reverse(a, a + x);
	sort(c, c + z), reverse(a, a + x);
	for (int i = 0; i < x; i++)
	{
		for (int j = 0; j < y; j++)
		{
			vec.push_back(a[i] + b[j]);
		}
	}
	sort(vec.begin(), vec.end()), reverse(vec.begin(), vec.end());
	for (int i = 0; i < min(x * y, k); i++)
	{
		for (int j = 0; j < z; j++)
		{
			G.push_back(vec[i] + c[j]);
		}
	}
	sort(G.begin(), G.end()), reverse(G.begin(), G.end());
	for (int i = 0; i < k; i++)
	{
		cout << G[i] << endl;
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 43364
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

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

    vi a(n);
    rep(i, 0, n) cin >> a[i];

    sort_v(a);
    cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back


char A[200005];
int ans=0;
int cnt[30];
signed main(){
    
    scanf("%s",A);
    int N=strlen(A);
    ans+= 1+(N*(N-1)/2 );
    rep(i,N){
        cnt[A[i]-'a']++;
    }
    rep(i,26){
        int K=cnt[i];
        ans-=K*(K-1)/2;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll mod=1e9+7;
ll pt( ll a, int b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll sil[200005], odw[200005];
ll dp[200005][2];
ll d[200005][2];
int n;
vector < pair < pair < int ,int > , int > > p;
ll newton( int a, int b)
{
	ll res=sil[a];
	res=(res*odw[b])%mod;
	res=(res*odw[a-b])%mod;
	return res;
}
bool cmp( pair < pair < int, int > , int > a , pair < pair < int, int >  , int > b)
{
	if(a.first.first!=b.first.first)
		return b.first.first>a.first.first;
	else
		return b.first.second>a.first.second;
}
bool cmp2( pair < pair < int, int > , int > a, pair < pair < int, int > , int > b )
{
	if(a.first.first!=b.first.first)
		return a.first.first>b.first.first;
	else
		return a.first.second>b.first.second;
}
int h,w;
int main(){
	sil[0]=odw[0]=1;
	for(int i=1;200000>=i;i++)
	{
		sil[i]=sil[i-1]*i%mod;
		odw[i]=pt(sil[i],mod-2);
	}
	cin>>h>>w>>n;
	for(int i=0;n>i;i++)
	{
		int a,b;
		cin>>a>>b;
		p.push_back({{a,b},i});
	}
	sort(p.begin(),p.end(),cmp);
	for(int i=0;n>i;i++)
	{
		int x=p[i].first.first;
		int y=p[i].first.second;
		dp[i][0]=newton(x+y-2,x-1);
		for(int j=0;i>j;j++)
			dp[i][0]=(dp[i][0]-(dp[j][0]*newton(x+y-p[j].first.first-p[j].first.second,x-p[j].first.first))%mod+mod)%mod;
		d[p[i].second][0]=dp[i][0];
	}
	sort(p.begin(),p.end(),cmp2);
	for(int i=0;n>i;i++)
	{
		int x=p[i].first.first;
		int y=p[i].first.second;
		dp[i][1]=newton(h+w-x-y,h-x);
		for(int j=0;i>j;j++)
			dp[i][1]=(dp[i][1]-(dp[j][1]* newton ( x+y-p[j].first.first-p[j].first.second, x-p[j].first.first))%mod+ mod )%mod;
		d[p[i].second][1]=dp[i][1];
	}
	ll out=newton(h+w-2,h-1);
	for(int i=0;n>i;i++)
		out=(out-(d[i][0]*d[i][1])%mod+mod)%mod;
	cout<<out;
	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 1000000007;
using namespace std;
using ll = long long;
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 dp[105][10005] = {};
int v[105],w[105];
int n,W;
int napsuck(){
    rep(i,n+1){
        rep(j,W+1){
            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]);
        }
    }
}
int main(){
    cin >> n >> W;
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    napsuck();
    PRINT(dp[n][W]);
}



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

int main() {
    int ans=1, N;   
    cin >> N;
    for(int i=1;i<=1000 ; i++){
	for(int j=2; j<=1000; j++){
	    if((int)pow(i, j) <=N)
		ans = max(ans, (int)pow(i, j));
	}
    }
    cout << ans<< endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<intt>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return (n*fact(n-1))%mod;
}

void go()
{
#ifndef ONLINE_JUDGE
  freopen("IN.txt","r",stdin);
  freopen("OUT.txt","w",stdout);
  #endif
}

int main(){
	go();
	fast_io
  int n;cin>>n;
  vector<ii> pa(n);
  for0(i,n){
    cin>>pa[i].ff;
    cin>>pa[i].ss;
  }
  bool yes=0;
  for0(i,n){
    if(pa[i].ff==pa[i].ss){
      if(i+2<n){
        if(pa[i+1].ff==pa[i+1].ss && pa[i+2].ff==pa[i+2].ss){
          yes=1;
          break;
        }
      }
    }
  }
  if(yes)
    cout << "Yes" <<"\n";
  else
    cout <<"No" <<"\n";
}





































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

using namespace std;

int top = 0, tot = 1;
int e[2000001], nxt[2000001], g[10001];
bool vis[10001];
int c[10001];
int cnt[2];

int a[1001][1001];
void add(int u, int v) {
	e[tot] = v; nxt[tot] = g[u]; g[u] = tot ++;
	e[tot] = u; nxt[tot] = g[v]; g[v] = tot ++;
}
bool ok;
bool dp[1001];
pair<int, int> stk[10001];
int n, m;
void dfs(int x, int col) {
	vis[x] = true;
	c[x] = col; cnt[col] ++;
	for (int i = g[x]; i; i = nxt[i]) {
		if (vis[e[i]]) {
			if (c[e[i]] == col) ok = true;
		}
		else {
			dfs(e[i], col ^ 1);
		}
	}
}
bool tmp[1001];
int main( ) {
	int x, y;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; i ++) {
		scanf("%d %d", &x, &y);
		if (x > y) swap(x, y);
		a[x][y] = true;
	}
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			if (a[i][j] == false) add(i, j);
	for (int i = 1; i <= n; i ++)
		if (!vis[i]) {
			cnt[0] = cnt[1] = 0;
			dfs(i, 0);
			if (ok) break;
			stk[++ top] = make_pair(cnt[0], cnt[1]);
		}
	if (ok) printf("-1\n");
	else {
		dp[0] = true;
		for (int i = 1; i <= top; i ++) {
			for (int j = 0; j <= n; j ++) tmp[j] = dp[j], dp[j] = false;
			for (int j = n; j >= stk[i].first; j --)
				dp[j] |= tmp[j - stk[i].first];
			for (int j = n; j >= stk[i].second; j --)
				dp[j] |= tmp[j - stk[i].second];
		}
		int idx = 0;
		for (int i = 0; i <= n / 2; i ++)
			if (dp[i]) idx = i;
		int idy = n - idx;
		printf("%d\n", idx * (idx - 1) / 2 + idy * (idy - 1) / 2);
	}
	return 0;
}


Measured memory_bytes: 10368
def f1(a)
  [a / (8/100r), (a + 1) / (8/100r)]
end

def f2(b)
  [b / (10/100r), (b + 1) / (10/100r)]
end

def find(a1, a2)
  bgn = [a1[0], a2[0]].max
  ed = [a1[1], a2[1]].min
  f = if ed == ed.floor
    bgn.ceil < ed
  else
    bgn.ceil <= ed.floor
  end
  f ? bgn.ceil : -1
end

a, b = gets.split.map(&:to_i)
puts find(f1(a), f2(b))

Measured memory_bytes: 1788
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

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

	if(a+b>= c){
		ans="Yes";
	}else{
		ans="No";
	}

	printf("%s", ans);

	return 0;
}

Measured memory_bytes: 128