akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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;
	}
}
int COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, m;
vector<int>sets[114514];
signed main() {
	int ans = 0;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c;
		uf.unite(a - 1, b - 1);
	}
	rep(i, n)sets[uf.find(i)].push_back(i);
	rep(i, 114514) {
		if (sets[i].size())ans++;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 9856
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}

Measured memory_bytes: 1152
def f(s,K):
 if K==0:
  return s,"",0
 res=0
 str=""
 for i in range(len(s)-1):
  if s[i]=="a":
   str+="a"
   res+=1
   continue
  if K>=123-ord(s[i]):
   str+="a"
   res+=1
   K-=123-ord(s[i])
  else:
   break
 if res==0:
  skip=0
  for skip in range(len(s)):
   if K>=123-ord(s[skip]):
    break
  return s[:skip],s[skip:],K
 return str,s[res:],K

ss=input()
KK=int(input())
sol=""
while len(ss)>1:
 x,ss,KK=f(ss,KK)
 sol+=x
if len(ss)==1:
 KK%=26
 if ord(ss[0])+KK<123:
  sol+=chr(ord(ss[0])+KK)
 else:
  sol+=chr(ord(ss[0])+KK-26)
print(sol)

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

int main() {
  bool f1 = false,f4 = false,f7 = false,f9 = false;
  rep(i,4){
    int a;
    cin >> a;
    if(a == 1) f1 = true;
    if(a == 4) f4 = true;
    if(a == 7) f7 = true;
    if(a == 9) f9 = true;
  }
  if(f1 && f4 && f7 && f9) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
from math import ceil
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
CA = Counter(A)
SCA = sorted(CA.items(), key=lambda x:x[0])

if len(CA) != ceil(N / 2):
  print(0)
  exit()

if N % 2 == 0:
  for i, j in zip(SCA, range(ceil(N / 2))):
    if not (i[0] == 1 + j * 2 and i[1] == 2):
      print(0)
      exit()
else:
  for i, j in zip(SCA, range(ceil(N / 2))):
    if j == 0:
      if not (i[0] == j * 2 and i[1] == 1 ):
        print(0)
        exit() 
    else:  
      if not (i[0] == j * 2 and i[1] == 2 ):
        print(0)
        exit()
print((2 ** (N // 2)) % (10 ** 9 + 7))

Measured memory_bytes: 58860
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A):
    c = Counter(A)
    N = len(A)
    s = 0
    for v in c.values():
        s += v*(v-1)//2

    return N*(N-1)//2 - s + 1


def main():
    A = read_str()
    # A = '0'*20000
    print(slv(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k, a[100010];
vector<int> vec[100010];
int ans;

int dfs(int v, int p) {
	int res = 0;
	for (int i = 0; i < (int)vec[v].size(); i++) {
		if (vec[v][i] == p)continue;
		res = max(res, dfs(vec[v][i], v));
	}
	if (res == k - 1) {
		if (p > 1)ans++;
		return 0;
	}
	return res + 1;
}

signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i != 1)vec[a[i]].push_back(i);
	}
	if (a[1] != 1)ans++;
	dfs(1, 0);
	cout << ans << endl;
}







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

using namespace std;

int main(){
	char input[100];
	bool is_find_C = false;
	int C_pos;
	cin >> input;
	int len = strlen(input);
	for(int i = 0; i < len; i++){
		if(input[i] == 'C'){
			is_find_C = true;
			C_pos = i;
			break;
		}
	}
	if(is_find_C){
		for(int i = C_pos; i < len; i++){
			if(input[i] == 'F'){
				cout << "Yes";
				return 0;
			} else {
				
			}
		}
	}
	cout << "No";
	return 0;
}

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

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

long long MOD=1000000007;

int main(){
    int N,K; // N:個数　K:これ以上選ぶ
    cin>>N>>K;
    long ans=0;
    for(long i=K;i<=N;i++){
        long minv=(i-1)*i/2;
        long maxv=(N+N-i+1)*i/2;
//        cout<<maxv<<" "<<minv<<endl;
        ans=(ans+(maxv-minv+1)%MOD)%MOD;
        //break;
    }
    ans=(ans+1)%MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main() {
    int iCount, iIndex = 0;
    int iInputNum[10000];

    while (1)
    {
        scanf("%d", &iInputNum[iIndex]);

        if (iInputNum[iIndex] == 0) {
            break;
        }
        iIndex++;
    }

    for (iCount = 0; iCount < iIndex; iCount++) {
        printf("Case %d: %d\n", iCount + 1, iInputNum[iCount]);
    }
    
    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

class UnionFind
{
private:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
    int _count;

public:
    UnionFind(int n) : par(n), rank(n, 0), sz(n, 1), _count(n) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;

        _count--;
        if (rank[x] < rank[y]) {
            par[x] = y; sz[y] += sz[x];
        } else {
            par[y] = x; sz[x] += sz[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return sz[find(x)]; }

    int count() { return _count; }
};

struct edge { int u, v; ll w; };
bool operator<(const edge &lhs, const edge &rhs) { return lhs.w < rhs.w; }

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

    int n; cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    vector<int> num(n);
    iota(num.begin(), num.end(), 0);

    vector<edge> es;

    sort(num.begin(), num.end(), [&](int i, int j) {return x[i] < x[j];});
    for (int i = 0; i < n - 1; i++) es.push_back({num[i], num[i+1], x[num[i+1]]-x[num[i]]});
    sort(num.begin(), num.end(), [&](int i, int j) {return y[i] < y[j];});
    for (int i = 0; i < n - 1; i++) es.push_back({num[i], num[i+1], y[num[i+1]]-y[num[i]]});

    sort(es.begin(), es.end());
    UnionFind uf(n);
    ll ans = 0;
    for (auto &e: es) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            ans += e.w;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7664
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
cnt = 0

for Ai in A:
    if Ai<0:
        cnt += 1

if cnt%2==0:
    print(sum(abs(Ai) for Ai in A))
else:
    A.sort(key=lambda x: abs(x))
    print(-abs(A[0])+sum(abs(Ai) for Ai in A[1:]))

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

int main(){
    string str;
    int a[4];
    cin >> str;
    for(int i=0;i<4;i++){
        a[i]=str[i]-'0';
    }
    string s="---";
    
    string ans;
    for(int bit=0;bit < (1<<3);bit++){
        s="---";
        int res=a[0];
        for(int i=0;i<3;i++){
            if(bit & (1<<i)){
                res+=a[i+1];
                s[i]='+';
            }else{
                s[i]='-';
                res-=a[i+1];
            }
        }
        if(res==7){
            ans=to_string(a[0])+s[0]+to_string(a[1])+s[1]+to_string(a[2])+s[2]+to_string(a[3])+"=7";
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    deque<ll> s;
    string S;
    cin>>S;
    rep(i,S.size()){
        if(S[i]=='0'){
            s.pb(0);
        }else if (S[i]=='1')
        {
            s.pb(1);
        }else{
            if(!s.empty()) s.pop_back();
        }
    }
    while(!s.empty()){
        cout<<s.front();
        s.pop_front();
    }
    cout<<endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
            puts("DENIED");
            return 0;
        }
    }
    puts("APPROVED");
    return 0;
}



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

using namespace std;

int main()
{
	int num = 0, i = 0;
	string operation, word;
	map<string, int> word_map;

	cin >> num;
	while ( i < num )
	{
		cin >> operation;
		cin >> word;
		if ( operation == "insert" )
		{
			word_map[word] = 1;
		}
		else if ( operation == "find" )
		{
			if ( word_map[word] == 1 )
			{
				cout << "yes" << endl;
			}
			else if ( word_map[word] == 0 )
			{
				cout << "no" << endl;
			}
		}

		i = i + 1;
	}

	return 0;
}

Measured memory_bytes: 52632
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cstring>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++(i))
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++(i))
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<int> vv[2010];
int match[2010];
bool used[2010];


bool matchdfs(int v)
{
	used[v] = true;
	for(int i = 0;i < vv[v].size();i++)
	{
		int u = vv[v][i],w = match[u];
		if(w < 0 || !used[w] && matchdfs(w))
		{
			match[u] = v;
			match[v] = u;
			return true;
		}
	}
	return false;
}

int two_matching_max(int l)
{
	int res = 0;
	memset(match,-1,sizeof(match));
	REP(v,l)
	{
		if(match[v] < 0)
		{
			memset(used,0,sizeof(used));
			if(matchdfs(v))res++;
		}
	}
	//cout << res << endl;
	return res;
}

int main()
{
	int cou = 0;
	int n,m,l;
	while(cin >> n >> m >> l,n|m|l)
	{

		REP(i,2010)vv[i].clear();
		int dist[n+1][n+1] = {};
		REP(i,n+1)REP(j,n+1)
		{
			if(i == j)dist[i][j] = 0;
			else dist[i][j] = 5e8;
		}
				
		REP(i,m)
		{
			int u,v,d;
			cin >> u >> v >> d;
			dist[u][v] = dist[v][u] = d;
		}
				
		REP(k,n)REP(i,n)REP(j,n)
		{
			dist[i][j] = min(dist[i][k] + dist[k][j],dist[i][j]);
		}
				
		vector<pair<int,int> > v(l);
		
		REP(i,l)
		{
			int p,t;
			cin >> p >> t;
			v[i] = MP(t,p);
		}
		
		sort(ALL(v));
		
		REP(i,l)rep(j,i,l)
		{
			
			if(i == j)continue;
			if(v[j].FI - v[i].FI >= dist[v[j].SE][v[i].SE])
			{
				vv[i].PB(l+j);
				vv[l+j].PB(i);
			}
		}
				
		int ret =  l - two_matching_max(2*l) ;
		cout << ret << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 9756
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int long long
#define mod 1000000007
#define maxN 1000005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pip pair<int,pii>
#define vi vector<int>
#define vpi vector<pii >
#define endl "\n"
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define repr(a,b,c) for(int(a) = b;a>=c;a--)
#define rep(i,n) for(int(i) = 0;i<n;i++)
#define fir first
#define sec second
#define beg begin()
#define e end()
#define len length()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;


int32_t main()
{
   fastIO;
   int n;
   cin>>n;
   string s[n];
   rep(i,n){
     cin>>s[i];
     sort(s[i].beg,s[i].e);
   }
   unordered_map<string,int> hash;
   int ans = 0;
   rep(i,n){
     hash[s[i]]++;
     ans+=hash[s[i]]-1;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 16036
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
sort(a,a+n);
int sum=0;
for(int i=0;i<k;i++)
{
    sum+=a[i];
}
cout<<sum;
}

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){

    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(llabs(a-b) >= 1000000000000000000LL){
        cout << "Unfair";
    }else if(k%2){
        cout << b-a;
    }else cout << a-b;

}
//for(int i=0;i<n;i++)

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    char s[11],t[12];	
    scanf("%s ",&s);	
    scanf("%s ",&t);
  
    int i;
    for (i = 0;s[i] != '\0';i++){
        if (s[i] != t[i]){
            printf("No");
            return 0;
        }
    }
 
    printf("Yes");
    return 0;
}


Measured memory_bytes: 1732
#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() {
    ll X;
    cin >> X;

    ll bal = 100;
    ll ans = 1;
    while (bal < X) {
        bal += bal / 100;
        if(bal >= X) {
            cout << ans << endl;
        }
        ans++;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e5 + 1;

int n, m;
int a[N];
bool vis[N];
vector<int> adj[N];

int32_t main() { cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cin >> m;
  set<pair<int, int>> s;
  for (int i = 1, v, k; i <= m; i++) {
    cin >> v >> k;
    a[v] = k;
    s.insert({-a[v], v});
  }
  while (!s.empty()) {
    int k = -s.begin()->first, v = s.begin()->second;
    s.erase(s.begin());
    if (vis[v]) continue;
    vis[v] = 1;
    for (auto& u : adj[v]) {
      if (vis[u] || s.find({-a[u], u}) != s.end()) continue;
      a[u] = k - 1;
      s.insert({-a[u], u});
    }
  }
  memset(vis, 0, sizeof vis);
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (vis[v]) continue;
    vis[v] = 1;
    for (auto& u : adj[v]) {
      if (abs(a[u] - a[v]) != 1) {
        return cout << "No", 0;
      }
      q.push(u);
    }
  }
  cout << "Yes\n";
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
}

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll N, ans=0, h, h1;
    cin >> N;
    rep(i, N) {
        cin >> h1;
        if(i and h>h1) ans += h-h1;
        h = h1;
    }

    cout << ans + h1 << nl;
}

Measured memory_bytes: 256
N = int(input())
T=[]
for n in range(N):
    T.append(int(input()))
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(T))


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

int main(){
  int n;
  cin>>n;
  vector<int>x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  vector<int>p(n);
  rep(i,n)p[i]=i;
  double dis=0;
  int cnt=0;
  do{
      rep(i,n-1){
    double dx=x[p[i]]-x[p[i+1]];
    double dy=y[p[i]]-y[p[i+1]];
    dis+=sqrt(dx*dx+dy*dy);
  }
    cnt++;
}while(next_permutation(p.begin(),p.end()));
  double ans=dis/cnt;
  printf("%.6f\n",ans);
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int aa, ab, ac;
  scanf("%d", &aa);
  for (ab = 0; ab <= 25; ab++)
  {
    for (ac = 0; ac <= 25; ac++)
      if (aa == ab * 7 + ac * 4)
      { printf("Yes\n");
    return 0;}
  }
      puts("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  int n ;
  cin >> n ;
  vint num(n) ;
  int sum = 0 ;
  int ans = INF ;
  
  REP(i,n){
    cin >> num.at(i) ;
  }
  
  sort(ALL(num)) ;
  
  int a = num.at(0) ;
  int b = num.at(n-1) ;
  
  
  FOR(i,a,b+1){
    REP(j,n){
      sum += (num.at(j)-i)*(num.at(j)-i) ;
    }
    ans = min(ans,sum) ;
    sum = 0 ;
  }
  
  cout << ans <<endl ;


  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int vis[5],path[6][6];
bool flag=false;
void dfs(int step)
{
	if(step==5)flag=true;
	for(int i=1;i<=4;i++)
	 if(!vis[i]&&path[step][i])
	  {vis[i]=1;
	   path[step][i]=0;
	   dfs(step+1);
	  }
}
int main()
{
	int x,y;
	for(int i=1;i<4;i++)
	 {cin>>x>>y;
	  path[x][y]=path[y][x]=1;
	 }
	dfs(1);
	if(flag==true)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;	
}

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

int main(){
string s, t;
cin >> s >> t;
ll n = s.size();
ll ans = 0;
for( ll i = 0; i< n; i++)
if(s[i] != t[i]) ans++;
cout << ans <<endl;
 return 0;
}

Measured memory_bytes: 3912
let s = read_line ()
let k = ref @@ read_int ()
let f c = Char.(chr @@ (code c - 97 + !k) mod 26 + 97)
let _ = String.(mapi (fun i c -> let d = (123 - Char.code c) mod 26 in if i = length s - 1 then f c else if d <= !k then (k := !k - d; 'a') else c) s) |> print_endline

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    ll n; cin >> n;
    ll ans;
    for(int i=(int)sqrt(n)+1; i>=1; i--){
        if((n%i)==0){
            ans=((n/i)-1)+i-1;
            break;
        }
    }
    cout << ans << endl;
return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll a;
    cin>>a;
    string b;
    cin>>b;
    ll x=stoll(b);
    ll as=a*x;
    reverse(all(b));
    b=b.substr(0,2);
    reverse(all(b));
    ll gg=stoll(b);
    as+=(a*gg)/100;
    cout<<as<<nl;
    return 0;
}


Measured memory_bytes: 3616
import math
n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort(reverse=True)

def check(m):
    m2 = m
    for i in range(n):
        if h[i] <= b * m:
            continue
        m2 -= math.ceil((h[i] - b * m) / (a - b))
        if m2 < 0:
            return False
    return True

l, r = 0, sum(h)//b+1
while r - l > 1:
    mid = (r + l) // 2
    # print(l, r, mid, check(mid))
    if check(mid):
        r = mid
    else:
        l = mid

print(r)


Measured memory_bytes: 7508
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
void solve(int n,int i){
  int buf=i*(i+1)/2;
  int sub=buf-n;
  rep1(j,i){
    if(j==sub)continue;
    else{
      cout<<j<<endl;
    }
  }
}
signed main(){
  int n;cin>>n;
  rep1(i,n){
    int buf=i*(i+1)/2;
    if(buf>=n){
      solve(n,i);
      break;
    }
  }  
  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;

void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    int g;
    cin >> g;
    int mx = g;
    int a;
    REP(i, n - 1) {
        cin >> a;
        chmax(mx, a);
        g = gcd(g, a);
    }
    cout << (mx >= k and k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

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

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

    long bs=0;
    vector<int> b(N);
    for(int i=0;i<N;i++){
        cin >> b[i];
        bs+=b[i];
    }

    long ac=0;
    for(int i=0;i<N;i++){
        int d=b[i]-a[i];
        if(d>0){
            ac+=(d+1)/2;
        }
    }

    if((bs-as)<ac){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}



Measured memory_bytes: 384
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
 
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<string.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<string.h>
#include<stack>
#include<queue>
#include<deque>
 
#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 100000007
 
using namespace std;
 
ll a[305][305],n,k;
 
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    ll n;
    sfl(n);
    if(n%1000 == 0) cout<<0;
    else
    {
    	ll x=n/1000;
    	x=(x+1)*1000;
    	cout<<x-n;
    }
    return 0;
}

Measured memory_bytes: 3280
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
     
     if(a >=13){
         cout << b << endl;
     }

    else if(a >=6){
       cout <<  b/2 <<endl;
    }

    else{
         cout << 0 <<endl;
    }
}


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

int main(){
    int n, k, s;
    scanf("%d%d%d", &n, &k, &s);
    std::vector <int> vec(n);
    if (s < int(1e9)){
        for (int i = 0; i < k; ++ i){
            vec[i] = s;
        }
        for (int i = k; i < n; ++ i){
            vec[i] = s + 1;
        }
    }
    else{
        for (int i = 0; i < k; ++ i){
            vec[i] = s;
        }
        for (int i = k; i < n; ++ i){
            vec[i] = s - 1;
        }
    }
    for (int i = 0; i < n; ++ i){
        printf("%d%c", vec[i], " \n"[i == n - 1]);
    }
    return 0;
}


Measured memory_bytes: 1664
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{
    int n , m ;
    scanf ("%d" , &n );
    string x[n];
    for (int i =0 ; i < n ;i++)cin >> x[i];
    scanf ("%d" , &m );
    string y[m];
    for (int i =0 ; i < m ;i++)cin>>y[i];
    map <string , int > frq ;

    for (int i =0 ; i < n ;i++)frq[ x[i] ]++;
    for (int i =0 ; i < m ;i++)frq[ y[i] ]--;
    int best =  0 ;
    for (auto S : frq )best = max (best , S.s );
    cout << best <<"\n";
}


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

int main() {
  int n1, n2, n3, n4;
  std::cin >> n1 >> n2 >> n3 >> n4;
  std::vector<int> ns = {n1, n2, n3, n4};
  std::sort(ns.begin(), ns.end());
  if (ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] ==9)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
}


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

int n;
int w;
vector<int> weight, value;
vector< vector<int> > dp;

main(){
	
	cin >> n >> w;
	
	weight.resize(n+1);
	value.resize(n+1);

	dp.resize(n+1, vector<int>(w+1));

	for(int i=1; i<=n; i++){
		cin >> weight[i] >> value[i];
	}

	for(int i=1; i<=w; i++){
		for(int j=1; j<=n; j++){
			if(i - weight[j] >= 0){
				dp[j][i] = max(dp[j][i], value[j] + dp[j-1][i-weight[j]]);
			}
			dp[j][i] = max(dp[j][i], dp[j-1][i]);
		}
	}

	cout << dp[n][w] << "\n";
}

/*

knapp(k, w) = valor max do subproblema com os k primeiros elementos e peso maximo de w

knapp(k, w) = max(knapp(k-1, w - peso[k]), knapp(k-1, w));

*/

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int cnt[500005];
int main(){
    char c[500005];
    //for(int i = 0;i<500000;i++)
    //    c[i]='9';
   // c[500000]=0;
    scanf("%s",c);
    int len=strlen(c);
    reverse(c,c+len);
    cnt[0]=c[0]-'0';
    for(int i = 1;c[i]!=0;i++){
        cnt[i-1]+=(c[i]-'0')*9;
        cnt[0]+=c[i]-'0';
    }
    priority_queue<int> pq;
    set<int> s;
    for(int i=len;i>=0;i--){
        if(cnt[i]>=10)pq.push(i);
        if(cnt[i])s.insert(i);
    }
    while(!pq.empty()){
        int x=pq.top();
        pq.pop();
      if(cnt[x]<10)continue;
        int y=*s.begin();
        if(x==y&&cnt[x]==10)break;
        cnt[y]--;
        if(cnt[y]==0)s.erase(y);
        if(y!=0){
            if(cnt[y-1]==0)s.insert(y-1),pq.push(y-1);
            cnt[y-1]+=10;
            
        }
        cnt[x]-=10;
        if(cnt[x]==0)s.erase(x);
        if(cnt[x]>=10)pq.push(x);
        if(cnt[x+1]==0)s.insert(x+1);
        cnt[x+1]++;
        if(cnt[x+1]>=10)pq.push(x+1);
    }
    int ans=0;
    for(int i = 0;i<=len;i++)
        ans+=cnt[i];
    printf("%d\n",(ans+8)/9);
}

Measured memory_bytes: 28016
#include <iostream>
using namespace std;
struct card{
    char suit,value;
};
void BubbleSort(struct card A[],int N){
    for (int i = 0; i < N; ++i) {
        for (int j = N-1; j >= i+1; --j) {
           if(A[j].value<A[j-1].value){
               card t=A[j];A[j]=A[j-1];A[j-1]=t;
           }
        }
    }
}
void SelectSort(struct card A[],int N){
    for (int  i = 0; i < N; ++i) {
       int minj=i;
        for (int j = i; j < N; ++j)
            if(A[j].value<A[minj].value) minj=j;
       card t=A[i];A[i]=A[minj];A[minj]=t;
    }
}
void print(struct card A[],int N){
    for (int i = 0; i < N; ++i) {
        if(i>0) cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}
bool isStable(struct card c1[],struct card c2[],int N){
    for (int i = 0; i < N; ++i)
        if(c1[i].suit != c2[i].suit) return false;
    return true;
}
int main() {
    card c1[100],c2[100];
    int N;
    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>c1[i].suit>>c1[i].value;
        c2[i]=c1[i];
    }
    BubbleSort(c1,N);
    SelectSort(c2,N);
    print(c1,N);
    cout<<"Stable"<<endl;
    print(c2,N);
    if(isStable(c1,c2,N)){
        cout<<"Stable"<<endl;
    } else {
        cout<<"Not stable"<<endl;
    }
    return 0;
}



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

int main()
{
	int k,a,b;
	scanf("%d%d%d",&k,&a,&b);
	if(a+2>=b) printf("%d\n",k+1);
	else
	{
		if(k<=a-1) printf("%d\n",k+1);
		else
		{
			k-=a-1;
			ll ans=0;
			int l=k/2;
			ans+=1ll*l*b-1ll*(l-1)*a;
			if(k&1) ans++;
			printf("%lld\n",ans);
		}
	 } 
	return 0;
}

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

int main() {
    int n, q, t;
    cin >> n >> q;
    string s;
    queue<pair<string, int> > Q;
    for(int i=0; i<n; i++) {
        cin >> s >> t;
        Q.push(make_pair(s, t));
    }
    pair<string, int> u;
    int ans=0, a;
    while(!(Q.empty())) {
        u=Q.front();
        Q.pop();
        a=min(q, u.second);
        u.second -= a;
        ans += a;
        if(u.second<=0) {
            cout << u.first << " " << ans << endl;
        }
        else Q.push(u);
    }
}


Measured memory_bytes: 6348
n = int(input())
box = []
for i in range(1,n+1):
  if i % 15 == 0:
    box.append(0)
  elif i % 3 == 0:
    box.append(0)
  elif i % 5 == 0:
    box.append(0)
  else:
    box.append(i)
print(sum(box))

Measured memory_bytes: 33692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;


int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	long long N, A, B;
	cin >> N >> A >> B;

	long long waru = N / (A + B);
	long long amari = N % (A + B);
	long long res = waru * A;
	res += min(A, amari);

	cout << res << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
int a[100010];

void solve() {
  cin >> n;
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  int res = 0;
  FOR(i, a[n/2-1]+1, a[n/2]+1) res++;
  cout << res << endl;
}

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


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<pii> r;

    rep(i,n){
        int x,l;
        cin >> x >> l;
        r.emplace_back(x+l,x-l);
    }

    sort(all(r));
    int R = -INF,res = 0;

    rep(i,n){
        if(R <= r[i].second){
            ++res;
            R = r[i].first;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 2420
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> A(n);
  if(x == 0 || n == x){
    cout << 0 << endl; 
    return 0;
  }
  rep(i,n) A[i] = 0;
  rep(i,m){
    int t;
    cin >> t;
    A[t] = 1;
  }
  int cost = 0;
  int ans = 0;
  for(int i = 0; i < x; i++){
    cost += A[i+1];
  }
  ans = cost;
  cost = 0;
  for(int i = n; i > x; i--){
    cost += A[i-1];
  }
  cout << min(ans,cost) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
ll dp[3010][3010];
int n;
vector<ll> a(3010);

int main(){
  cin >> n;
  rep(i,n) cin >> a[i];
  rep(i,n){
    rep(j,n){
      dp[i][j] = 0;
    }
  }
  for(int l=1;l<=n;l++){
    for(int i=0;i<=n-l;i++){
      if((n-l)%2==0) dp[i][i+l]=max(dp[i][i+l-1]+a[i+l-1],dp[i+1][i+l]+a[i]);
      if((n-l)%2==1) dp[i][i+l]=min(dp[i][i+l-1]-a[i+l-1],dp[i+1][i+l]-a[i]);
    }
  }
  cout << dp[0][n];
}

Measured memory_bytes: 70784
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)


Measured memory_bytes: 3188
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

#define forsn(i,s,n) for(int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define sq(x) ((x)*(x))

typedef long long int tint;

typedef long long int tint;

int main() {
	tint n, k; cin >> n >> k;
	
	map<int,tint> values;
	forsn(i,1,n + 1) if (!((2 * i) % k)) values[i % k]++;
	
	tint res = 0;
	for (auto entry : values) {
		res += sq(entry.second) * entry.second;
	}
	
	cout << res << endl;
}



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

int seiyaku_check(double i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

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


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n,a,b;
	std::cin >> n >> a >> b;
	int min = std::min(b,n*a);
	print(min);
	return 0;
}


Measured memory_bytes: 256
let id x = x

let rec fact2 n = 
  let m = n / 5 in
  if m = 0 then 0
  else m + fact2 m

let _ = 
  let rec loop () = 
    let n = Scanf.scanf "%d\n" id in
    if n = 0 then ()
    else
      begin
        Printf.printf "%d\n" (fact2 n);
        loop ()
      end
  in loop ()

Measured memory_bytes: 2416