akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    str ans = "000";
    str n = in<str>();
    rep(i, 3){
        if (n[i] == '1'){
            ans[i] = '9';
        } else {
            ans[i] = '1';
        }
    }
    print(ans);
}

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

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	long long ans=0;
	long long  l=0,r=0;
	long long t=a[0];
	while(l<n){
		while(!(t&a[r+1])&&r<n-1) t+=a[++r];
		ans+=r-l+1;
		t-=a[l++];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ans = 0; cin >> n;
	vector<int> a(n);
	vector<bool> ok(1e6 + 1, 1);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++) if(ok[a[i]])
	{
		int j = 2 * a[i];
		bool flag = 1;
		if(i) flag &= a[i] > a[i - 1];
		if(i < n - 1) flag &= a[i] < a[i + 1];
		if(!flag) ok[a[i]] = 0;
		while(j < 1e6 + 1)
		{
			ok[j] = 0;
			j += a[i];
		}
	}
	for(int i = 0; i < n; i++) if(ok[a[i]]) ans++;
	cout << ans;

	return 0;
}

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

int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;

    double p[n+1];

    for(ll i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1];
     
     for(ll i=0;i<=n;i++)
        for(ll j=0;j<=n;j++)
           dp[i][j]=0;

       dp[0][0]=1;

    for(ll i=1;i<=n;i++)
    {
        dp[i][0]=(1-p[i])*dp[i-1][0];

        for(ll j=1;j<=i;j++)
        {
           // if(j==i)
            // {
                // dp[i][j]=p[i]*dp[i-1][j-1];
                // continue;
            // }
            dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
        }
    }


  

    double ans=0;

     
    for(int i=(n/2)+1;i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed;
    cout<<setprecision(10)<<ans;

}

Measured memory_bytes: 70528
def main():
    h,w = map(int,input().split())
    #縦3分割
    h1 = h//3
    h2 = (h-h1)//2
    h3 = h-h1-h2
    ans = (max(h1,h2,h3)-min(h1,h2,h3))*w
    #横3分割
    w1 = w//3
    w2 = (w-w1)//2
    w3 = w-w1-w2
    a = (max(w1,w2,w3)-min(w1,w2,w3))*h
    if a<ans:
        ans = a
    #縦1横２分割
    h1 = h//3
    h2 = h-h1
    w1 = w//2
    w2 = w-w1
    a = max(h1*w,h2*w1,h2*w2)-min(h1*w,h2*w1,h2*w2)
    if a<ans:
        ans = a
    h1 = h//3+1
    h2 = h-h1
    w1 = w//2
    w2 = w-w1
    a = max(h1*w,h2*w1,h2*w2)-min(h1*w,h2*w1,h2*w2)
    if a<ans:
        ans = a
    #縦2横1分割
    w1 = w//3
    w2 = w-w1
    h1 = h//2
    h2 = h-h1
    a = max(w1*h,w2*h1,w2*h2)-min(w1*h,w2*h1,w2*h2)
    if a<ans:
        ans = a
    w1 = w//3+1
    w2 = w-w1
    h1 = h//2
    h2 = h-h1
    a = max(w1*h,w2*h1,w2*h2)-min(w1*h,w2*h1,w2*h2)
    if a<ans:
        ans = a
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	ll x[1000], y[1000];
	cin>>x[0]>>y[0];
	bool odd=0;
	if((x[0]+y[0])%2) odd=1;
	for(int i=1; i<n; i++){
		cin>>x[i]>>y[i];
		if((!odd && (x[i]+y[i])%2!=0) || (odd && (x[i]+y[i])%2==0)){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<40<<endl;
	ll d[40];
	if(odd){
		for(int i=39; i>=0; i--){
			cout<<(1ll<<i)<<" ";
			d[39-i]=(1ll<<i);
		}
		cout<<endl;
	}else{
		for(int i=38; i>=0; i--){
			cout<<(1ll<<i)<<" ";
			d[38-i]=(1ll<<i);
		}
		d[39]=1;
		cout<<1<<endl;
	}
	for(int i=0; i<n; i++){
		ll xn=0, yn=0;
		string ans;
		for(int j=0; j<40; j++){
			if(abs(xn-x[i])>abs(yn-y[i])){
				if(xn>x[i]){
					ans+='L';
					xn-=d[j];
				}else{
					ans+='R';
					xn+=d[j];
				}
			}else{
				if(yn>y[i]){
					ans+='D';
					yn-=d[j];
				}else{
					ans+='U';
					yn+=d[j];
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A, B, K = map(int, input().split())

turn = True
for i in range(K):
    if turn:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2
        turn = False
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2
        turn = True

print(A, B)


Measured memory_bytes: 3060
#include<iostream>
#include<string>

char func(char b) {
	switch (b) {
	case 'A':
		return 'T';
	case 'T':
		return 'A';
	case 'C':
		return 'G';
	case 'G':
		return 'C';
	default:
		break;
	}
}

int main() {
	char b;
	std::cin >> b;
	std::cout << func(b) << std::endl;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if (k >= s.size()){
    cout << s << endl;
  } else {
    for(int i = 0; i < k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }  
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int n,d,k,sa,l,r,a[200005],sum=0,sum2=0,res[200005]={};
long long int used[100005]={},x[11][11];
queue<long long int> qu[100005];

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        if(i%2==0){
            sum2+=2*a[i];
        }
    }
    res[1]=sum-sum2;
    for(int i=2;i<=n;i++){
        res[i]=a[i-1]*2-res[i-1];
    }
    for(int i=1;i<=n;i++){
        cout<<res[i]<<" ";
    }
} 


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

void solve(long long H, long long W) {
    if (H <= 1 || W <= 1) {
        cout << 1 << endl;
        return;
    }
    ll ans = (H * W + 1) / 2;
    cout << ans << endl;
}

int main() {
    long long H;
    std::cin >> H;
    long long W;
    std::cin >> W;
    solve(H, W);
    return 0;
}


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

bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main(){
    ll n; cin >> n;
    vector<ll> num = calc_divisor(n);
    ll ans = 0;
    for(int i=1; i<num.size(); i++){
        if(num[i]!=num[i-1]+1){
            if(n/(num[i]-1)==n%(num[i]-1)) ans+=num[i]-1;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3716
#include <stdio.h>

int main()
{
    int i,j;
    int H ,W;
    while(1){
    scanf("%d %d",&H,&W );
        if(H==0 && W==0){
           break;
    }
    for(i = 0; i < H; i++ ){
        for(j=0; j< W; j++)
            printf("#");
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2100
n,k,q=map(int,input().split())
cnt=[0]*n
for i in range(q):
  cnt[int(input())-1]+=1
for i in range(n):
  cnt[i]+=k-q
for i in range(n):
  if cnt[i]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 7880
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

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


Measured memory_bytes: 3652
import sys
def cross(a, b):
	return (a.conjugate() * b).imag
def dot(a, b):
	return (a.conjugate() * b).real
def ccw(a, b, c):
	x = b - a
	y = c - a;
	cr = cross(x, y)
	if cr != 0: return cr
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0
for line in sys.stdin:
	t = map(float, line.split())
	if len(t) == 0: continue
	a, b, c, p = map(complex, t[0::2], t[1::2])
	l = [(a, b), (b, c), (c, a)]
	x = cmp(ccw(l[0][0], l[0][1], p), 0)
	if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]):
		print "YES"
	else:
		print "NO"

Measured memory_bytes: 5300
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    map<string, int> mp;
    for(int i = 0; i < q; i++)
    {
        int com, x;
        string k;
        cin >> com >> k;
        if(com == 0)
        {
            cin >> x;
            mp[k] = x;
        }
        if(com == 1)
        {
            cout << mp[k] << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 25992
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
typedef long long  ll;

using namespace std;

int ans, cnt;

int main() {

	int N,K;
	cin >> N >> K;
	
	while (N > 0) {
		N /= K;
		ans++;
	}

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


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

bool isPrime[MAXN];
long primeList[MAXN];
long ans[MAXN];
int primeCount = 0;

void solve()
{
        memset( isPrime, true, sizeof( isPrime));
        memset( primeList, 0, sizeof( primeList));
        memset( ans, 0, sizeof( ans));

        for ( int i = 2; i < MAXN; ++ i) {
                if ( isPrime[i]) {
                        primeCount = primeCount + 1;
                        primeList[ primeCount] = i;
                }
                ans[i] = primeCount;

                for ( int j = 1; j <= primeCount; ++ j) {
                        if ( i * primeList[j] > MAXN) {
                                break;
                        }
                        isPrime[ i * primeList[j]] = false;

                        if ( 0 == i % primeList[j]) {
                                break;
                        }
                }

        }

        ans[0] = ans[1] = 0;

        return ;
}





int a[60];
int main()
{
    int N,sum=0;
    solve();
    while(cin>>N)
    {

        int x=N;
        int now=1;
        for(int i=1;i<=x;)
        {
            while(primeList[now]%5!=1) now++;
            a[i++]=primeList[now++];
        }
        for(int i=1;i<=x;i++)
        {
            sum+=a[i];
            if(i!=x)
                cout<<a[i]<<" ";
            else
                cout<<a[i]<<endl;
        }

        //cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 16896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int a = A + B;
		int b = A - B;
		int c = A * B;
		
		System.out.println(Math.max(Math.max(a, b), c));
		
	}
}


Measured memory_bytes: 23380
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int , int);
int setHeight(int);
int getSibling(int);
void print(int);

int main()
{
  int v,l,r,root = 0,i;

  scanf("%d",&n);

  for(i = 0; i < n; i++)T[i].parent = NIL;

  for(i = 0; i < n; i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }

  for(i = 0; i < n; i++)if(T[i].parent == NIL)root = i;

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++)print(i);
  
  return 0;
}

void setDepth(int u, int d)
{
  if(u == NIL)return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u)
{
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left) + 1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right) + 1;
  }

  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u)
{
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;

  return NIL;
}

void print(int u)
{
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}



Measured memory_bytes: 2128
<?php
fscanf(STDIN, "%d %d", $n, $k);
$inputs = array_map('intval', explode(' ', trim(fgets(STDIN))));

$count = 0;
if (count($inputs) > $k) {
    rsort($inputs);
    $tmp = array_slice($inputs, $k);
    #var_dump([$inputs, $tmp, $k]);
    $sum = array_sum($tmp);
    $count = $sum;
}

echo $count;


Measured memory_bytes: 31220
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto dp = new int[](1000001);
    foreach(i; iota(1, dp.length.to!int)) {
        int k = i;
        while(k % 2 == 0) {
            k /= 2;
        }
        while(k % 3 == 0) {
            k /= 3;
        }
        while(k % 5 == 0) {
            k /= 5;
        }
        if(k == 1) {
            dp[i] = dp[i-1] + 1;
        } else {
            dp[i] = dp[i-1];
        }
    }
    while(true) {
        auto l = readInts();
        if(l.length == 1) {
            return;
        }
        auto m = l[0];
        auto n = l[1];
        writeln(dp[n] - dp[m-1]);
    }
}

Measured memory_bytes: 6084
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
c = Counter(A)
keys = c.keys()
ans = 0
for i in keys:
    if c[i] % 2 != 0:
        ans +=1
print(ans)

Measured memory_bytes: 16624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

map<ll, ll> cost;
const ll INF = 1e18;
ll a[6], d;
ll get(ll n) {
  if (cost.find(n) != cost.end()) return cost[n];
  ll val = INF;
  for (int k: {2, 3, 5}) {
    for (ll nn: {n / k, (n + k - 1) / k}) {
      val = min(val, a[k] + get(nn) + llabs(n - nn*k) * d);
    }
  }
  if (val / d >= n) val = n * d;
  return cost[n] = val;
}

int main() {
#ifdef LOCAL_EXEC
	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int t; cin >> t;
  while (t--) {
    ll n; cin >> n >> a[2] >> a[3] >> a[5] >> d;
    cost.clear();
    cost[0] = 0;
    cost[1] = d;
    cout << get(n) << endl;
  }

  return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    vector<int> A(7);
    vector<int> B(4);
    A = {1, 3, 5, 7, 8, 10, 12};
    B = {4, 6, 9, 11};
    bool flagX = false;
    bool flagY = false;
    for (int i = 0; i < 7; i++){
        if (A[i] == x){
            flagX = true;
        }
        else if (A[i] == y){
            flagY = true;
        }
    }
    if (flagX && flagY){
        cout << "Yes" << endl;
    }
    else{
        flagX = false;
        flagY = false;
        for (int i = 0; i < 4; i++){
            if (B[i] == x){
                flagX = true;
            }
            else if (B[i] == y){
                flagY = true;
            }
        }
        if (flagX && flagY) {
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
import Data.List

main = do
  [_,k] <- map read.words <$> getLine
  hs    <- map read.lines <$> getContents
  print $ solve k $ sort hs

solve :: Int -> [Int] -> Int
solve k hs = minimum ds
  where
  ds = go hs as
  go _ [] = []
  go (b:bs) (a:as) = a-b : go bs as
  as = drop (k-1) hs


Measured memory_bytes: 17704
#include<bits/stdc++.h>
typedef long long int lli;
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _READ freopen("input.txt","r", stdin);
#define F first
#define S second
using namespace std;
int main()
{
	lli n,m;
	cin>>n>>m;
	vector<lli> ar(n);
	lli sum=0;
	for(auto &i:ar)
	{
		cin>>i;
		sum+=i;
	}
	lli cnt=0;
	for(auto &i:ar)
	{
		if(i*4*m>=sum)
			++cnt;
	}
	if(cnt>=m)
	cout<<"Yes";
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const int mn=1e5+4;
int vc[mn];
int f[mn][11];
vector<pll> ve;
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m; scanf("%d%d",&n,&m);
	for (int i=0;i<m;i++) {
		int x,y; scanf("%d%d",&x,&y); ve.PB(MP(x,y)); ve.PB(MP(y,x));
	}
	int qn; scanf("%d",&qn);
	for (int i=1;i<=qn;i++) {
		int v,d;
		scanf("%d%d%d",&v,&d,&vc[i]);
		chkmax(f[v][d],i);
	}
	for (ll d=9;d>=0;d--) {
		for (auto &e:ve) {
			ll x=e.fst,y=e.snd;
			chkmax(f[y][d],f[x][d+1]);
		}
	}
	for (ll x=1;x<=n;x++) {
		ll ans=0;
		for (ll d=0;d<=10;d++) {
			chkmax(ans,f[x][d]);
		}
		printf("%d\n",vc[ans]);
	}
}



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

typedef long long ll;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    for(int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    int cnt=0;
    for(int i = 0; i < n; i++)
    {
        int score=0;
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            score += a[i][j]*b[j];
        }
        score+=c;
        if(score>0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int selectionsort(int a[],int n){
    int t,sw=0,minj;
    for(int i=0;i<n-1;i++){
        minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]) minj=j;
        }
        t=a[i];
        a[i]=a[minj];
        a[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(){
    int a[100];
    int n,sw;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    sw=selectionsort(a,n);
    for(int i=0;i<n;i++){
        if(i>0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll R, G;
  cin >> R >> G;

  cout << 2*G - R << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{

static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long q = long.Parse(input[1]);
static long[] parents = new long[n];//親
static long answer = 1;
  
	static void Main()
	{
    for(long i = 1; i < n; i++)
    {
    parents[i] = i;
    }
    
    for(long i = 0; i < q; i++)
    {
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
        if(whatParent(nums[0]-1) != whatParent(nums[1]-1))
          parents[whatParent(nums[0]-1)] = whatParent(nums[1]-1);//親を結合して統一。親が2人できることはない。
    }

    for(long i = 0; i < n-1; i++)
    {
      if(whatParent(i) != whatParent(i+1))//別の島
      {
        answer++;
        parents[whatParent(i)] = whatParent(i+1);
      }
    }

    Console.WriteLine(answer);
	}

  static long whatParent(long child)
  {
    if(parents[child] == child) return child;
    else return parents[child] = whatParent(parents[child]);
  }
  
}

Measured memory_bytes: 16944
import sys

X, Y = map(int, input().split())

if Y % 2 != 0:
    print("No")
    sys.exit()
else:
    for i in range(0, X + 1):
        for j in range(0, X + 1 - i):
            if i + j == X and (i * 2) + (j * 4) == Y:
                print("Yes")
                sys.exit()
    print("No")

Measured memory_bytes: 9048
/////////// <----------------------  Quicksilver_ ---------------------> ///////////
#include <bits/stdc++.h>
#include <sstream>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>
#include <utility>
#include <set>

using namespace std;
#define endl '\n'
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) cout<<" :: "<<#arr<<" :: "<<endl; rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<ll,ll> pii;
typedef vector<pii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


bool prime[3001];
void SieveOfEratosthenes()
{
    memset(prime, true, sizeof(prime));
    prime[1]=false;
    for (int p=2; p*p<=3000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=3000; i += p)
                prime[i] = false;
        }
    }
}

ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%998244353;
        a = (a * a)%998244353;
        b >>= 1;
    }
    return res;
}

// ll gcd(ll a,ll b,ll& x,ll& y)
// {
//   if(a==0)
//   {
//     x=0;
//     y=1;
//     return b;
//   }
//   else
//   {
//     ll x1,y1;
//     ll g=gcd(b%a,a,x1,y1);
//     x=y1-(b/a)*x1;
//     y=x1;
//     return g;
//   }
// }

ll arr[1000010];
ll freq[1000010];
ll counter[1000010];
ll mul[1000010];
vector<pii> temp;
vector<pii> queries;
map<ll,ll> m;


int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  cc(a,b);
  cc(c,d);
  ll div=c/b;
  if (c%b) div++;
  ll div2=a/d;
  if (a%d) div2++;
  if(div<=div2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

using namespace std;

int main(){
        int N;
        while (cin>>N,N) {
                vector<int>D(N);
                for (int i = 0; i < N; i++) {
                        string S;
                        cin>>S;
                        D[i] = S.length();
                }
                for (int i = 0; i < N; i++) {
                        int j = i;
                        int sum = 0;
                        while (sum<5) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=5) {
                                continue;
                        }
                        while (sum<12) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=12) {
                                continue;
                        }
                        while (sum<17) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=17) {
                                continue;
                        }
                        while (sum<24) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=24) {
                                continue;
                        }
                        while (sum<31) {
                                sum += D[j];
                                j++;
                        }
                        if (sum!=31) {
                                continue;
                        }
                        cout<<i+1<<endl;
                        break;
                }
        }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	map<pair<int, int>, int> m;
	int n;
	cin >> n;
	rep2(i, 1, n+1){
		string s = to_string(i);
		pair<int, int> p = make_pair(s.front() - '0', s.back() - '0');
		m[p]++;
	}
	// for(auto p : m){
	// 	cerr << p.first.first << " " << p.first.second << " " << p.second << endl;
	// }
	ll ans = 0;
	rep2(i, 1, 10){
		rep(j, 10){
			ans += m[{i,j}] * m[{j, i}];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE(x) ((x).size())
#define PB push_back

using namespace std;

const int N = 100001;

int n, x;
int a[N];

bool read() {
    if (!(cin >> n >> x)) {
        return false;
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i] = abs(a[i] - x);
    }
    return true;
}

void solve() {
    //sort(a, a + n);
    int A = a[0];
    for (int i = 1; i < n; i++) {
        A = __gcd(A, a[i]);
    }
    cout << A << endl;
}

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


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }


int main(int,char**) {
    ios_base::sync_with_stdio(false);

    string s; cin >> s;
    int N = s.size();
    int p = 0, r = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'p') {
            if (p < r) {
                ++p;
            } else {
                ++r;
                --ans;
            }
        } else if (s[i] == 'g') {
            if (p < r) {
                ++p;
                ++ans;
            } else {
                ++r;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    long long m = min(a,min(b,min(c,min(d,e))));
    long long x = n%m == 0 ? n/m : n/m+1;
    cout << x + 4 << endl;
}

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

int main(){
	vector<int> a;
	for(int i = 0; i< 6; i++){
		int input;
		cin >> input;
		a.push_back(input);
	}
	for(int i =0; i < a.size() - 1; i++){
		for(int j = 0; j < a.size() - 1; j++){
			if(abs(a[i] - a[j]) > a[5]){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;


	return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int x,y;
  cin>>x>>y;
  for (int i = 0; i <= x; ++i)
  {
    if(y==(2*i+4*(x-i)))
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

//順列を入力し、条件を満たす数を計算するクラス
class DividetheProblems{
    vector<int> vec; //入力された数列を格納する配列
    int answer; //整数Kの選び方の数
    void func0(); //変数answerを求める関数
public:
    DividetheProblems(vector<int> vec0);
    void print(); //変数answerを出力
};

DividetheProblems::DividetheProblems(vector<int> vec0){
    vec = move(vec0); //引数の配列をメンバ変数に格納
    func0(); 
}

//変数answerを求める関数
void DividetheProblems::func0(){
    sort(vec.begin(),vec.end()); //配列の値を昇順で並べ替え
    int centerIndex = vec.size() / 2; //配列の中心右のインデックスを求める
    answer = vec[centerIndex] - vec[centerIndex - 1]; //中心の2つの整数の差が答え 
}

void DividetheProblems::print(){
    cout << answer << endl;
}

int main(void){
    int N = 0;
    vector<int> vec;
    cin >> N; //配列の要素数を決定
    //配列の要素を入力
    vec.reserve(N + 1);
    for(int i = 0; i < N; i++){
        int value;
        cin >> value;
        vec.push_back(value);
    }
    DividetheProblems dp(move(vec));
    dp.print();
    return 0;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    class BIT:
        def __init__(self,n):
            self.size = n
            self.tree = [0]*(n+1)

        def add(self,i,x):
            while i <= self.size:
                self.tree[i] += x
                i += i&-i

        def sum(self,i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i&-i
            return s

    N,Q = map(int,input().split())
    C = list(map(int,input().split()))
    LR = []
    for i in range(Q):
        l,r = map(int,input().split())
        LR.append((l,r,i))
    bit = BIT(N)
    #color[i] => 色iが最後に登場したインデックス(1-indexed)
    color = [0]*(N+1)

    ANS = [0]*Q
    LR.sort(key=lambda x: x[1])
    cur = 1
    for l,r,j in LR:
        for i in range(cur,r+1):
            c = C[i-1]
            if color[c] != 0:
                bit.add(color[c],-1)
            color[c] = i
            bit.add(i,1)
        cur = r+1
        ANS[j] = bit.sum(r)-bit.sum(l-1)
    for a in ANS:
        print(a)
main()

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

int main(){
    int n;
    cin>>n;
    int odd = 0;
    for(int i=1;i<=n;i++){
        if(i%2 != 0)odd++;
    }
    double ans = (1.0*odd)/n;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int a, b;
	cin >> a >> b;
	if (a == b)cout << "Draw";
	else {
		if (a == 1)cout << "Alice";
		else {
			if (b == 1)cout << "Bob";
			else {
				if (a > b)cout << "Alice";
				else cout << "Bob";
			}
		}
	}
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o'){
      cnt++;
    }
  }
  cout << 700 + 100 * cnt << endl;
  return 0;
}

Measured memory_bytes: 3608
a, b, c =map(int, input().split())

if a== b and b==c and c==a and a%2 ==0:
    print(-1)
else:
    count = 0 
    while(a%2==0 and b%2==0 and c%2 ==0):
        new_a, new_b, new_c = b//2 + c//2, a//2 + c//2, a//2 + b//2
        a, b, c = new_a, new_b, new_c
        count+=1
    print(count)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,d,x,i,j,a;
    cin>>n;
    cin>>d>>x;
    int ch=0;
    for (i=0;i<n;i++)
    {
        cin>>a;
        for (j=0;j<d;j+=a)
            ch++;
    }
    cout<<ch+x<<endl;
}

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

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

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

    int n; cin >> n;
    int c[n-1], s[n-1], f[n-1];
    for (int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n-1; i++) {
        int t = 0;
        for (int j = i; j < n-1; j++) {
            int st = t;
            if (st % f[j]) st += f[j] - (st % f[j]);
            st = max(st, s[j]);
            t = st + c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
v=list(map(int,input().split()))
v_sort=sorted(v,reverse=False)
for i in range(N):
    v_sort=sorted(v_sort,reverse=False)
    v_sort.append((v_sort[0]+v_sort[1])/2)
    del v_sort[0]
    del v_sort[0]
    if len(v_sort)==1:
        break
print(*v_sort)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
  
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, k;
string s;
int main (){
    cin >> n >> k >> s;
    int cnt = 0, ans = 0;
    char last = 'c';
    for (int i = 0; i < n; ++i){
        if (s[i] != last){
            ++cnt;
            last = s[i];
        }
        if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') ++ans;
        else if (s[i] == 'R' && i < n - 1 && s[i + 1] == 'R') ++ans;
    }
    if (k > ((cnt - 1) / 2)) ans = n - 1;
    else ans += k * 2;
    return !printf ("%d\n", ans);
}

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

int main()
{
    long long a, b;
    cin >> a >> b;

    long long answer = 1;
    for (int i = 1; i < b + 1; i++)
    {
        if ((i * a) % b == 0)
        {
            answer = i * a;
            cout << answer << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            // writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut buf = String::new();

    let n = sc.read();
    let mut dic = BTreeSet::new();
    for _ in 0..n {
        let com: String = sc.read();
        let s: String = sc.read();
        match com.as_str() {
            "insert" => {
                dic.insert(s);
            },
            _ => {
                if dic.contains(&s) {
                    buf += "yes\n";
                } else {
                    buf += "no\n";
                }
            },
        }
    }

    print!("{}", buf);
}



Measured memory_bytes: 25448
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s, t := nextString(), nextString()
	a, b := nextInt(), nextInt()
	u := nextString()

	switch u {
	case s:
		a--
	case t:
		b--
	}
	fmt.Println(a, b)
}


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

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

    int n, k;
    cin >> n >> k;

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

    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < k; i++)
        ans += a[i];

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
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...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		map<int,int>mp,mp2;
		fn{
			cin >> ar[i];
			mp[ar[i]]++;
		}

		int ans=0;
		for(auto i : mp){
			int sz = i.se;
			mp2[i.fi] = (sz*(sz-1))/2;
			// trace(i.fi,mp2[i.fi]);
			ans+=mp2[i.fi];
		}
		// trace(ans);
		fn{
			int cur = ar[i];
			int temp = ans-mp2[cur];
			int x = mp[cur];
			// trace(cur,x,temp);
			trace(temp);
			x--;
			x = (x*(x-1))/2;
			temp+=x;
			cout << max(0ll,temp)<< endl;
		}

	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 21504
#include <iostream>
#include <string>

int main() {
    int n;
    std::string s, t;
    std::cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        std::cout << s[i] << t[i];
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
if a > b:
    a,b = b,a
b -= a
n -= 1
dif = d-c
for i in range(n%2,n+1,2):
    if c*i-dif*((n-i)//2) <= b <= d*i+dif*((n-i)//2):
        print("YES")
        exit()
print("NO")



Measured memory_bytes: 9172
N,K=(int(x) for x in input().split(" "))
def comb(n):
    return int(n*(n-1)/2)
limit=comb(N-1)
max=comb(N)

if K>limit:
    print (-1)
else:
    print (max-K)
    a=0
    for i in range (1,N+1):
        for j in range (i+1,N+1):
            if a<max-K:
                a+=1
            else:
                break
            c=str(i)
            d=str(j)
            print (c+" "+d)
        if a>=max-K:
            break

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long

using namespace std;



vector <ll> indeg ;
vector <bool> vis ;
vector < vector <ll> > g ;
vector <ll> dist;

void dfs(ll u)
{
    vis[u] = 1;

    for(ll v : g[u])
    {
        dist[v] = max(dist[v] , 1 + dist[u]);
        indeg[v]--;
        if(indeg[v] == 0)
        {
            dfs(v);
        }
    }

}

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

    indeg = vector <ll> (n,0);
    vis = vector <bool> (n,0);
    g = vector <vector<ll> > (n);
    dist = vector <ll> (n,0);

    while(m--)
    {
        int u , v ;
        cin >> u >> v ;
        u-- , v--;
        g[u].push_back(v);
        indeg[v]++;
    }


    for(int i = 0 ; i < n ; i++)
    {
        if(!vis[i] && indeg[i] == 0)
        {
            dfs(i);
        }
    }

    cout << *max_element(dist.begin() , dist.end() ) <<endl;


    return 0;
}

Measured memory_bytes: 10368