akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define u64 unsigned long long
using namespace std;
ll c[123][123];
void Ad(ll lim,int ty,ll sm[],int k)
{
	int bt=0;
	for(int i=k;i>=0;--i)
		if(lim>>i&1){
			for(int j=0;j<=i;j++)
				sm[bt+j]+=ty*c[i][j];
			++bt;
		}
	sm[bt]+=ty;
}
ll a[1234],cc[1234],d[1234];
ll tmp[64];
u64 gg=1234321237ll;
u64 Hsh(int n)
{
	u64 tmp=0;
	for(int i=2;i<=n;i++)
		tmp=tmp*gg+(u64)(cc[i]-cc[i-1]);
	return tmp;
}
unordered_map<u64,int> bok;
vector<pair<ll,ll>> sg[123456];
void solve()
{
	int n;
	ll kk;
	scanf("%d%lld",&n,&kk);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int maxn=0;
	bok.clear();
	for(int k=0;k<=60;k++){
		for(int i=1;i<=n;i++)
			d[i]=a[i]%(1LL<<k);
		sort(d+1,d+n+1);
		d[0]=-1;
		d[n+1]=(1LL<<k)-1;
		for(int i=0;i<=n;i++){
			if(d[i]==d[i+1]||d[i]+1>a[1])continue;
			memset(tmp,0,sizeof(tmp));
			Ad(min(d[i+1],a[1]),1,tmp,k-1);
			if(i)Ad(d[i],-1,tmp,k-1);
			for(int j=1;j<=n;j++)
				cc[j]=(a[j]-d[i+1])>>k;
			u64 nv=Hsh(n);
			int id=bok[nv];
			if(!id){
				id=bok[nv]=++maxn;
				sg[maxn].clear();
			}
			for(int j=0;j<=k&&j+k<=kk;j++)
				if(tmp[j]){
					ll r=cc[1],l=max(r-(kk-j-k),0LL);
					sg[id].push_back(make_pair(l,r));
				}
		}
	}
	ll als=0;
	for(int i=1;i<=maxn;i++){
		sort(sg[i].begin(),sg[i].end());
		ll mx=-1,nl=0;
		for(pair<ll,ll>o:sg[i])
			if(o.first<=mx)mx=max(mx,o.second);
			else als+=(mx-nl+1)%MOD,mx=o.second,nl=o.first;
		als+=(mx-nl+1)%MOD;
	}
	printf("%lld\n",als%MOD);
}
int main()
{
	for(int i=0;i<=100;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	int t=1;
//	scanf("%d",&t);
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 8960
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		double max = -1;
		int maxTotal = 0;
		int maxSugar = 0;
		for (int i = 0; i * a * 100 <= f; i++) {
			for (int j = 0; i * a * 100 + j * b * 100 <= f; j++) {
				for (int k = 0; i * a * 100 + j * b * 100 + k * c <= f; k++) {
					if ((i * a + j * b) * e < k * c) {
						break;
					}
					for (int l = 0; i * a * 100 + j * b * 100 + k * c + l * d <= f; l++) {
						if ((i * a + j * b) * e < k * c + l * d) {
							break;
						}
						double dd = (100.0 * (k * c + l * d)) / (i * a * 100 + j * b * 100 + k * c + l * d);
						if (max < dd) {
							max = dd;
							maxTotal = i * a * 100 + j * b * 100 + k * c + l * d;
							maxSugar = k * c + l * d;
						}
					}
				}
			}
		}
		System.out.println(maxTotal + " " + maxSugar);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    unordered_map<ll, ll> M;
    ll SUM = 0;
    for(int i = 0; i < N; i++){
        ll x; cin >> x; 
        M[x]++;
        SUM += x;
    }
    ll Q; cin >> Q;
    for(int i = 0; i < Q; i++){
        ll b, c; cin >> b >> c;
        ll bx = M[b];
        SUM = SUM - b*bx + c*bx;
        M[b] = 0;
        M[c] += bx;
        cout << SUM << endl;
    }
}

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

int main(){
    int x,a,b,c,cnt=0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    for(int l=0;l<=a;++l){
        for(int m=0;m<=b;++m){
            for(int n=0;n<=c;++n){
                if(x/50 == l*10 + m*2 + n){
                    ++cnt;
                    break;
                }
            }
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int i = 0; i < A+1; i++){
    for(int j = 0; j < B+1; j++){
      for(int k = 0; k < C+1; k++){
        if(X == 500*i + 100*j + 50*k){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
N=int(input())
D=[int(i) for i in input().split()]
M=int(input())
T=[int(i) for i in input().split()]
D.sort()
T.sort()
d=dict()
t=dict()
for i in range(N):
    if not D[i] in d:
        d[D[i]]=1
    d[D[i]]+=1
for i in range(M):
    if not T[i] in t:
        t[T[i]]=1
    t[T[i]]+=1
S=set(T)
for i in S:
    if not i in d:
        print("NO")
        exit()
    if d[i]<t[i]:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 65876
#include <cstdio>

int main(){
	while(1){
		int h, w;
		scanf(" %d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				if( (i+j)%2==0 ) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

Measured memory_bytes: 1000
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  long long int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<long long int> dp(F+1, -1);
  dp[0] = 0;
  for (long long int i = 100*A; i <= F; i++){
    long long int a = -1, b = -1, c = -1, d = -1;
    if ((i >= 100*A) && (dp[i-100*A] != -1)){
      a = dp[i-100*A];
    }
    if ((i >= 100*B) && (dp[i-100*B] != -1)){    
      b = dp[i-100*B];
    }
    if ((i >= C) && (dp[i-C] != -1)){        
      c = dp[i-C]+C;
    }
    if ((i >= D) && (dp[i-D] != -1)){            
      d = dp[i-D]+D;
    }
    //cerr << a << ',' << b << ',' << c << ',' << d << endl;
    if ((100*a*(100+E)) <= (100*E*i)){
      dp[i] = max(dp[i], a);
    }
    if ((100*b*(100+E)) <= (100*E*i)){
      dp[i] = max(dp[i], b);
    }
    if ((100*c*(100+E)) <= (100*E*i)){    
      dp[i] = max(dp[i], c);
    }
    if ((100*d*(100+E)) <= (100*E*i)){        
      dp[i] = max(dp[i], d);
    }    
  }
  long long int maxresult = 0;
  long long int maxi = 0;
  double maxm = 0;
  for (long long int i = 100*A; i <= F; i++){
    //cerr << dp[i] << ',';
    if ((dp[i] >= (i*maxm)) && ((100*dp[i]*(100+E)) <= (100*E*i))){
      //cerr << i << endl;
      maxi = i;
      maxresult = dp[i];
      maxm = (double)dp[i]/(double)i;
    }
  }
  cout << maxi << ' ' << maxresult;
  return 0;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

constexpr const int mod = 1000000007;
// constexpr const int mod = 998244353;
class mint {
 public:
  long long x;
  constexpr mint(long long x = 0) noexcept : x((x % mod + mod) % mod) {}
  constexpr int getmod() { return mod; }
  constexpr mint operator-() const noexcept { return mint(-x); }

  constexpr mint& operator+=(const mint& a) noexcept {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator-=(const mint& a) noexcept {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator*=(const mint& a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint& operator/=(const mint& a) noexcept {
    return (*this) *= a.inv();
  }

  constexpr mint operator+(const mint& a) const noexcept {
    return mint(*this) += a;
  }
  constexpr mint operator-(const mint& a) const noexcept {
    return mint(*this) -= a;
  }
  constexpr mint operator*(const mint& a) const noexcept {
    return mint(*this) *= a;
  }
  constexpr mint operator/(const mint& a) const noexcept {
    return mint(*this) /= a;
  }

  constexpr mint inv() const noexcept { return pow(mod - 2); }
  constexpr mint pow(long long t) const noexcept {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  friend istream& operator>>(istream& is, mint& a) noexcept {
    return is >> a.x;
  }
  friend ostream& operator<<(ostream& os, const mint& a) noexcept {
    return os << a.x;
  }
};

struct BiCoef {
  vector<mint> fact, ifact;
  BiCoef(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }

  mint P(int n, int r) {
    if (r < 0 || r > n) return 0;
    return fact[n] * ifact[n - r];
  }

  mint C(int n, int r) {
    if (r < 0 || r > n) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
  }

  mint H(int n, int r) {
    if (r < 0 || 0 > n) return 0;
    return C(n + r - 1, r);
  }
};

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

  BiCoef bi(n + 2);
  for (ll i = 1; i <= k; i++) {
    cout << bi.C(n - k + 1, i) * bi.C(k - 1, i - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 3656
from collections import Counter
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s = Counter(s)
t = Counter(t)

ans = 0
for key, num in s.items():
    if key in t:
        if ans < num - t[key]:
            ans = num - t[key]
    else:
        if ans < num:
            ans = num

print(ans)

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int k, p;
        cin >> k >> p;
        cout << (k%p == 0 ? p : k%p) << endl;
    }

    return 0;
}



Measured memory_bytes: 3064
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    int k=2;
    ll height[n];
    for(int i=0 ; i<n ; i++)
        cin >> height[i];
    ll dp[n];
    for(int i=0 ;i<n ; i++)
        dp[i] = 1e15;
    dp[0] = 0;

    for(int i=1 ; i<n ; i++)
    {
        for(int j=i-1 ; j>=max(0,(i-k)) ; j--)
            dp[i] = min(dp[i],dp[j] + abs(height[i] - height[j]));
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 5084
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;




int main() {
	int n;
	ll k;

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

	int l = 0;
	int r = 1e9 + 5;
	int mid = (l + r) / 2;

	while (mid != l) {
		ll cnt = 0;
		for (int ai:a) {
			cnt += (ai / mid);
			if (ai % mid == 0) {
				cnt--;
			}
		}

		if (cnt <= k) {
			r = mid;
		}
		else {
			l = mid;
		}

		mid = (l + r) / 2;

	}

	cout << (mid + 1) << endl;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;
	cin>>n;
	ll f[n],a[n];
	for(ll i=0;i<n;i++){
	    cin>>a[i];
	}
	f[0]=0;
	f[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++){
	    f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<f[n-1];
	return 0;
}

Measured memory_bytes: 1792
a, b, c = [int(x) for x in input().split()]
i = temp = 0
temp_set = set()
ans = "NO"
while temp not in temp_set:
    temp_set.add(temp)
    if temp == c:
        ans = "YES"
        break
    i += 1
    temp = (a * i) % b
print(ans)

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

int main() {
	ll X,Y;
	cin >> X >> Y;
  ll cnt = 0;
  ll now = X;
  while(now<=Y){
    cnt +=1;
    now*=2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int underf(int a, int b){
	return a%b==0? a/b:(a+b-a%b)/b;
}

int main (){
	int nn,kk;
	cin >> nn >> kk;
	int one = 0;
	int a=0;
	rep(i,nn){
		cin >> a;
		if(a == 1) one = i;
	}
	int ans;
	ans = underf(nn-1,kk-1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main()
{
	int a,b,d,e,f;
	scanf("%d %d",&a,&b);
	d=a+b;e=a-b;f=a*b;
	
	if(d>=e&&d>=f)
	{
		printf("%d\n",d);
	}
	
	else if(e>=d&&e>=f)
	{
		printf("%d\n",e);
	}
	
	else if(f>=d&&f>=e)
	{
		printf("%d\n",f);
	}
	return 0;
}

Measured memory_bytes: 760
#include <stdio.h>
#include <math.h>

int counter( long long int n ){
    int count = 0;
    while( n > 0 ){
        n = n/10;
        count++;
    }
    return count;
}

int main(void){
    
    long long int i,n;
    int a,b,ans=1;
    
    scanf( "%lld",&n );
    
    for( i = 1; i <= sqrt((double)n); i++ ){
        if( n % i == 0 ){
            a = counter(i);
            b = counter(n/i);
            if( a > b ) ans = a;
            else ans = b;
        }
    }
    printf( "%d\n",ans );

    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

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

const int MOD = 998244353;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



int A[100], B[100];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int cnt = 0;
	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	bool ok = false;
	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				B[k] = A[k];
			}
			swap(B[i], B[j]);
			bool ok2 = true;
			REP(k, N - 1) {
				if (B[k + 1] != B[k] + 1)ok2 = false;
			}
			if (ok2) {
				print("YES"); return 0;
			}
		}
	}
	print("NO");
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char


main :: IO ()
main = do
    (n,k) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> BS.getLine
    let jj = n`mod`k
    print $ min jj (k-jj)



readInt :: BS.ByteString -> Maybe (Int,BS.ByteString)
readInt = BS.readInt . BS.dropWhile isSpace

Measured memory_bytes: 380
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

#print(n,a,b,c)

t = -10
ans = 0

for i in range(n):
	#print('-------')
	#print(i)
	#print(b[a[i]-1])
	ans = ans + b[a[i]-1]
	#print(ans)
	if a[i]-t == 1 :
		#print(c[t-1])
		ans = ans + c[t-1]	
		#print(ans)
	t = a[i]
	
print(ans)


Measured memory_bytes: 3064
n = $stdin.gets.chomp.to_i
h = Hash.new()
h["ac"] = 0;h["wa"] = 0;h["tle"] = 0;h["re"] = 0
n.times do
  n = $stdin.gets.chomp.downcase
  h[n] += 1
end

puts "AC x #{h["ac"]}"
puts "WA x #{h["wa"]}"
puts "TLE x #{h["tle"]}"
puts "RE x #{h["re"]}"


Measured memory_bytes: 14288
#include <iostream>

using namespace std;

bool is_prime(int x)
{
	if (x == 2)
		return true;

	if (x % 2 == 0)
		return false;

	for (int i = 3; i*i <= x; i += 2)
		if (x % i == 0)
			return false;

	return true;
}

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

	int n;
	cin >> n;

	int count = 0, x;
	while (n--)
	{
		cin >> x;
		count += is_prime(x);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1196
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    # s, t
    s = list(input())
    t = list(input())
    count = 0
    for i in range(3):
        if s[i] == t[i]:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
   int k,a,b,i;
   cin>>k>>a>>b;
   for(i=a;i<=b;i++)
   {
       if(i%k==0)
       {
           cout<<"OK"<<endl;
           return 0;
       }
   }
   cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b && b < c){
        System.out.println("Yes");
        }
        else{
        System.out.println("No");
        }
	}

}


Measured memory_bytes: 26184
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

template <typename T> class segtree
{
private:
    std::size_t N;
    std::vector<T> data;

    T query(std::size_t a, std::size_t b, std::size_t k, std::size_t l, std::size_t r)
    {
        if (r <= a || b <= l)
        {
            return std::numeric_limits<T>::min();
        }
        if (a <= l && r <= b)
        {
            return data[k];
        }
        size_t m = (l + r) / 2;
        return std::max(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
    }

public:
    segtree(const std::size_t n, const T init)
    {
        N = 1;
        while (N < n)
        {
            N *= 2;
        }
        data.resize(N * 2, init);
    }

    void update(std::size_t k, T a)
    {
        k += N - 1;
        data[k] = a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            data[k] = std::max(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    T query(std::size_t a, std::size_t b) { return query(a, b, 0, 0, N); }
};

int main()
{
    int n;
    cin >> n;
    segtree<int64_t> tree(n, 0);

    vector<pair<int64_t, int>> vs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vs[i].first;
        vs[i].second = i;
    }
    sort(vs.begin(), vs.end(), [&](const pair<int64_t, int>& p1, const pair<int64_t, int>& p2) {
        if (p1.first != p2.first)
        {
            return p1.first > p2.first;
        }
        else
        {
            return p1.second < p2.second;
        }
    });

    for (auto& v : vs)
    {
        const int count = tree.query(0, v.second);
        tree.update(v.second, count + 1);
    }
    cout << tree.query(0, n) << endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int, ll> P;
struct edge{
    int to, cost;
};
vector<edge> G[100005];
bool used[100005];
int ans[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        if(w % 2 == 0)  w = 0;
        else            w = 1;
        G[u].push_back((edge){v, w});
        G[v].push_back((edge){u, w});
    }
    
    queue<int> que;
    ans[0] = 0;
    used[0] = true;
    que.push(0);
    while(!que.empty()){
        int u = que.front();
        que.pop();
        
        for(int i = 0; i < G[u].size(); ++i){
            edge e = G[u][i];
            if(used[e.to])     continue;
            
            ans[e.to] = (ans[u] + e.cost) % 2;
            used[e.to] = true;
            que.push(e.to);
        }
    }
    
    for(int i = 0; i < n; ++i){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 7040
use std::io;

fn main() {
    let (n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    if k == 1 { println!("0"); return; }
    println!("{}", n - k);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.Vector;
import java.math.BigInteger;

class Main{
  public static void main(String[] av) throws Exception{
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    while(sc.hasNextBigInteger()){
      BigInteger bi1 = sc.nextBigInteger();
      BigInteger bi2 = sc.nextBigInteger();
      BigInteger sum = bi1.add(bi2);
      if ( 80 < sum.toString().length() ){
        System.out.println("overflow");
        continue;
      }
      System.out.println( sum ); 
    }
  }
}

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

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

    int n; cin>>n;
    int ans=0;
    while(n>=500){
        n-=500;
        ans+=1000;
    }
    while(n>5){
        n-=5;
        ans+=5;
    }
    cout<<ans;

}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut ab = Vec::new();
    for _ in 0..n {
        let (a, b) = {
            let i = read::<usize>();
            (i[0], i[1])
        };
        ab.push((a, b));
    }
    ab.sort_by(|x, y| (y.0).cmp(&x.0));
    // println!("{:?}", ab);

    let mut que = BinaryHeap::new();
    let mut ans: usize = 0;
    let mut idx = 0;
    let mut i = 0;

    while i < m {
        i += 1;
        for j in idx..n {
            if ab[n - j - 1].0 <= cmp::min(m, i) { que.push(ab[n - j - 1].1); }
            else { break; }
            idx = j + 1;
        }
        if let Some(b) = que.pop() {
            ans += b;
        }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include <cmath>



using namespace std;
int main(){
  int n,t,a;cin >>  n >> t >> a;
  a -=t;
  double ans= 1.0e+9, ansi;
  for(int i = 0; i < n; ++i){
    double h; cin >> h;
    h = abs(a + (0.006 * h));
    if(h < ans){
      ans = h;ansi = i;
    }
  }
  cout << ansi+1<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100004
#define ll long long
#define F first
#define S second
using namespace std;
vector<pair<ll,ll> > v;
ll rep=0,midx;
ll a[N];
int main(){
    ios_base::sync_with_stdio(0);
    ll n,k,m,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        v.push_back(make_pair(x,i));
    }
    if(n==1){
        cout<<x<<endl;
        return 0;
    }
    sort(v.begin(),v.end());
    midx=v[n-1].S;
    for(int i=v.size()-1;i>0;i--){
        rep++;
        if(v[i-1].F==v[i].F){
            midx=min(midx,v[i-1].S);
            continue;
        }
        k=rep*(v[i].F-v[i-1].F);
        a[midx]+=k;
        midx=min(midx,v[i-1].S);
    }
    a[1]+=(rep+1)*v[0].F;
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, l[210];

    cin >> n;
    for(int i=0; i<2*n; i++){
        cin >> l[i];
    }

    sort(l, l+2*n);


    int ans = 0;
    for(int i=0; i<2*n; i+=2){
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n-1)cin >> a[i];
    vector<int> ans(n);
    REP(i,n-1)ans[a[i]-1]++;

    REP(i,n)cout << ans[i] << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int ans2 = n;
    while(n > 0){
        ans += n % 10;
        n /= 10;
    }
    if(ans2 % ans == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007LL
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll

struct node {
	vector<int> v,w;
};



signed main() {
	fast;

	int x,y;
	cin>>x>>y;

	if(y%2==1) {cout<<"No";return 0;}

	int a = 2*x - y/2;
	int b = y/2 - x;

	if(a<0||b<0) {cout<<"No";return 0;}
	cout<<"Yes";

}

Measured memory_bytes: 3636
import math
a, b = map(int, input().split())

x1 = math.ceil(a / .08)
b1 = math.floor(x1 * .1)

x2 = math.ceil(b / .1)
a1 = math.floor(x2 * .08)

if(b==b1):
    print(x1)
elif (a == a1):
    print(x2)
else:
    print(-1)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int m, d;
	while (true)
	{
		scanf("%d %d", &m, &d);
		if (m == 0 && d == 0)
			break;

		int total = d;
		int dd[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		for (int i = 1; i < m; ++i)
		{
			total += dd[i-1];
		}
		char* days[] = { "Monday", "Tuesday", "Wednesday", "Thursday",
			"Friday", "Saturday", "Sunday" };
		puts(days[(total+2)%7]);
	}
	return 0;
}

Measured memory_bytes: 0
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(x) {
    var args = x.split(' ').map(Number);
    var a = args[0];
    var b = args[1];
    var c = args[2];
    console.log('%s', a < b && b < c ? 'Yes' : 'No');
});

Measured memory_bytes: 15476
S = input()
Q = int(input())
query_list = []
for i in range(Q):
    query_list.append(input())
# print(S, Q, query_list)

M = 10 ** 6
start_position = int(M / 2)
left_position = start_position
right_position = start_position + len(S)
result = ["-"] * M
for i in range(len(S)):
    # print(i + left_position)
    result[i + left_position] = S[i]

# result = "".join(result[left_position:right_position])
# print(result)
# exit(0)
reverse_flag = False

for i in range(Q):
    # print(i + 1)
    # print(result[left_position:right_position])
    q = query_list[i]
    # print(q)
    t = int(q[0])
    if t == 1:
        reverse_flag = not reverse_flag
    else:
        t, f, c = q.split()
        f = int(f)
        c = c
        if f == 1:
            if reverse_flag:
                result[right_position] = c
                right_position += 1
            else:
                result[left_position - 1] = c
                left_position -= 1
        else:
            if reverse_flag:
                result[left_position - 1] = c
                left_position -= 1
            else:
                result[right_position] = c
                right_position += 1
    # print(t, f, c, result)
    # print("--------")
    #print(result[left_position:right_position])
# result = str(result)
# result = "".join(result)
# print(result)
# print(result[left_position:right_position])

result = "".join(result[left_position:right_position])
if reverse_flag:
    result = result[::-1]
print(result)

Measured memory_bytes: 26384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    string t;
    cin >> s >> t;
    bool match = false;
    string ans;
    for(int i=s.length()-t.length();i>=0;i--){
        bool f = false;
        string a = s;
        for(int j= 0;j<t.length();j++){
            if(a[i+j]=='?') continue;
            if(a[i+j]!=t[j]) f = true;
        }
        if(f) continue;
        for(int j=0;j<t.length();j++) a[i+j]=t[j];
        for(int j=0;j<s.length();j++) if(a[j]=='?') a[j]='a';
        if(ans.empty()) ans =a;
        else ans = min(ans,a);
    }
    
    if(ans.empty()==false){
        cout << ans << endl;       
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int dp[1001][1001];
string x,y;

int calc_dp(int m, int n){
  for ( int i = 0; i <= m; i++){dp[i][0] = 0; }
  for ( int i = 0; i <= n; i++){dp[0][i] = 0; }

  for ( int i = 1; i <= m; i++){
    for ( int l = 1; l <= n; l++){
      if(x[i] == y[l]){
        dp[i][l] = dp[i-1][l-1] + 1;
      } else {
        dp[i][l] = max(dp[i][l-1], dp[i-1][l]);
      }
    }
  }
  return dp[m][n];
}

int main(){
  int q;
  cin >> q;
  // init
  for ( int i = 0 ; i < q; i++){

    string X, Y;
    cin >> X >> Y;
    x = ' ' + X;
    y = ' ' + Y;

    cout << calc_dp(X.length(), Y.length()) << endl;
  }
  return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
string s;
int w,cnt=0,l;
int LiangJiaJun(){
    cin>>s;
    cin>>w;
    cnt=0;
    l=s.size();
    for(int i=0;i<l;i++){
        if(cnt%w==0)cout<<s[i];
        ++cnt;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;

const ll MOD = 998244353;


const int MAX_N = 400010;
ll fac[MAX_N],inv[MAX_N];
ll qpow(ll x, int k)
{
    x=x%MOD;
    ll ans=1;
    while(k)
    {
        if(k&1) ans=ans*x%MOD;
        x=x*x%MOD;
        k>>=1;
    }
    return ans;
}
void init()
{
    fac[0]=1;
    for(int i=1; i<MAX_N; i++)
        fac[i]=fac[i-1]*i%MOD;
    inv[MAX_N-1]=qpow(fac[MAX_N-1],MOD-2);
    for(int i=MAX_N-1; i>0; i--)
        inv[i-1]=inv[i]*i%MOD;
}
ll Comb(int n, int m)
{
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}


/*
int N,K;
ll mo=998244353;

ll combi(ll N_, ll C_) {
	const int NUM_=1400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
*/
int main(){
  ll n,a,b,k;
  cin >> n >> a >> b >> k;
  vector <P> c;
  init();
  REP(i,n+1){
    if(((k-b*i)%a) == 0 && (k-b*i) >= 0 && (k-b*i)/a <= n){
      c.pb(mk((k-b*i)/a, i));
      //cout << (k-b*i)/a << "  " << i << endl;
    }
  }
  ll sum = 0;
  REP(i,c.size()){
    
      sum = (sum + ((Comb(n,c[i].first)%998244353*Comb(n, c[i].second)%998244353)%998244353))%998244353;
      
    
  }
  sum %= 998244353;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 11504
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
using namespace std;
int main()
{
    long long n,k,i,t=0,j=0,m,a,b,x=0,y=0;
    cin>>m>>a>>b;
    if((a-m)==(b-a))
      cout<<"YES";
    else
      cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using ll = long long;

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

int main() {
	int K; std::cin >> K;
	int ans = 0;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;

  vector<int> score(n, k-q);
  for (int i = 0; i < q; i++) {
    int a; cin >> a;
    score[a-1]++;
  }
  for (int i = 0; i < n; i++) {
    if (score[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
a,b=[],[]
for i in range(n):
  s,p=input().split();p=int(p)
  if not s in a:a.append(s);b.append([s,[[p,i]]])
  else:b[a.index(s)][1].append([p,i])
b.sort()
for i in range(len(b)):
  b[i][1].sort(reverse=1)
  for j in b[i][1]:print(j[1]+1)

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

typedef double du;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef long long int lli;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl ;
#define Yes cout << "Yes" << endl ;
#define NO cout << "NO" << endl ;
#define No cout << "No" << endl ;

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

int main()
{
    fastio

    lli num;
    cin >> num;
    lli s[3];

    for(lli i = 0 , k = 1 ; i < 3 ; i ++ , k *= 10)
    {
        s[i] = (num % 10) * k ;
        num /= 10 ;
    }
    lli solve = 0;
    for (lli i = 2 , k = 100 ; i >= 0 ; i -- , k /= 10)
    {
        if (s[i] / k == 1)
            s[i] *= 9 ;
        else if (s[i] / k == 9)
            s[i] /= 9 ;
        solve += s[i];
    }
    cout << solve;

        return 0;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}


int main(){
    long long n, k, sum = 0;
    string s;
    cin >> n;
    cin >> s;
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

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

    int n = 100 * a + 10 * b + c;
    bool y = n % 4 == 0;

    cout << (y ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
def ret():
	print(0)
	return
for i in range(m):
	s[i],c[i] = map(int,input().split())

def ret1():
	for i in range(0 if n == 1 else 10**(n-1),10**n):
		flag = 1
		for j in range(m):
			if i//(10**(n-s[j]))%10 != c[j]:
				flag = 0
		if flag == 1:
			print(i)
			return
	print(-1)
	return

if m == 1 and n == 1 and c[0] == 0:
	ret()
else:
	ret1()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
ll n,L,T,x,w,a,b,num=0;
vector<ll> at;
ll D(ll c,ll d){
	ll ret=c%d;
	if(ret<0)return ret+d;
	return ret;
}
int main(){
	cin>>n>>L>>T>>x>>w;
	ll oneant;
	if(w==1)oneant=D(x+T,L);
	if(w==2)oneant=D(x-T,L);
	at.push_back(oneant);
	lol(i,n-1){
		cin>>a>>b;
		if(b==1){
			at.push_back(D(a+T,L));
			if(w==2){
				num=D(num-(2*T+L-D(x-a,L))/L,n);
			}
		}
		if(b==2){
			at.push_back(D(a-T,L));
			if(w==1){
				num=D(num+(2*T+L-D(a-x,L))/L,n);
			}
		}
	}
	sort(at.begin(),at.end());
	int p;
	lol(i,n){
		if(at[i]==oneant){
			p=i;
			if(w==2)break;
		}
	}
	p=D(p-num,n);
	lol(i,n){
		cout<<at[p]<<endl;
		p=(p+1)%n;
	}
	return 0;
}


Measured memory_bytes: 2164
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	a := make([]int, 3)
	a[0] = readInt()
	a[1] = readInt()
	a[2] = readInt()
	sort.Ints(a)
	println(a[2]*10 + a[1] + a[0])

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;



    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

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

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

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;


void solve() {
    size_t n;
    cin >> n;
    size_t a = n % 10;
    if (a == 3) {
        cout << "bon" << endl;
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 8536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

signed main(){
  int l; cin>>l;
  int kaz=0;
  for(int i=0; i<18; i++){
    if(l&(1<<i)) {
      kaz++;
    }
  }
  kaz+=l>>18;
  cout<<"20 "<<kaz+36<<en;
  
  for(int i=0; i<18; i++){
    cout<<i+1<<" "<<i+2<<" 0"<<en;
    cout<<i+1<<" "<<i+2<<" "<<(1<<i)<<en;
  }
  
//  cout<<en;
//  cout<<bitset<23>(1000000)<<en;
  
  for(int i=0; i<18; i++){
    if(l&(1<<i)) {
      cout<<i+1<<" 20 "<<(l&((1<<i)-1))<<en; //<<"    "<<(l&(1<<i))<<en;
    }
  }
  
  int num=l>>18;
//  cout<<"  num: "<<num<<en;
  for(int i=1; i<=num; i++) cout<<"19 20 "<<(i-1)*(1<<18)+(l&((1<<18)-1))<<en;
}


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

using namespace std;

int SelectionSort(int a[], int n) {
    int count = 0;
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (minj != i) {
            int tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
            count++;
        }
    }

    return count;
} 

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

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

    int count = SelectionSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << a[i];
    }

    cout << endl << count << endl;

    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n;
   cin >> n;
   int odd = 0, even = 0;
   rep (i, n) {
      int x;
      cin >> x;
      if (x&1) {
         odd++;
      }else {
         even++;
      }
   }

   if (even==n) {
      puts("YES");
   } else {
      if (odd&1) {
         puts("NO");
      } else {
         puts("YES");
      }
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  int ans = 0;
  while (true) {
    rep(i, 0, n) {
      if (v[i] & 1) {
        cout << ans << endl;
        return 0;
      }

      v[i] /= 2;
    }
    ans++;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,x=0,temp=0;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep0(i,n){
        if(s[i]=='I'){ 
            x++;
            a.push_back(x);
        }
        else if(s[i]=='D'){ 
            x--;
            a.push_back(x);
        }
    }
    sort(a.begin(),a.end(),greater<int>());
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 3632