akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int, []int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n, k := scanInt(sc), scanInt(sc)
	// 0-indexed
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = scanInt(sc)
	}
	return n, k, hs
}

func resolve(n, k int, hs []int) int {
	states := make([]int, n)
	states[0] = 0
	for i := 1; i < n; i++ {
		states[i] = inf
	}
	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i+j < n {
				changeToMin(&(states[i+j]), states[i]+abs(hs[i]-hs[i+j]))
			}
		}
	}
	return states[n-1]
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

const (
	inf  = math.MaxInt32
	ninf = math.MinInt32
)

func changeToMin(v *int, cand int) (updated bool) {
	if *v > cand {
		*v = cand
		updated = true
	}
	return updated
}

func changeToMax(v *int, cand int) (updated bool) {
	if *v < cand {
		*v = cand
		updated = true
	}
	return updated
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2816
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template <class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    rep (i, N) { cin >> A[i]; }
    rep (i, M) { cin >> B[i]; }

    debug(A.size());
    debug(B.size());
    debug(M);
    debug(N - M);

//    if (N == 1 && M == 1)
//    {
//        if (A[0] == B[0])
//        {
//            cout << "Yes\n";
//            return 0;
//        }
//        else
//        {
//            cout << "No\n";
//            return 0;
//        }
//    }

    rep (ay, N - M + 1)
    {
        rep (ax, N - M + 1)
        {
            int cnt = 0;
            rep (by, M)
            {
                rep (bx, M)
                {
                    if (A[ay+by][ax+bx] == B[by][bx])
                    {
                        cnt++;
                    }
                }
            }
            if (cnt == M*M)
            {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }

    cout << "No" << "\n";


    return 0;
}


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

s=list(sorted(s))
if n%2==1:
    s.remove(0)
    for i in range(n-1):
        s[i] -= 1

a = []
for i in range(n//2):
    a.append(2*i+1)

if s[0::2]==s[1::2] and s[0::2] ==a :
    print((2**((len(s))//2))%(10**9+7))
else:
    print(0)

Measured memory_bytes: 14008
import std.stdio;
import std.string;
import std.conv;

void main() {
    
    for(;;) {
        
        // input
        int R, C;
        {
            auto temp = readln.split;
            R = to!int(temp[0]);
            C = to!int(temp[1]);
        }
        
        if(R == 0 && C == 0) {
            break;
        }
        
        bool[][] board;
        board.length = R;
        for(int i=0; i<R; ++i) {
            board[i].length = C;
        }
        
        for(int i=0; i<R; ++i) {
            auto temp = readln.split;
            for(int j=0; j<C; ++j) {
                board[i][j] = cast(bool) to!int(temp[j]);
            }
        }
        
        // calc
        int ret = 0;

        int rowsEnd = 1 << R;
        for(int rInt=0; rInt<rowsEnd; ++rInt) {
            
            int val;
            for(int i=0; i<C; ++i) {
                
                int temp;
                for(int j=0; j<R; ++j) {
                    
                    bool r = cast(bool) (rInt & (1 << j));
                    if(r != board[j][i]) {
                        ++temp;
                    }
                    
                }
                temp = temp > R - temp ? temp : R - temp;
                val += temp;
                
            }
            if(ret < val) {
                ret = val;
            }
            
        }

        writeln(ret);
    }
}

Measured memory_bytes: 5456
n = int(input())
li = []

for i in range(n):
    a = int(input())
    li.append(a)
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

while len(li) > 1:
    a = li[0]
    b = li[1]
    li.pop(1)
    li.pop(0)
    ans = a * b // gcd(a, b)
    li.append(ans)

print(li[0])


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a += b;
  c += d;

  puts(
      a==c ? "Balanced" :
      a < c ? "Right" : "Left");

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m, c;
    int b[100];
    int a;
    int sum;
    int cnt=0;
    cin >> n >> m >> c;
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        sum=0;
        for(int j=0; j < m; j++){
            cin >> a;
            sum+=(a*b[j]);
        }
        if((sum+c)>0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define all(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

// Rが，S'の代わり
string R,T;

int main()
{
  cin >> R >> T;

  // 答えの候補の文字列
  vector<string> vec;

  // Rに，部分文字列Tがあるか考える
  REP(i,0, R.length()) {
    // R[i]からの |T| 文字が，T と一致するか？
    bool is_same = true;
    REP(j,0, T.length()) {
      // 違うとわかった時点で抜ける
      if (R[i+j] != '?' && R[i+j] != T[j]) {
        is_same = false;
        break;
      }
    }

    // is_same ならば，R[i] から，Tに一致
    if (is_same) {
      string s = R;             // 答えの候補を作る
      // R[i]までに ? があれば，それは a にする
      REP(j,0,i) {
        if (R[j] == '?') s[j] = 'a';
      }
      // R[i]からは，Tにする
      REP(j,0, T.length()) s[i+j] = T[j];
      // R[i+|T|] から，?があればそれはaに
      REP(j, i + T.length(), R.length()) {
        if (R[j] == '?') s[j] = 'a';
      }

      vec.push_back(s);
    }
  }

  string ans;
  if (vec.empty()) ans = "UNRESTORABLE";
  else {
    sort(vec.begin(), vec.end());
    ans = vec[0];               // vecのうち最小のもの
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      a,b,c = A[i],A[j],A[k]
      if len(set([a,b,c]))<=2:
        continue
      if abs(a-b)<c<a+b:
        ans += 1
print(ans)
      

Measured memory_bytes: 9204
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;	
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)1e5+5;
int main(void){
	int a, b;
	cin >> a >> b;
	if(a > b) printf("%d", a-1);
	else printf("%d", a);
	return 0;
}


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

int n;

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	vector<int> A(n);
	int mod = 1000000007;
	long long sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> A[i];
		sum += A[i];
		sum %= mod;
	}

	long ans = 0;

	for(int i = 0; i < n; i++) {
		sum -= A[i];
		if(sum < 0) sum += mod;

		ans += A[i] * sum;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4040
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll n ; cin >> n ;
	string ans ;
	while(n>0){
		n-- ;
		ans += (char)('a'+n%26) ;
		n /= 26 ;
	}
	reverse(all(ans)) ;
	cout << ans << endl ;
}




Measured memory_bytes: 3628
import math

N,M = map(int,input().split())
if abs(N-M) >= 2:
    print(0)
    exit()
elif abs(N-M) == 1:
    res = math.factorial(N)*math.factorial(M)
    print(res%(10**9+7))
else:
    res = math.factorial(N)*math.factorial(M) * 2
    print(res%(10**9+7))

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,arr[1000],sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
    {
       sum=sum+arr[i];
    }
    cout<<sum<<endl;





    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, T = map(int, raw_input().split())

ans = INF
for i in range(N):
    c, t = map(int, raw_input().split())
    if t <= T:
        ans = min(ans, c)

if ans == INF:
    print 'TLE'
else:
    print ans

Measured memory_bytes: 2812
#include "bits/stdc++.h"
using namespace std;

int main() {
	static long long N, A[100000];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	if (A[N - 1] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (N % 3 != 0) {
		cout << "No" << endl;
		return 0;
	}
	if (A[0] == A[N / 3 - 1] && A[N / 3] == A[N * 2 / 3 - 1] && A[N * 2 / 3] == A[N - 1] && (A[0] ^ A[N / 3]) == A[N * 2 / 3]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int MAXX=2010;
struct node
{
	int x,y;
}e[MAXX];
int head[MAXX],ver[MAXX<<1],nxt[MAXX<<1],deep[MAXX];
int n,k,tot;
inline void add(int x,int y){
	ver[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
inline void dfs(int x,int f,int dp){
	deep[x]=dp;
	for(int i=head[x];i;i=nxt[i]){
		int y=ver[i];
		if(y==f)continue;
		dfs(y,x,dp+1);
	}
} 
int main(){
   scanf("%d%d",&n,&k);
   for(int i=1;i<n;++i){
   	scanf("%d%d",&e[i].x,&e[i].y);
   	add(e[i].x,e[i].y);
   	add(e[i].y,e[i].x);
   }
   int ans=0x3f3f3f3f;
   if(k&1){
      for(int i=1;i<n;++i){
      	int cnt=0;
      	dfs(e[i].x,e[i].y,0);
      	dfs(e[i].y,e[i].x,0);
      	for(int j=1;j<=n;++j)if(deep[j]>(k-1)/2)cnt++;
      	ans=min(ans,cnt);
      } 
   }
   else {
   	  for(int i=1;i<=n;++i){
   	  int cnt=0;
      dfs(i,0,0);
      for(int j=1;j<=n;++j)if(deep[j]>k/2)cnt++;
      ans=min(ans,cnt);
   	  }
   	}
   	cout<<ans;
   	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int d,i;
	cin>>d;
	int p[d];
	for(i=0;i<d;i++)cin>>p[i];
	sort(p,p+d);
	int ans=p[d-1]/2;
	for(i=0;i<d-1;i++)ans+=p[i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    int turn;

    for(turn = 0; ((A > 0) || (C > 0)); turn++) {
        if((turn % 2) == 0) {
            C -= B;
        } else {
            A -= D;
        }
    }

    if((turn % 2) == 0) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 998244353;

int dp[3005][3005];
int psum[3005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, S; gi(N), gi(S);
	int ans = 0;
	rep(i, N) {
		int v; gi(v);
		dp[i][v] = i+1;
		if(i) for(int j=v; j<=S; j++) dp[i][j] = (dp[i][j] + psum[j-v]) % MOD;
		for(int j=v; j<=S; j++) psum[j] = (psum[j] + dp[i][j]) % MOD;
		ans = (ans + 1ll*(N-i)*dp[i][S])%MOD;
	}
	print(ans);
}


Measured memory_bytes: 39168
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-26 15:54:41 +0900
# LastModified: 2020-06-26 16:12:17 +0900
#


import copy
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    x_y = []
    goal = []
    for i in range(n):
        x_y.append(list(map(int, input().split())))
    for i in range(m):
        goal.append(list(map(int, input().split())))

    for xy in x_y:
        tmp = list(map(lambda x: abs(xy[0]-x[0])+abs(xy[1]-x[1]), goal))
        print(tmp.index(min(tmp))+1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s, t;
	cin >> s >> t;

	vector<set<int> > graph(26, set<int> ());
	for (int i = 0; i < (int) s.size(); ++i) {
		graph[s[i] - 'a'].insert(t[i] - 'a');
	}

	for (int i = 0; i < 26; ++i) {
		int c = 0;
		for (int j = 0; j < 26; ++j) {
			if (graph[j].size() > 1) {
				cout << "No\n";
				return 0;
			}

			if (graph[j].size() != 0 && *graph[j].begin() == i) {
				++c;
			} 
		}

		if (c > 1) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";

	return 0;

}

Measured memory_bytes: 916
import sys
sys.setrecursionlimit(500000)
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(input())

def dfs(h,w,i,c):
    # グループ分け
    V[h][w] = i
    # 上
    if h>0 and V[h-1][w]==0:
        if c=="#" and S[h-1][w]==".":
            dfs(h-1,w,i,".")
        elif c=="." and S[h-1][w]=="#":
            dfs(h-1,w,i,"#")
    # 左
    if w>0 and V[h][w-1]==0:
        if c=="#" and S[h][w-1]==".":
            dfs(h,w-1,i,".")
        elif c=="." and S[h][w-1]=="#":
            dfs(h,w-1,i,"#")
    # 下
    if h<H-1 and V[h+1][w]==0:
        if c=="#" and S[h+1][w]==".":
            dfs(h+1,w,i,".")
        elif c=="." and S[h+1][w]=="#":
            dfs(h+1,w,i,"#")
    # 右
    if w<W-1 and V[h][w+1]==0:
        if c=="#" and S[h][w+1]==".":
            dfs(h,w+1,i,".")
        elif c=="." and S[h][w+1]=="#":
            dfs(h,w+1,i,"#")

V = [[0 for _ in range(W)] for _ in range(H)]
ans = 0
i = 0
for h in range(H):
    for w in range(W):
        if S[h][w]=="#" and V[h][w]==0:
            i += 1
            dfs(h,w,i,"#")

# iグループに分割完了
cnt_b = [0]*i
cnt_w = [0]*i

for h in range(H):
    for w in range(W):
        group = V[h][w]
        if group != 0:
            if S[h][w]=="#":
                cnt_b[group-1] += 1
            else:
                cnt_w[group-1] += 1

ans = 0
for i in range(len(cnt_b)):
    ans += cnt_b[i]*cnt_w[i]

print(ans)

Measured memory_bytes: 138796
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
vector<int> v[100005];
int indegree[100005];
int dp[100005];
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        indegree[y]++;
        v[x].pb(y);
    }
    queue<int> q;
    for(int i=1;i<=n;i++){
        if(indegree[i]==0){
            q.push(i);
        }
    }
    int ans=0;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        ans=max(ans,dp[x]);
        for(auto it:v[x]){
            dp[it]=max(dp[it],dp[x]+1);
            if(--indegree[it]==0){
                q.push(it);
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; ll k; cin >> n >> k;
	vi pl, mi;
	rep(i, n){
		int a; cin >> a;
		if(a < 0) mi.pb(-a);
		else pl.pb(a);
	}
	sort(all(pl)); sort(all(mi));
	
	auto calc = [&](const vi &a, const vi &b, ll lim){
		ll res = 0;
		int j = b.size();
		for(int i : a){
			while(j > 0 && b[j - 1] * (ll)i > lim) j--;
			res += j;
		}
		return res;
	};
	
	ll lo = -1.1e18, hi = 1.1e18, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		ll cnt = 0;
		if(mid >= 0){
			ll cntp = calc(pl, pl, mid);
			ll cntm = calc(mi, mi, mid);
			for(int i : pl) if((ll)i * i <= mid) cntp--;
			for(int i : mi) if((ll)i * i <= mid) cntm--;
			cnt += (ll)pl.size() * mi.size();
			cnt += (cntp + cntm) / 2;
		}
		else{
			cnt += (ll)pl.size() * mi.size() - calc(pl, mi, -mid - 1);
		}
		if(cnt >= k) hi = mid;
		else lo = mid;
	}
	cout << hi << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
double a[101];
int main() {

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int votes = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        votes += a[i];
    }
    double limitVotes = (double)votes / (double)(4 * m);
    int cntM = m;
    for(int i = 0; i < n; i++){
        if(cntM == 0)
            break;
        if(a[i] >= limitVotes)
            cntM--;
    }
    if(cntM == 0){
        cout<<"Yes";
    } else {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations

MARCH = ['M', 'A', 'R', 'C', 'H']
counts = [0]*5
N = int(input())
for i in range(N):
    head = input()[0]
    if head in MARCH:
        counts[MARCH.index(head)] += 1
alist = [t for t in zip(MARCH, counts) if t[1] != 0]

if len(alist) > 2:
    ans = 0
    for combination in combinations(range(5), 3):
        i, j, k = combination
        ans += counts[i] * counts[j] * counts[k]
    print(ans)
else:
    print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,k;
ll ans;
ll cnt[200005];
vector<ll> v;
int main()
{
        cin >> n >> k;
        for(ll i=0;i<n;i++)
        {
                ll a;
                cin >> a;
                cnt[a]++;
        }
        for(ll i=1;i<=200001;i++)
        {
                if(cnt[i] == 0) continue;
                v.push_back(cnt[i]);
        }
        //cout << v.size() << endl; return 0;
        sort(v.rbegin() , v.rend());
        //for(auto i : v) cout << i << endl; return 0;
        if(v.size() <= k){
                cout << "0\n"; return 0;
        }
        ll i = k;
        for(;i<v.size();i++)
                {
                        ans += v[i];
                       // cout << v[i] << endl;
                }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 3956
a,b,k = map(int,input().split())
bit = 0
while k:
  if bit==0:
    if a%2!=0:
      a -= 1
    b += a//2
    a //= 2
    bit = 1
  else:
    if b%2!=0:
      b -= 1
    a += b//2
    b //= 2
    bit = 0
  k -= 1


print(a,b)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    int i;
    cin >> s ;
    string ans = "";
    for(i=0;i<4;i++)
        ans = ans + s[i];
    ans = ans + " ";
    for(i=4;i<12;i++)
        ans = ans + s[i];
    cout << ans << endl;
    return 0;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    string s;
    cin >> s;
    string ans = "";

    for(int i = 0;i < s.size();i ++){
        if(s.at(i) == '0'){
             ans= ans + '0';
        }else if(s.at(i) == '1'){
            ans = ans + '1';
        }else{
            if(ans.size() == 0){
                continue;
            }else{
                ans.pop_back();
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define ld long double
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, M, D; cin >> N >> M >> D;
  ld ans;
  if (D == 0) {
    ans = (ld)(M - 1) / N;
  } else {
    ans = (ld)(M - 1) * (N - D) * 2 / (N * N);
  }
  cout << fixed << setprecision(10) << ans << endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int N;
vi g[MN];
int A[MN];

ll dfs(int v, int p)
{
	bool leaf = 1;
	ll sum = 0;
	ll maxi = 0;

	for (int to : g[v]) if (to != p) {
		ll t = dfs(to, v);
		if (t == -1) return -1;
		maxi = max(maxi, t);
		sum += t;
		leaf = 0;
	}

	if (leaf) {
		return A[v];
	} else {
		ll res = A[v] * 2 - sum;
		if (res < 0 || (p == -1 && res != 0)) return -1;
		maxi = max(maxi, res);
		if (maxi > A[v]) {
			return -1;
		} else {
			return res;
		}
	}
}

int main() {
	cin >> N;
	rep(i, N) cin >> A[i];

	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}

	if (N == 2) {
		puts(A[0] != A[1] ? "NO" : "YES");
		return 0;
	}

	int r = -1;
	rep(i, N) if (g[i].size() > 1) {
		r = i;
	}

	puts(dfs(r, -1) == -1 ? "NO" : "YES");
	return 0;
}

Measured memory_bytes: 13312
//#pragma GCC optimize(2) 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define clr(a,b) memset(a,b,sizeof(a))
ll n,m,k,ans;
ll f[300005];
ll mod=1000000007;
ll pow1(ll x,ll y){
	ll a=1,b=x;while(y){if(y&1)a=(a*b)%mod;b=(b*b)%mod;y>>=1;}
	return a;
}
int main(){
	//freopen("P1429_6.in","r",stdin);
	//freopen("match.out","w",stdout);
    ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	for(int i=k;i>=1;i--){
		f[i]=pow1(k/i,n);
		for(int j=2;i*j<=k;j++){
			f[i]-=f[i*j];
		}
		ans=(ans+((f[i]*i)%mod+mod)%mod+mod)%mod;
	}
	cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int a[1010][1010];
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  FOR(i,0,n+1){
    FOR(j,0,m+1){
      if(k==(i*m+j*n-2*i*j)){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;


}


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

int main()
{
    int A[5];
    for(int i=0;i<5;i++)
    {
        cin>>A[i];
        if(A[i]==0)
        {
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int Q, s = 0; scanf("%*d%d", &Q); Q*=2;
	while(Q--) {
		int x; scanf("%d", &x);
		s ^= x;
	}
	puts(s ? "NO" : "YES");
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
int N;
int a[100010] = {0};
int sum[100010] = {0};
int ji = 0,ou = 0;
queue<int> one,two;

int main(){
	scanf("%d",&N);
	for(int i = 1;i <= N;i++){
		scanf("%d",&a[i]);
		if(sum[a[i]] == 0){
			ji++;
		}
		else{
			if(sum[a[i]] & 1)ji--,ou++;
			else ou--,ji++;
		}
		sum[a[i]]++;
	}
	for(int i = 1;i <= 100000;i++)if(sum[i]!=0){
		if(sum[i]&1)one.push(i),sum[i] = 1;
		else two.push(i),sum[i] = 2;
	}
	for(int i = 1;i <= 100000;i++){
		if(sum[i] == 1 || sum[i] == 0)continue;
		two.pop();
		if(!two.empty()){
			int x = two.front();two.pop();
			sum[x]--;
			one.push(x);
		}
		else{
			int x = one.front();one.pop();
			sum[x]--;
		}
		sum[i]--;
		one.push(i);
	}
	int ans = 0;
	for(int i = 1;i <= 100000;i++)ans += sum[i];
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int N, i;
    int ans = 0;
    int A[210];
    bool e_flag = false;

    cin >> N;
    for (i=0; i<N; i++){
        cin >> A[i];
    }

    while (1){
        for (i=0; i<N; i++){
            if (A[i]%2==0)
                A[i] = A[i]/2;
            else{
                e_flag=true;
                break;
             }
        }
        if (e_flag == true)
            break;
        else
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b, c,tmp;

	scanf("%d%d%d", &a, &b, &c);

	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp=b;
		b=c;
		c=tmp;
		}
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;

}


Measured memory_bytes: 2088
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll x,k,d;cin>>x>>k>>d;
  x=abs(x);
  ll m=x/d;
  if(k<m){
    cout<<x-d*k<<endl;
  }
  else{
    k-=m;
    if(~k&1)cout<<x-d*m<<endl;
    else cout<<abs(x-d*(m+1))<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
n,r = map(int,input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

ans = Base_10_to_n(n, r)

print(len(str(ans)))

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static long GetInteger() { return long.Parse(Console.ReadLine()); }
    public static IEnumerable<ulong> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)); }
}

namespace AtCoder.E
{
    public class Program
    {
        public static long N { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            N = CR.GetInteger();

            // 奇数の時点でNG
            if (N % 2 != 0) return 0;

            var fize = 0L;
            var under = 2L;
            while (under <= N)
            {
                under *= 5;
                //fize = (long)Math.Floor((double)N / under); // NG
                fize += N / under;
            }

            return fize;
        }
    }
}


Measured memory_bytes: 11092
import math
def is_prime(n):
  if n==2:
    return True
  elif n%2==0 or n<=1:
    return False
  else:
    for i in range(3,int(math.sqrt(n))+1,2):
      if n%i==0:
        return False
    return True
num=int(input())
ans=0
for _ in range(num):
  n=int(input())
  #print(is_prime(n))
  ans += is_prime(n)
print(ans)



Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n; cin >> n;
  vi h(n); rep(i,n) cin >> h[i];
  vi a(n+2,1e9);
  a[0] = 0;

  rep(i,n) {
    if(i+2 < n) chmin(a[i+2],a[i] + abs(h[i+2] - h[i]));
    if(i+1 < n) chmin(a[i+1],a[i] + abs(h[i+1] - h[i]));
  }

  cout << a[n-1] << endl;
}


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

int main(){
  int n;
  cin>>n;
  string str;
  cin>>str;
  n=str.size();
  int I=0,J=0,O=0,JO=0,IOI=0,JOI=0;

  for(int i=0;i<n;i++){
    if(str[i]=='I'){
      I++;
      if(O*J*JO)J--,JO--,O--,JOI++;
      else if(O*I)O--,IOI++;
    }

    if(str[i]=='O') {
      if(I-IOI+J>O) O++;
      if(J>JO) JO++;
    }
    if(str[i]=='J') J++;
  }
  int ans=JOI;
  I-=JOI;
  ans+=min(IOI,I/2);
  cout<<ans<<endl;
  



return 0;
}

Measured memory_bytes: 2068
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N[] = new int[3];
    for (int i = 0; i < 3; i++) {
      N[i] = scanner.nextInt();
    }
    Arrays.sort(N);
    System.out.println(N[2]*10+N[1]+N[0]);
    scanner.close();
  }
}


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

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

    int r;
    cin >> r;
    if (r < 1200) {
            cout << "ABC" << endl;
    } else if (r < 2800) {
            cout << "ARC" << endl;
    } else {
            cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9552
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    string w;
    scan(w);
    auto c  = new int[](26);
    foreach (ch ; w) {
        c[ch - 'a']++;
    }
    yes(c.all!"a % 2 == 0");
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// こちらを参考にした
// https://drken1215.hatenablog.com/

func main() {
	var A, B100 int
	var B string
	fmt.Scan(&A, &B)
	B100 = int(B[0]-'0')*100 + int(B[2]-'0')*10 + int(B[3]-'0')
	ans := (A * B100) / 100
	fmt.Println(ans)
}

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

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define X first
#define Y second

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

struct IOS { IOS() { ios::sync_with_stdio(0); cin.tie(0); } } IOS;
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;

int N;
vi a, dist;
vvi adj;
int K;

int dfs(int u) {
	if (u == 0) return (dist[u] = 0);
	else if (dist[u] < INT_MAX) return dist[u];
	else return (dist[u] = 1 + dfs(a[u]));
}

void fix(int u) {
	dist[u] = -1;
	for (int v : adj[u])
		if (dist[v] != -1)
			fix(v);
}

int main() {
	cin >> N >> K;
	a.resize(N);
	adj.resize(N);
	FOR(i,0,N) {
		cin >> a[i]; a[i]--;
		if (i != 0)	adj[a[i]].push_back(i);
	}
	
	int ans = 0;
	
	// The capital must teleport to itself
	if (a[0] != 0) { ans++; a[0] = 0; }
	
	// Compute distances
	dist.assign(N, INT_MAX);
	FOR(u,0,N) dfs(u);
	
	// Note outdegrees
	vi outdegree(N);
	FOR(u,0,N) outdegree[u] = (int)adj[u].size();
	
	// Find the leaves
	priority_queue<pii> leaves;
	FOR(u,1,N) {
		if (adj[u].empty() && dist[u] > K)
			leaves.push({dist[u], u});
	}
	
	// Fix the tree
	// While there is a leaf with dist[u] > K
	while (!leaves.empty()) {
		
		int u = leaves.top().second; leaves.pop();
		
		if (dist[u] <= K) continue;
		
		// Find the k - 1 ancestor of u
		int v = u;
		FOR(i,0,K-1) v = a[v];
		
		// Attach v to the root
		ans++;
		
		// Mark all of my children as good
		fix(v);
		
		// Mark my parent as a leaf if I was his last child
		outdegree[a[v]]--;
		if (outdegree[a[v]] == 0) {
			leaves.push({dist[a[v]], a[v]});
		}
	}
	
	cout << ans << endl;
  
}





Measured memory_bytes: 9984
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>

#include <string>

using namespace std;

typedef long long ll;

bool ispal(const string& s) {
  return equal(s.cbegin(), s.begin() + s.size() / 2, s.crbegin());
}

string s;

void solve() {
  cin >> s;

  int n = (int)s.size();

  int mid = n / 2;

  string left = s.substr(0, mid);
  string right = s.substr(mid + 1);

  string ans = "No";

  if (ispal(s) && ispal(left) && ispal(right))
    ans = "Yes";

  cout << ans << '\n';
}

int main() {
  int t = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  t = 3;
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  while (t--)
    solve();
}


Measured memory_bytes: 256
# coding=utf-8
from collections import deque
n = int(input())
deque = deque()
input_lines = [input().split() for x in range(n)]

for i in range(n):
    inp = input_lines[i]
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque)

Measured memory_bytes: 557384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
int num[300000];
int ans[300000];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	cin>>ans[i];
	for(int i=0;i<k;++i){
		int pass=1;
		for(int j=1;j<=n;++j)
		num[j]=0;
		for(int j=1;j<=n;++j){
			if(j-ans[j]<=1)num[1]++;
			else ++num[j-ans[j]];
			if(j+ans[j]<=n)num[j+ans[j]+1]--;
		}
		int sum=0;
		for(int j=1;j<=n;++j){
			sum+=num[j];
			ans[j]=sum;
			if(sum!=n)pass=0;
		}
		if(pass)break;
	}
	for(int i=1;i<=n;++i)
	cout<<ans[i]<<" ";
	return 0;
}
/*
4 1
0 0 0 0
1 1 1 1
4 1
1 0 0 0
1 2 1 1
4 1
4 0 0 0
1 2 2 2
*/


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int arr[200005], sequence[200005];
bool visited[200005];
long long n, k;
int main() {
	cin >> n >> k;
	for(int i = 0; i < n; i++)	cin >> arr[i];
	sequence[0] =  1;
	visited[0] = true;
	int i = 1, current = 1;
	while(i == 1 || visited[current - 1] == false) {
		visited[sequence[i - 1] - 1] = true;
		sequence[i] = arr[current - 1];
		current = sequence[i];
		i++;
	}
	int idx = 0;
	for(int j = 0; j < i; j++) {
		if(sequence[j] == current) {
			idx = j;
			break;
		}
	}
	if(k <= idx)	cout << sequence[k] << endl;
	else	cout << sequence[idx + ((k - idx) % (i - 1 - idx))] << endl;
	return 0;
}

Measured memory_bytes: 5344