akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<map>//map(辞書)

using namespace std;

int main(void){
    int N, a, b;
    string s;
    cin >> N >> s;
    a = b = 0;
    for(int i = 0; i < N; i++){
        if(s[i] == 'R'){a+=1;}
        else{b+=1;}     
    }

    if(a > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

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

int main() {
    int n; cin >> n;
    while (n--) {
        string str; cin >> str;
        set<string> s; s.insert(str);
        rep(i,str.length()) {
            string str1 = str.substr(0, i+1);
            string str2 = str.substr(i+1, str.length());
            if (str1.length() && str2.length()) {
                rep(i, 2) {
                    rep(j, 2) {
                        s.insert(str1+str2);
                        reverse(str2.begin(), str2.end());
                    }
                    rep(j, 2) {
                        s.insert(str2+str1);
                        reverse(str2.begin(), str2.end());
                    }
                    reverse(str1.begin(), str1.end());
                }
            }
        }
        cout << s.size() << endl;
    }
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	for(int i =a ;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
}

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

int dice[6];
int dice2[6];


void turnDice2(char s) {
	int tmpNumber;
	if (s == 'E'){
		tmpNumber = dice2[0];
		dice2[0] = dice2[3];
		dice2[3] = dice2[5];
		dice2[5] = dice2[2];
		dice2[2] = tmpNumber;
	} 
	else if (s == 'W'){
		tmpNumber = dice2[0];
		dice2[0] = dice2[2];
		dice2[2] = dice2[5];
		dice2[5] = dice2[3];
		dice2[3] = tmpNumber;
	} 
	else if (s == 'S'){
		tmpNumber = dice2[0];
		dice2[0] = dice2[4];
		dice2[4] = dice2[5];
		dice2[5] = dice2[1];
		dice2[1] = tmpNumber;
	} 
	else if (s == 'N'){
		tmpNumber = dice2[0];
		dice2[0] = dice2[1];
		dice2[1] = dice2[5];
		dice2[5] = dice2[4];
		dice2[4] = tmpNumber;
	} 
}

bool makeDice2TopEqualToDice1(int result) {
	switch (result) {
		case 0:
			break;
		case 1:
			turnDice2('N');
			break;
		case 2:
			turnDice2('W');
			break;
		case 3:
			turnDice2('E');
			break;
		case 4:
			turnDice2('S');
			break;
		case 5:
			turnDice2('S');
			turnDice2('S');
			break;
		case -1:
			return false;
	}
	return true;
}

void rotateDice() {
	int tmpNumber;
	tmpNumber = dice2[1];
	dice2[1] = dice2[2];
	dice2[2] = dice2[4];
	dice2[4] = dice2[3];
	dice2[3] = tmpNumber;
}

bool checkDice2EqualToDice1() {
	for (int i=0; i<6; i++) {
		if (dice[i] != dice2[i])
			return false;
	}
	return true;
}

bool checkDice() {
	for (int i=0; i<6; i++) {
		if (dice[0] == dice2[i]) {
			makeDice2TopEqualToDice1(i);
			for (int i=0; i<4; i++) {
				rotateDice();
				if (checkDice2EqualToDice1()) {
					return true;
				}
			}
		}
	}

	return false;
}
int main(int argc, char const* argv[])
{
	for (int i=0; i<6; i++) {
		cin >> dice[i];
	}
	for (int i=0; i<6; i++) {
		cin >> dice2[i];
	}
	if (checkDice()) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int n, m, a, b;
int x[110];
int y[110];

int main() {
	cin >> n >> m >> a >> b;
	rep(i, n)cin >> x[i];
	rep(i, m)cin >> y[i];
	sort(x, x + n);
	sort(y, y + m);
	if (max(a,x[n - 1]) < min(b,y[0]))puts("No War");
	else puts("War");
	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 256
S = str(input())
n = int(len(S))
ans = [str(0) for i in range(n)]
cntLo = 0
cntRo = 0
cntLe = 0
cntRe = 0
for i in range(n-1):
    if S[i] == "R" and S[i+1] == "L":
        j = 1
        k = 1
        while i-j >= 0 and S[i-j] == "R":
            if j % 2 == 0:
                cntRe += 1
            else:
                cntRo += 1
            j += 1
        while i+1+k <= n-1 and S[i+1+k] == "L":
            if k % 2 == 0:
                cntLe += 1
            else:
                cntLo += 1
            k += 1
        ans[i] = str(cntRe + cntLo+1)
        ans[i+1] = str(cntRo + cntLe+1)
        cntLo = 0
        cntRo = 0
        cntLe = 0
        cntRe = 0
print(" ".join(ans))

Measured memory_bytes: 80012
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 11;
int n, mod;
int a[N];
bool check(int pos){
    int l = pos + 1, r = 2 * n;
    while(l <= r){
        if(a[l] + a[r] < mod)return 0;
        l++; r--;
    }
    return 1;
}
int main(){
    cin>>n>>mod;
    for(int i = 1;i <= n + n; i++){
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n + n);
    int l = 0, r = n, ans = n;
    while(l <= r){
        int mid = l + r >> 1;
        if(check(mid << 1))r = mid - 1, ans = min(ans, mid);
        else l = mid + 1;
    }
    l = 1, r = 2 * ans;
    int Z = 0;
    while(l <= r){
        Z = max(Z, a[l] + a[r]);
        l++; r--;
    }
    l = 2 * ans + 1;r = 2 * n;
    while(l <= r){
        Z = max(Z, a[l] + a[r] - mod);
        l++; r--;
    }
    //printf("ans=%d Z=%d\n", ans * 2, Z);
    cout<<Z<<endl;
    return 0;
}

Measured memory_bytes: 1024
from scipy import ndimage
import numpy as np
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
 
A_array = np.array(
    [[0 if s == "#" else 1 for s in input()[:-1]] for i in range(H)])
# print(A_array)
 
 
# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))

Measured memory_bytes: 54056
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main(){
  int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
for (int i=1; i<=365; i++){
	cout<<i%26+1<<endl;}}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
int mizu(int *a,int x,int y);
int main(){
  int n,ans=0;
  cin >> n;
  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int l=0;l<n;l++){
    while(h[l] > 0){
      int r;
      for(r=l+1;r<n;r++){
        if(h[r] == 0){
          break;
        }
      }
      for(int a=l;a<r;a++){
        h[a]--;
      }
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
def primeFact(n):
    i = 2
    pl = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            pl.append(i)
        i += 1
    if n > 1:
        pl.append(int(n))
    return pl


a, b = map(int, input().split())
print(len(set(primeFact(a)) & set(primeFact(b))) + 1)


Measured memory_bytes: 9224
# 2019-11-10 20:23:41(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    N, T = (int(x) for x in sys.stdin.readline().split())

    ct = []
    for i in range(N):
        c, t = (int(x) for x in sys.stdin.readline().split())
        if t <= T:
            ct.append((c, t))
    
    ct.sort()
    print(ct[0][0] if ct else 'TLE')


if __name__ == "__main__":
    main()


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


int main(void){
	long int N, K; cin >> N >> K;
	int i;
	long int sum = 0, sumsum = 0;

	for (i = 1; i <= N; i++) {
		if (i%K == 0) {
			sum += 1;
		}
		if (K % 2 == 0 && i%K == K / 2) {
			sumsum += 1;
		}
	}

	cout << sum * sum * sum + sumsum * sumsum * sumsum << endl;

	return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin>>k;
    if(k%7==0)k/=7;
    int now=0;
    rep(i,50000000){
        now*=10;
        now+=1;
        now%=k;
        if(now==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 3628
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
ps = [list(input().split()) for i in range(m)]
check = [True] * n
ac = 0
wa = [0] * n
cnt_wa = 0
for p, s in ps:
    p = int(p)
    if check[p - 1]:
        if s == 'AC':
            check[p - 1] = False
            ac += 1
        else:
            wa[p - 1] += 1
for i in range(n):
    if not check[i]:
        cnt_wa += wa[i]
print(ac, cnt_wa)


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

using namespace std;

int main() {
	//------------入力------------
	//文字列a,b,cを定義
	string a, b, c;
	//a,b,cを入力
	cin >> a >> b >> c;

	//------------出力------------
	//しりとりになっているかを判定し、Y/Nを出力
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = ["#"*(W+2)]+["#"+input()+"#" for _ in [0]*H] + ["#"*(W+2)]

h = [[-int(c=="#") for c in row] for row in S]
v = [[-int(c=="#") for c in row] for row in S]

for i in range(1,H+1):
    l = 1
    cnt = 0
    for j in range(1,W+2):
        if S[i][j] == "#" and S[i][j-1] == ".":
            h[i][l:j] = [cnt]*(j-l)
        elif S[i][j] == "." and S[i][j-1] == "#":
            l = j
            cnt = 1
        elif S[i][j] == "." and S[i][j-1] == ".":
            cnt += 1
            
for j in range(1,W+1):
    l = 1
    cnt = 0
    for i in range(1,H+2):
        if S[i][j] == "#" and S[i-1][j] == ".":
            for k in range(l,i):
                v[k][j] = cnt
        elif S[i][j] == "." and S[i-1][j] == "#":
            l = i
            cnt = 1
        elif S[i][j] == "." and S[i-1][j] == ".":
            cnt += 1

print(max(h[i][j]+v[i][j] for i in range(1,H+1) for j in range(1,W+2))-1)

Measured memory_bytes: 123864
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> one, zero;
  if (s[0] == '0')
    one.push_back(0);
  char bef = s[0];
  int c = 1;
  rep(i, 1, n) {
    if (bef == s[i]) {
      c++;
    } else {
      if (bef == '0')
        zero.push_back(c);
      else
        one.push_back(c);
      c = 1;
    }
    bef = s[i];
  }
  if (bef == s[n - 1]) {
    if (bef == '0')
      zero.push_back(c);
    else
      one.push_back(c);
  }

  ll ans = 0;
  rep(i, 0, n) {
    ll sumone = 0, sumzero = 0;
    rep(j, i, min((int)one.size(), i + k + 1)) {
      sumone += one[j];
      if (j < min((int)zero.size(), i + k))
        sumzero += zero[j];
    }
    chmax(ans, sumone + sumzero);
  }
  cout << ans << endl;
}

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

n=int(input())

t=list(map(int,input().split()))

m=int(input())

for i in range(m):
    a,b=map(int,input().split())
    if t[a-1]==b:
        print(sum(t))
    elif t[a-1]>b:
        print(sum(t)-(t[a-1]-b))
    elif t[a-1]<b:
        print(sum(t)+(b-t[a-1]))


Measured memory_bytes: 3064
my @list = (1, 3, 5, 6, 7, 8, 10, 12);

my @input1 = split / /, <>;
my @input2 = split / /, <>;

if (grep { $_ == $input1[0] } @list)  {
    if ($input1[1] == 31) {
        print 1;
    }
    else {
        print 0;
    }
}
else {
    if (($input1[0] == 2 && $input1[1] == 28) || $input1[1] == 30) {
        print 1;
    }
    else {
        print 0;
    }
}


Measured memory_bytes: 512
s = input()
l = len(s)

patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

/*!* [intutil] *!*/
/*+* 整数演算いろいろ *+*/
i64 divceil(i64 a, i64 b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
i64 logceil(i64 a, i64 b) {
    for(i64 i = 0, x = 1; a >= 2; x *= a, i++) if(x <= b) return i; return 0;
}

// O(N)
int main() {
    using P = pair<i64, i64>;
    i64 N, D, A, B = 0, ans = 0;
    cin >> N >> D >> A;
    // (X, H) |-> 座標X, 体力Hの敵
    vector<P> e(N);
    for(P &a : e) {
        cin >> a.first >> a.second;
    }
    sort(WHOLE(e));
    // (F, R) |-> 強さF, 範囲[R-2D:R]の既に使用された爆弾
    queue<P> q;
    for(P &a : e) {
        i64 X, H;
        tie(X, H) = a;
        // 有効圏外の爆弾を削除
        while(q.size() && q.front().second < X) {
            B -= q.front().first;
            q.pop();
        }
        i64 M = divceil(H - B, A);
        if(M > 0) {
            ans += M;
            B += M * A;
            q.push({M * A, X + 2 * D});
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<cstdio>

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

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
  int len = 0, cnt = 0;
  char str[101];
  
  scanf("%s", str);
  
  while(str[len] != '\0'){
    len++;
  }
  
  for(int i = 0;i < len / 2;i++){
     if(str[i] != str[len - 1 - i]){
        cnt++;
     }
  }
  
  printf("%d", cnt);
  
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

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

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	G := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}
	var R []int
	done := make([]bool, N)
	var dfs func(cur int, root []int)
	dfs = func(cur int, root []int) {
		if cur == N-1 {
			r := make([]int, len(root))
			for i := 0; i < len(root); i++ {
				r[i] = root[i]
			}
			R = r
		}
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if !done[next] {
				done[next] = true
				dfs(next, append(root, next))
			}
		}
	}
	done[0] = true
	dfs(0, []int{0})
	l := len(R)
	black := R[ceil(l, 2)-1]
	white := R[ceil(l, 2)]

	total := 0
	done2 := make([]bool, N)
	var count func(cur int)
	count = func(cur int) {
		for i := 0; i < len(G[cur]); i++ {
			next := G[cur][i]
			if next != white && !done2[next] {
				done2[next] = true
				total++
				count(next)
			}
		}
	}
	done2[black] = true
	total++
	count(black)
	bc, wc := total, N-total
	if bc > wc {
		fmt.Fprintln(wtr, "Fennec")
	} else {
		fmt.Fprintln(wtr, "Snuke")
	}
}


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

#define REP(i,n) for(int i=0; i<n; i++)
using P = complex<double>;

const double eps = 1e-7;

double dot(P a, P b) {
  return (a * conj(b)).real();
}

double cross(P a, P b) {
  return (conj(a) * b).imag();
}

int ccw(P a, P b, P c) {
  if(cross(b-a, c-a) > eps) return 1;
  if(cross(b-a, c-a) < -eps) return -1;
  if(dot(b-a, c-a) < -eps) return -2;
  if(dot(a-b, c-b) < -eps) return 2;
  return 0;
}

bool isIntersectedSS(P a1, P a2, P b1, P b2) {
  int a = ccw(b1, b2, a1);
  int b = ccw(b1, b2, a2);
  int c = ccw(a1, a2, b1);
  int d = ccw(a1, a2, b2);

  return a * b <= 0 && c * d <= 0;
}

double distanceSP(P a, P b, P c) {
  if(dot(b-a, c-a) < eps) return abs(c-a);
  if(dot(a-b, c-b) < eps) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

double getDistance(P a1, P a2, P b1, P b2) {
  if(isIntersectedSS(a1, a2, b1, b2)) return 0;

  return min({
	      distanceSP(a1, a2, b1),
	      distanceSP(a1, a2, b2),
	      distanceSP(b1, b2, a1),
	      distanceSP(b1, b2, a2),
    });
}

bool solve() {
  int N, M, L;
  int x[101], y[101], a[101], r[101];
  P points[101][5];
  
  cin >> N >> M >> L;

  if (N == 0) return false;

  for(int i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> a[i] >> r[i];
    a[i] += 90;
    
    for(int j=0; j<5; j++) {
      double sx = cos((j * 72 + a[i]) / 180.0 * M_PI) * r[i] + x[i];
      double sy = sin((j * 72 + a[i]) / 180.0 * M_PI) * r[i] + y[i];
      points[i][j] = P(sx, sy);
    }
  }

  double dist[101][101];

  for(int i=0; i<N; i++)
    for(int j=0; j<N; j++)
      dist[i][j] = (i != j) * 1e17;

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

      for(int i2=0; i2<5; i2++) {
        for(int j2=0; j2<5; j2++) {
          dist[i][j] = dist[j][i] =
            min(dist[i][j], 
              getDistance(points[i][i2], points[i][(i2+2)%5],
              points[j][j2], points[j][(j2+2)%5])
            );
        }
      }      
    }
  }

  REP(k,N)REP(i,N)REP(j,N)dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);

  printf("%.10lf\n", dist[M-1][L-1]);


  return true;
}

int main(){
  while(solve());

}



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

int main()
{
	double t, a, h, now, min = 100000;
	int n, ans;
	cin >> n >> t >> a;
	for (int i = 0; i < n; ++i)
	{
		cin >> h;
		now = abs(a - (t - h * 0.006));
		if (now < min)
		{
			min = now;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    N, K = map(int, input().split())
    a = [[] for _ in [0]*10]
    l = []
    for c, g in (tuple(map(int, input().split())) for _ in [0]*N):
        a[g-1].append(c)

    for i, prices in enumerate(a):
        ln = len(prices)
        if ln == 0:
            continue
        dp = [0]*(K+1)
        for j, price in enumerate(prices):
            _k = j if j < K-1 else K-1
            for k, prev, cur in zip(range(_k, -1, -1), dp[_k::-1], dp[_k+1::-1]):
                if prev+price+k*2 > cur:
                    dp[k+1] = prev+price+k*2
        l.append(dp[1:ln+1])

    dp = [float("-inf")]*(K+1)
    dp[0] = 0
    for prices in l:
        cdp = dp[:]
        for i, price in enumerate(prices, start=1):
            if i > K:
                break
            for j, cur, prev in zip(range(K, -1, -1), cdp[::-1], dp[K-i::-1]):
                if 0 < prev+price > cur:
                    cdp[j] = prev+price
        dp = cdp

    print(max(dp))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 8120
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    char a = s[0],b;
    int cnt_a = 0,cnt_b = 0;
    for(int i = 1;i < 4;i++){
        if(a != s[i]){
            b = s[i];
        }
    }

    for(int i = 0;i < 4;i++){
        if(s[i] == a){
            cnt_a++;
        }
        else if(s[i] == b){
            cnt_b++;
        }
    }

    if(cnt_a == 2 && cnt_b == 2){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    

    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int main()
{
	int n;
	while (cin >> n, n)
	{
		int ans = INF;
		for (int z = 100; z >= 0; z--)
		{
			int e = n;
			e -= z*z*z;
			if (e < 0) continue;
			for (int y = 1000; y >= 0; y--)
			{
				int x = e;
				x -= y*y;
				if (x < 0) continue;
				ans = min(ans, x + y + z);
			}
		}
		cout << ans << endl;
	}


	return 0;
}

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

ll lcm(ll a, ll b)
{
    ll t = __gcd(a, b);
    return t ? (a / t * b) : 0;
}

int factor2(int x) {
  int res=0;
  while(x>0 && x%2==0){
    x/=2;res++;
  }
  return res;
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,m;cin>>n>>m;
  vector<int> a(n);
  ll t = 0;
  int cnt2 = 0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i] /= 2;
    if(i==0){
      t=a[i];
      cnt2 = factor2(t);
    }else{
      t=lcm(t, a[i]);
      if (cnt2 != factor2(a[i])){
        puts("0");return 0;
      }
    }
  }

  ll ans = ceil((m/t)/2.0);
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 640
from collections import Counter

n = int(input())
v = input().split()
v1 = []
v2 = []

for k in range(n):
    if k%2 == 0:
        v1.append(v[k])
    else:
        v2.append(v[k])

v1Counter = Counter(v1)
v2Counter = Counter(v2)
a1, b1 = zip(*v1Counter.most_common(2))
a2, b2 = zip(*v2Counter.most_common(2))

if a1[0] != a2[0]:
    print(n-b1[0]-b2[0])

else:
    if b1[0]==n/2 and b2[0]==n/2:
        print(int(n/2))
    elif b1[0]==n/2:
        print(n-b1[0]-b2[1])
    elif b2[0]==n/2:
        print(n-b2[0]-b1[1])
    else:
        c = max(b1[0]+b2[1],b1[1]+b2[0])
        print(n-c)


Measured memory_bytes: 19820
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    vec B = A; Sort(B); Reverse(B);

    vec ans(N);
    REP(i, N){
        if(A[i] == B[0]) ans[i] = B[1];
        else ans[i] = B[0];
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 7936
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

const int maxn = 3e5 + 5;
const int maxw = 1e5 + 1;
const int lim = (1 << 9);

int n, Q;
int v[maxn], w[maxn];

int dp[lim + 5][maxw + 5];

void read_input()
{
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i] >> w[i];
}

void init()
{
    fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), -1);
    dp[0][0] = 0;
    for(int i = 1; i < min(lim, n + 1); ++i)
    {
        int par = i / 2;
        for(int j = 0; j < maxw; ++j)
        {
            dp[i][j] = max(dp[i][j], dp[par][j]);
            if(j + w[i] < maxw && dp[par][j] != -1)
                dp[i][j + w[i]] = max(dp[i][j], dp[par][j] + v[i]);
        }
    }
    for(int i = 1; i < min(lim, n + 1); ++i)
        for(int j = 1; j < maxw; ++j)
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
}

int get_max_val(vector<int>&vtx, int mx)
{
    if(sz(vtx) < 10) return dp[vtx[0]][mx];
    int len = sz(vtx) - 9;
    int res = 0;
    for(int mask = 0; mask < (1 << len); ++mask)
    {
        int totw = 0, totv = 0;
        for(int i = 0; i < len; ++i)
            if(mask >> i & 1)
            {
                totw += w[vtx[i]];
                totv += v[vtx[i]];
            }
        if(totw <= mx)
            res = max(res, totv + dp[vtx[len]][mx - totw]);
    }
    return res;
}

void solve()
{
    cin >> Q;
    for(; Q > 0; --Q)
    {
        int u, mx;
        cin >> u >> mx;
        vector<int> vtx;
        while(u > 0)
        {
            vtx.push_back(u);
            u /= 2;
        }
        cout << get_max_val(vtx, mx) << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    init();
    solve();
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	REP(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

ll read() {
	ll i;
	scanf("%" SCNd64, &i);
	return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
	printf("%" PRId64, x);
	if (suc == 1)
		printEoln();
	if (suc == 2)
		printSpace();
}

string readString() {
	static char buf[3341000];
	scanf("%s", buf);
	return string(buf);
}

char *readCharArray() {
	static char buf[3341000];
	static int bufUsed = 0;
	char *ret = buf + bufUsed;
	scanf("%s", ret);
	bufUsed += strlen(ret) + 1;
	return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }


signed main() {
	int ans = 0;
	string s = readString();
	REP(i, 4) {
		if (s[i] == '+')
			ans++;
		else
			ans--;
	}
	print(ans);
}


Measured memory_bytes: 2304
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, M;
Vec< Vec< int > > arc;

double run(vector< double >& dp) {
	dp.assign(N, 0);
	dp[N-1] = 0;
	for (int v=N-2; v>=0; --v) {
		int c = 0;
		for (int u : arc[v]) {
			if (u >= 0) {
				dp[v] += dp[u] + 1;
				++c;
			}
		}
		dp[v] /= c;
	}
	return dp[0];
}

int main() {
	cin >> N >> M;
	arc.assign(N, Vec< int >());
	for (int i=0; i<M; ++i) {
		int s, t;
		cin >> s >> t;
		--s; --t;
		arc[s].push_back(t);
	}
	
	vector< double > dp;
	double ans = run(dp);
	
	for (int v=0; v<N-1; ++v) {
		if (arc.size() == 1) continue;
		int tar_i = 0;
		for (int i=0, m=arc[v].size(); i<m; ++i) if (dp[arc[v][tar_i]] < dp[arc[v][i]]) tar_i = i;
		int p = arc[v][tar_i];
		arc[v][tar_i] = -1;
		vector< double > dp_;
		ans = min(ans, run(dp_));
		arc[v][tar_i] = p;
	}
	
	printf("%.9f\n", ans);
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = {25, 10, 5, 1};
        int count = 0;
        for (int i = 0; i < 4; i++) {
            if (n != 0) {
                count += n / a[i];
                n %= a[i];
            }
        }
        System.out.println(count);
    }
}



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

int gcd(int a,int b){
  if(a%b==0) return b;
  else return gcd(b,a%b);
}
 int main(){
   int K;
   cin>>K;
   int count=0;
   for(int a=1;a<K+1;a++){
     for(int b=1;b<K+1;b++){
       for(int c=1;c<K+1;c++){
         count+=gcd(a,gcd(b,c));
       }
     }
   }
   cout<<count<<endl;
 }

Measured memory_bytes: 3588
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    println(problemSumitomoMitsuiC(x))
}

fun problemSumitomoMitsuiC(x: Int): Int {
    val divide = x / 100
    val remainder = x % 100
    if (remainder == 0) return 1

    val divide2 = remainder / 5
    val ans = if (remainder % 5 != 0) divide2 + 1 else divide2
    return if (ans <= divide) 1 else 0
}

Measured memory_bytes: 31272
#include<bits/stdc++.h>
using namespace std;
 
struct route
{
    int cost,time;
};
 
bool operator<(route a,route b)
{
    if(a.cost!=b.cost)
        return a.cost<b.cost;
    else
        return b.cost<a.cost;
}
int main()
{
    int n,t;
 
    while(cin>>n>>t)
    {
        route r[n];
 
        for(int i=0;i<n;i++)
        {
            cin>>r[i].cost>>r[i].time;
        }
        sort(r,r+n);
 
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(r[i].time<=t)
            {
                cout<<r[i].cost<<endl;
                flag=1;
                break;
            }
        }
        if(flag==0)
            cout<<"TLE"<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 200000
using namespace std;
main(){
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    if(H%h==0&&W%w==0) {cout<<"No";return 0;}
    cout<<"Yes"<<endl;
    int a=((H/h)*(W/w)/(H%h*W+W%w*H-(H%h)*(W%w))+1);
    rep2(i,1,H){
        rep2(j,1,W){
            if(i%h==0&&j%w==0){
                cout<<(-a*h*w+a-1)<<" ";
            }
            else{
                cout<<a<<" ";
            }
        }
        cout<<endl;
    }
    
    return 0;
}

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

int main() {
	int N, T, A, H, minP = 0, minH = 100000000;
	cin >> N >> T >> A;
	for (int i = 0; i < N; i++) {
		cin >> H;
		int t = T * 1000 - H * 6;
		int d = abs(A * 1000 - t);
		if (d < minH) {
			minH = d;
			minP = i;
		}
	}
	cout << minP + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll n, a, b;

ll power(ll p, ll k)
{
	ll res = 1;
	while (k)
	{
		if (k & 1)	res = res * p % mod;
		p = p * p % mod; k >>= 1;
	}
	return res;
}

ll C(ll n, ll m)
{
	ll res = 1;
	for (ll i = 1, j = n; i <= m; i++, j--)
	{
		res = res * j % mod;
		res = res * power(i, mod - 2) % mod;
	}
	return res;
}

ll lucas(ll n, ll m)
{
	if (m == 0)	return 1;
	return (C(n % mod, m % mod) * lucas(n / mod, m / mod)) % mod;
}

int main()
{
	cin >> n >> a >> b;
	cout << (power(2, n) - (lucas(n, a) % mod + lucas(n, b) % mod) % mod - 1 + mod) % mod;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
ratio = []
for i in range(N):
  ratio.append([int(j) for j in input().split(" ")])
               
vote = ratio[0]

for i in range(len(ratio)-1):
  if ratio[i+1][0] >= vote[0] and ratio[i+1][1] >= vote[1]:
    vote = ratio[i+1]
  
  else:
    a0 = 0
    b0 = 0
    if ratio[i+1][0] < vote[0]:
      seed = ratio[i+1][0]
      mul = vote[0]//ratio[i+1][0]
      if vote[0]%ratio[i+1][0] != 0:
        mul += 1
      seed *= mul
      a0 = seed
      a1 = mul * ratio[i+1][1]
      la = [a0,a1] 
    
    if ratio[i+1][1] < vote[1]:
      seed = ratio[i+1][1]
      base = ratio[i+1][1]
      
      mul = vote[1]//ratio[i+1][1]
      if vote[1]%ratio[i+1][1] != 0:
        mul += 1
      seed *= mul
      b1 = seed
      b0 = mul * ratio[i+1][0]
      lb = [b0,b1]
    if a0 > b0:
      vote = [la[0],la[1]]
    else:
      vote = [lb[0],lb[1]]
print(sum(vote))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;


int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int temp = b-a;
	if(temp%2 == 0)
		cout << "Alice" << endl;
	else
		cout << "Borys" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;
    ll la = 2;
    ll lb = 1;
    ll l;

    for (int i = 2; i <= n; ++i) {
        l = la + lb;
        la = lb;
        lb = l;
    }
    if (n == 1) l = 1;

    cout << l << endl;

    return 0;
}


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

using namespace std;

int main() {

  int n, m, i, in, def = 0, ans = 0, before = 0;

  cin >> n >> m;
  
  for(i = 0; i < m; i++) {
    cin >> in;
    
    if(i == 0 && in != 1) {
      def = in - 1;
    }

    else def = (in-before)/2 +0.5;

    ans = max(ans, def);

    before = in;
  }

  ans = max(ans, n - in);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue> 
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    cout<<(a+b)/2+(a+b)%2<<endl;
    return 0;
}

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

using namespace std;
const int MAXN = 55;

int n;
int a[MAXN];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			ans += a[i] * a[j];
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

struct zalis{
public:
    zalis *prev;
    zalis *next;
    int v;
    int l,r;//[l,r]
    zalis(int v,int l,int r):v(v),l(l),r(r){
        prev= nullptr;
        next= nullptr;
    }

    int size(){
        return r-l+1;
    }
};

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        zalis za(-1,0,1000000000);
        zalis *frontza=&za;
        for (int i = 0; i < n; ++i) {
            char c;
            cin>>c;
            if(c=='W'){
                int value,length;
                cin>>value>>length;
                zalis *tempza=frontza;
                while(tempza!= nullptr){
                    if(tempza->v==-1){
                        if(tempza->size()<=length){//入りきらない
                            tempza->v=value;
                            length-=tempza->size();
                            if(length==0)break;
                        }
                        else {//入りきる
                            zalis *newempty=new zalis(value,tempza->l,tempza->l+length-1);
                            if(newempty->l==0)frontza=newempty;

                            tempza->l+=length;

                            if(tempza->prev!= nullptr)tempza->prev->next=newempty;
                            newempty->prev=tempza->prev;

                            newempty->next=tempza;
                            tempza->prev=newempty;

                            break;
                        }
                    }
                    tempza=tempza->next;
                }
            }
            else if(c=='D'){
                int k;
                cin>>k;
                zalis *tempza=frontza;
                while(tempza!= nullptr){
                    if(tempza->v==k)tempza->v=-1;
                    tempza=tempza->next;
                }
            }
            else {//c=='R'
                int k;
                cin>>k;
                zalis *tempza=frontza;
                while(tempza!= nullptr){
                    if(tempza->l<=k&&tempza->r>=k){
                        cout<<tempza->v<<endl;
                        break;
                    }
                    tempza=tempza->next;
                }
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s,s1,s2,ss;
  long q,i,n1;
  int t,f;
  char c;
  cin>>s>>q;
  n1=0;
  s1="";s2="";
  for(i=0;i<q;i++){
    cin>>t;
    if (t==1) n1++;
    else if (t==2) {
      cin>>f>>c;
      if (n1%2==0 && f==1) s1=c+s1;
      else if (n1%2==0 && f==2) s2=s2+c;
      else if (n1%2==1 && f==1) s2=s2+c;
      else if (n1%2==1 && f==2) s1=c+s1;
    }
  }
  if (n1%2==0) cout<<s1+s+s2<<endl;
  else if (n1%2==1) {
    ss=s1+s+s2;
    reverse(ss.begin(),ss.end());
    cout<<ss<<endl;
  }
}

Measured memory_bytes: 1512
#include <iostream>

int main(){
    while(true){
    int n, a_score = 0, b_score = 0;
    std::cin >> n;
    
    if(n == 0)
        break;

    for(int i = 0; i < n; ++i){
        int a, b;
        std::cin >> a >> b;
        if(a > b)
            a_score += a + b;
        else if(a < b)
            b_score += a + b;
        else
            a_score += a, b_score += b;
    }

    std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll a;
    string s;
    cin >> a >> s;
    cout << (a>=3200 ? s : "red") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool isPrime(int x) {
    int i;
    if (x < 2)return false;
    else if (x == 2) return true;
    if (x % 2 == 0) return false;
    for (i = 3; i * i <= x; i += 2) if (x % i == 0) return false;
    return true;
}
int main() {
	int q, l, r;int k[100001];
    cin >> q;k[1] = 0;
	for (int i = 3;i < 100001;i += 2) {
        k[i] = k[i - 2];
        int o = (i + 1) / 2;
        if (isPrime(i) && isPrime(o)) {
            k[i]++;
        }
	}
    for (int i = 0; i < q;i++) {
        cin >> l >> r;
        if (l != 1) {
            cout << k[r] - k[l - 2] << endl;
        }
        else
            cout << k[r] << endl;
    }
}

Measured memory_bytes: 3952
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
const int N = 1e5 + 10;
vector<int> v[N];
void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> H(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> H[i];
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        bool check = false;
        for (auto &it : v[i]) {
            if (H[i] <= H[it]) {
                check = true;
                break;
            }
        }
        if (!check) {
            ans++;
        }
    }
    cout << ans << endl;
}
int32_t main() {
    BOLT;
    solve();
}


Measured memory_bytes: 9768
import math
a, b, h, m = map(int, input().split())

min=60*h+m

ax=a*math.sin(math.radians(360*min/720))
ay=a*math.cos(math.radians(360*min/720))

bx=b*math.sin(math.radians(360*m/60))
by=b*math.cos(math.radians(360*m/60))

print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 9520
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       
 

int main() {
	string s,s2;
	cin >> s;
	int q;
	cin >> q;
    int rev=0;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {swap(s,s2);}
		if (t == 2) {
			int f;
			cin >> f;
			char c;
			cin >> c;
           if(f==1){s2+=c;}else{s+=c;}
		}
	}
  reverse(s2.begin(), s2.end());
  s2+=s;
		cout << s2 << endl;
}


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

using namespace std;

int main(){
	
	int m,d;
	int count=0;
	cin >> m >> d;
	
	for(int i=1;i<=m;i++){
		for(int j=2;j<=d;j++){
			for(int k=2;k<10;k++){
				if(10*j+k>d)continue;
				if(j*k==i)count++;
			}
		}
	}
	
	cout << count << endl;
	
	return 0;
}


Measured memory_bytes: 256