akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    from itertools import accumulate
    N, M = MI()
    imos = [0]*(N+2)
    for _ in range(M):
        l, r = MI()
        imos[l] += 1
        imos[r+1] -= 1
    cum = list(accumulate(imos))
    ans = 0
    for a in cum:
        if a == M:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47580
import sys
input = sys.stdin.readline
from collections import *

N, P = map(int, input().split())
S = input()[:-1]

if P in [2, 5]:
    ans = 0
    
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
    
    print(ans)
    exit()

cnt = defaultdict(int)
cnt[0] = 1
now = 0
ans = 0

for i in range(N-1, -1, -1):
    now = (int(S[i])*pow(10, N-1-i, P)+now)%P
    ans += cnt[now]
    cnt[now] += 1

print(ans)

Measured memory_bytes: 42956
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())

    for i in range(n+1):
        for j in range(n+1):
            if 4 * i + 7 * j == n:
                print("Yes")
                exit()

    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

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

	int n, k;
	cin >> n >> k;

	vector<int> pref(n + 1);

	map<int, int> mp;
	
	/*
	sumR - sumL = R - L
	sumR - R = sumL - L
	*/

	pref[0] = 0;
	mp[0] = 1;


	ll res = 0;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;

		pref[i] = (pref[i - 1] + x - 1) % k;

		if(i >= k) mp[pref[i - k]]--;

		res += mp[pref[i]];
		mp[pref[i]]++;
		// debug() << imie(i) << imie(pref);
	}

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 10368
from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = list(map(int, input().split()))

  dic = defaultdict(int)
  for i, a in enumerate(A):
    dic[a] += 1

  for i in range(1, N+1):
    print(dic[i])


if(__name__ == '__main__'):
  main()


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

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

	cin >> n;

	long long int res = 1e18;
	for(long long int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			long long int a = i;
			long long int b = n/i;
			res = min(res,a+b-2);
		}
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>

#define BEFORE_STR ("Hoshino")
#define AFTER_STR  ("Hoshina")
int main()
{
	int  i,n,k;
	char inp[1024];
	char *wk_p;

	/**--init --**/
	/**--inpot--**/
	gets(inp);
	sscanf(inp,"%d",&n);

	for (i=0 ; i<n ; i++) {
		gets(inp);

		/*PROC*/
		wk_p = inp;
		for (k=0 ;; k++) {
			wk_p = strstr(wk_p,BEFORE_STR);
			if (wk_p == NULL) {
				break;
			}
			memcpy(wk_p,AFTER_STR,sizeof(AFTER_STR)-1);
			wk_p += sizeof(AFTER_STR)-1;
		}
		printf("%s\n",inp);
	}
	return 0;
}

Measured memory_bytes: 592
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  if(s[0] === s[1] && s[1] === s[2])return "No";
  if(s[0] === s[3] && s[1] === s[2])return "Yes";
  if(s[0] === s[1] && s[2] === s[3])return "Yes";
  if(s[0] === s[2] && s[1] === s[3])return "Yes";
  return "No";
}

Measured memory_bytes: 7372
#include <stdio.h>

int main(void) {
    char b;

    scanf("%c", &b);

    switch(b) {
        case 'A':
            puts("T");
            break;
        case 'C':
            puts("G");
            break;
        case 'G':
            puts("C");
            break;
        case 'T':
            puts("A");
            break;
        default:
            break;
    }

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 与えられた文字列の幸福度は、LとRの入れ替わりの数だけで決まることに着目
# 幸福度は、最初の方は2ずつ上げることができる。
# 端数が出る場合は最後に1だけ上げられる

#        change   happiness
# LLLLL  0        4
# LLLRR  1        3 -> 4
# LLRRL  2        2 -> 4
# LLRLR  3        1 -> 3 -> 4


import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


def solve(N, K, S):
    prev = S[0]
    change = 0
    for ch in S[1:]:
        change += ch != prev
        prev = ch

    happiness = N - 1 - change

    # K回のうち、use回を使って、幸福度をuse * 2上昇させる
    use = min(K, change // 2)
    happiness += use * 2
    K -= use

    # まだねじれがあれば修正
    if K > 0 and happiness != N - 1:
        happiness += 1

    return happiness


N, K = map(int, input().split())
S = input()
print(solve(N, K, S))

# assert solve(1, 1, "L") == 0
# assert solve(2, 1, "LR") == 1
# assert solve(2, 2, "LR") == 1
# assert solve(2, 2, "LL") == 1
# assert solve(3, 1, "LLL") == 2
# assert solve(3, 1, "LRL") == 2
# assert solve(3, 2, "LRL") == 2
# assert solve(3, 1, "LLR") == 2


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

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

	REP(i,0,n)cout<<s.at(i)<<t.at(i);
	cout<<endl;

	return 0;
}

Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<char> = s.trim().chars().collect();
    let mut prev = s[0];
    let mut ans = false;
    for c in s[1..].iter() {
        if *c != prev {
            ans = true;
        }
        prev = *c;
    }
    let out = if ans {"Yes"} else {"No"};
    println!("{}", out);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


	int arr[5];
	for (ll i = 0; i < 5; i++)
	{
		cin >> arr[i];
	}
	for (ll i = 0; i < 5; i++)
	{
		if (arr[i] == 0)
		{
			cout << i + 1;
		}
	}

}


Measured memory_bytes: 3584
#include <stdio.h>

int isprime(int n){
        int i;
	for(i=2;i*i<=n;i++){
		if(n%i==0) return 0;
	}
	return 1;
}

int main(){
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=n;i>=5;i--){
			if(isprime(i)==1&&isprime(i-2)==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vaibhav ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{ string s;
  int a;
  cin>>a;
  cin>>s;
  if(a<3200)
    cout<<"red";
  else
   cout<<s;
  return 0;
  
}

 

Measured memory_bytes: 256
MOD = 10**9 + 7
N = 10**6  # 10**6が限界
factorial_mod = [1, 1]  # factrial_mod[i] := i! mod p
modular_multiplicative_inverse = [0, 1]  # モジュラ逆数 := i^(-1) ≡ x (mod p) となるx
factorial_inverse_mod = [1, 1]  # factrial_inverse_mod[i] := (i!)^(-1) mod p

for i in range(2, N + 1):  # O(N)
    factorial_mod.append((factorial_mod[i - 1] * i) % MOD)
    modular_multiplicative_inverse.append((-modular_multiplicative_inverse[MOD % i] * (MOD // i)) % MOD)
    factorial_inverse_mod.append((factorial_inverse_mod[i-1] * modular_multiplicative_inverse[i]) % MOD)

def nCr_mod(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return factorial_mod[n] * factorial_inverse_mod[r] * factorial_inverse_mod[n - r] % MOD

def nPr_mod(n, r):
    return factorial_mod[n] * factorial_inverse_mod[n - r] % MOD

# ---------------------- #

n, k = (int(x) for x in input().split())
ans = 0
for i in range(min(n - 1, k) + 1):
    # nCi * n-iHi = nCi * n-1Ci
    ans += nCr_mod(n, i) * nCr_mod(n - 1, i)
    ans %= MOD
print(ans)


Measured memory_bytes: 213308
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
const long long int MOD=1e9+7;

int main(){
  int n, cnt=1;
  string s;
  cin >> n >> s;
  char cur=s[0];
  for(int i=1;i<n;i++){
    if(cur!=s[i]){
      cnt++;
      cur =s[i];
    }
  }
  cout << cnt << endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll ans=0;
  for (int i=A; i<=B; i++) {
    if (i/10000==i%10&&(i/1000)%10==(i/10)%10) ans++;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main(){
    int a, b, answer;
    char c;

    while(c != '?'){
        scanf("%d %c %d",&a ,&c ,&b);
        if(c == '+'){
            answer = a+b;
        }
        else if(c == '-'){
            answer = a-b;
        }
        else if(c == '*'){
            answer = a*b;
        }
        else if(c == '/'){
            answer = a/b;
        }
        else if(c == '?'){
            return 0;
        }
        printf("%d\n",answer);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main(void){

	int time = 0;

	int n, x, t;
	cin >> n >> x >> t;
	
	while(1){
	
		time++;
	
		n = n - x;
		
		if(n <= 0){
		
			break;
		
		}
	
	}
	
	cout << time * t << endl;

return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(b<c||d<a)
	printf("0");
	else
	{
		if((a==0&&c!=0&&d>b)||(a<c&&b<d))
		{
			printf("%d",b-c);
			return 0;
		}
		if((c==0&&a!=0&&d<b)||(a>c&&b>d))
		{
			printf("%d",d-a);
			return 0;
		}
		if(a>c&&b<d)
		{
			printf("%d",b-a);
			return 0;
		}
		if(c>a&&d<b)
		{
			printf("%d",d-c);
			return 0;
		}
		if(a==0&&c==0)
		{
			if(b<d)
			printf("%d",b);
			else
			printf("%d",d);
			return 0;
		}
		if(a==c&&b==d)
		{
			printf("%d",b-a);
			return 0;
		}
		if(b==d)
		{
			if(a<c)
			printf("%d",d-c);
			else
			printf("%d",b-a);
			return 0;
		}
		if(a==c)
		{
			if(b>d)
			printf("%d",d-c);
			else
			printf("%d",b-a);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
fun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)
fun main(args:Array<String>) {
    val(a,b) = readLine()!!.split(" ").map(String::toLong)
    println(lcm(a,b))
}


Measured memory_bytes: 37872
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):
    ins=s[0]
    for j in range(n-1):
        if i&(1<<j):
            ins+="+"+s[j+1]
        else:
            ins+=s[j+1]
    ans+=eval(ins)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

 main(){

   int i,N,K;   //ここにheight[N]を一緒に作ったがNが定義されていないのでダメ
   scanf("%d%d",&N,&K);
  int height[N];
   
   for(i=0;i<N;i++){
     scanf("%d",&height[i]);
   }  //ここでheight[]を作る
   
    int j,counter=0; 
   for(j=0;j<N;j++){
     if(height[j]>=K){
       counter++;
     }
   }
   printf("%d",counter);  
   
}
    

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
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 REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int A, B, C;  cin >> A >> B >> C;
  ll ans = 0;
  if(A == B && B == C){
    if(A % 2)  cout << 0 << endl;
    else       cout << -1 << endl;
  }else{
    ll ans = 0;
    while(!(A % 2) && !(B % 2) && !(C % 2)){
      int a = A, b = B, c = C;
      A = b / 2 + c / 2;
      B = a / 2 + c / 2;
      C = a / 2 + b / 2;
      ans += 1;
    }

    cout << ans << endl;
  }

  return 0;
}


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

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n;
vector<int> e[100009];
bool visit[100009];
ll white[100009], all[100009];

void dfs(int x) {
    visit[x] = true;
    ll b = 1, w = 1;
    rep(i, e[x].size()) {
        if(!visit[e[x][i]]) {
            dfs(e[x][i]);
            (b *= white[e[x][i]]) %= mod;
            (w *= all[e[x][i]]) %= mod;
        }
    }
    white[x] = w;
    all[x] = (b + w) % mod;
}

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

    cin >> n;
    rep(i, n - 1) {
        int x, y;
        cin >> x >> y;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    dfs(1);
    cout << all[1] << endl;

    return 0;
}

Measured memory_bytes: 12928
import math
# N = int(input())
N, K = map(int, input().split())
# A = list(map(int, input().split()))

C = [math.ceil(math.log2((K - 1) // i + 1)) for i in range(1, N + 1)]
maxC = max(C)

P = [1.0] * (maxC + 1)
for i in range(1, maxC + 1):
    P[i] = P[i - 1] * 0.5

S = 0.0
for c in C:
    S += P[c]
print(S / N)


Measured memory_bytes: 3864
n = int(input())
arr_old = [0,0,0]
for i in range(n):
    arr = list(map(int,input().split()))
    if arr[0] % 2 != (arr[1]+arr[2]) % 2:
        print("No")
        exit()
    if abs(arr[1]-arr_old[1])+abs(arr[2]-arr_old[2]) > arr[0]-arr_old[0]:
        print("No")
        exit()
    arr_old = arr
print("Yes")

Measured memory_bytes: 3316
#include <stdio.h>
/*
recommend usage
initial
*/

#define N 3
#define D 10

int main(void){
    // Your code here!
    //int a,b,c;

    int a[D]={0};
    int tmp=0;
    for(int i=0; i<N; i++) scanf("%d",&a[i]); //scanf("%d %d %d",&a,&b,&c);
    //solve(a,b);


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

  for(int j=N-1; j>i; j--){ //for(int j=N-1;j-1>=i;j--){ //for(int j=N-1;j>=0;j++){

    if( a[j-1] > a[j] ){
        tmp=a[j-1];
        a[j-1]=a[j];
        a[j]=tmp;
    }//Per one turn, one unsorted groups min is found

  }

}

 for(int i=0;i<N;i++){
 if( i==3-1 ) printf("%d\n",a[i]);
  else printf("%d ",a[i]);
 //puts("");
}

return 0;

}


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

const int V = 1e5;

int dp[105][V + 5];

signed main() {
	int n, m; cin >> n >> m;
	vector<int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	memset(dp, 0x3f, sizeof(dp));
	for (int i = 0; i <= n; i++) dp[i][0] = 0;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= V; j++) {
		if (j < v[i]) dp[i][j] = dp[i - 1][j];
		else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
	}
	int i = V; while (dp[n][i] > m) i--;
	cout << i << '\n';
}


Measured memory_bytes: 85664
#include <cstdio>
using namespace std;

int max(int a, int b){
	if(a > b) return a;
	return b;
}

int main(){
	const int MAX_N = 10000;
	int N, ball[MAX_N];
	int ub, lb, base, res, ans;
	
	while(true){
		scanf("%d", &N);
		
		if(N == 0) break;
		
		for(int i = 0; i < N; i++){
			scanf("%d", &ball[i]);
		}
		
		res = 0;
		for(int i = 0; i < N; i++){
			for(int j = 1; j <= 3; j++){
				ub = i - 1; lb = i + 1;
				ans = 0; base = j;
				while(true){
					while(ub >= 0 && ball[ub] == base) ub--;
					while(lb < N && ball[lb] == base) lb++;
					if(lb - ub - 1 - ans >= 4){
						ans += lb - ub - 1 - ans;
						if(ub < 0 || lb >= N || ball[ub] != ball[lb]) break;
						base = ball[ub];
					}
					else break;
				}
				res = max(ans, res);
			}
		}
		printf("%d\n", N - res);
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "debug.h"
#endif

int solve(vector<int> v) {
	int n = v.size();
	int ret = 0;

	for (int i = 0; i < n; i++) {
		bool iseven = false;
		for (int bit = 0; bit < 20; bit++) {
			if ((((n - 1) & (1 << bit)) == 0)
				&&
				((i & (1 << bit)) > 0)) {
				iseven = true;
				break;
			}
		}
		if (!iseven) ret ^= v[i];
	}

	return ret;
}

int brute(vector<int> v) {
	while (v.size() > 1) {
		// debug() << v;
		for (int i = 0; i < v.size() - 1; i++) v[i] = abs(v[i + 1] - v[i]);
		v.pop_back();
	}
	// debug() << v;
	return v[0];
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		char c;
		scanf(" %c", &c);
		v[i] = c - '0';
	}

	if (n == 1) {
		cout << v[0] << endl;
		return 0;
	}

	for (int &i : v) i--;

	// cout << brute(v) << endl;

	vector<int> _v = v;
	for (int &i : _v) i %= 2;
	// debug() << name(v);
	// debug() << name(_v);
	// cerr << solve(_v) << endl;
	if (solve(_v) % 2 == 1) cout << 1 << endl;
	else {
		for (int i : v) if (i == 1) {
			cout << 0 << endl;
			return 0;
		}

		for (int &i : v) i /= 2;
		if (solve(v) == 1) cout << 2 << endl;
		else cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 11964
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        if (s.contains("C")) {
            s=s.substring(s.indexOf("C"));
            if (s.contains("F")) {
                System.out.println("Yes");
                return ;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 3000.0;
double temp_end = 0.01; 
int climb_loop = 11000000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = (eng() % D) + 1;
    int q = eng() % 26;
    if(q != t[d]) {
      temp = temp_start + (temp_end - temp_start)*x/climb_loop;
      int diff = s[d][q] - s[d][t[d]];
      int cur = d;
      while(cur <= D && last[cur][t[d]] == d) {
        diff -= c[t[d]] * (d - last[cur-1][t[d]]);
        last[cur][t[d]] = last[cur-1][t[d]];
        cur++;
      }
      cur = d;
      while(cur <= D && last[cur][q] < d) {
        diff += c[q] * (d - last[cur][q]);
        last[cur][q] = d;
        cur++;
      }
      if(diff > 0 || uniform_01(eng) < exp((double)diff/temp)) {
        t[d] = q;
        content += diff;
      } else {
        int day = d;
        while(day <= D && last[day][t[d]] < d) {
          last[day][t[d]] = d;
          day++;
        }
        day = d;
        while(day <= D && last[day][q] == d) {
          last[day][q] = last[day-1][q];
          day++;
        }
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 1000000007
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}
 



vector<ipii> p;
ll dp[1003][20004];

bool comp(ipii a,ipii b){
     return (a.ft+a.sd.ft)<(b.ft+b.sd.ft);
}


int main(){
      sync;
      ll n;
      cin>>n;
      int f=0;
      for(int i=0;i<n;i++){
            ll w,s,v;
            cin>>w>>s>>v;
            if(s>10000||w>10000) f=1;
            p.pb({s,{w,v}});
      }
       
        if(f){
            cout<<"Hold ON!"<<endl;
            return 0;
        }
        sort(all(p),comp);
        ll ans=0;
        for(int i=0;i<=20004;i++){
               dp[0][i]=(p[0].sd.ft<=i?p[0].sd.sd:0);
        }
        for(int i=1;i<n;i++){
             for(int j=0;j<=20000;j++){
                  if(j==0){
                       dp[i][j]=0;continue;
                  }
                  dp[i][j]=dp[i-1][j];
                  if(p[i].sd.ft<=j){
                        dp[i][j]=max(dp[i][j],dp[i-1][min(j-p[i].sd.ft,p[i].ft)]+p[i].sd.sd);
                  }
             }
        }

        for(int i=0;i<=20000;i++) ans=max(ans,dp[n-1][i]);
        cout<<ans<<endl; 
}

Measured memory_bytes: 156544
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  #print(i)
  if pos > i:
    #print('i, pos : ',i,pos)
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    #print(i,j)
    if ex_s==s:
      #print('ex_s, s: ',ex_s,s)
      continue
    else:
      # sが2文字、かつ残りが2文字の場合は詰みなので回避
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      #print(s,i,j,'ok')
      break;

print(k)
  

Measured memory_bytes: 3500
N,M=map(int,input().split())
p=[0]+list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(list)
f=defaultdict(int)

for _ in range(M):
    x,y=map(int,input().split())
    d[x].append(y)
    d[y].append(x)
ans=0
for i in range(1,N+1):
    if f[i]==0:
        ind={i}
        val={p[i]}
        que=d[i]
        while len(que)>0:
            tmp=[]
            for q in que:
                if f[q]==0:
                    f[q]=1
                    ind.add(q)
                    val.add(p[q])
                    tmp+=d[q]
            que=tmp
        ans+=len(ind&val)
print(ans)




Measured memory_bytes: 102888
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  REP2(i,l,r+1){
    if(i%d == 0) ++cnt;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 1e5+5;
int n,m,val[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	for(ri i=1;i<=m;++i) read(val[i]),n-=val[i];
	if(n<0) puts("-1");
	else print(n);
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int [] m = new int [N];
        int sum = 0;
        
        for(int i=0; i<N; i++){
            m[i] = sc.nextInt();
            sum +=m[i];
        }
        
        int nokori = X -sum;
        int ans =0;
        int min = m[0];
        
        for(int i=1; i<N; i++){
            if(min>m[i]){
                min = m[i];
            }
        }
        
        ans =N + (int)nokori/min;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35792
s = list(map(int, input()))

top_zero = []
top_one = []

for i in range(len(s)):
    if i % 2 == 0:
        top_zero.append(0)
        top_one.append(1)
    else:
        top_zero.append(1)
        top_one.append(0)

count_zero = 0
count_one = 0

for i in range(len(s)):
    if top_zero[i] == s[i]:
        count_zero += 1
    if top_one[i] == s[i]:
        count_one += 1

print(min(count_zero, count_one))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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; }

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int d, n;
	cin >> d >> n;

	if (n == 100)
	{
		cout << 101 * (int)pow(100, d) << endl;
	}
	else
	{
		cout << n * (int)pow(100, d) << endl;
	}
	debug;
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N;
  cin >> N;
  vector<int> b(N);
  REP(i, N) cin >> b[i];

  vector<int> ans;
  RREP(i, N) RREP(j, i+1){
    if(b[j] == j+1){
      ans.push_back(b[j]);
      b.erase(b.begin()+j);
      break;
    }
  }

  if(ans.size() == N){
    RREP(i, N){
      cout << ans[i] << endl;
    }
  }else{
    cout << "-1" << endl;
  }
   

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	ws := []string{"SUN","MON","TUE","WED","THU","FRI","SAT"}

	for k,w := range ws {
		if w == s {
			fmt.Println(7-k)
			return
		}
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int main(){
    char a[1200];
    int i;
    fgets(a, 1200, stdin);
    for(i = 0; i <= strlen(a); i++){
        if(a[i] >= 65 && a[i] <= 90){
            a[i] = a[i] + 32;
        }
        else if(a[i] >= 97 && a[i] <= 122){
            a[i] = a[i] - 32;
        }
    }
    printf("%s", a);
    return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N = 1e5 + 7;

int n, m, q, u, v;
int x[N], dis[N], c[N], ans[N];
bool vis[13][N];
vector <int> edge[N];

void solve(int u, int d, int col){
	if(vis[d][u]) return;
	queue < pair <int, int> > q;
	q.push(mp(u, d));
	for(int i = d; i >= 0; i--) vis[i][u] = true;
	while(!q.empty()){
		int cur = q.front().fi, ds = q.front().se;
		q.pop();
		if(!ans[cur]) ans[cur] = col;
		if(ds == 0) continue;
		for(int v : edge[cur]){
			if(!vis[ds - 1][v]){
				for(int i = ds - 1; i >= 0; i--) vis[i][v] = true;
				q.push(mp(v, ds - 1));
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	cin >> q;
	for(int i = 1; i <= q; i++){
		cin >> x[i] >> dis[i] >> c[i];
	}
	for(int i = q; i >= 1; i--){
		solve(x[i], dis[i], c[i]);
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 9808
#include <bits/stdc++.h>
 
#define M_PI       3.14159265358979323846
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
 
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
 
 
struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};
 
typedef vector<vector<Edge>> AdjList;
AdjList graph;
 
vector<vector<int>> G(200010);
ll ans[200010];
ll plusl[200010];

void dfs(int v, ll x, int prev){
    ans[v] = x;
 
    for(int i=0; i<G[v].size(); ++i){
        int u = G[v][i];
      	if(u == prev) continue;
        dfs(u, x+plusl[u], v);
    }
}
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
 
    int N,Q; cin >> N >> Q;
    
    REP(i,N-1){
        ll a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
 
    set<ll> st;
    REP(i, Q){
        ll p, x; cin >> p >> x;
        p--;
        st.insert(p);
        plusl[p] += x;
    }
 
    dfs(0, plusl[0], -1);
 
    REP(i, N){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
 
}


Measured memory_bytes: 34944
s = input()
k = int(input())
li = set()
def insert(x):
    if x in li:
        return
    if len(li)<k:
        li.add(x)
    elif x<max(li):
        li.remove(max(li))
        li.add(x)

for i in range(26):
    b = chr(i+ord('a'))
    for i in range(len(s)):
        if s[i]!=b:
            continue
        for j in range(k):
            if i+j<len(s):
                insert(s[i:i+j+1])
    if len(li)==k:
        break
li = list(li)
li.sort()
print(li[k-1])

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   string s;
   cin  >> s;
   if(s == "A" or s == "T"){
      if(s == "A"){
         cout << "T";
      }else{
         cout << "A";
      }
   }else{
      if(s == "C"){
         cout << "G";
      }else{
         cout << "C";
      }
   }
   return 0;
}

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

//repetition
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
// typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI l(n),r(n);
  int ll = 0;
  int rr = 1e9;
  int mm = 0;

  rep(i,n){
    cin >> l[i] >> r[i];
    ll = max(l[i],ll);
    rr = min(r[i],rr);
    mm = max(r[i] - l[i] + 1, mm );
  }
  int ans = mm + max(rr-ll+1,0);

  // serch lmax rmin same
  // vector<PII> rv;
  vector<PII> lv;

  rep(i,n) {
    // rv.push_back(PII(r[i]-ll + 1, l[i]));
    lv.push_back(PII(rr-l[i] + 1, -r[i]));
  }

  // sort(all(rv));
  sort(all(lv));
  int minR = 1e9;
  rep(i,n-1){
    minR = min(minR ,-lv[i].second);
    ans = max(lv[i+1].first + (minR - ll + 1), ans);
  }

  // int maxL = 0;
  // rep(i,n-1){
  //   maxL = max(maxL ,rv[i].second);
  //   ans = max(rv[i+1].first + (rr - maxL + 1), ans);
  // }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
N, K = list(map(int, input().split()))
S = input()
if K == 1:
    print(S[0:1].lower() + S[1:])
elif K == N:
    print(S[0:K - 1] + S[-1].lower())
else:
    print(S[0:K - 1] + S[K - 1:K].lower() + S[K:])



Measured memory_bytes: 3060
# ABC142E - Get Everything
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    p = 1 << N
    INF = 1 << 60
    dp = [INF] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = map(int, input().split())
        x = sum(1 << (i - 1) for i in map(int, input().split()))
        for y in range(p):
            if dp[x | y] > dp[y] + a:
                dp[x | y] = dp[y] + a
    ans = dp[-1] if dp[-1] != INF else -1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
   ll r;
   cin>>r;
   cout<<3*r*r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  VEC<int>A(N);
  REP(i,0,N)cin>>A[i];
  LL mi= LLONG_MAX;
  REP(p,1,101){
    LL sum=0;
    REP(i,0,N){
      sum+=(A[i]-p)*(A[i]-p);
    }
    mi=min(mi,sum);

  }
  cout<<mi<<endl;

  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5 && b==5 &&c==7)cout<<"YES"<<endl;
  else if(a==5 && b==7 &&c==5)cout<<"YES"<<endl;
  else if(a==7 && b==5 &&c==5)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
  int i, n, x, count;
  string s;
  bool check;

  cin >> n;
  for(i=0, count=0, check=true; i<n; ++i){
    cin >> s >> x;
    if(!check) continue;

    if(s == "(") count += x;
    else count -= x;

    if(count < 0) check = false;
  }
  if(count != 0) check = false;

  if(check) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 1200
/*************************************
 * problem:      id_name.
 * user ID:      63720.
 * user name:    Jomoo.
 * time:         2019-08-14.
 * language:     C++.
 * upload place: Luogu.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;
#define puts_return(x) { puts(x); return 0; }
#define write_return(x) { write(x); return 0; }

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

size_t n, m;
vector<pair<uint32, uint8> > G[100003];
int8 col[100003];
uint64 block_cnt, edge_cnt, cnt[4];
enum Kinds_block {strong_connect = 1, weak_connect = 2} block_kind;

void clear_data()
{
    block_cnt = edge_cnt = cnt[0] = cnt[1] = cnt[2] = 0;
    block_kind = weak_connect;
}

void color(int u)
{
    // printf("color(%d) [myCol = %d].\n", u, col[u]);
    block_cnt++;
    cnt[col[u]]++;
    for (size_t i = 0; i < G[u].size(); i++) {
        if (G[u][i].second == 1) edge_cnt++;
        if (col[G[u][i].first] != -1) {
            if (col[G[u][i].first] != (col[u] + G[u][i].second) % 3) block_kind = strong_connect;
        } else {
            col[G[u][i].first] = (col[u] + G[u][i].second) % 3;
            color(G[u][i].first);
        }
    }
}

int main()
{
    n = read<size_t>();
    m = read<size_t>();
    uint32 u, v;
    while (m--) {
        u = read<uint32>();
        v = read<uint32>();
        G[u].push_back(make_pair(v, 1));
        G[v].push_back(make_pair(u, 2));
    }
    uint64 ans(0);
    memset(col, -1, sizeof(col));
    for (size_t i = 1; i <= n; i++) {
        if (col[i] == -1) {
            clear_data();
            col[i] = 0;
            color(i);
            if (block_kind == strong_connect) {
                // printf("[Point #%u] Case #1 : block_cnt = %llu\n", i, block_cnt);
                ans += block_cnt * block_cnt;
            } else if (cnt[0] && cnt[1] && cnt[2]) {
                // printf("[Point #%u] Case #2 : cnt = {%llu, %llu, %llu}\n", i, cnt[0], cnt[1], cnt[2]);
                ans += cnt[0] * cnt[1] + cnt[0] * cnt[2] + cnt[1] * cnt[2]; 
            } else {
                // printf("[Point #%u] Case #3 : edge_cnt = %llu\n", i, edge_cnt);
                ans += edge_cnt;
            }
        }
    }
    write(ans, 10);
    return 0;
}

Measured memory_bytes: 10496
import math
height,width = map(int,input().split())
ans = []

def func(h, w):
  ans = []

  for i in range(1,h):

    s1 = i * w
    s2 = math.ceil((h-i)/2)*w
    s3 = h*w - s1 - s2
    maxv = max([s1,s2,s3])
    minv = min([s1,s2,s3])
    ans.append(maxv-minv)
    s2 = (h-i) * math.ceil(w/2)
    s3 = h*w - s1 - s2
    maxv = max([s1,s2,s3])
    minv = min([s1,s2,s3])
    ans.append(maxv-minv)
  return min(ans)
  
min1 = func(height,width)
min2 = func(width,height)
print(min([min1,min2]))

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

using ll=long long;

int main() {
  int N,K; cin >>N >>K;
  int a=(N+1)/2;
  cout <<(a>=K ? "YES":"NO") <<endl;
  return 0;
}


Measured memory_bytes: 3624
#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: 2104
def guchoku(n,k,mod):
    dp=[1]*(n+1)
    dp[0]=0
    for _ in range(k-1):
        ndp=[0]*(n+1)
        for i in range(1,n+1):
            ndp[i]+=sum([dp[j+1] for j in range(n//i)])
            ndp[i]%=mod
        dp=ndp.copy()
    return sum(dp)%mod
def main(n,k,mod):
    ary=[]
    tmp=0
    for i in range(1,int(n**0.5)+1):
        ary.append(n//i-n//(i+1))
        tmp+=ary[-1]
    tmp=n-tmp
    ary+=[1]*tmp
    ary.reverse()
    dp=[x for x in ary]
    m=len(ary)
    for i in range(m-1):
        dp[i+1]+=dp[i]
        dp[i+1]%=mod
    for _ in range(k-1):
        ndp=[0]*m
        for i in range(m):
            ndp[i]+=dp[-i-1]*ary[i]
            ndp[i]%=mod
            pass
        for i in range(m-1):
            ndp[i+1]+=ndp[i]
            ndp[i+1]%=mod
        dp=[x for x in ndp]
    return dp[-1]

n,k=map(int,input().split())
mod=10**9+7
#print(guchoku(n,k,mod))
print(main(n,k,mod))

Measured memory_bytes: 127212
A,B,C,D,E,F = gets.split.map(&:to_i)

itika = []
nino = []
miku = []
yotuba = []
ituki = []



for a in 0..F / (100 * A)
    for b in 0..(F - (100 * A * a) ) / (100 * B)
        for c in 0..(F - (100 * A * a + 100 * B * b)) / C 
            for d in 0..(F - (100 * A * a + 100 * B * b + C * c)) / D 

                itika.push(a)
                nino.push(b)
                miku.push(c)
                yotuba.push(d)
                
                if C * c + D * d <= E * (A * a + B * b) && (a != 0 || b != 0 || c != 0 || d != 0)

                    ituki.push((C * c + D * d).to_f / (100 * A * a + 100 * B * b + C * c + D * d))

                else

                    ituki.push(0)

                end
            end
        end
    end
end

x = ituki.index(ituki.max)

if ituki.max > 0
puts "#{100 * A * itika[x] + 100 * B * nino[x] + C * miku[x] + D * yotuba[x]} #{C * miku[x] + D * yotuba[x]}"
else 
    puts "#{100 * [A,B].min} #{0}"
end


Measured memory_bytes: 76208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n;
    a=n/10;
    b=n%10;
    if(a==9||b==9)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

Measured memory_bytes: 256