akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include <atcoder/all>
//using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
constexpr char ln = '\n';
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    string S; cin >> S;
    if (S.back()=='s') S += "es";
    else S += 's';

    cout << S << ln;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void) {
	char A[11], B[11], C[11];
	int i,j;
	scanf("%s", A);
	scanf("%s", B);
	scanf("%s", C);
	for (i = 0; A[i] != '\0';i++) {
	}
	for (j = 0; B[j] != '\0'; j++) {
	}
	
	if (A[i-1]==B[0]) {
		if (B[j - 1] == C[0]) {
			printf("YES");
		}
		else {
			printf("NO");
		}
	}
	else {
		printf("NO");
	}
	return 0;
}

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

int main(){
  string o, e;

  cin>>o>>e;

  if((int)o.size() == (int)e.size()){
    for(int i=0;i<(int)o.size();i++){
      cout<<o[i]<<e[i];
    }
    cout<<endl;
  }

  else{
    for(int i=0;i<(int)o.size() - 1;i++){
      cout<<o[i]<<e[i];
    }
    cout<<o[(int)o.size()-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=85;
//↑templete
signed main(){
	int a, b;
	cin>>a>>b;
	cout<<(a^b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b,c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
D = list(map(int,input().split()))
for i in range(N*10):
    n = str(N + i)
    ok = True
    for j in D:
        if n.find(str(j)) != -1:
            ok = False
            break
    if ok:
        print(n)
        break

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n,m;
	cin>>n>>m;
	int flag[m];
	rep(i,m)flag[i]=0;
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int tmp;
			cin>>tmp;
			flag[tmp-1]++;
		}
	}
	int ans=0;
	rep(i,m)if(flag[i]==n)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
A = [[int(i) for i in input().split()] for j in range(3)]
B = [[0 for i in range(3)] for j in range(3)]
n = int(input())
num_to_loc = dict()
for i in range(3):
    for j in range(3):
        num_to_loc[A[i][j]] = (i,j)
for i in range(n):
    b = int(input())
    if b in num_to_loc:
        x = num_to_loc[b]
        B[x[0]][x[1]] = 1
tmp = max([sum([B[i][j] for i in range(3)]) for j in range(3)])
tmp = max(tmp, max([sum([B[i][j] for j in range(3)]) for i in range(3)]))
tmp = max(tmp, sum([B[i][i] for i in range(3)]), sum([B[i][2-i] for i in range(3)]))
if tmp == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 300005

ll N;
ll POW[60];
ll A[SIZE];


int main(){

	POW[0] = 1;
	for(int i = 1; i < 60; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%lld",&N);

	for(int i = 0; i < N; i++){

		scanf("%lld",&A[i]);
	}

	ll ans = 0;

	for(int i = 0; i < 60; i++){

		ll num_zero = 0;
		ll num_one = 0;

		for(int k = 0; k < N; k++){
			if(A[k] & POW[i]){

				num_one++;

			}else{

				num_zero++;
			}
		}

		ll tmp = num_zero*num_one;
		tmp %= MOD;

		for(int k = 0; k < i; k++){

			tmp *= 2;
			tmp %= MOD;
		}

		ans += tmp;
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        cin>>a[i][j];
    }
    vector<pair<int,int>> v,vv;
    int cnt=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        if(a[i][j]%2==1){
            if(j!=w-1){
                a[i][j]--;
                a[i][j+1]++;
                cnt++;
                v.push_back(make_pair(i+1,j+1));
                vv.push_back(make_pair(i+1,j+2));
            }
            else if(i!=h-1){
                a[i][j]--;
                a[i+1][j]++;
                cnt++;
                v.push_back(make_pair(i+1,j+1));
                vv.push_back(make_pair(i+2,j+1));
            }
            
        }
    }
    cout<<cnt<<endl;
    for(int i=0;i<cnt;i++){
        cout<<v[i].first<<" "<<v[i].second<<" "<<vv[i].first<<" "<<vv[i].second<<endl;
    }
    

}

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

double p[5000];
double dp[3005][3005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	dp[0][0] = 1.00;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dp[i+1][j+1] += dp[i][j]*(p[i]);
			dp[i+1][j] += dp[i][j]*(1.0-p[i]);
		}
	}
	double prob = 0;
	for(int i = n/2+1;i<=n;i++)prob += dp[n][i];
	cout<<std::fixed;
	cout<<std::setprecision(10)<<prob<<endl;
	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=998244353;
char s[105];
map<__int128,int> Map;
int Log(__int128 x){
	int len=-1;
	while (x)x>>=1,len++;
	return len;
}
int dfs(__int128 x){
	if (x<=2)return 1;
	if (x==3)return 2;
	if (Map.count(x))return Map[x];
	int len=Log(x);
	Map[x]=dfs(x>>1)*((x&1)+1)%M;
	for (int i=1;i<len;i++){
		__int128 now=x&(((__int128)1<<i)-1);
		for (int j=i;j+i<=len;j+=i){
			now&=(x>>j)&(((__int128)1<<i)-1);
			(Map[x]+=dfs(now|((__int128)1<<i))*dfs(x>>(i+j)))%=M;
		}
	}
	return Map[x];
}
signed main(){
	scanf("%s",s+1);
	__int128 now=1;
	for (int i=1;s[i];i++)now=now*2+s[i]-48;
	printf("%lld\n",dfs(now));
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <istream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

struct score_board {
	int id;
	int score;
	int frames[32];
	int throws[32];

	score_board() {
		id = -1; score = -1;
		for(int i = 0; i < 32; i++) {
			frames[i] = -1;
			throws[i] = -1;
		}
	}

	int set_score() {
		if(score != -1)
			return score;
		score = 0;

		for(int f = 0; f < 10; f++) {
			score += max(0, throws[frames[f*2]]) + max(0, throws[frames[f*2 + 1]]);
			if(max(0, throws[frames[f*2]]) == 10) {
				score += max(0, throws[frames[f*2] + 1]) + max(0, throws[frames[f*2] + 2]);
			}
			else if(max(0, throws[frames[f*2]]) + max(0, throws[frames[f*2 + 1]]) == 10) {
				score += max(0, throws[frames[f*2 + 1] + 1]);
			}
		}

		return score;
	}

	bool operator<(const score_board& b) const {
		if(score == b.score)
			return id > b.id;
		return score < b.score;
	}
};

istream& operator>>(istream& istr, score_board& sb) {
	string s;
	int count = 0;
	istr >> sb.id;
	getline(istr, s);
	stringstream sstr(s);
	
	int n = 0;
	int frame_count = 0;
	int throw_count = 0;
	int pin = 0;
	while(sstr >> sb.throws[n]) {
		pin += sb.throws[n];
		sb.frames[frame_count * 2 + throw_count] = n;
		if(pin == 10 || (throw_count > 0 && frame_count < 9)) {
			pin = 0;
			throw_count = 0;
			frame_count++;
		}
		else
			throw_count++;
		n++;
	}
	sb.set_score();

	/*
	cout << "id:" << sb.id << endl;
	for(int i = 0; i < 10; i++) {
		cout << ":" << sb.throws[sb.frames[i*2]] << " " << sb.throws[sb.frames[i*2 + 1]];
	}
	cout << endl;
	*/

	return istr;
}

int main() {
	int n;
	while(cin >> n, n) {
		vector<score_board> in;
		for(int i = 0; i < n; i++) {
			score_board tmp;
			cin >> tmp;
			in.push_back(tmp);
		}
		sort(in.rbegin(), in.rend());
		for(int i = 0; i < in.size(); i++) {
			cout << in[i].id << " " << in[i].score << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int Board[100][100] = {};
int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};
string m;
long int ans = 0;

void dfs_1(int i, long int temp);
void dfs_2(int i, long int before_val, long int temp);

int main() {
	cin >> m;
	dfs_1(0, 0);
	cout << ans <<endl;
	return 0;

}

void dfs_1(int i, long int temp) {
	long int val = m[i] - '0';
	ans += val;
	//cout << ans << ", " << val <<endl;
	if(i == m.length()-1) { return; }
	dfs_1(i+1, temp+val);
	ans += temp;
	dfs_2(i+1, val*10, temp);
}

void dfs_2(int i, long int before_val, long int temp) {
	long int val = m[i] - '0';
	ans += before_val + val;
	//cout << ans << ", " << before_val << ", " << val <<endl;
	if(i == m.length()-1) { return; }
	dfs_1(i+1, temp + before_val + val);
	val = (val+before_val)*10;
	ans += temp;
	dfs_2(i+1, val, temp);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>s;
  int ans=0;
  for(int i=0;i<6;i++){
    if(s[i]=='1')ans++;
  }
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		ArrayList<Integer> V = new ArrayList<>();
		for(int i=0; i<N; i++) {
			V.add(sc.nextInt());
		}

		long ans = 0;
		for(int l=0; l<=K; l++) {
			for(int r=0; r<=K-l; r++) {

				if(l+r>N) continue;

				int d = K-(l+r);
				ArrayList<Integer> s = new ArrayList<>();
				long tmp=0;

				for(int i=0; i<l; i++) {
					tmp += V.get(i);
					s.add(V.get(i));
				}

				for(int i=N-r; i<N; i++) {
					tmp += V.get(i);
					s.add(V.get(i));
				}

				Collections.sort(s);
				for(int i=0; i<d; i++) {
					if(s.size()<=i) break;
					if(s.get(i)>=0) break;
					tmp -= s.get(i);
				}
				ans = Math.max(tmp, ans);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 24020
#include<stdio.h>

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


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	vector <int> v;
	v.push_back(1);
	for (int i = 2; i * i <= n; i ++) {
		int k = i;
		while (k <= n) {
			v.push_back(k);
			k *= i;
		}
	}
	sort(v.rbegin(), v.rend());
	for (int i : v) {
		if (i <= n) {
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 

int main(){
	FIO;
	int n; cin >> n;
    n %= 10;
    if(n==3) cout << "bon" << endl;
    else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
    else cout << "hon" << endl;
	return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {
		
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
	
		int prime[] = new int[N+1];
		Arrays.fill(prime, 1);
		for(int k=2;k<=N;k++) {
			int tmp = k;
			for(int i=2;i*i<=k;i++) {
				while(tmp%i==0) {
					tmp /= i;
					prime[i]++;
				}
			}
			if(tmp!=1)prime[tmp]++;
			
		}
		
		int _3up = 0;
		int _5up = 0;
		int _15up = 0;
		int _25up = 0;
		int _75up = 0;
		
		for(int i=0;i<N+1;i++) {
			
			if(prime[i]>=75) _75up ++;
			else if(prime[i]>=25) _25up ++;
			else if(prime[i]>=15) _15up ++;
			else if(prime[i]>=5)  _5up ++;
			else if(prime[i]>=3)  _3up ++;
		}
		
		int sum = _75up + _25up + _15up + _5up + _3up;
		
		int ans = _75up + (_75up + _25up) * (sum - 1) + (_75up + _25up + _15up) * (sum - _3up - 1)
					+ (_75up + _25up + _15up + _5up) * (_75up + _25up + _15up + _5up - 1)/2 * (sum - 2);
				
		
		System.out.println(ans);
	}
	
	
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

H,W = inputIL()

print("#"*(W+2))
for i in range(H):
  print("#"+"".join(inputS())+"#")
print("#"*(W+2))

Measured memory_bytes: 38256
#include <stdio.h>

int main() {
  char str[10001];
  int sumjoi, sumioi, i;
  while(scanf("%s", str) != EOF) {
    sumjoi = sumioi = 0;
    for(i = 0; i < strlen(str)-3; i++) {
      if(str[i] == 'J' && str[i+1] == 'O'
	 && str[i+2] == 'I')
	sumjoi++;
      if(str[i] == 'I' && str[i+1] == 'O'
	 && str[i+2] == 'I')
	sumioi++;
    }
    printf("%d\n%d\n", sumjoi, sumioi);
  }
  return 0;
}

Measured memory_bytes: 0
#include <climits>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

void bfs(int start, vector<int>& dist, vector<vector<int>>& G) {
  queue<int> que;
  que.emplace(start);
  dist[start] = 0;
  int level = 0;
  while (!que.empty()) {
    int size = que.size();
    ++level;
    rep(i, size) {
      int v = que.front();
      que.pop();
      dist[v] = level;
      for (auto nv : G[v]) {
        if (dist[nv] != INT_MAX) continue;
        que.emplace(nv);
      }
    }
  }
}

int main(void) {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<int> fv(N, INT_MAX);
  bfs(0, fv, G);
  vector<int> sv(N, INT_MAX);
  bfs(N - 1, sv, G);

  int count = 0;
  rep(i, N) {
    if (fv[i] <= sv[i]) ++count;
  }
  if (count <= (N - count))
    cout << "Snuke" << endl;
  else
    cout << "Fennec" << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <cstdint>
#include <iostream>

using namespace std;

static bool is_get(long long x, long long n)
{
  if (x <= (5 * n + (n + 1) / 2)) return true;

  return false;
}

int32_t main()
{
  long long x;
  cin >> x;

  long long left = 0;
  long long right = x + 1;
  long long mid = (left + right) / 2;

  while (left + 1 < right) {
    if (is_get(x, mid)) {
      right = mid;
    } else {
      left = mid;
    }
    mid = (left + right) / 2;
  }

  cout << right << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    N = int(input())
    X = [[] for i in range(N)]
    for i in range(N):
        for j in LI():
            X[i].append(j-1)
        X[i].reverse()

    Q = []
    def check(i):
        if len(X[i])==0:
            return
        j = X[i][-1]
        if len(X[j])==0:
            return
        if i==X[j][-1]:
            if i<j:
                Q.append((i,j))
            else:
                Q.append((j,i))

    for i in range(N):
        check(i)

    day = 0
    while len(Q)>0:
        day += 1
        Q.sort()
        Q = list(set(Q))
        prevQ = Q.copy()
        Q = []
        for i,j in prevQ:
            X[i].pop()
            X[j].pop()
        for i,j in prevQ:
            check(i)
            check(j)

    for i in range(N):
        if len(X[i])>0:
            print("-1")
            return

    print(day)
    return

main()

Measured memory_bytes: 35612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

 int H,W;
 int dy[4] = {-1, 0, 1, 0};
 int dx[4] = {0, 1, 0, -1};
 string s[1010];
 int dist[1000][1000];


int main(int argc, char const *argv[]) {
  cin >> H >> W;
  rep(i,H) cin >> s[i];
  rep(i,H) rep(j,W) dist[i][j]=INF;
  queue<pii> que;
  rep(i,H) rep(j,W) if(s[i][j]=='#'){
    que.push(pii(i,j));
    dist[i][j]=0;
  }

  while (!que.empty()) {
    pii now=que.front();
    que.pop();
    int y=now.fi;
    int x=now.se;
    rep(i,4){
      int ny=y+dy[i];
      int nx=x+dx[i];
      if(ny<0 || ny>=H || nx<0 || nx>=W || dist[ny][nx]<=dist[y][x]+1) continue;
      dist[ny][nx]=dist[y][x]+1;
      que.push(pii(ny,nx));
    }
  }

  int ans=0;
  rep(i,H) rep(j,W) ans=max(ans,dist[i][j]);
  cout << ans << endl;

  return 0;
}


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

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using LL   =  long long;
using pii  =  pair <int, int>;
using vii  =  vector <pii>;

const int INF = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n;
    set <int> s;
    cin>>n;
    while(n--) {
        int x;
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int read() {
    int x = 0, f = 1; char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

const int Max = 200033;
const int mod = 1000000007;
const int inf = 1100000000;

int n, b[Max], dp[Max];
int ans, mn[Max], mx[Max];

struct man {
	int x, v;
    friend bool operator< (man a, man b) {
        return a.x < b.x;
    }
} p[Max];
struct line {
	int l, r;
    friend bool operator< (line a, line b) {
        return a.r == b.r ? a.l < b.l : a.r < b.r;
    }
} q[Max];

#define ls x << 1
#define rs x << 1 | 1
struct SegmentTree {
    int sum[Max * 8];
    void update(int x, int l, int r, int pos, int v) {
        if (l == r) {
            sum[x] = (sum[x] + v) % mod;
            return;
        }
        int mid = (l + r) >> 1;
        if (pos <= mid) update(ls, l, mid, pos, v);
        else update(rs, mid + 1, r, pos, v);
        sum[x] = (sum[ls] + sum[rs]) % mod;
    }
    int query(int x, int l, int r, int L, int R) {
        if (L <= l && r <= R) {
            return sum[x];
        }
        int re = 0, mid = (l + r) >> 1;
        if (L <= mid) re = (re + query(ls, l, mid, L, R)) % mod;
        if (R > mid) re = (re + query(rs, mid + 1, r, L, R)) % mod;
        return re;
    }
} sgt;

signed main() {
    n = read();
    for (int i = 1; i <= n; i++)
        p[i].x = read(), b[i] = p[i].v = read();
    sort(p + 1, p + n + 1);
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++)
       p[i].v = lower_bound(b + 1, b + n + 1, p[i].v) - b;
    mn[n + 1] = inf;
    for (int i = n; i >= 1; i--)
        mn[i] = min(mn[i + 1], p[i].v);
    for (int i = 1; i <= n; i++)
        mx[i] = max(mx[i - 1], p[i].v);
    for (int i = 1; i <= n; i++) {
        q[i].l = mn[i], q[i].r = mx[i];
    }
    sort(q + 1, q + n + 1);
    dp[1] = 1;
    sgt.update(1, 1, n, q[1].r, dp[1]);
    for (int i = 2; i <= n; i++) {
        dp[i] = sgt.query(1, 1, n, max(1ll, q[i].l - 1), q[i].r);
        if (q[i].l == 1) dp[i]++;
        sgt.update(1, 1, n, q[i].r, dp[i]);
    }
    for (int i = n; i >= 1 && q[i].r == q[n].r; i--)
    	ans = (ans + dp[i]) % mod;
    printf("%lld\n", ans);
    return 0;
}

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

int main() {

  int h,w; cin >> h >> w;
  
  vector<string> vec(h);
  for(int i=0; i<h; i++){
    string s; cin >> s;
    vec.at(i) = s;
  }
  
  string ans = "Yes";
  for(int i=0; i<h; i++){    
    for(int j=0; j<w; j++){
      
      if (vec.at(i).at(j) == '#'){
        int f = 0;
        
        if (i > 0 && vec.at(i-1).at(j) == '#') f=1;
        if (i < h-1 && vec.at(i+1).at(j) == '#' ) f =1;
        if (j > 0 && vec.at(i).at(j-1) == '#') f=1;
        if (j < w-1 && vec.at(i).at(j+1) == '#' ) f=1;
        
        if (f == 0) {
          ans = "No";
          break;
        }
      }
      

    }    
  }
  
  cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;

#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
  string s;
  cin >> s;

  ll l = s.length();
  cout << s.c_str()[0] << l-2 << s.c_str()[l-1] << endl;
  return 0;
}



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

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << a - 1 << endl;
	}
	else {
		cout << a << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if((i + 1) % 2 == 0 && s[i] == 'R')
        {
            cout << "No";
            return 0;
        }
        if((i + 1) % 2 == 1 && s[i] == 'L')
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  deque<char> str; string s; cin >> s; ll oecount = 0;
  
  for(ll i=0; i < s.size(); i++){
    str.push_back(s[i]);
  }
  
  ll q; cin >> q;
  
  for(ll i=0; i < q; i++){
    ll x; cin >> x;
    
    if(x==1) oecount++;
    
    else{
      ll f; char c; cin >> f >> c;
      
      if((f == 1 && oecount % 2 == 0) || (f == 2 && oecount % 2 == 1))
        str.push_front(c);
      else str.push_back(c);
    }
  }
 
  while(!str.empty()){
    if(oecount % 2 == 0){
      cout << str.front();
      str.pop_front();
    }
    else{
      cout << str.back();
      str.pop_back();
    }
    
  } 
  
  cout << endl;
}

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

typedef long long LL;
typedef std::vector<bool> VB;
typedef std::vector<int>  VI;
typedef std::vector<long long> VLL;
typedef std::vector< VI > VI2;

const int upper = 7368793;
int m, n;
VB isPrime(7368793);
int main() {
    int i, j, k;
    while(std::cin >> m >> n, m != 0 && n != 0) {
        isPrime.assign(upper, true);
        k = m;
        for(i = 0; i < n; ++i) {
            while(!isPrime[k]) ++k;
            for(j = 1; k*j < upper; ++j) {
                isPrime[k*j] = false;
            }
        }
        ++k;
        while(!isPrime[k]) ++k;
        std::cout << k << std::endl;
    }
}


Measured memory_bytes: 3428
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int ra = 0, rb = 0;
    bool pa = true;
    char c = getchar();
    while (c == '0' || c == '1') {
        c -= '0';
        if ((bool)c == pa) {
            ++rb;
        }
        else {
            ++ra;
        }
        pa = !pa;
        c = getchar();
    }
    cout << min(ra, rb) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll a, b;
    cin(a);
    cin(b);

    ll mi = min(a, b);
    ll ma = max(a, b);

    rep(ma) {
        printf("%lld", mi);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h, w, k, sy, sx, gy, gx;
    cin >> h >> w >> k >> sy >> sx >> gy >> gx;

    --sy;
    --sx;
    --gy;
    --gx;

    vector<string> mat(h);

    rep(i,h){
        cin >> mat[i];
    }

    auto inside = [&](int y, int x){
        return (0 <= y && 0 <= x && y < h && x < w);
    };

    vector<vector<int> > min_cost(h, vector<int>(w, LINF));
    min_heap<tuple<int, int, int> > pq;
    min_cost[sy][sx] = 0;
    pq.emplace(0, sy, sx);

    while(!pq.empty()){
        auto [v, y, x] = pq.top();
        pq.pop();
        if(min_cost[y][x] < v) continue;
        rep(i,4){
            int ny = y, nx = x;
            rep(j,k){
                ny += dy[i];
                nx += dx[i];
                if(inside(ny, nx) && mat[ny][nx] != '@'){
                    if(chmin(min_cost[ny][nx], min_cost[y][x] + 1)){
                        pq.emplace(min_cost[ny][nx], ny, nx);
                    }else if(min_cost[ny][nx] != min_cost[y][x] + 1){
                        break;
                    }
                }else{
                    break;
                }
            }
        }
    }

    if(min_cost[gy][gx] == LINF){
        cout << -1 << '\n';
    }else{
        cout << min_cost[gy][gx] << '\n';
    }

    return (0);
}


Measured memory_bytes: 19756
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d[10000],f[10000],g[1001][1001],h,i,j,k;
int main(void)
{
	scanf("%d %d",&a,&s);
	for(i=0;i<a;i++)
		scanf("%d",&d[i]);
	for(i=0;i<s;i++)
		scanf("%d",&f[i]);
	for(i=0;i<=s;i++){
		for(j=0;j<=a;j++)
			g[i][j]=-1;
	}
	/*for(i=0;i<a;i++)
		printf("%d\n",d[i]);
	for(i=0;i<s;i++)
		printf("%d\n",f[i]);*/
	g[0][0]=0;
	for(i=0;i<=s;i++){
		for(j=0;j<=a;j++){
			if(g[i][j]+d[j]*f[i]<g[i+1][j+1]||g[i+1][j+1]==-1){
				if(g[i][j]!=-1)
					g[i+1][j+1]=g[i][j]+d[j]*f[i];
			}
			if(g[i][j]<g[i+1][j]||g[i+1][j]==-1){
				if(g[i][j]!=-1)
					g[i+1][j]=g[i][j];
			}
		//	printf("%d  ",g[i][j]);
		}
	//	printf("\n");
	}
	printf("%d\n",g[s][a]);
	return 0;
}

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

#include<algorithm>
#include<cstring>

int main(){

	int n, m, a[101], b[101];
	int point[101];
	memset(point, 0, sizeof(point));

	cin >> n >> m;

	for (int i = 1; i <= m; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++){
		for (int j = 1; j <= n; j++){
			cin >> b[j];
			if (b[j] == a[i])point[j]++;
			else point[a[i]]++;
		}
	}

	for (int i = 1; i <= n; i++)
		cout << point[i] << endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a*b*1)%2||(a*b*2)%2||(a*b*3)%2)
	{
		cout<<"Yes\n";
	 } 
	else 
	{
		cout<<"No\n";
	}
	return 0;
 } 

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
b=sorted(a)
c=0
for i in range(n-1):
    t,cnt=0,0
    x=a.index(b[i])
    while x!=i:
        y=a.index(b[x])
        a[x],a[y]=b[x],b[i]
        t+=b[x]+b[i]
        cnt+=1
        x=y
    if cnt:
        c+=min(t,(b[i]+b[0])*2+t-(b[i]-b[0])*cnt)
print(c)


Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<string> v(n);
    for(int i = 0; i< n; i++) {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end(), [](const string &a, const string &b){return a < b;});
    
    int m = 0;
    for(int i = 0; i < n; i++) {
        int cnt = 0;
        while(i + 1 + cnt < n && v[i] == v[i + 1 + cnt]) {
            cnt++;
        }
        m = max(m, cnt);
        i += cnt;
    }
    
    for(int i = 0; i < n; i++) {
        int cnt = 0;
        while(i + 1 + cnt < n && v[i] == v[i + 1 + cnt]) {
            cnt++;
        }
        
        if(cnt == m) {
            cout << v[i] << endl;
        }
        
        i += cnt;
    }
    
    return 0;
}



Measured memory_bytes: 14208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
    int ans,A=-1,B;
    string S;
int main(){
    cin>>S;
    REP(i,(signed)S.size()){
        if(A==-1&&S[i]=='A')A=i;
        if(S[i]=='Z')B=i;
    }
    ans=B-A+1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
/*
 * atcoder/abc146/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <map>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * スタート頂点1からDFSで各辺が異なるように色分けする
 */
const int MAX = 100000;
int N;
vector<int> C;
vector<int> G[MAX];
map<pair<int, int>, int> M;
void dfs(int n = 0, int prev = -1, int prev_c = -1) {
  int c = prev_c == 0 ? 1 : 0;
  for (auto &&u: G[n]) {
    if (u == prev) continue;
    C[M[make_pair(n, u)]] = c;
    dfs(u, n, c);
    c++;
    if (c == prev_c) c++;
  }
}
void solve() {
  cin >> N;
  C.resize(N-1);
  int a, b;
  loop(n,0,N-1) {
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    M[make_pair(a, b)] = n;
    M[make_pair(b, a)] = n;
  }
  dfs();
  int max_c = 0;
  loop(n,0,N-1) chmax(max_c, C[n]);
  cout << max_c+1 << endl;
  loop(n,0,N-1) cout << C[n]+1 << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<long long int> A(N+1);
    long long int wa=0;
    for(int i=0;i<N+1;i++){
        cin>>A[i];
        wa=wa+A[i];
    }
    vector<long long int> B(N);
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    long long int ans=0;
    for(int i=0;i<N;i++){
        if(B[i]>=A[i]+A[i+1]){
            ans=ans+A[i]+A[i+1];
            A[i+1]=0;
        }
        else if(B[i]>A[i]){
            ans=ans+B[i];
            A[i+1]=A[i+1]-(B[i]-A[i]);
        }
        else{
            ans=ans+B[i];
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProgrammingContest
{
    class MainClass
    {
        Scanner sc;
        static void Main(string[] args)
        {
            new MainClass().Solve();
        }

        void Solve()
        {
#if DEBUG
            string backPath = "..";
            char dirSep = System.IO.Path.DirectorySeparatorChar;
            string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt";
            sc = new Scanner(new System.IO.StreamReader(inFilePath));
#else
            sc = new Scanner();
#endif

            string s = sc.Next;
            bool[] u = new bool[26];
            fill(u, false);
            foreach (char c in s)
            {
                u[c - 'a'] = true;
            }
            for (int i = 0; i < 26; i++)
            {
                if (!u[i])
                {
                    Write((char)('a' + i));
                    return;
                }
            }
            Write("None");
        }

        void Write(object val)
        {
            Console.WriteLine(val.ToString());
        }
        void Write(string format, params object[] vals)
        {
            Console.WriteLine(format, vals);
        }
        void fill<T>(T[] ar, T val)
        {
            for (int i = 0; i < ar.Length; i++)
            {
                ar[i] = val;
            }
        }
    }
    class Scanner
    {
        Queue<String> buffer;
        char[] sep;
        System.IO.TextReader reader;
        public Scanner(System.IO.TextReader reader = null)
        {
            this.buffer = new Queue<string>();
            this.sep = new char[] { ' ' };
            this.reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.buffer.Count == 0 && this.reader.Peek() >= 0)
            {
                string[] sreArray = this.reader.ReadLine().Split(this.sep);
                foreach (String elStr in sreArray)
                {
                    this.buffer.Enqueue(elStr);
                }
            }
        }

        public String Next
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Dequeue();
            }
        }

        public int NextInt
        {
            get
            {
                return int.Parse(this.Next);
            }
        }
        public double NextDouble
        {
            get
            {
                return double.Parse(this.Next);
            }
        }

        public long NextLong
        {
            get
            {
                return long.Parse(this.Next);
            }
        }
        public bool IsEmpty
        {
            get
            {
                this.CheckBuffer();
                return this.buffer.Count == 0;
            }
        }
    }
}


Measured memory_bytes: 13268
package main

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

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

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	k, n := scanInt(), scanInt()
	a := scanInts(n)
	sort.Ints(a)
	a = append(a, a[0])
	res := k
	for i := 1; i <= n; i++ {
		p := a[i-1]
		if p < a[i] {
			p += k
		}
		x := p - a[i]
		if res > x {
			res = x
		}
	}
	fmt.Println(res)
}


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

int main()
{
    int n,m,i,g=1;
    cin>>n>>m;
    for(i=1; i<=sqrt(m); i++)
    {
        if(m%i == 0)
        {
            if(m/i >=n)
                g = max(i,g);
            if(i >= n)
                g = max(m / i,g);
        }
    }
    cout<<g<<endl;
}


Measured memory_bytes: 256
N = int(input())
t = [[0] * 10 for _ in range(10)]
cnt = 0

for i in range(N + 1):
    s = str(i)
    t[int(s[0])][int(s[-1])] += 1

for i in range(1, 10):
    for j in range(1, 10):
        cnt += t[i][j] * t[j][i]

print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}

int n;
string s;
int w[200000], b[200000];

int count(int i)
{
  return b[i] + (w[n - 1] - w[i]);
}

int main()
{
  cin >> n >> s;
  int white = 0, black = 0;
  REP(i, n)
  {
    if(s[i] == '.'){
      white++;
    } else {
      black++;
    }
    w[i] = white;
    b[i] = black;
  }

  int ans = w[n-1];
  REP(i, n)
  {
    ans = min(ans, count(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2180
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    s, t = map(int, input().split())
    G[s-1].append(t-1)

ans = 10000

for block in range(-1, N-1):
    dp = [0]*N
    
    for v in range(N-2, -1, -1):
        M = 0
        cnt = 0
        
        for nv in G[v]:
            if dp[nv]>M:
                M = dp[nv]
                
            dp[v] += dp[nv]
            cnt += 1
        
        if block==v and cnt>=2:
            dp[v] -= M
            cnt -= 1
        
        dp[v] /= cnt
        dp[v] += 1
    
    if dp[0]<ans:
        ans = dp[0]

print(ans)

Measured memory_bytes: 62940
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x.size())
int dp[3005][3005];
string a, b, ans;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b;
    for (int i = 1; i <= sz(a); i++){
        for (int j = 1; j <= sz(b); j++){
            if (a[i - 1] == b[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int i = sz(a), j = sz(b);
    while(i > 0 && j > 0){
        if (dp[i][j] == dp[i - 1][j]) i--;
        else if (dp[i][j] == dp[i][j - 1]) j--;
        else {
            ans = a[i - 1] + ans;
            i--; j--;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
   fast_io
   ll h,w,m;
   cin>>h>>w>>m;
   map< ll,ll> row,col;
   map< pair<ll,ll> , ll  > mp;
   while(m--){
      ll x,y;
      cin>>x>>y;
      row[x]++;
      col[y]++;
      mp[{x,y}]++;
   }
   ll maxrow = 0;
   ll rows = 0;
   ll colmn = 0;
   for(ll i = 1;i<=h;i++){
      maxrow = max(maxrow,row[i]);
   }
   ll maxcol = 0;
   for(ll i = 1;i<=w;i++){
      maxcol = max(maxcol,col[i]);
   }
   ll ans = maxrow+maxcol;
   vector<ll> ro,co;
   for(ll i = 1;i<=h;i++){
      if(row[i] == maxrow){
         ro.push_back(i);
      }
   }
   for(ll i = 1;i<=w;i++){
     if(col[i] == maxcol){
        co.push_back(i);
     }    
   }
   bool ok = false;
   for(ll i = 0;i<ro.size();i++){
       for(ll j = 0;j<co.size();j++){
           if(mp[{ro[i],co[j]}] == 0){
              ok = true;
              break;
           }      
       }
   }
   if(ok == true){
      cout<<ans<<endl;
   }
   else{
      cout<<ans-1<<endl;
   }
   return 0;
}

Measured memory_bytes: 82840
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 400005, P = 1e9 + 7;
typedef long long LL;
int n, K, fact[N], infact[N];
int power(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = (LL) res * a % P;
		a = (LL) a * a % P;
		b >>= 1;
	}
	return res;
}
int C(int a, int b) {
	if (b < 0 || b > a) return 0;
	return (LL)fact[a] * infact[b] % P * infact[a - b] % P;
}
int main() {
	scanf("%d%d", &n, &K);
	fact[0] = infact[0] = 1;
	for (int i = 1; i < N; i++) fact[i] = (LL) fact[i - 1] * i % P;
	infact[N - 1] = power(fact[N - 1], P - 2);
	for (int i = N - 2; i; i--) infact[i] = (LL) infact[i + 1] * (i + 1) % P;
	int ans = 0;
	for (int i = 0; i <= min(K, n); i ++) {
		if (K == 1 && i == 0) continue;
		// i 中自转。 K - i 是操作数
		 ans = (ans + (LL)C(n, i) * C(n - 1, n - i - 1)) % P;
	}
	printf("%d\n", ans);
}	// K

Measured memory_bytes: 3328