akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiWayIf                 #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE UndecidableInstances       #-}
import qualified Data.Vector.Unboxing         as VU
import qualified Data.Vector.Unboxing.Mutable as VUM

main :: IO ()
main = do
  n <- readLn :: IO Int

  print $ powMod 10 n - 2 * powMod 9 n + powMod 8 n


solve :: Int -> IntMod
solve !n = sum $ zipWith (*) (nCkMods n) (map (\k -> powMod 8 (n-k)) [n,(n-1)..1])


nPkMods :: Int -> [IntMod]
nPkMods !n' = scanr (\y x -> fromIntegral y * x) (fromIntegral n') [1..(n'-1)]


nCkMods :: Int -> [IntMod]
nCkMods !n = zipWith (*) (nPkMods n) (map invMod (scanr (\y x -> fromIntegral y * x) 1 [n,(n-1)..2]))


modulus :: Int
-- modulus = 10^9 + 7
modulus = 1000000007

newtype IntMod = IntMod Int deriving Eq deriving newtype VU.Unboxable

fromIntegralIntIntMod :: Int -> IntMod
fromIntegralIntIntMod n = IntMod (n `mod` modulus)
{-# RULES
"fromIntegral/Int->IntMod"
    fromIntegral = fromIntegralIntIntMod
#-}

instance Show IntMod where
  show (IntMod x) = show x

instance Num IntMod where
  IntMod x + IntMod y = IntMod ((x + y) `mod` modulus)
  IntMod x - IntMod y = IntMod ((x - y) `mod` modulus)
  IntMod x * IntMod y = IntMod ((x * y) `mod` modulus)
  fromInteger n = IntMod (fromInteger (n `mod` fromIntegral modulus))
  abs = undefined
  signum = undefined

im0 :: IntMod
im0 = 0

powMod :: IntMod -> Int -> IntMod
powMod !x 1 = x
powMod !x !k
  | even k = powMod (x * x) (k `div` 2)
  | otherwise = x * powMod (x * x) (k `div` 2)

invMod :: IntMod -> IntMod
invMod 0  = error "inverse of 0"
invMod !x = powMod x (modulus - 2)


Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 9999999999999LL
#define NINF -999999999999LL
#define EPS 0.0000001f
using namespace std;

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

lli n,c,k,t[100009],ans,load;
deque<lli> b;

int main() {
	ans = 0;
	scanf("%lld %lld %lld",&n,&c,&k);
	for(lli i=0;i<n;i++){
		scanf("%lld",&t[i]);
	}
	sort(t,t+n);
	for(int i=0;i<n;i++){
		// add passenger to queue
		b.push_back(t[i]);
		//printf("%lli\n",t[i]);
	}
	for(lli i=0;i<n;i++){
		//printf("Passenger %lli at time %lli\n",i,t[i]+k);
		// current time is t[i] + k
		// if the earliest person in queue needs to go
		while(!b.empty() && b.front() + k <= t[i] + k){
			//printf("bus sent at %lli\n",i);
			// send one bus
			ans++;
			// send as many people as possible
			load = 0;
			while(!b.empty() && b.front() <= t[i] + k && load < c){
				load++;
				b.pop_front();
			}
		}
	}
	printf("%lli",ans);
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2431&lang=jp
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
/*
	??§????????????????????????????????????????????????????????????????°??????????????????????????????????????????§???(?????????????¢??????¨?????????

	???????¢??????¨?????????????????????????????§???????????????
	?????????????????????????´?????????????????????\?????????????????¨?????????????????¨?????§???????????§???????????¨??????????????????????????????
	 ??????dp[k] = max(dp[1]~dp[k-1])+k
	    RMQ?????¨??????????????§??????????´¢??????????????´??°????????????

	?????????dp????????§?????¨??¨?????????(1/2*n(n+1))??¨??????
*/

/* ???????????????*/
struct SegTree {
	using type = ll; 	type INIT_VAL = 0;
	type merge(type a, type b) { return max(a, b); } 
	type N; vector<type> dat;
	SegTree(type _N) { N = 1;	while (N < _N)N *= 2;dat = vector<type>(N * 2 - 1,INIT_VAL); }
	void update(int k, type val) { k += N - 1; dat[k] = val;	while (k) { k = (k - 1) / 2; dat[k] = merge(dat[k * 2 + 1], dat[k * 2 + 2]); } }
	type query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return INIT_VAL; if (a <= l&&b >= r)return dat[k];
		type v1 = query(a, b, k * 2 + 1, l, (l + r) / 2); type v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);	return merge(v1, v2);
	}
	inline type query(int a, int b) { return query(a, b, 0, 0, N); }
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n; cin >> n;
	vector<ll> x(n);
	for (int i = 0; i < n;i++)cin >> x[i];
	SegTree seg(n + 1);
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		ll max_v = seg.query(1, x[i]);
		ans = max(ans, max_v + x[i]);
		seg.update(x[i], max_v + x[i]);
	}
	//cout << n*(n + 1) / 2 - ans << endl;
	cout << n*(n + 1) / 2 - seg.dat[0] << endl;
	return 0;
}

Measured memory_bytes: 5736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_digits(void) {
	long long n;
	int k;

	cin >> n >> k;
	int keta = 0;
	while (n > 0) {
		n /= k;
		keta++;
	}
	cout << keta << endl;
}
int main()
{
    b_digits();

    return 0;
}



Measured memory_bytes: 3592
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	t <- getLine
	let
		ss = s ++ s
	putStrLn $ which "Yes" "No" $ t `isInfixOf` ss

Measured memory_bytes: 508
#include<cstdio>
#include<vector>
#include<queue>
int N,M;
std::vector<int>a[200010];
int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++){
		int l,r;scanf("%d%d",&l,&r);
		a[l].push_back(r);
	}
	int sz=N,s1=1<<30,s2=1<<30;
	for(int i=1;i<=M+1;i++){
		sz-=a[i-1].size();
		if(sz+i-1<s1)s1=sz+i-1;
	}
	std::priority_queue<int>Q;
	for(int i=M;i>=0;i--){
		for(int j=a[i].size();j--;)Q.push(a[i][j]>s1?a[i][j]:s1+1);
		if(i&&i<=s1)Q.pop();
	}
	sz=N-s1;
	for(int i=1;i<=M+1;i++){
		while(sz&&Q.top()==M-i+2)Q.pop(),--sz;
		if(sz+i-1<s2)s2=sz+i-1;
	}
	printf("%d\n",N-s1-s2);
}

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

int main() {
	// your code goes here
	string S;
	cin>>S;
	if(S[0]=='Y' && S[1]=='A' && S[2]=='K' && S[3]=='I'){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define F first
#define FF first.first
#define FS first.second
#define S second
#define SF second.first
#define SS second.second
#define ii pair<int,int>
#define iii pair<ii, int>
#define iiii pair<ii, ii>
#define viiii vector< iiii >
#define viii vector< iii >
#define vii vector< ii >
#define vi vector< int >
#define vvi vector<vector< int > >
#define int long long

#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define FOR(v, i, l) for(int v = i; v < (int)l; ++v)
#define REP(v, l) FOR(v, 0, l)

#define EPS 1e-6
#define oo (1LL<<60)
#define MAX 1000000000000000000LL
#define MOD 1000000007LL
#define debug(x) cout << #x << " is " << x << "\n";

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

int PAsum(int in, int fi, int s){
   if(fi<in)return 0;
   return ((in+fi)*(1+(fi-in)/s))/2LL;
}

int modPow(int x, int y, int mod = MOD){
   int ans = 1;
   while( y ){
      if(y%2){
         ans = (ans*x)%mod;
      }
      x = (x*x)%mod;
      y /= 2;
   }
   return ans;
}

int countBit(int x){
   int ans  = 0;
   while(x){
      ans += (x%1);
      x /= 2;
   }
   return ans;
}

int N, M, K, L, R, J, P, CASES;
int A,B,C,D;

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

   if( M%2 == 0 and M >= N*2 and M <= N*4 ) printf("Yes\n");
   else printf("No\n");
}

/*

*/


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

using namespace std;
using ll=long long;

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    while (q--) {
        int k; cin >> k;
        ll d = 0, m = 0, dm = 0, dmc = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'D') d++;
            else if (s[i] == 'M') {
                m++;
                dm += d;
            } else if (s[i] == 'C') {
                dmc += dm;
            }

            if (i >= k-1) {
                if (s[i-k+1] == 'D') {
                    dm -= m;
                    d--;
                } else if (s[i-k+1] == 'M') {
                    m--;
                }
            }
        }
        cout << dmc << "\n";
    }
}

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


Measured memory_bytes: 1948
#include<cstdio>

int main(){
  int n;
  scanf("%d",&n);
 
  
  int a[n];
  for(int i = 0; i < n ; i++){
    scanf("%d",&a[i]);
  }
  for(int i=n-1;i >=0;i--){
    if(i != 0){
      printf("%d ",a[i]);
    }
    else {
      printf("%d",a[i]);
    }
  }
    printf("\n");
  
  return 0;

}



Measured memory_bytes: 2600
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    string[] r;
    foreach(s;stdin.byLine())
    {
        auto m = s.split().map!(to!int);
        immutable a=m[0], b=m[1];
        if(a==0 && b==0) break;
        auto ys = iota(a,b+1).filter!(y=>y%400==0 || (y%4==0 && y%100)).array();
        if(ys.length==0) r~="NA";
        else r~=ys.map!(to!string).join("\n");
    }
    r.join("\n\n").writeln();
}

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

using namespace std;

int main(){
	int n;
	int x;
	int y;
	int tmp;
	int max;

	cin >> n;
	cin >> x;
	tmp = 0;
	max = 0;

	for(int i = 1; i < n; i++){
		cin >> y;

		if(x >= y){
			tmp++;
		}
		else{
			if(tmp > max){
				max = tmp;
			}
			
			tmp = 0;
		}

		// cout << "x = " << x << ", y = " << y << ", tmp = " << tmp << ", max = " << max << "\n";
		x = y;
	}

	if(tmp > max){
		max = tmp;
	}

	cout << max;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
d = abs(30*h + 30*(m/60) - 6*m)
if d > 180:
    d = 360 - d
c = math.cos(math.radians(d))
e = a**2 + b**2 - 2*a*b*c
ans = math.sqrt(e)
print(ans)

Measured memory_bytes: 9500
N=28
i=1
j=1
S=0
J=[]
I=[int(input()) for _ in range (N)]
I.sort()
for i in range(N):
    S=I[i]
    if S==j:
        j+=1
        i+=1
        pass
    else:
        j+=2
        i+=1
        print(S-1)
l=I[27]        
if l == 30:
    pass
else:
    print(30)


Measured memory_bytes: 5604
#include <stdio.h>

// Euclidean Algorithm
int gcd(int x, int y) {
    return y ? gcd(y, x % y) : x;
}

int main() {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%d\n", gcd(x, y));
    return 0;
}



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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  int n;
  cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << n*2 << endl;
}

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

template< class T >
void exchange( T &a, T &b )
{
    T c  = a;
    a = b;
    b = c;
}

int main()
{
    string str, words[100];
    int p, d[100];

    int i = 0;
    while( cin >> str )
    {
        cin >> p;
        words[i] = str;
        d[i] = p;
        i++;
    }

    for( int j = 0; j < i - 1; j++ )
        for( int k = j + 1; k < i; k++ )
            if( words[j] > words[k] )
            {
                exchange( words[j], words[k] );
                exchange( d[j], d[k] );
            }

    for( int j = 0; j < i - 1; j++ )
        for( int k = j + 1; k < i; k++ )
            if( words[j] == words[k] && d[j] > d[k] )
                exchange( d[j], d[k] );

    cout << words[0] << endl << d[0];
    for( int j = 1; j < i; j++ )
        if( words[j-1] == words[j] )
            cout << " " << d[j];
        else
            cout << endl << words[j] << endl << d[j];
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(s[i]=='P')
            cout<<"P";
        else
            cout<<"D";
    }
    return 0;
}


Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		long result = 1;
		for(int i = 1 ; i<=N;i++){
			result*=i;
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 23968
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
typedef long long ll;
using namespace std;
ll a[100005];
int main(){
	long long m,n;
	cin>>m>>n;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	sort(a,a+m);
	long long ans=a[m-1];
	for(int i=0;i+n-1<m;i++){
		ans=min(ans,a[i+n-1]-a[i]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  x, y, z = map(int, input().split())
  a.append((x, y, z))
res = -float("inf")
for k in range(8):
  dp = [[-float("inf")] * (M + 1) for _ in range(N + 1)]
  for i in range(N):
    dp[i][0] = 0
    x, y, z = a[i]
    x *= (-1) ** ((k & 1 == 1))
    y *= (-1) ** ((k & 2 == 2))
    z *= (-1) ** ((k & 4 == 4))
    #print(k, x, y, z)
    for j in range(M + 1):
      if dp[i][j] == -float("inf") and (j > 0): continue
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
      if j < M:
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + x + y + z)
  #print(dp)
  res = max(res, dp[-1][-1])
print(res)

Measured memory_bytes: 129244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))



int main()
{
	ios_base::sync_with_stdio(false);

	ll n,ans=0;cin>>n;
	for(int i=1;i<=n;i++){
		ll m = n/i;
		ll sum = m*(m+1);sum/=2;
		ans+= sum*i;
	}
	cout<<ans<<endl;

}



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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

constexpr int MAX_N = 500;
constexpr int INF = (1 << 28);

struct State {
    int r;
    int c;
    int cost;
};

int cost[MAX_N][MAX_N];
bool moved[MAX_N][MAX_N];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    using P = pair<int, int>;   // (行, 列)
    vector<P> order;
    for (int i = 0; i < n * n; i++) {
        int p;
        cin >> p;
        p--;

        int r = p / n,
            c = p % n;
        order.emplace_back(r, c);
        cost[r][c] = min({r, n - r - 1, c, n - c - 1});
    }

    auto isInside = [&](int r, int c) {
        return 0 <= r && r < n && 0 <= c && c < n;
    };

    memset(moved, false, sizeof(moved));
    int dr[] = {1, 0, -1, 0},
        dc[] = {0, 1, 0, -1};
    int ans = 0;
    for (P p : order) {
        int r = p.first,
            c = p.second;

        ans += cost[r][c];
        moved[r][c] = true;

        queue<State> que;
        que.push({r, c, cost[r][c]});

        while (!que.empty()) {
            State st = que.front();
            que.pop();

            for (int i = 0; i < 4; i++) {
                int nr = st.r + dr[i],
                    nc = st.c + dc[i];
                if (!isInside(nr, nc)) continue;
                int ncost = st.cost + !moved[st.r][st.c];

                if (cost[nr][nc] > ncost) {
                    cost[nr][nc] = ncost;
                    que.push({nr, nc, cost[nr][nc]});
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6560
n, a, b = [int(x) for x in input().split()]
cnt_global, cnt_foreign = 0, 0
for x in input():
    if x == 'a':
        if cnt_global < a + b:
            cnt_global += 1
            print('Yes')
        else:
            print('No')
    elif x == 'b':
        if cnt_global < a + b and cnt_foreign < b:
            cnt_global += 1
            cnt_foreign += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 54744
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll,ll> P;
 
//最大公約数
ll gcd(ll a,ll b){
    if(b){return gcd(b,a%b);}else{return a;}
}
 
int main(){
    int k;
    cin>>k;
    ll sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                sum+=gcd(gcd(a,b),c);
            }
        }
    }
    cout<<sum;
 
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

ll N;
vector<vector <int> > M(110,vector<int>(110)); 
bool visit[110];
vector<ll> d(110,INF);

void bfs(int s){
    queue<int> que;
    que.push(s);
    d[s] = 0;

    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int u = 0;u < N;u++){
            if(M[v][u] == 0) continue;
            if(d[u] != INF) continue;
            if(visit[u] == false){
                d[u] = d[v] + 1;
                que.push(u);
            }
        }
    }
}

int main(){
    cin >> N;
    rep(i,N){
        int u,k; cin >> u >> k;
        u--;
        rep(j,k){
            int v; cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    bfs(0);

    rep(i,N){
        ll dist;
        (d[i] == INF) ? dist = -1 : dist = d[i];
        cout << i+1 << " " << dist << endl;
    }
}


Measured memory_bytes: 3220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    char a[100][101];
    int x[100] = {};
    int y[100] = {};
    int i, j;

    for (i=0; i<h; i++)
    {
        scanf("%s", a[i]);
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (a[i][j] == '#') {
                x[j] = 1;
                y[i] = 1;
            }
        }
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (x[j] && y[i])
            printf("%c", a[i][j]);
        }
        if (y[i]) printf("\n");
    }

    return 0;
}


Measured memory_bytes: 128
import re
 
class IO_for_Contest(object):
    @staticmethod
    def my_input():
        #return raw_input()
        return input()
 
    @staticmethod
    def read_from_input():
        n, k = IO_for_Contest.read_n_int(2)
        d = IO_for_Contest.read_n_int(k)
        return n, d
 
    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()
 
    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())
 
    @staticmethod
    def read_n_int(n):
        return list(map( \
                int, \
                re.split('\s+', IO_for_Contest.my_input().strip())))[ : n]
 
def solve():
    n, d = IO_for_Contest.read_from_input()
    print(inner_solve(n, d))

def inner_solve(n, d):
    while True:
        s_n = str(n)
        success = False
        for i in range(len(s_n)):
            if int(s_n[i]) in d:
                break
        else:
            success = True
        if success:
            return n
        n += 1

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3316
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    string s, t;
    
    cin >> s >> t;
    
    int n = s.length(), ans = 0;
    
    for(int K=0; K<n; K++){
		if(s[K]!=t[K]) ans++;
	}
	
	cout << ans << "\n";
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}




Measured memory_bytes: 3812
#include<iostream>
#include <string>
using namespace std;
int main(void){
    
    string A;
    int i,j,N;
    bool jud;
    cin>>A;
    N=A.size();
    jud=true;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
          if(i==j){
          }else{
            if(A[i]==A[j]){
            jud=false;
            }
          }
        }
        j=0;
    }

    
   if(jud==true){
       cout<<"yes"<<endl;
   }else{
    cout<<"no"<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>

using namespace std;
        
int main(){
    int x,y,z;
    cin>>x>>y>>z;
    int len=x,ans=0;
    while(1){
            len-=z;
            len-=y;
            if(len>=z){
                ans++;
            }else{
                cout<<ans<<endl;
                break;
            }
    }
    return 0;
}

Measured memory_bytes: 384
// In the name of god
#include <bits/stdc++.h>
using namespace std;
int a,n;
bool b;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==0){
			if((a%3)>0&&(a%5)>0){
				b=1;
			}
		}
	}
	if(!b){
		cout<<"APPROVED";
	}
	else{
		cout<<"DENIED";
	}
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
tasks=[]
for i in range(N):
    ab = list(map(lambda x: int(x),input().split()))
    tasks.append(ab)

tasks.sort(key=lambda x: (x[1],-x[0]))
costs = [0]
for i in range(len(tasks)):
  costs.append(costs[-1]+tasks[i][0])
#print(tasks)
#print(costs)
x = np.array(tasks).T[1]
y = np.array(costs[1:])
ans = ""
#print(tasks)
#print(x)
#print(y)
if len(np.where(x-y<0)[0])>0:
    ans="No"
else:
    ans = "Yes"
print(ans)

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

int main() {
	int N, p, ans = 0, tmp = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> p;
		if (p == i + 1) ++tmp;
		else {
			ans += (tmp + 1) / 2;
			tmp = 0;
		}
	}
	ans += (tmp + 1) / 2;
	cout << ans;
}

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


using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > a(k);
  for(int i = 0; i < k; i++){
    cin >> a[i].first >> a[i].second;
    a[i].second %= 3;
  }
  sort(a.begin(), a.end());
  a.push_back(make_pair(-1, -1));
  int dp[101][3][3] = {0};
  int now = 0;
  for(int i = 0; i < 3; i++){
    dp[1][i][1] = 1;
  }
  if(a[0].first == 1){
    ++now;
    for(int i = 0; i < 3; i++){
      if(a[0].second == i) continue;
      dp[1][i][1] = 0;
    }
  }
  for(int i = 2; i <= n; i++){
    if(a[now].first == i){
      for(int K = 0; K < 3; K++){
        if(a[now].second == K) continue;
        dp[i][a[now].second][1] += dp[i - 1][K][1] + dp[i - 1][K][2];
        dp[i][a[now].second][1] %= 10000; 
      }
      dp[i][a[now].second][2] += dp[i - 1][a[now].second][1];
      dp[i][a[now].second][2] %= 10000;
      ++now;
      continue;
    }
    for(int j = 0; j < 3; j++){
      for(int K = 0; K < 3; K++){
        if(j == K) continue;
        dp[i][j][1] += dp[i - 1][K][1] + dp[i - 1][K][2];
        dp[i][j][1] %= 10000; 
      }
      dp[i][j][2] += dp[i - 1][j][1];
      dp[i][j][2] %= 10000;
    }
  }
  int ans = 0;
  for(int i = 0; i < 3; i++){
    ans += dp[n][i][1] + dp[n][i][2];
    ans %= 10000;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3108
from sys import stdin
from collections import deque
H, W = [int(x) for x in stdin.readline().rstrip().split()]
grid = ["#"*(W+2)]
for i in range(H):
    grid.append("#"+input()+"#")
grid.append("#"*(W+2))

ans = 0
for h in range(1, H+1):
    for w in range(1, W+1):
        if grid[h][w] == ".":
            ans += 1

visited = [[False for i in range(W+2)] for i in range(H+2)]

visit_p = deque()
visit_p.append((1, 1, 0))
cnt = 0

f = False

while visit_p:
    nh, nw, num = visit_p.popleft()

    for dh, dw in [(0, 1), (1, 0), (-1, 0), (0, -1)]:

        if not (0 < nh+dh < H+2) or not (0 < nw+dw < W+2):
            # 範囲外
            continue

        if visited[nh+dh][nw+dw] or grid[nh+dh][nw+dw] == '#':
            # 壁または訪問済み
            continue

        visit_p.append((nh+dh, nw+dw, num+1))
        visited[nh+dh][nw+dw] = True

        if nh+dh == H and nw+dw == W:
            cnt = num + 2
            f = True
            break
    else:
        continue
    break

if f:
    ans -= cnt
    print(ans)

else:
    print(-1)

Measured memory_bytes: 3316
N, u, v = map(int, input().split())
u -= 1
v -= 1
tonari = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  tonari[a].append(b)
  tonari[b].append(a)

d_from_u = [float('inf') for _ in range(N)]
d_from_v = [float('inf') for _ in range(N)]
d_from_u[u] = 0
d_from_v[v] = 0
#print(tonari)
now = [v] #追いかける方
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_v[t] > d:
        d_from_v[t] = d
        nextvisit.append(t)
  now = nextvisit



now = [u] #逃げる方
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_v[t] <= d: #追いかける方より遠い地点は排除
        continue
      elif d_from_u[t] > d:
        d_from_u[t] = d
        nextvisit.append(t)
  now = nextvisit


distance = []
for U, V in zip(d_from_u, d_from_v):
  if U < N+1: #infを排除
    distance.append((U, V))

if distance:
  ans = max(distance, key= lambda x: x[1])[1] - 1
else:
  ans = 0
print(ans)

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

typedef long long ll;

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int s, t, p, q, m, y;
    cin >> s >> t >> p >> q >> m >> y;
    cout << (s ^ t ^ y) << endl;

    return 0;
}



Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
//using atcorder.DataStructure;
namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }


    public class Test
    {
        public static void Run()
        {
            Input input = new Input(' ');
            input.ReadLine();
            int N = input.Next<int>();
            int K = input.Next<int>();
            Console.WriteLine(N - K + 1);
        }
    }




    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = ' ')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
	int n, m;
  	cin >> n >> m;
  int arr[m];
    //storing in array
  	for(int i = 0; i < m; i++)
      cin >> arr[i];
  	// sorting the array
  	sort(arr, arr+m);
  	if(n < m){
    	int arr1[m-1];
      for (int i = 0; i < m-1; i++)
        arr1[i] = arr[i+1]-arr[i];
      // sorting arr1 -- difference array
      sort(arr1, arr1+m-1);
      // summing up
      cout << accumulate(arr1, arr1+m-n, 0)<<'\n';
    }
  else cout << "0\n";

	return 0;
}

Measured memory_bytes: 1024
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		String s;
		Double n;
		while((s=r.readLine())!=null){
			n=Double.parseDouble(s);
			if(n<=48.00){System.out.println("light fly");}
			else if(n>48.00 &&n<=51.00){System.out.println("fly");}
			else if(n>51.00 &&n<=54.00){System.out.println("bantam");}
			else if(n>54.00 &&n<=57.00){System.out.println("feather");}
			else if(n>57.00 &&n<=60.00){System.out.println("light");}
			else if(n>60.00 &&n<=64.00){System.out.println("light welter");}
			else if(n>64.00 &&n<=69.00){System.out.println("welter");}
			else if(n>69.00 &&n<=75.00){System.out.println("light middle");}
			else if(n>75.00 &&n<=81.00){System.out.println("middle");}
			else if(n>81.00 &&n<=91.00){System.out.println("light heavy");}
			else{System.out.println("heavy");}
		}
	}
}

Measured memory_bytes: 16904
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll N, K, W, H, M;

int main() {
	cin >> N;
	vector<ll> x(N);
	for(int i = 0; i < N; ++i) {cin >> x[i] ;}
  	ll lim = *max_element(ALL(x));
	vector<ll> p(lim+1,0);
	for(int i = 0; i <= lim; ++i){
		for(int j = 0; j < N ; ++j){
			p[i] += ((ll)i-x[j])*((ll)i-x[j]);
		}
	}
	cout << *min_element(ALL(p));
	return 0;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('Inf')] * (10 ** 5 + 1)
dp[0] = 0
for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[n - 1])


Measured memory_bytes: 55264
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
$X = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}

$mx =max($X);
$mi =min($X);

$res=10**9;
for($i=$mi;$i<=$mx;$i++) {
  $sum=0;
  for($j=0;$j<$N;$j++) {
    $sum+=($X[$j]-$i)**2;
  }
  $res=min($res,$sum);
}
printf("%d\n",$res);


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

int main(){
    int r,g,b;
    1<=r,g,b<=9;
    cin>>r>>g>>b;
    int a=r*100+g*10+b;
    if(a%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && b != c) || (b == c && c != a) || (a == c && c != b))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
	string a,b;
	cin>>a>>b;
	a=a+a;
	for(int i=0;i<b.size();i++){
		if(a.substr(i,b.size())==b){
			cout<<"Yes"<<endl;
	        return 0;
		}
	}
	cout<<"No"<<endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  if (n == 2 || m == 2) {
    cout << 0 << endl;
    return 0;
  }
  if (m == 1) {
    cout << max(n-2, 1LL) << endl;
    return 0;
  }

  ll mul = m-2;
  ll v = max(n-2, 1LL);
  cout << v*mul << endl;
  
  return 0;
}


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

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define FOR(i, n) for(int i = 0; i < (n); i++)

#define itn int

typedef uint64_t INT64;

int main()
{
    using namespace std;

    int n;
    vector<int> a;

    cin >> n;

    FOR(i, 3 * n)
    {
        int t;
        cin >> t;
        a.push_back(t);
    }

    sort(RALL(a));

    INT64 ret = 0;

    FOR(i, 2 * n)
    {
        if(i % 2 == 1)
        {
            ret += a[i];
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
#include <unordered_map>

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int> A,B;
	A.resize(n+1);
	B.resize(n+1);

	rep(i, n) {
		cin>>A[i+1];
	}

	for (int i = n; i >= 1; i--){
		int sum=0;
		for(int j=i+i;j<=n;j+=i){
			sum ^=B[j];
		}
		B[i] = sum ^ A[i];
	}

	vector<int> ans;

	rep(i, n+1) {
		if (B[i]) {
			ans.push_back(i);
		}
	}

	cout << ans.size() << endl;
	rep(i, ans.size()) {
		printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
	}
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        vector<long long int> score(N);
        for (int i = 0; i < N; i++) {
            int t;
            cin >> t >> score[i];
            int s = 0;
            for (int j = 0; j < t; j++) {
                int start, end;
                cin >> start >> end;
                for (int k = start; k < end; k++) v[i] |= (1 << (k - 6));
            }
        }

        vector<map<int, long long int> > m(N+1);
        m[0][0] = 0;
        for (int i = 0; i < N; i++) {
            for (auto j : m[i]) {
                m[i+1][j.first] = max(m[i+1][j.first], j.second);
                if (j.first & v[i]) continue;
                int next = j.first + v[i];
                m[i+1][next] = max(m[i+1][next], j.second + score[i]);
            }
        }

        long long int res = 0;
        for (auto i : m[N]) {
            res = max(res, i.second);
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 11280
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  let cmd;
  for (let i = 0; i < n; i++) {
    cmd = lines[i];
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  }
})();



Measured memory_bytes: 201964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define YN(c) (c)?(print("YES")):(print("NO"))
#define Yn(c) (c)?(print("Yes")):(print("No"))
#define yn(c) (c)?(print("yes")):(print("no"))
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  while(a>0){
    c-=b;
    if(c<=0){
      print("Yes");
      return 0;
    }
    a-=d;
  }
  print("No");
  return 0;
}

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

//#include "atcoder.hpp"

int main() {
    int N, r=0;
    vector<int> a;
    
    cin >> N;
    
    for (int i=0;i<N;i++){
        int t;
        
        cin >> t;
        a.push_back(t);
    }
    sort(a.begin(), a.end());
    int sum=0, cnt =0;
    
    for (auto i : a) {
        auto rest = i - sum;
        sum = i;
        
        if (rest%2 == 1)
            r ^= (a.size() - cnt);
        
        cnt++;
    }
    
    
    cout << (r != 0 ? "first" : "second") << endl;
    return 0;
}

Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Di = Sarray();
            if (Di[0] != 0 || Di.Count(d => d == 0) != 1)
            {
                WriteLine(0);
                return;
            }
            var dst = new long[N];
            foreach (var d in Di)
                ++dst[d];
            var ans = 1L;
            var max = Di.Max();
            for (var i = 1; i <= max; ++i)
            {
                if (dst[i - 1] == 0)
                {
                    WriteLine(0);
                    return;
                }
                ans = ans * ModPow(dst[i - 1], dst[i], Mod) % Mod;
            }
            WriteLine(ans);
            //Out.Flush();
        }
        static long ModPow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
    }
}

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

int A, B;

int main() {
  cin >> A >> B;

  int ans = 0;

  for (int i = A; i <= B; i++) {
    bool one_five = (i % 10 == (i / 10000) % 10);
    bool two_four = ((i / 10) % 10 == (i / 1000) % 10);
    if (one_five && two_four) ++ans;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    cin>>x;
    if(x>=400&&x<=599){
        cout<<8<<endl;
    }
    else if(x>=600&&x<=799){
        cout<<7<<endl;
    }
    else if(x>=800&&x<=999){
        cout<<6<<endl;
    }
    else if(x>=1000&&x<=1199){
        cout<<5<<endl;
    }
    else if(x>=1200&&x<=1399){
        cout<<4<<endl;
    }
    else if(x>=1400&&x<=1599){
        cout<<3<<endl;
    }
    else if(x>=1600&&x<=1799){
        cout<<2<<endl;
    }
    else {
        cout<<1<<endl;
    }

    return 0;
}

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

using namespace std;

typedef long long lint;

int main()
{

    lint n;
    cin >> n;
    lint mn = n - 1;
    for(lint i = 1; i * i <= n; i ++)
    {
        if(n % i == 0)
        {
            mn = min(mn, n / i - 1 + i - 1);
        }
    }

    cout << mn << "\n";

    return 0;
}


Measured memory_bytes: 256
import array
import collections


class UnionFind(object):
    def __init__(self, number_of_nodes):
        # Don't use self.par directly! (call self.root)
        self.par = array.array("L", range(number_of_nodes))
        self.rank = array.array("L", (0 for _ in range(number_of_nodes)))

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def in_the_same_set(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x == y:
            pass
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n, k, l = map(int, input().split())
roads = [map(int, input().split()) for _ in range(k)]
trains = [map(int, input().split()) for _ in range(l)]

uf1 = UnionFind(n+1)
for p, q in roads:
  uf1.unite(p, q)

uf2 = UnionFind(n+1)
for r, s in trains:
  uf2.unite(r, s)

count = collections.Counter([(uf1.root(i), uf2.root(i)) for i in range(1,n+1)])

print(' '.join([str(count[(uf1.root(i), uf2.root(i))]) for i in range(1,n+1)]))


Measured memory_bytes: 112160
use std::io::*;
use std::str::FromStr;
use std::cmp;


macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
 

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    input!{
        N: i64,
        Y: i64
    }
    let mut ans = None;
    'outer: for a in 0..N+1{
    	for b in 0..N-a+1{
        	if Y==10000*a + 5000*b + 1000*(N-a-b) {
            	ans = Some((a,b,N-a-b));
                break 'outer;
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);
    
}


Measured memory_bytes: 4352