akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    
    int m, r, f;
    int sum;
    while(1){
        scanf("%d %d %d\n", &m, &r, &f);
        if(m == -1 && r == -1 && f == -1) break;
        if(m == -1 || r == -1){
            printf("F\n");
            continue;
        }
        
        sum = m + r;
        
        if(80 <= sum) printf("A\n");
        if(65 <= sum && sum < 80) printf("B\n");
        if(50 <= sum && sum < 65) printf("C\n");
        if(30 <= sum && sum < 50 && 50 <= f) printf("C\n");
        else if(30 <= sum && sum < 50 && f < 50) printf("D\n");
        if(sum < 30) printf("F\n");
    }
    
    
    return 0;
    
}

Measured memory_bytes: 588
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import lru_cache

import numpy as np

MOD = 10 ** 9 +7

n,m = map(int,read().split())
  
@lru_cache(None)
def F(N, K):

    assert N >= 0
    if N< 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q,r = divmod(N,10)
    ret = 0
    if K>= 1:
        ret += F(q,K-1)*r
        ret += F(q-1,K-1)*(9-r)
    
    ret +=F(q,K)
    return ret

print(F(n,m))

Measured memory_bytes: 12508
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int k = int.Parse(In[1]);
            int cnt =0;
            string[] In2 = Console.ReadLine().Split(' ');
            for(int i=0; i < n; i++)
            {
                if (int.Parse(In2[i]) >= k) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


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

int main() {

int N,D,X,ans=0;
  cin>>N>>D>>X;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);ans++;
    int j=1;
  while(j*A.at(i)+1<=D){ans++;j++;}
  }
  
cout<<ans+X<<endl;
 
}


Measured memory_bytes: 256
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = str(input())
    if s == 'AC':
        ac += 1
    if s == 'WA':
        wa += 1
    if s == 'TLE':
        tle += 1
    if s == 'RE':
        re += 1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)
        

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, x = MAP()
A = LIST()

ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        need = A[i] + A[i+1] - x
        ans += need
        # 先にある方から優先して減らす
        A[i+1] -= min(A[i+1], need)
print(ans)


Measured memory_bytes: 14436
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <climits>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>

#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    int arr[h][w];
    int n;
    cin>>n;
    int a[n];
    int k = 0;
    for(int i = 0; i < n; i++)cin>>a[i];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i%2 == 0)arr[i][j] = k+1;
            else arr[i][w-1-j] = k+1;
            a[k]--;
            if(a[k] == 0)k++;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
// PrintAChessboard.cc
// 以下のような、たてH cm よこ W cm のチェック柄の長方形を描くプログラムを作成して下さい。
//
//   #.#.#.#.#.
//   .#.#.#.#.#
//   #.#.#.#.#.
//   .#.#.#.#.#
//   #.#.#.#.#.
//   .#.#.#.#.#
// 上図は、たて 6 cm よこ 10 cm の長方形を表しています。
// 長方形の左上が "#" となるように描いて下さい。
// 【入力】
// 入力は複数のデータセットから構成されています。各データセットの形式は以下のとおりです：
//   H W
// H, W がともに 0 のとき、入力の終わりとします。
// 【出力】
// 各データセットについて、たて H cm よこ W cm の枠を出力して下さい。
// 各データセットの後に、１つの空行を入れて下さい。
// 【制約】
// 1 ≤ H, W ≤ 300
// 【例】
// 入力：
// 3 4
// 5 6
// 3 3
// 2 2
// 1 1
// 0 0
// 出力：
// #.#.
// .#.#
// #.#.
//
// #.#.#.
// .#.#.#
// #.#.#.
// .#.#.#
// #.#.#.
// 
// #.#
// .#.
// #.#
// 
// #.
// .#
//
// #
#include<iostream>
using namespace std;

int main( void) {
  int H, W;

  while ( true) {
    cin >> H >> W;

    if ( H == 0 && W == 0) break;

    for ( int h = 1; h <= H; h++ ) {
      for ( int w = 1; w <= W; w++ ) {
	if ( (h + w) % 2 == 0) cout << "#";
	else if ( (h + w) % 2 != 0) cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}




Measured memory_bytes: 3068
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=200005;
ll sum[maxn];
ll ABS(ll x){
  return x>=0?x:-x;
}
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i)scanf("%lld",sum+i);
  for(int i=1;i<=n;++i)sum[i]+=sum[i-1];
  ll ans=1ll<<62;
  for(int i=1;i<n;++i){
    ans=min(ans,ABS(sum[i]-(sum[n]-sum[i])));
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int max = 0;
	int output = 0;
	for (int i = 0; i < N; i++)
	{
		int temp = 0;
		cin >> temp;
		if (max <= temp)
		{
			max = temp;
			output++;
		}
	}
	cout << output << endl;
	return 0;
}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
#define pb push_back
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e3+5;
int a[N];

int main()
{
//	freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n)cin>>a[i];
	ll s[2]={};
	rep(i,1,n)
	if(a[i]>0)s[i%2]+=a[i];
	
	if(s[0]<=0&&s[1]<=0)
	{
		int mx=a[1];
		rep(i,2,n)chmax(mx,a[i]);
		printf("%d\n",mx);
		printf("%d\n",n-1);
		int i=1;
		for(;mx!=a[i];++i)puts("1");
		int j=n;
		for(;j>i;--j)printf("%d\n",j-i+1);
		return 0;
	} 
	
	vector<int>ans;
	int i=1;bool d;
	if(s[0]>s[1])
	{
		d=0;
		cout<<s[0]<<endl;
	}
	else 
	{
		d=1;
		cout<<s[1]<<endl;
	}
	int dep=0;
	for(;i<=n;++i)
	{
		++dep;
		if(a[i]<0||i%2!=d)
		{
			if(dep==1)
			{
				ans.pb(1);
				--dep;
			}
			else 
			if(dep>3)
			{
				ans.pb(3);
				dep-=2;
			}
		}
		else
		{
			if(dep==3)
			{
				ans.pb(2);
				dep-=2;
			}
		}
	}
	while(dep>1)
	{
		ans.pb(dep);
		--dep; 
	}
	printf("%d\n",int(ans.size()));
	for(auto x:ans)printf("%d\n",x);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>>a(h, vector<char>(w));
	vector<int>clear_low, clear_line;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cin >> a[i][j];
	for (int i = 0; i < h; i++) {
		bool all_w = true;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#')all_w = false;
		}
		if (all_w)clear_low.emplace_back(i);
	}
	for (int i = 0; i < w; i++) {
		bool all_w = true;
		for (int j = 0; j < h; j++) {
			if (a[j][i] == '#')all_w = false;
		}
		if (all_w)clear_line.emplace_back(i);
	}
	if (clear_line.size() == 0 && clear_low.size() == 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)cout << a[i][j];
			cout << endl;
		}
		return 0;
	}
	int p = 0, q = 0;
	for (int i = 0; i < h; i++) {
		if (i == clear_low[p]) {
			p++;
			continue;
		} else {
			for (int j = 0; j < w; j++) {
				if (j == clear_line[q]) {
					q++;
					continue;
				} else {
					cout << a[i][j];
				}
			}
			cout << endl;
			q = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  string t = s;
  reverse(t.begin(), t.end());
  if (s != t) ok = false;
  string u = "";
  for (int i = 0; i < (n - 1) / 2; ++i) {
    u += s[i];
  }
  string v = u;
  reverse(v.begin(), v.end());
  if (u != v) ok = false;
  string w = "";
  for (int i = (n + 3) / 2 - 1; i < n; ++i) {
    w += s[i];
  }
  string x = w;
  reverse(x.begin(), x.end());
  if (w != x) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
fun main() {
    val builder = StringBuilder()

    val (n, m) = readInputLine().split(" ").map { it.toInt() }

    for (i in m downTo 1) {
        if ((i and 1) == 1) {
            builder.appendln("${1 + (m - i) / 2} ${1 + (m - i) / 2 + i}")
        } else {
            builder.appendln("${n - (m - i) / 2 - i} ${n - (m - i) / 2}")
        }
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 50912
x = int(input())
if x == 2:
    print(2)
    exit()
if x % 2 == 0:
    x += 1
while True:
    flag = False
    i = 3
    while i <= x**0.5:
        if x % i == 0:
            flag = True
            break
        i += 2
    if flag:
        x += 2
    else:
        print(x)
        break


Measured memory_bytes: 2940
function main (s) {
	s=s.split(" ");
	var a,b;
	a=parseInt(s[0]);
	b=parseInt(s[1]);
	console.log(((a*b)%2===0)?"Even\n":"Odd\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 998244353

int mpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * a % MOD;
		a = (int64_t) a * a % MOD;
	}
	return res;
}
int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	std::vector<int64_t> cnt(1000001);
	for (int i = 0; i < n; i++) cnt[a[i]] += a[i];
	for (int i = 0; i <= 1000000; i++) cnt[i] %= MOD;
	
	auto converted = cnt;
	for (int x = 1; x <= 1000000; x++) {
		for (int y = 2 * x; y <= 1000000; y += x) converted[x] += converted[y];
		converted[x] %= MOD;
	}
	for (auto &i : converted) i *= i, i %= MOD;
	for (int x = 1000000; x >= 1; x--) {
		for (int y = 2 * x; y <= 1000000; y += x) converted[x] -= converted[y];
		converted[x] %= MOD;
	}
	for (int i = 0; i < n; i++) converted[a[i]] -= (int64_t) a[i] * a[i];
	int64_t ans = 0;
	for (int i = 1; i <= 1000000; i++) {
		converted[i] = converted[i] % MOD + MOD;
		if (converted[i] >= MOD) converted[i] -= MOD;
		ans += (int64_t) converted[i] * mpow(i, MOD - 2) % MOD;
	}
	std::cout << (ans % MOD * 499122177 % MOD) << std::endl;
	
	return 0;
}


Measured memory_bytes: 16640
program name
    implicit none
    character(26):: s
    character(1):: mins
    integer(4):: ls,i,mic, ri
    integer(4),allocatable:: si(:)
    logical:: is_use(26)

    read*, s
    ls = len_trim(s)
    allocate(si(ls))

    do i=1,ls
        si(i) = ichar(s(i:i)) - ichar('a') + 1
    end do

    is_use(:) = .false.

    do i=1,ls
        is_use(si(i)) = .true.
    end do

    mic=10001
    do i=1,26
        if (.not. is_use(i))  mic=min(mic,i)
    end do

    if (mic==10001) then
        ri = 1000
        do i=ls,2,-1
            if (s(i-1:i-1) < s(i:i)) then
                ri = i
                exit
            end if
        end do

        if(ri == 1000) then
            print*, -1
            stop
        end if
        mins='z'
        do i=ri,ls
            if (s(ri-1:ri-1) >= s(i:i)) cycle
            mins = min(s(i:i),mins)
        end do
        print*, s(1:ri-2) // mins
        stop
    end if



    s(ls+1:ls+1) = char(mic+ichar('a')-1)

    print*, trim(s)


end program name

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
int n, a[100005], ans;
int main() {
    scanf("%d", &n);
    for (int i=1;i<=n;i++) scanf("%d", &a[i]);
    for (int i=1;i<=n;i++) {
        if (a[i]==i) swap(a[i], a[i+1]), ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

bool solve(int A[],int n,int idx,int m){
  if(m==0) return true;
  if(idx<n){
    return solve(A,n,idx+1,m-A[idx]) ||
           solve(A,n,idx+1,m);
  }if(idx==n){
    return m==0;
  }
}

int main(){
  int n; cin>>n;
  int A[n]; for(int i=0;i<n;i++) cin>>A[i];
  int q; cin>>q;
  
  for(int i=0;i<q;i++){
    int m; cin>>m;
    if(solve(A,n,0,m)){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str s,t;
void rot(){
    str temp = "";temp+=s[0];
    s.replace(0,1,"");
    s+=temp;

}
bool valid;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s>>t;
    for(int i=1;i<=s.size();i++){
        rot();
        if(s==t)valid=true;
    }
    if(valid)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 764
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val k = scn.nextInt()

	val arr = Array(k+1){ ModInt.ZERO}
	var ans = ModInt(0)
	for (i in k downTo 1){
		val t = k/i
		var cnt = ModInt.pow(t, n)
		for (p in 2..t){
			cnt -= arr[p*i]
		}
		arr[i] = cnt
		ans += cnt*i
	}
	println(ans)
}

class ModInt {
	var v: Long
		private set
	constructor(v: Int){
		this.v = when {
			v>=0 -> v.toLong() % MOD
			v==Int.MIN_VALUE -> 852516373
			else -> MOD.toLong() - (-v%MOD)
		}
	}
	constructor(v: Long){
		this.v = when {
			v>=0 -> v % MOD
			v==Long.MIN_VALUE -> 708828003
			else -> MOD - (-v%MOD)
		}
	}

	override fun toString() = v.toString()
	fun toInt() = v.toInt()
	fun toLong() = v
	override fun equals(other: Any?): Boolean {
		return if (other is ModInt) v == other.v else false
	}
	override fun hashCode() = 31*17 + v.hashCode()

	operator fun unaryPlus() = this
	operator fun unaryMinus() = ModInt(MOD-this.v)

	private operator fun plus(o: Long) = ModInt(this.v + o)
	operator fun plus(o: ModInt) = this.plus(o.v)
	operator fun plus(o: Int) = this.plus(o.toLong())
	private operator fun minus(o: Long) = this.plus(-o)
	operator fun minus(o: ModInt) = this.minus(o.v)
	operator fun minus(o: Int) = this.minus(o.toLong())
	private operator fun times(o: Long) = ModInt(this.v*o)
	operator fun times(o: ModInt) = this.times(o.v)
	operator fun times(o: Int) = this.times(o.toLong())
	private operator fun div(o: Long) = this.times(pow(o, MOD-2))
	operator fun div(o: ModInt) = this.div(o.v)
	operator fun div(o: Int) = this.div(o.toLong())

	operator fun inc() = this.plus(1)
	operator fun dec() = this.minus(1)

	companion object{
		const val MOD = 1000000007
		val ZERO = ModInt(0)

		private fun pow(b:Long, e: Int): ModInt{
			if (b==1L) return ModInt(1)
			var ans = 1L
			var b = b; var e = e
			while (e!=0){
				if (e%2==1) ans = (ans*b)%MOD
				b = (b*b)%MOD
				e /= 2
			}
			return ModInt(ans)
		}
		fun pow(b: Int, e: Int): ModInt = pow(b.toLong(), e)
		fun pow(b: ModInt, e: Int): ModInt = pow(b.v, e)
	}
}

Measured memory_bytes: 58420
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd

L = int(readline())
S = readline().rstrip().decode('utf-8')
T = readline().rstrip().decode('utf-8')

ST = S + T
TS = T + S
if ST > TS:
    S,T = T,S

# Sを手前にした方が得

LS = len(S)
LT = len(T)

n = 0
for x in range(L+1):
    if (L - LS * x) % LT == 0:
        n = x
        break

n1, m1 = n, (L - LS * n) // LT
d = gcd(LS,LT)
n2, m2 = n1, m1
dn, dm = LT//d, LS//d
while m2 >= dm:
    m2 -= dm
    n2 += dn

x = S * n1 + T * m1
y = S * n2 + T * m2
answer = min(x,y)
print(answer)

Measured memory_bytes: 6556
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int r = 0, b = 0;

  string s; cin >> s;

  int ans = 0;
  for(int i=0; i<s.size(); ++i){
    if(s[i] == '0') ++r;
    else            ++b;

    if(r > 0 && b > 0){
      --r;
      --b;
      ans += 2;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    string array[7] = { "SUN", "MON", "TUE", "WED",
                       "THU", "FRI", "SAT" };
    string s;
    cin >> s;
    rep(i, 7) {
        if (array[i] == s) {
            cout << 7 - i << endl;
        }
    }
    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void) {
     long double X,W;
    cin >> X; 
    W = 100; 
    long long int j = 100;
long long int i = 0;
while(j < X){
    j = j * 1.01;
    i++;
}

printf("%lld\n",i);
  return 0;
}

Measured memory_bytes: 3788
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      
      if (n<10) System.out.println(n);
      else if (n>=10 	&& n<100) System.out.println(9);
      else if (n>=100 	&& n<1000) System.out.println(9+(n-99));
      else if (n>=1000 	&& n<10000) System.out.println(909);
      else if (n>=10000 && n<100000) System.out.println(909+(n-9999));
      else if (n==100000) System.out.println(90909);
      else System.out.println(1);
      
    }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	long long int ans = 0;
	rep(i,k){
		ans += p[i];
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#define int long long
using namespace std;
int K = 1000000007;
int32_t main(){
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	int dp[s1.size()+1];
    dp[0] = 1;
    for (int i=0; i < s1.size(); i++){
		if (s1[i] == s2[i]){
			if (i == 0){
				dp[i+1] = dp[i] * 3;
				dp[i+1] %= K;
			}
			else{
				if (s1[i-1] == s2[i-1]){
					dp[i+1] = dp[i] * 2;
				}
				else dp[i+1] = dp[i];
				dp[i+1] %= K;
			}
		}
		else{
            if (i < s1.size() - 1 && s1[i] == s1[i+1]){
				if (i == 0) dp[i+1] = dp[i] * 6;
				else if (s1[i-1] == s2[i-1]){
					dp[i+1] = dp[i] * 2;
				}
				else dp[i+1] = dp[i] * 3;
				dp[i+1] %= K;
            }
            else{
				dp[i+1] = dp[i];
				continue;
            }
		}
    }
    cout << dp[s1.size()] << endl;
	return 0;
}

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

int n, m, a, b, road[50];

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> a >> b;
        road[a-1]++;
        road[b-1]++;
    }
    rep(i, n) {
        cout << road[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll keta(ll n){
  ll i,ans=0;
  while(n>0){
    n/=10;
    ans++;
  }
  return ans;
}
int main(){
  ll n;
  cin >> n;
  ll i,cp=n,ans=1000;
  for(i=1;i*i<=n;i++){
    if(cp%i==0){
      ll q=cp/i;
      ll a=keta(q);
      ll b=keta(i);
      ll maxi=max(a,b);
      ans=min(ans,maxi);
    }
  }
  cout << ans;
}
  

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

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

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kMax9 = 1000000010;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, int n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

double dist(double lhs, double rhs) {
  return sqrt(lhs * lhs + rhs * rhs);
}

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

int main() {
  ll ans = 0;
  ll n, m, a, b, x, y;
  string s, t;
  vector<string> ss;
  vector<ll> aa;
  vector<ll> ba;
  vector<ll> xx;
  vector<ll> yy;

  cin >> n;

  if (n % 2 == 1) {
    cout << 0 << endl;
  } else {
    ll n0 = n / 10;
    ans = n0;
    const ll p = 5;
    while (n0 > 0) {
      ans += n0 / p;
      n0 = n0 / p;
    }
    cout << ans << endl;
  }

  return 0;
}


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

int n, m;
int tot = 0, fir[N], nxt[N << 1], to[N << 1];
int x[N << 1], y[N << 1], z[N << 1];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int vis[N], d[N];

void dfs(int u) {
    vis[u] = 1;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (vis[v]) continue;
        dfs(v);
        if (d[v]) z[(i + 1) / 2] ^= 1, d[v] = 0, d[u] ^= 1;
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i),
        addEdge(x[i], y[i]), addEdge(y[i], x[i]), d[x[i]] ^= 1, z[i] = 1;
    dfs(1);
    if (d[1]) {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= m; ++i)
        if (z[i]) printf("%d %d\n", x[i], y[i]);
        else printf("%d %d\n", y[i], x[i]);
    return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;


void solve(std::string S, std::string T){
    int cnt=0;
    rep(i,3) if(S[i]==T[i]) cnt++;
    std::cout << cnt << std::endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int INF = 1e8;

int main(){
	string S, T;
	cin >> S >> T;
	int s=S.size(), t=T.size();
	int ans=INF;
	rep(i,s-t+1){
		int res=0;
		rep(j,t){
			if(T[j]!=S[j+i]) res++;
		}
		ans=min(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
	
	static int change = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		StringBuilder sb = new StringBuilder();
		
		int N = sc.nextInt();
		
		String S = sc.next();
		
		char[] sChar = S.toCharArray();
		
		int ans = 0;
		
		for(int i = 0 ; i < N-1 ; i++) {
			if(sChar[i] != sChar[i+1]) {
				ans++;
			}
		}
		
        System.out.println(ans+1);
	}

}


Measured memory_bytes: 26580
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n;
ll x[220000];
ll y[220000];
vector<pair<int, int> > vv;
int cc[220000];

int main() {
    cin >> n;
    ll mn1 = 1e9;
    ll mn2 = 1e9;
    ll mx1 = 0;
    ll mx2 = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        if (x[i] > y[i])
            swap(x[i], y[i]);
        mn1 = min(mn1, x[i]);
        mn2 = min(mn2, y[i]);
        mx1 = max(mx1, x[i]);
        mx2 = max(mx2, y[i]);
    }
    ll ans = (mx1 - mn1) * (mx2 - mn2);
    ll now = max(mx1, mx2) - min(mn1, mn2);
    for (int i = 0; i < n; ++i)
        vv.push_back(make_pair(x[i], i)), vv.push_back(make_pair(y[i], i));
    sort(vv.begin(), vv.end());
    int cur = 0;
    int cb = n;
    for (int i = 0; i < vv.size(); ++i) {
        while (cur < vv.size() && cb) {
            ++cc[vv[cur].second];
            if (cc[vv[cur].second] == 1)
                --cb;
            ++cur;
        }
        if (cb)
            break;
        ans = min(ans, now * (vv[cur - 1].first - vv[i].first));
        --cc[vv[i].second];
        if (cc[vv[i].second] == 0)
            ++cb;
    }
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 9584
n = gets.to_i
a = gets.split.map(&:to_i)
b = {}
ans = 'YES'
for i in 0..n - 1
  if b[a[i].to_s.to_sym]
    ans = 'NO'
    break
  else
    b[a[i].to_s.to_sym] = 1
  end
end
puts ans


Measured memory_bytes: 92164
#include <stdio.h>
#include<memory.h>
#define len 362888
#define le 9
typedef int state[le];
state st[len],goal;
int dis[len],fact[le],head[len],vis[len],der[4][2]= {{-1,0},{1,0},{0,-1},{0,1}};
void encode()
{
    int i;
    for(i=fact[0]=1; i<le; i++)
        fact[i]=fact[i-1]*i;
}
int decode(int s)
{
    int i,j,code,cnt;
    for(i=code=0; i<le; i++)
    {
        for(cnt=0,j=i+1; j<le; j++)    if(st[s][i]>st[s][j])     cnt++;
        code+=cnt*fact[8-i];
    }
    if(vis[code])   return 0;
    else            return vis[code]=1;
}
int bfs()
{
    int front=1,rear=2,i,x,y,z,nx,ny,nz;
    encode();
    while(front<rear)
    {
        state& s=st[front];
        if(memcmp(s,goal,sizeof(s))==0)
            return front;
        for(i=0; i<le; i++)
            if(s[i]==0)     break;
        x=i/3;
        y=i%3;
        z=i;
        for(i=0; i<4; i++)
        {

            nx=x+der[i][0];
            ny=y+der[i][1];
            nz=nx*3+ny;
            if(nx>=0&&nx<3&&ny>=0&&ny<3)
            {
                state& t=st[rear];
                memcpy(&t,&s,sizeof(s));
                t[z]=s[nz];
                t[nz]=s[z];
                dis[rear]=dis[front]+1;
                if(decode(rear))
                    rear++;
            }
        }
        front++;
    }
    return 0;
}
int main(void)
{
    int i,oj;
    int ppp = 1;
    for(i=0; i<le; i++)   scanf("%d",&st[1][i]);
    for(i=0; i<le; i++){
        goal[i] = ppp;
        ppp++;
    }
    goal[8] = 0;

    //for(i=0; i<le; i++)   scanf("%d",&goal[i]);
    oj=bfs();
    if(oj)    printf("%d\n",dis[oj]);
    else    puts("Impossible");
    return 0;
}



Measured memory_bytes: 11268
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = judge(sc.next());
        int b = judge(sc.next());
        if(a*b==1){
            System.out.println("H");
        }else{
            System.out.println("D");
        }
    }
    static int judge(String S){
        if("H".equals(S)){
            return 1;
        }else{
            return -1;
        }
    }
}


Measured memory_bytes: 21332
def gcd(a, b):
    x = min(a, b)
    y = max(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z


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


A, B = map(int, input().split())
print(lcm(A, B))


Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

A, V = parseMap(split(readline()))
B, W = parseMap(split(readline()))
T = parseInt(readline())

d = abs(A - B)

if A != B
    if V - W != 0
        t  = d / (V - W)
    else 
        t = 10 ^ 10
    end
else
    t = 0
end

if t > 0
    if  T >= t
        println("YES")
    else
        println("NO")
    end
elseif t == 0
    println("Yes")
else
    println("NO")
end

Measured memory_bytes: 160404
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let c: Vec<char> = s.chars().collect();

    let mut l: u32 = 0;
    let mut d: u32 = 0;
    for i in 0..n {
        if c[i] == '(' {
            d += 1;
        } else if d == 0 {
            l += 1;
        } else {
            d -= 1;
        }
    }
    let mut r: u32 = 0;
    let mut d: u32 = 0;
    for i in (0..n).rev() {
        if c[i] == ')' {
            d += 1;
        } else if d == 0 {
            r += 1;
        } else {
            d -= 1;
        }
    }

    for _ in 0..l {
        print!("(");
    }
    print!("{}", s);
    for _ in 0..r {
        print!(")");
    }
    println!("");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
int main()
{
    ll y[5];
    ll n , i , j;
    for(int i = 0 ; i < 4 ; i ++)
    {
        cin >> y[i];
    }
    cin >> n ;
    y[1] = min(y[1],2*y[0]);
    y[2] = min(y[2],2*y[1]);
    y[3] = min(y[3],2*y[2]);
    long long ans1 = (n/2)*y[3] + (n%2)*y[2];
    cout << ans1 ;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K; string S; cin >> N >> S >> K;
  char x;
  x = S[K-1];
  
  for (int i = 0; i < N; ++i) {
    if (S[i] != x) {
      S.replace(i, 1, "*");
    }
  }
  
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

char game(int K, vector<int> &a, vector<int> &in_set, vector<char> &state) {
	if (state[K] != 'X') return state[K];
	if (in_set[K]) {
		state[K] = 'W';
		return 'W';
	}
	char curr_state = 'L';
	for (int i = 0; i < a.size(); i++) {
		if (K - a[i] >= 0 && game(K - a[i], a, in_set, state) == 'L') {
			curr_state = 'W';
			break;
		}
	}
	state[K] = curr_state;
	return curr_state;
}

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	vector<int> in_set(k + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		in_set[a[i]]++;
	}
	vector<char> state(k + 1, 'X');
	state[0] = 'L';
	char ans = game(k, a, in_set, state);
	if (ans == 'W') {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}

	return 0;
}

Measured memory_bytes: 9004
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int n;
int p[100001];
 
int check() {
    imfor(i, n) {
        if (p[i + 1] == i + 1) {
            return 1;
        }
    }
    return 0;
}
 
int main() {
    
    cin >> n;
    imfor(i, n) {
        cin >> p[i + 1];
    }
    int ans = 0;
    while (check()) {
        imfor(i, n) {
            if (p[i + 1] == i + 1) {
                if (i + 1 == 1) {
                    swap(p[i + 1], p[i + 2]);
                }
                else if (i + 1 == n) {
                    swap(p[i], p[i + 1]);
                }
                else if (abs(p[i] - i - 1) > abs(p[i + 2] - (i + 2) + 1)) {
                    swap(p[i + 1], p[i + 2]);
                }
                else {
                    swap(p[i], p[i + 1]);
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()
    ans = s.count(".")
    cur = ans

    for i, char in enumerate(s):
        if char == ".":
            cur -= 1
        else:
            cur += 1
        ans = min(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, m, ans = 0;
	cin >> n >> m;
	vector<int> dish(m);

	rep(i, n)							// n人分データを受け取る
	{
		int k, x;
		cin >> k;
		rep(j, k)						// 好きな料理として挙がったものをカウント
		{
			cin >> x;
			dish[x-1]++;
		}
	}

	rep(i, m) if (dish[i] >= n) ans++;	// 全員が好きだと答えた料理をカウント
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using LL = long long int;
using namespace std;
const LL MOD = 1e9 + 7;

int main (void) {
  int N;
  cin >> N;
  vector<LL> T(N), A(N);
  REP (i, N)
    cin >> T[i];
  REP (i, N)
    cin >> A[i];

  // mujun
  if (T[N - 1] != A[0]) {
    cout << 0 << endl;
    return 0;
  }

  LL ans = 1;
  FOR (i, 1, N - 1) {
    if (T[i] == T[i - 1] && A[i] == A[i + 1]) {
      ans = (ans * (min(T[i], A[i]))) % MOD;
    }
    if (T[i] > T[i - 1] && T[i] > A[i]) {
      // cout << "index: " << i << endl;
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area=a*b;
        int length=(a+b)*2;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26132
#include<stdio.h>

  

#define BLACK 200
#define WHITE 201
#define GRAY 202
void BFS(int);
void Enqueue(int);
int Dequeue();
  
int t =0,num = 0,head =0,tail =0,save=0,change=1000000;
int d[101],color[101],num4[101][101];
int Q[101];
  
int main(){
  int i,j,num2,num3,num5,flag;
  scanf("%d",&num);
   
  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      num4[i][j] = 0;
    }
  }
   
   for(i=1;i<=num;i++){
     scanf("%d",&num5);
     save = num5;
     if(save < change) change = save;
  
     scanf("%d",&num2);
     if(num2 == 0)continue; 
     else{
       for(j=0;j<num2;j++){
     scanf("%d",&num3);
     num4[i][num3] = 1; 
       }
     }   
   }
  
  
    
     BFS(change);  //i=min ????
     
  
  
   for(i=1;i<=num;i++){
     if(d[i]==1000000000){
       d[i] = -1;
}
  
     printf("%d %d\n",i,d[i]);
     }
        
     
   return 0;
}
  
  
void BFS(int s){
  int i,v,Q;
  for(i=1;i<=num;i++){
    color[i]=WHITE;
    d[i]=1000000000;
  }
  color[s] =GRAY;
  d[s] = 0;
    
  Enqueue(s);
    
  while(head !=tail){
    i = Dequeue();
    for(v=1;v<=num;v++){
  
      if(color[v] == WHITE && num4[i][v] == 1){
  
    color[v] = GRAY;
    d[v] =d[i] + 1;
        Enqueue(v);
      }
    }
   
    color[i] = BLACK;
 }
    
}
  
void Enqueue(int x){
  
  Q[tail] = x;
  tail++;
  
}
  
int Dequeue(void){
  
  int x;
  
  x = Q[head];
  head++;
  
  return x;
}

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void Main()
{
	int n;
	cin >> n;
	vector<int> V(n);
	rep(i, n)
			cin >>
		V.at(i);
	int sum;
	sum = accumulate(V.begin(), V.end(), 0);
	if (sum % 10)
	{
		cout << sum << endl;
		return;
	}
	sort(V.begin(), V.end());
	rep(i, n)
	{
		if (V.at(i) % 10)
		{
			cout << sum - V.at(i) << endl;
			return;
		}
	}
	cout << 0 << endl;
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class TsurugaCastle
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                var hist = new int[7];
                for (int i = 0; i < n; i++)
                {
                    int age = int.Parse(Console.ReadLine());
                    if (age < 10) { hist[0]++; }
                    else if (age < 20) { hist[1]++; }
                    else if (age < 30) { hist[2]++; }
                    else if (age < 40) { hist[3]++; }
                    else if (age < 50) { hist[4]++; }
                    else if (age < 60) { hist[5]++; }
                    else { hist[6]++; }
                }

                for (int i = 0; i < 7; i++) { Console.WriteLine(hist[i]); }
            }

            return 0;
        }
    }
}

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

int main()
{
  int a,b,c,k;
  cin >> a>>b>>c>>k;
  int ans = 0;
  rep(i,a){
    ans++;
    k--;
    if(k == 0){
      cout << ans << endl;
      return 0;
    }
  }
  rep(i,b){
    //ans++;
    k--;
    if(k == 0){
      cout << ans << endl;
      return 0;
    }
  }
  rep(i,c){
    ans--;
    k--;
    if(k == 0){
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
k = int(input())
a = [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]
print(a[k-1])

Measured memory_bytes: 9056
let () =
  let is_right l =
    match l with
      [a;b;c] -> if a*a + b*b = c*c then "YES" else "NO"
    | _ -> "NO" and
      n = read_int () in
  let rec read i =
    let line = Scanf.scanf "%d %d %d\n" (fun x y z-> [x;y;z] ) |> List.sort compare in
    is_right line |> print_endline;if i > 0 then read (i-1)
  in read (n-1);;

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

int main(){
    int n,count=0;
    cin >> n;
    int a[100];
    for(int i=0;i<n;i++)cin>>a[i];
    
    for(int i=0;i<n;i++){
        int minj=i;
            for(int j=i;j<n;j++){
                if(a[j]<a[minj]){
                    minj=j;
                    
                }
            }
            if(i!=minj){
            swap(a[minj],a[i]);
            count++;
            }
    }
    for(int i=0;i<n;i++){
        if(i!=n-1)cout<<a[i]<<" ";
        else cout<<a[i];
    }
    cout<<endl;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3100
# https://atcoder.jp/contests/abc136/tasks/abc136_c



N = gets.to_i
Hs = gets.split.map(&:to_i)

min_from_last = {}
idx = N - 1
min = Hs[idx]
Hs.reverse_each do |height|
  min = height if height < min
  min_from_last[idx] = min
  idx -= 1
end

Hs.each_with_index do |height, idx|
  if min_from_last[idx + 1] && height - min_from_last[idx + 1] >= 2
    puts 'No'
    exit
  end
end

puts 'Yes'


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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e6;

class Event{
    public:
    int t, d, x;
};

bool cmp(const Event &a, const Event &b){ return a.t < b.t || (a.t == b.t && a.d < b.d); }

int N, Q, S[MAX], T[MAX], X[MAX], D[MAX];

int main(){
    cin >> N >> Q;
    for(int i=0;i<N;i++) cin >> S[i] >> T[i] >> X[i];
    for(int i=0;i<Q;i++) cin >> D[i];

    vector< Event > v;
    for(int i=0;i<N;i++){
        Event e;
        e.t = S[i] - X[i];
        e.d = 1;
        e.x = X[i];
        v.push_back(e);
        e.t = T[i] - X[i];
        e.d = 0;
        e.x = X[i];
        v.push_back(e);
    }

    for(int i=0;i<Q;i++){
        Event e;
        e.t = D[i];
        e.d = 2;
        e.x = -1;
        v.push_back(e);
    }

    sort(v.begin(), v.end(), cmp);

    set<int> sx;
    vector<P> ans;
    for(auto e : v){
        if(e.d == 1){
            // 通行止め発生
            sx.insert(e.x);
        } else if(e.d == 0){
            // 通行止め終了
            sx.erase(e.x);
        } else {
            // 進行開始
            cout << ( sx.empty()? -1 : *sx.begin() ) << endl;
        }
    }

}

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

int n,t,a[20],b,c;

int main()
{
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> t;
		a[t - 1] = i;
	}
	int ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> b;
		ans += b;
	}
	for (size_t i = 0; i < n - 1; i++)
	{
		cin >> c;
		if (a[i] + 1 == a[i + 1])
		{
			ans += c;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.*;

public class Main
{
	static int rec(int d, int now, int n, int ii)
	{
		if(d == 0)
		{
			if(now == n)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		int ans = 0;
		for (int i = ii; i < 10; i++)
		{
			ans += rec(d - 1, now + i, n, i + 1);
		}
		return ans;
	}
	public static void main(String args[])
	{
		Scanner sc= new Scanner(System.in);
		int n, s;
		while(true)
		{
			n = sc.nextInt();
			s = sc.nextInt();
			if(n == 0 && s == 0)
			{
				break;
			}
			System.out.println(rec(n, 0, s, 0));
		}
		sc.close();
	}
}


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

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

using namespace std;
using ll = long long;

int H, W;
bool used[500][500];
int coin[500][500];
int mov[250000][4];
int vecidx = 0;
pair<int, int> vec[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(0, -1), make_pair(-1, 0)};

void solve();

void init(){
    rep(i, 500) rep(j, 500) used[i][j] = true;
}

bool direction(int x, int y){
    int kari_x = x + vec[vecidx].first;
    int kari_y = y + vec[vecidx].second;
    return !(0 <= kari_x && kari_x < H && 0 <= kari_y && kari_y < W && !used[kari_x][kari_y]);
}

int main(void){
    cin >> H >> W;
    init();
    rep(i, H) rep(j, W) used[i][j] = false;

    rep(i, H) rep(j, W) cin >> coin[i][j];
    int x = 0, y = 0;
    int cnt = 0;
    while(!used[x][y]){
        used[x][y] = true;
        if(direction(x, y)){
            if(vecidx == 3) vecidx = 0;
            else vecidx++;
        }
        if(direction(x, y)) break;

        int next_x = x + vec[vecidx].first;
        int next_y = y + vec[vecidx].second;
        if(coin[x][y] % 2 == 1){
            coin[x][y]--; coin[next_x][next_y]++;
            mov[cnt][0] = x+1; mov[cnt][1] = y+1; mov[cnt][2] = next_x+1; mov[cnt][3] = next_y+1;
            cnt++;
        }
        x = next_x; y = next_y;
    }
    cout << cnt << endl;
    rep(i, cnt){
        rep(j, 4){
            if(j == 3) cout << mov[i][j] << endl;
            else cout << mov[i][j] << " ";
        }
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

typedef long long ll;

using namespace std;

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

	multiset<int> S;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		S.insert(x);
	}
	
	int ans = 0;
	while (S.size()) {
		int t = *S.rbegin();
		S.erase(--S.end());
		
		int p = 1;
		while (p <= t) p *= 2;
		
		if (S.find(p - t) != S.end()) {
			ans++;
			S.erase(S.find(p - t));
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9600