akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int i = 0;
    ll ans = 0;
    v2ll dp(S.size() + 2, vll(2, LINF));

    dp[0][0] = 0;
    //dp[0][1] = 0;
    REP(i, 1, S.size() + 2) {
        if (i >= S.size() + 1) {
            dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + 1);
            continue;
        }
        if (S[i - 1] != '9' && S[i - 1] != '0') {
            dp[i][0] = min(dp[i - 1][0] + (S[i - 1] - 0x30), dp[i - 1][1] + (S[i - 1] - 0x30 + 1));
            dp[i][1] = min(dp[i - 1][0] + 10 - (S[i - 1] - 0x30), dp[i - 1][1] + 9 - (S[i - 1] - 0x30));
        }
        else if (S[i - 1] == '0') {
            dp[i][0] = min(dp[i - 1][0] + (S[i - 1] - 0x30), dp[i - 1][1] + (S[i - 1] - 0x30 + 1));
        }
        else {
            dp[i][0] = dp[i - 1][0] + (S[i - 1] - 0x30);
            dp[i][1] = min(dp[i - 1][1], dp[i - 1][0] + 10 - (S[i - 1] - 0x30));
        }
    }
    //while (1) {
    //    if(i > S.size()) break;
    //    if (S[i] == 0) {
    //        i++;
    //        continue;
    //    }
    //    int cost1 = S[i] - 0x30;
    //    int cost2 = 10 - (S[i] - 0x30);
    //    int j = i + 1;
    //    while (S[j] == '9') {
    //        
    //        if (j >= S.size()) {
    //            break;
    //        }
    //        cost1 += '9' - 0x30;
    //        j++;
    //    }
    //    
    //    if (j < S.size()) {
    //        cost1 += S[j] - 0x30;
    //        cost2 += S[j] - 0x30 + 1;
    //    }
    //    else{
    //        cost2 += 1;
    //    }
    //    if (cost1 < cost2) {
    //        ans += cost1;
    //        i++;
    //    }
    //    else {
    //        ans += cost2;
    //        i = j + 1;
    //    }

    //}

    cout << dp[S.size() + 1 ][0]<< endl;
    return 0;
}

Measured memory_bytes: 55964
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {// テーブルを作る前処理
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

int main(){
	COMinit();
	int n,m;
	ll ans=1LL;
	cin >>n>>m;
	int bef=m;
	map<int,int>co;
	int c=0;
	for(int i=2;i<=sqrt(bef);i++){
		c=0;
		while(bef%i==0){
			bef/=i;
			c++;
		}
		if(c){
			co[i]+=0;
			co[i]+=c;
		}
	}
	if(bef!=1){
		co[bef]+=0;
		co[bef]++;
	}
	for(auto itr=co.begin();itr!=co.end();itr++){
		ans*=COM(itr->S + n-1 , n-1);
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <stdio.h>

int main(void) {
    int a[3];
    int sum[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    
    sum[0] = a[0]*10 + a[1] + a[2];
    sum[1] = a[1]*10 + a[2] + a[0];
    sum[2] = a[2]*10 + a[0] + a[1];

    int max = sum[0];

    max = (max>=sum[1])?max:sum[1];
    max = (max>=sum[2])?max:sum[2];
    
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repe(i,n) for (int i = 1; i <= (n); ++i)
#define reps(i,start,end,step) for (int i = start; i < end; i+=step)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
using namespace std;
typedef long long ll;
typedef string str;
const ll INF = 1e18;
const int MX = 2005;
const double pi = 3.141592653589793238;

int main() {

  string S;
  cin >> S;
  int cnt_all = 0;
  rep(i,S.size()){
    int cnt = 0;
    reps(j,i,S.size(),1){
      if(S[j] != 'A' & S[j] != 'C' & S[j] != 'G' & S[j] != 'T') break;
      else cnt += 1;
    }
    if(cnt > cnt_all) cnt_all = cnt;
  }
  cout << cnt_all << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int N, K; cin >> N >> K;
    int ans = 1;
    N -= K;
    int temp = ceil((double)N / (K - 1));
    ans += temp;
    COUT(ans);
}

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

using namespace std;



int main() {
	int X, Y;
	cin >> X >> Y;

	int f = 300000, s = 200000, t = 100000;



	if (X == 1) {
		if (Y == 1) {
			cout << f+f+400000 <<endl;
		}
		else if (Y == 2) {
			cout << f + s  << endl;
		}
		else if (Y == 3) {
			cout << f + t  << endl;
		}
		else {
			cout << f << endl;
		}
	}
	else if (X == 2) {
		if (Y == 1) {
			cout << s + f << endl;
		}
		else if (Y == 2) {
			cout << s + s << endl;
		}
		else if (Y == 3) {
			cout << s + t << endl;
		}
		else {
			cout << s << endl;
		}
	}
	else if (X == 3) {
		if (Y == 1) {
			cout << t + f << endl;
		}
		else if (Y == 2) {
			cout << t + s << endl;
		}
		else if (Y == 3) {
			cout << t + t << endl;
		}
		else {
			cout << t << endl;
		}
	}
	else {
		if (Y == 1) {
			cout << f << endl;
		}
		else if (Y == 2) {
			cout << s << endl;
		}
		else if (Y == 3) {
			cout << t << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

coin = 0
if A >= B:
    A -= 1
    coin += A+1
else:
    B -= 1
    coin += B+1
if A >= B:
    A -= 1
    coin += A+1
else:
    B -= 1
    coin += B+1

print(coin)


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

tmp = 1
Gtmp = 0
Ktmp = 0

for i in range(N-1):
    if A[i] == A[i+1]:
        tmp += 1
    elif tmp % 2 == 0:
        Gtmp += 1
        tmp = 1
    else:
        Ktmp += 1
        tmp = 1
if tmp % 2 == 0:
    Gtmp += 1
else:
    Ktmp += 1

ans = Ktmp + Gtmp - Gtmp % 2

print(ans)

Measured memory_bytes: 14004
#include<stdio.h>

int main(void){
    int A,B; //高橋君の体力A,攻撃力B,Yes
    int C,D; //青木君の体力C,攻撃力D,No

    scanf("%d%d%d%d",&A,&B,&C,&D);

    while(A>0){
        C -= B;
        if(C<=0){
            printf("Yes");
            break;
        }
        A -= D;
    }

    if(A<=0) printf("No");

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
int main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  while (q--) {
    ll x;
    cin >> x;
    ll res = INF;
    int s1 = lower_bound(s.begin(), s.end(), x) - s.begin(), s2 = -1;
    int t1 = lower_bound(t.begin(), t.end(), x) - t.begin(), t2 = -1;
    if (s1 > 0) s2 = s1 - 1;
    if (t1 > 0) t2 = t1 - 1;
    if (s1 < a && t1 < b) res = min(res, s[s1] + t[t1] - 2 * x - min(s[s1] - x, t[t1] - x));
    if (s2 != -1 && t1 < b) {
      res = min(res, min(x - s[s2], t[t1] - x) + t[t1] - s[s2]);
    }
    if (t2 != -1 && s1 < a) {
      res = min(res, min(x - t[t2], s[s1] - x) + s[s1] - t[t2]);
    }
    if (s2 != -1 && t2 != -1) {
      res = min(res, 2 * x - s[s2] - t[t2] - min(x - s[s2], x - t[t2]));
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
C_map = [list(map(int, input().split())) for _ in range(N)]

#計算しやすいよう、色Indexは全部-1する
for y in range(N):
    for x in range(N):
        C_map[y][x] -= 1

#
col_lines = [[0 for _ in range(C)] for _ in range(3)]
for y in range(N):
    for x in range(N):
        idx = (x + y) % 3
        col_lines[idx][C_map[y][x]] += 1

# 各行ごとにC色すべてに変更するときのコストを求める
def calc_cost(line, target_color):
    cost = 0
    for col, count in enumerate(line):
        cost += D[col][target_color] * count
    return cost

#[cost, 色] を覚える
costs = [[0 for _ in range(C)] for _ in range(3)]
for i in range(3):
    for c in range(0, C):
        costs[i][c] = [calc_cost(col_lines[i], c), c]
    costs[i].sort(key=lambda x: x[0])

# 貪欲法的に探す。i1, i2, i3 は各costsのIndex
# 他と色がかぶったらIndexをずらして調査、そうでなければOK
def find_min(i1, i2, i3):
    if i1 >= 3 or i2 >= 3 or i3 >= 3: #3色でいいので、4つ以上奥にいく必要がない
        return 100000000000000

    line1 = costs[0]
    line2 = costs[1]
    line3 = costs[2]
    if i1 >= len(line1) or i2 >= len(line2) or i3 >= len(line3):
        return 1000000000000
    c1 = line1[i1][1]
    c2 = line2[i2][1]
    c3 = line3[i3][1]
    if c1 == c2 and c1 == c3:
        return min(
            find_min(i1 + 1, i2, i3),
            find_min(i1, i2 + 1, i3),
            find_min(i1, i2, i3 + 1)
        )
    if c1 == c2:
        return min(
            find_min(i1 + 1, i2, i3),
            find_min(i1, i2 + 1, i3),
        )
    if c1 == c3:
        return min(
            find_min(i1 + 1, i2, i3),
            find_min(i1, i2, i3 + 1)
        )
    if c2 == c3:
        return min(
            find_min(i1, i2 + 1, i3),
            find_min(i1, i2, i3 + 1)
        )
    return line1[i1][0] + line2[i2][0] + line3[i3][0]

print(find_min(0, 0, 0))


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;

	priority_queue<ll> p, q, r, Q;
	REP(i, A) {ll a; cin >> a; p.push(a);}
	REP(i, B) {ll a; cin >> a; q.push(a);}
	REP(i, C) {ll a; cin >> a; r.push(a);}

	REP(i, X) {Q.push(p.top()); p.pop();}
	REP(i, Y) {Q.push(q.top()); q.pop();}
	while (!r.empty()) {Q.push(r.top()); r.pop();}

	ll res{0};
	REP(i, X+Y)
	{
		res += Q.top();
		Q.pop();
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 8816
/*0ms,1008KB*/

#include<cstdio>
#include<cstring>

int a[15], l[15], r[15], t, i, j, lc, rc, cnt;
bool vis[15], flag;

bool solve()
{
	for (i = 0; i < 1024; ++i)
	{
		memset(l, 0, sizeof(l));
		memset(r, 0, sizeof(r));
		lc = rc = 0;
		for (cnt = 0, j = i; cnt < 10; ++cnt, j >>= 1)
		{
			if (j & 1) l[lc++] = a[cnt];
			else r[rc++] = a[cnt];
		}
		flag = true;
		for (j = 1; j < lc; ++j)
			if (l[j] < l[j - 1])
			{
				flag = false;
				break;
			}
		if (flag)
			for (j = 1; j < rc; ++j)
				if (r[j - 1] > r[j])
				{
					flag = false;
					break;
				}
		if (flag) return true;
	}
	return false;
}

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		memset(vis, 0, sizeof(vis));
		for (i = 0; i < 10; ++i)
			scanf("%d", &a[i]);
		puts(solve() ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1008
import itertools
N,M = map(int,input().split())
ary1 = map(int,input().split())
if N>=M:
  print(0)
else:
  ary2 = sorted(list(ary1))
  ary3 = ary2[1:]
  ary4 = ary2[:-1]
  d1  = ary2[M-1]-ary2[0]
  dist1 = sorted([i-j for i,j in zip(ary3,ary4)])[M-N:M]
  d2 =  sum(dist1)
  print(d1-d2)

Measured memory_bytes: 14336
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
using namespace std;

int main() {
  int n, tmp;
  cin >> n;
  vector <int> ans(n+10);
  for (int i = 1; i < n; i++){
    cin >> tmp;
    ans[tmp]++; 
  }
  for (int i = 1; i < n+1; i++){
    cout << ans[i] << endl;
  }
return 0;
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

Measured memory_bytes: 4052
N,M = map(int,input().split())
H = list(map(int, input().split()))
AB=[]
good=[1]*N
for i in range(M):
  a,b=map(int,input().split())

  ah=H[a-1]
  bh=H[b-1]
  if ah>bh:
    good[b-1]=0
  elif ah<bh:
    good[a-1]=0
  else:
    good[a-1]=0
    good[b-1]=0
counter=0
for i in good:
  if i==1:
    counter=counter+1
print(counter)

Measured memory_bytes: 20132
using System;
using System.Collections.Generic;
using System.Linq;
class Dict
{
    internal readonly Dictionary<char, string> toBit = new Dictionary<char, string>()
        {
            {' ',"101" },
            {'\'',"000000" },
            {',',"000011" },
            {'-',"10010001" },
            {'.',"010001" },
            {'?',"000001" },
            {'A',"100101" },
            {'B',"10011010" },
            {'C',"0101" },
            {'D',"0001" },
            {'E',"110" },
            {'F',"01001" },
            {'G',"10011011" },
            {'H',"010000" },
            {'I',"0111" },
            {'J',"10011000" },
            {'K',"0110" },
            {'L',"00100" },
            {'M',"10011001" },
            {'N',"10011110" },
            {'O',"00101" },
            {'P',"111" },
            {'Q',"10011111" },
            {'R',"1000" },
            {'S',"00110" },
            {'T',"00111" },
            {'U',"10011100" },
            {'V',"10011101" },
            {'W',"000010" },
            {'X',"10010010" },
            {'Y',"10010011" },
            {'Z',"10010000" }
        };

    internal readonly char[] toChar = new char[]
        {
            'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','.',',','-','\'','?'
        };
}
class Program
{
    static void Main()
    {
        var dc = new Dict();
        Read().ToList().ForEach(delegate (string str)
        {
            string bit = "";
            string ans = "";
            str.ToCharArray().ToList().ForEach(x => bit += dc.toBit[x]);
            bit += new string('0', (5 - bit.Length % 5) % 5);

            for (int i = 0; i < bit.Length; i += 5)
            {
                ans += dc.toChar[Convert.ToInt32(bit.Substring(i, 5), 2)];
            }

            Console.WriteLine(ans);
        });
    }
    private static IEnumerable<string> Read()
    {
        string n;
        while (!string.IsNullOrEmpty(n = Console.ReadLine()))
        {
            yield return n;
        }
        yield break;
        Console.WriteLine("invalid object inserted...");
        Environment.Exit(0);
    }
}



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

bool isSame(string s){
    if(s[0] != '.')
        return false;
    for(int i=0;i<s.size()-1;i++){
        if(s[i] != s[i+1])
            return false;
    }
    return true;
}

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

    int h, w;
    cin >> h >> w;
    string str[h];
    vector <bool> row(h, false);
    vector <bool> col(w, false);

    for(int i=0;i<h;i++){
        cin >> str[i];
        if(isSame(str[i]))
            row[i] = true;
    }

    for(int i=0;i<w;i++){
        string s;
        for(int j=0;j<h;j++){
            s+=str[j][i];
        }
        if(isSame(s)){
            col[i] = true;
        }
    }
    for(int i=0;i<h;i++){
        if(!row[i]){
            for(int j=0;j<w;j++){
                if(!col[j]){
                    cout << str[i][j];
                }
            }
            cout << '\n';
        }
    }
    return 0;
}


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

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

    int n;
    cin >> n;
    int s[n][26] = {0};
    string str;
    rep(i, n) {
        cin >> str;
        rep(j, str.size()) ++s[i][str[j] - 'a'];
    }
    string res = "";
    rep(j, 26){
        int min_n = 51;
        rep(i, n) min_n = min(min_n, s[i][j]);
        rep(i, min_n) res += 'a' + j;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,ans=0;
  cin >> n >> k;
  ll l[n];
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l,l+n,greater<ll>());
  for(int i=0;i<k;i++){
    ans += l[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s, t;
    cin >> s >> t;
    Yes(s == t.substr(0, s.length()));
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=998244353;
struct node
{
    int x,y;
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
}a[N];
int n,t[N],hs[N];
ll lu[N],ld[N],ru[N],rd[N];
ll f[N];
void add(int x)
{
    while(x<=n)
        t[x]++,x+=x&-x;
}
int query(int x)
{
    int ans=0;
    while(x) ans+=t[x],x-=x&-x;return ans;
}
int main()
{
    f[0]=1;
    for(int i=1;i<N;i++)
        f[i]=f[i-1]*2%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y),hs[i]=a[i].y;
    sort(a+1,a+1+n);
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++)
        a[i].y=lower_bound(hs+1,hs+1+n,a[i].y)-hs;
    for(int i=1;i<=n;i++)
    {
        ld[i]=query(a[i].y);
        lu[i]=i-1-ld[i];
        add(a[i].y);
    }
    memset(t,0,sizeof(t));
    for(int i=n;i>=1;i--)
    {
        rd[i]=query(a[i].y);
        ru[i]=n-i-rd[i];
        add(a[i].y);
    }
    ll ans=0;
	for(int i=1;i<=n;++i)
    {
		ans=(ans+f[n-1])%mod;
		ans=(ans+f[n-1])%mod;
		ans=(ans-f[lu[i]+ld[i]])%mod;
		ans=(ans-f[ru[i]+rd[i]])%mod;
        ans=(ans-f[lu[i]+ru[i]])%mod;
        ans=(ans-f[ld[i]+rd[i]])%mod;
        ans=(ans+f[lu[i]])%mod;
        ans=(ans+f[ru[i]])%mod;
        ans=(ans+f[ld[i]])%mod;
        ans=(ans+f[rd[i]])%mod;
        ans=(ans-1)%mod;
	}
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}
/*
6
0 0
1 1
-1 -1
2 -2
-2 2
-3 3
*/


Measured memory_bytes: 11136
def sumdidits(x):
  res=0
  while x:
    res+=x%10
    x//=10
  return res

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  t=sumdidits(i)
  if a<=t<=b:
    ans+=i
print(ans)

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

int main() {
    long long N, C; cin >> N >> C;
    vector<long long> x(N + 2), v(N + 2);
    for(long long i = 1; i <= N; i++) {
        cin >> x[i] >> v[i];
    }
    x[0] = 0;
    x[N + 1] = C;

    long long cal = 0;
    vector<vector<long long>> dp(2, vector<long long>(100010, 0));

    for (long long i = 1; i <= N; i++)
    {
        cal -= x[i] - x[i - 1];
        cal += v[i];
        dp[0][i] = max(dp[0][i - 1], cal);
    }

    cal = 0;
    for (long long i = N; i >= 1; i--)
    {
        cal -= x[i + 1] - x[i];
        cal += v[i];
        dp[1][i] = max(dp[1][i+1], cal);
    }

    long long maxcal = 0;
    for (long long i = 0; i <= N; i++)
    {
        cal = dp[0][i] + dp[1][i + 1] - x[i];
        maxcal = max(maxcal, cal);

        cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
        maxcal = max(maxcal, cal);
    }

    cout << maxcal << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    for (int i  = 0;i<3;i++){
        if(a[i]!=b[2-i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 
  int x,y,z,w;
  scanf("%d%d%d%d",&x,&y,&z,&w);
 
 
  if(abs(x-z)>w&&(abs(x-y)>w||abs(y-z)>w)){
  printf("No");
  }else{
    printf("Yes");
  }
 
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(void) {
	long X;
	scanf("%ld", &X);
	while (1) {
		bool isPrime = true;
		for (long j = 2; j*j < X; j++) {
			// cout << X + i << " " << j << endl;
			if (X % j == 0) {
				isPrime = false;
				break;
			}
		}
		if (isPrime) {
			printf("%ld", X);
			return 0;
		}
		X++;
	}

	return 0;
}


Measured memory_bytes: 3784
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num == 0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n;
}

int n, k, p[1234],c;
signed main() {
	cin >> n >> k;
	rep(0, n)cin >> p[i];
	sort(p, p + n);
	rep(0, k) {
		c += p[i];
	}cout << c << endl;
}


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

int main( void )
{
  int a, b, c;
  cin >> a >> b >> c;

  int sum = a * 100 + b * 10 + c;

  if( sum % 4 == 0 )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w) cout << "unsafe";
  if (s > w) cout << "safe";
  return 0;
}

Measured memory_bytes: 3624
n = gets.to_i
t, x, y = 0, 0, 0

n.times do
  ti, xi, yi = gets.split.map(&:to_i)
  time = ti - t
  dist = (xi - x).abs + (yi - y).abs
  if time < dist || time % 2 != dist % 2
    puts "No"
    exit
  end
  ti, xi, yi = t, x, y
end
puts "Yes"


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    x = int(lines[0])

    return (x, )


def solve(x, ):


    y = x // 500
    z = x % 500
    w = z // 5

    result = 1000 * y + 5 * w


    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int n,i,j,v,cnt,minj,temp,fmin;
    int a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    cnt=0;
    for(i=0;i<n;i++){
        minj=i;
        fmin=minj;
        for(j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        temp=a[i];
        a[i]=a[minj];
        a[minj]=temp;
        if(fmin!=minj){
            cnt++;
        }
    }
    for(i=0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1992
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int n;
    cin >> n;
    
    printf("%.10llf\n", (ld)(n - n / 2) / n);
	
	return 0;
}

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

int main()
{
	string str;
	int i;
	bool check=0;
	cin>>str;
	for(i=1;i<4;i++){
		if(str.at(i)==str.at(i-1)){
			check=1;
		}
	}
	if(check){
		cout<<"Bad";
	}else{
		cout<<"Good";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++)
	{
		if((i*a)%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
// g++ -I ~/Documents/AtCoder -std=gnu++14 -o test ~/Documents/AtCoder/test.cpp && ./test && rm test
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;

class UnionFind {
    vector<int> data; //  0以上なら自身の親ノードを指す 0未満なら集合の要素数×-1
    int root(int x) {
        if( data[x] < 0 ) { return x; }
        return data[x] = root( data[x] );
    }
public:
    UnionFind(int n) :data( vector<int>(n,-1) ) {}
    bool unite(int x, int y) { // 元々同じ素集合ならtrue, 別の集合同士を結合させたならfalse
        x = root(x); y = root(y);
        if(x == y) { return true; }
        if(data[x] > data[y]) { swap(x, y); }
        data[x] += data[y]; data[y] = x;
        return false;
    }
    bool same(int x, int y) { // 同じ集合の要素ならtrue, 別の集合ならfalse
        return root(x) == root(y);
    }
    int size(int x) { //  属する集合の要素数
        return -data[ root(x) ];
    }
};


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N=in, M=in;

    int count = 0;
    UnionFind uf(N);
    rep( i, M ) {
        int x=in-1, y=in-1, z=in;
        if( !uf.unite(x,y) ) count ++;
    }

    cout << (N - count) << '\n';
}


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

int main(){
    int A,B;
    int count = 0;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        int m = i / 10000;
        int t = (i % 10000) / 1000;
        int ten = (i % 100) / 10;
        int iti = i % 10;
        if(m == iti && t == ten) count++;
    }    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) cin >> ab[i].second >> ab[i].first;
    sort(all(ab));
    ll sum = 0;
    rep(i, n) {
        sum += ab[i].second;
        if (sum > ab[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
#define int long long 
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
const int mod = 1000000007;
const double PI = 3.1415926535898;

#define N 100005

const int INF = (1LL << 62) - 1;


vector<bool> vis(N,false);
vector<int> dist(N,INF);
vector<int> par(N,-1);

vector<int> adj[N];


void bfs(int s)
{
  queue<int> q;

  q.push(s);
  vis[s] = true;
  dist[s] = 0;

  while(!q.empty())
  {
    int k = q.front();
    q.pop();

    for(auto i : adj[k])
    {
       if(1 + dist[k] < dist[i])
        {
          dist[i] = dist[k] + 1;
          par[i] = k;
        }

      if(!vis[i])
      {
        q.push(i);
        vis[i] = true;
        if(par[i] == -1) par[i] = k;

        if(1 + dist[k] < dist[i])
        {
          dist[i] = dist[k] + 1;
          par[i] = k;
        }
      }
    }
  }
}




int32_t main()
{




      int n,m;
      cin >> n >> m;

      for(int i = 1; i <= m; i++)
      {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
      }


      bfs(1);

      for(int i = 1; i <= n; i++)
      {
        if(!vis[i])
        {
          cout << "No";
          return 0;
        }
      }

      cout << "Yes" << endl;
      
      for(int i = 2 ; i <= n; i++)
      {
        cout << par[i] << endl;
      }


    return 0;
}



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

int main(void){
 
    int A,B,sum =0;
    cin >> A >> B;
    
    if(A >= B){
        sum += A;
        A--;
    }
    else{
        sum += B;
        B--;
    }
    
    if(A >= B){
        sum += A;
        A--;
    }
    else{
        sum += B;
        B--;
    }
    
    cout << sum <<endl;
}

Measured memory_bytes: 3644
N, X, Y = map(int, input().split())
ans_list = [0] * (N+1)

for i in range(1, N):
    for j in range(i+1, N+1):
        ans_list[min((j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))] += 1

for i in ans_list[1:-1]:
    print(i)
    

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

int main() {
	int h, w; scanf("%d%d", &h, &w);
	rep(i, h) {
		string s; cin >> s;
		cout << s << endl << s << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll x,y;
  std::cin>>x>>y;

  if((y-2*x)%2!=0){
    std::cout<<"No\n";
    return 0;
  }

  if(2*x<=y&&y<=4*x)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}

Measured memory_bytes: 3648
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n, *a = map(int, read().split())

    if 0 in a:
        print(0)
        sys.exit()
    a = deque(a)
    s = 10 ** 18
    r = 1
    while a:
        r = r * a.popleft()
        if r > s:
            print(-1)
            sys.exit()
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22300
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 n, l;
  cin >> n >> l;
  i64 MIN = abs(l);
  i64 A = l;
  i64 sum = 0;
  for(int i = 1;i <= n;i++) {
    i64 a = l + i - 1;
    if(MIN > abs(a)) {
      MIN = abs(a);
      A = a;
    }
    sum += a;
  }
  cout << sum - A << endl;
}


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

maxDis = (k - lst[-1]) + lst[0]
for i in range(n-1):
    if lst[i + 1] - lst[i] > maxDis:
        maxDis = lst[i + 1] - lst[i]
print(k - maxDis)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll a, b, k;
    cin>>a>>b>>k;
    if(k>=a){
        k = k-a;
        a = 0;
    }
    else{
        a -= k;
        k = 0;
    }   
    if(k>=b){
        k = k-b;
        b = 0;
    }
    else{
        b -= k;
        k = 0;
    }
    cout<<a<<" "<<b;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      ans += "x";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
int main()
{ 
    fast;
    ll n;
    cin>>n;
    ll a[n];
    vi v;
    f(i,n)
        cin>>a[i];
    ll xorr=a[0];
    for(ll i=1;i<n;i++)
    {
        xorr=xorr^a[i];
    }
    f(i,n)
    {
        ll ans=xorr^a[i];
        v.push_back(ans);
    }
    f(i,(ll)v.size())
    {
        cout<<v[i]<<" ";
    }
}

Measured memory_bytes: 6864
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		List<Double> list = new ArrayList<Double>();
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextDouble()) {
			 list.add(sc.nextDouble());
			}
			Double[] d = list.toArray(new Double[0]);
			Arrays.sort(d);
			System.out.println(d[d.length-1]-d[0]);

		} finally {
			sc.close();
		}

	}

}

Measured memory_bytes: 18680
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

map<ll, int > prime_factor(ll n) {
  map<ll, int > 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;
}

int main()
{
  INT(N);
  VEC(ll,A,N);
  map<ll,int> mp;
  REP(i,N){
    for(auto x:prime_factor(A[i])){
      mp[x.fi]=max(mp[x.fi],x.se);
    }
  }

  mint LCM=1;
  for(auto x:mp){
    mint y=x.fi;
    LCM*=y.pow(x.se);
  }

  mint ans = 0;
  REP(i,N){
    ans+=LCM/A[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 4124
#include <stdio.h>

int main(){
   int d;
    
   scanf("%d",&d);
   if (d==25) puts("Christmas");
   else  if (d==24) puts("Christmas Eve");
   else  if (d==23) puts("Christmas Eve Eve");
   else  if (d==22) puts("Christmas Eve Eve Eve");
   return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

def f(x):
    return (x + 1) * x // 2

l = 0
r = 1000000
a = 0

for _ in range(100):
    a = (l + r) // 2
    c = f(a)
    if c < N:
        l = a
    elif c > N:
        r = a
    else:
        break

if f(a) == N:
    for i in range(1, a + 1):
        print(i)
else:
    p = f(a + 1) - N
    for i in range(1, a + 2):
        if i != p:
            print(i)

Measured memory_bytes: 3408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, double> pdd;
typedef pair<ll, pii> key;

vector<int> edges[100005];
int k;
int ret;

int dfs(int curr) {
  int maxD = 0;
  for(int out: edges[curr]) {
    int d = dfs(out);
    if(d == k-1 && curr != 1) ret++;
    else maxD = max(maxD, d+1);
  }
  return maxD;
}

void solve() {
  int n;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    int to;
    cin >> to;
    if(i == 1 && to != 1) ret++;
    if(i > 1) edges[to].push_back(i);
  }
  dfs(1);
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 10368
s = input()
K = int(input())
ssorted = sorted(set(list(s)))
j = 0
dic = []
while len(dic) < K:
  w = ssorted[j]
  index = -1
  idxs =[]
  while True:
    index = s.find(w, index + 1)
    if index == -1:
      break
    else:
      idxs.append(index)
  dic += sorted(set([w] + 
                   [s[i:i+2] for i in idxs] +
                   [s[i:i+3] for i in idxs] +
                   [s[i:i+4] for i in idxs] +
                   [s[i:i+5] for i in idxs]))
  j += 1
print(dic[K-1])

Measured memory_bytes: 4724