akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
ll N,A,B;
int main()
{
    cin>>N>>A>>B;
    ll k=N/(A+B);
    ll s=N%(A+B);
    if(s>A)
        s=A;
    cout<<k*A+s<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d%d%d%d',$N,$M,$X,$Y);
$x=explode(" ",trim(fgets(STDIN)));
$y=explode(" ",trim(fgets(STDIN)));
$Judge=0;
for ($i=$X+1; $i <=$Y ; $i++) {
  // code...
  if(max($x)<$i&&min($y)>=$i){
    $Judge=1;
  }
}
if($Judge==1){
  echo "No War";
}else{
  echo "War";
}

 ?>


Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>A>>B;
    if(A==B){
        cout<<A<<endl;
        return 0;
    }
    ans=0;
    ll tmp;
    tmp=(B+1)%4;
    if(tmp/2==1){
        ans^=1;
    }
    tmp=A%4;
    if(tmp/2==1){
        ans^=1;
    }
    ll i=1;
    while(true){
        ll num=pow(2,i);
        if(num>B)break;
        ll tmp1=B%(num*2);
        if(tmp1/num==1 && tmp1%2==0){
            ans+=num;
        }
        i++;
    }
    ll ans2=0;
    i=1;
    A--;
    if(A<=0)A=0;
    while(true){
        ll num=pow(2,i);
        if(num>A)break;
        ll tmp1=A%(num*2);
        if(tmp1/num==1 && tmp1%2==0){
            ans2+=num;
        }
        i++;
    }
    cerr<<ans<<" "<<ans2<<endl;
    cout<<(ans^ans2)<<endl;
	return 0;
}


Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


# 区間スケジューリングか？
N = read_a_int()
ST = []
for _ in range(N):
    x, l = read_ints()
    ST.append((x - l, x + l))

from operator import itemgetter
ST.sort(key=itemgetter(1))

# 区間スケジューリングを適応していく
pret = ST[0][1]
ans = 0
for s, t in ST:
    if s < pret:
        continue
    ans += 1
    pret = t
print(ans + 1)


Measured memory_bytes: 18316
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main(){
	int n,m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1);
}

Measured memory_bytes: 256
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(args, *params):
    return tuple(p(v) for p, v in zip(params, next(args).split()))

# エントリーポイント
def main(args):
    N, A, B, C = parse(args, int, int, int, int)
    L = tuple(int(next(args)) for _ in range(N))

    def solve(n, l, a, b, c, cost):
        if n == 0:
            if not all((a, b, c)): return INF
            return abs(A - a) + abs(B - b) + abs(C - c) + cost - 30
        r = []
        r += [solve(n - 1, l, a, b, c, cost)]
        r += [solve(n - 1, l, a + l[n - 1], b, c, cost + 10)]
        r += [solve(n - 1, l, a, b + l[n - 1], c, cost + 10)]
        r += [solve(n - 1, l, a, b, c + l[n - 1], cost + 10)]
        return min(r)

    print(solve(N, L, 0, 0, 0, 0))

import sys
if __name__ == '__main__':
    main(iter(sys.stdin.read().split("\n")))


Measured memory_bytes: 3064
#include <stdio.h>
int prime(int);
int main(){
  int A[10000];
  int i,n;
  int count=0;

scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&A[i]);
}
for(i=0;i<n;i++){
if(prime(A[i]))count++;
}
printf("%d\n",count);

return 0;
}


int prime(int A){
  int j;
  if(A<2)return 0;
  if(A==2)return 1;
  if(A%2==0)return 0;
for(j=3;j*j<=A;j+=2){
      if(A%j==0)return 0;
  }
return 1;
 }

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

typedef long long ll;

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

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N),Y;
    REP(i,N){
        cin >> X[i];
    }
    
    Y = X;
    sort(X.begin(),X.end());
    
    int midm, midp;
    midm = X[N/2-1];
    midp = X[N/2];
    
    REP(i,N){
        if ( Y[i] < midp ){
            cout << midp << endl;
        } else {
            cout << midm << endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 4844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=1e6+10,P=1e9+7;
int a,b,c,f[N],fac[N],ifac[N],inv[N],ff;
long long ans;
int C(int n,int k){
    if(n<k||k<0) return 0;
    return 1ll*fac[n]*ifac[k]%P*ifac[n-k]%P;
}
void pre(int n){
    fac[0]=1;rep(i,1,n) fac[i]=1ll*fac[i-1]*i%P;
    inv[1]=1;rep(i,2,n) inv[i]=1ll*(P-P/i)*inv[P%i]%P;
    ifac[0]=1;rep(i,1,n) ifac[i]=1ll*ifac[i-1]*inv[i]%P;
}
int main(){
    scanf("%d%d%d",&a,&b,&c);pre(a+b+c);f[0]=1;
    rep(i,1,b+c) f[i]=3ll*f[i-1]%P;
    if(b>c) swap(b,c);ff=1;
    rep(i,0,b+c){
        ans+=1ll*f[b+c-i]*C(a-1+i,i)%P*ff%P;
        ff=ff*2%P;
        if(i>=b) ff=(ff-C(i,b)+P)%P;
        if(i>=c) ff=(ff-C(i,c)+P)%P;
    }
    printf("%lld\n",ans%P);
    return 0;
}

Measured memory_bytes: 16604
// inputに入力データ全体が入る
function Main(input) {
	input = parseInt(input);
  	let x = input;
  	let y = Math.floor(input/2);
  	let arr = {};
  	for( let i = y; i<=x; i++){
		let B = yakusu(i);//約数の数
      	arr[i] = B;
    }
  	var keys=[];
    for(var key in arr)keys.push(key);
    	function Compare(a,b){
        return arr[a]-arr[b];    
    }

    keys.sort(Compare);
	console.log(parseInt(keys[keys.length-1]));
}




  
function yakusu(num){
  let result = 0;
  while(num>0){
    if(num%2 === 0){
      result ++;
      num = num /2;
    }else{
      break;
    }
  }
  return result;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29696
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
import pprint



sys.setrecursionlimit(2147483647)
INF = 100
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


x, n = LI()
P = set(LI())
i = 0
while True:
    if x - i not in P:
        print(x - i)
        break
    elif x + i not in P:
        print(x + i)
        break
    i += 1


Measured memory_bytes: 76760
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int N, M;
	struct edge { int from, to, cost; };
	vector<edge> es;
	vector<int> d;

	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		es.push_back(edge{ a - 1, b - 1, -c });
	}
	d.assign(N, INF_L);
	d[0] = 0;

	for (int v = 0; v < N - 1; ++v) {

		bool update = false;
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;
	}

	bool negative[1000];
	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}
	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
			if (negative[e.from] == true) {
				negative[e.to] = true;
			}
		}
	}



	cout << (negative[N - 1] ? "inf" : to_string(-d[N - 1])) << endl;




	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> x >> y;
	for(i=1;i<=3;i++)
	{
		if(i!=x && i!=y)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String s = sc.next();
			String []t = s.split("[+,=]");
			BigInteger[] bi = new BigInteger[3];
			boolean flag0 = true;
			for(int i = 0; i <= 9; i++) {
				boolean flag = true;
				for(int j = 0; j < 3; j++) {
					String k = t[j];
					if(i == 0 && k.charAt(0) == 'X' && k.length() != 1) {
						flag = false;
						break;
					}else {
						k = k.replaceAll("X", Integer.toString(i));
						bi[j] = new BigInteger(k);
					}
				}
				if(flag) {
					if(bi[2].equals(bi[0].add(bi[1]))) {
						System.out.println(i);
						flag0 = false;
						break;
					}
				}
			}
			if(flag0) {
				System.out.println("NA");
			}
		}
		sc.close();
	}
}


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

int main() {
long long a,b,k;
cin >> a >> b >>k;
if(a>=k){cout << a-k <<" "<< b;
return 0;}
if(k<=a+b){cout << "0" << " " <<a+b-k;
return 0;}
else{cout << "0" << " " << "0";}
}



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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

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

const int MOD = 1000000007;

void solve() {
  int H, W, N;
  cin >> H >> W >> N;
  int m = max(H, W);
  int ans = N / m;
  if (N % m) {
    ans++;
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


bool palindrome(string s)
{
	string rev=s;
	reverse(rev.begin(),rev.end());
	return s==rev;
}
//edge cases when n=1 , m=1. wrong variable in loop. if<->while
signed main()
{
	speed
	string str;cin>>str;
	int n=str.length(),i=0;
	string f="",s="";
	for(i=0;i<n/2;++i)
	{
		f+=str[i];
	}
	++i;
	for(;i<n;++i)
	{
		s+=str[i];
	}
	if(palindrome(str) and palindrome(f) and palindrome(s)){cout<<"Yes\n";}
	else{cout<<"No\n";}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  long a,b,k;
  cin >> a >> b >> k;
  if(a - k >= 0) {
    cout << a - k << " " << b << endl;
  }
  else if(a - k < 0) {
    if(b - (k - a) > 0) {
      cout << 0 << " " << b - (k - a) << endl;
    }
    else cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int xg=1, yg=1;
		int[] g2 = {4,6,9,11};
		if(x == y){
			System.out.println("Yes");
			System.exit(0);
		}
		if(x == 2 || y == 2){
			System.out.println("No");
			System.exit(0);
		}
		for(int i=0; i<g2.length; i++){
			if(x == g2[i]){
				xg = 2;
			}
			if(y == g2[i]){
				yg = 2;
			}
		}

		if(xg == yg){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll prime[100];

void factrization(ll N) {
    for(ll i=2; i*i<=N; i++) {
        while(N%i==0) {
            prime[i]++;
            N/=i;
        }
    }
    
    if(N!=1) {
        prime[N]++;
    }
    
}


int main(void) {
    ll N;
    cin >> N;
    ll i;
    ll ans=0;
    
    for(i=2; i<=N; i++) {
        factrization(i);
    }
    
    
    ll cnt3=0, cnt5=0, cnt15=0, cnt25=0, cnt75=0;
    for(i=0; i<100; i++) {
        if(prime[i]+1>=75) cnt75++;
        if(prime[i]+1>=25) cnt25++;
        if(prime[i]+1>=15) cnt15++;
        if(prime[i]+1>=5) cnt5++;
        if(prime[i]+1>=3) cnt3++;
        
    }
    
    ans+=(cnt3-2)*cnt5*(cnt5-1)/2;
    ans+=(cnt3-1)*cnt25;
    ans+=(cnt5-1)*cnt15;
    ans+=cnt75;
    pr(ans);
}



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

string make_t(string s, string t);
string make_s(string t);

int main() {
  int n;
  string s;
  cin >> n >> s;
  string t[] = {"11", "01", "10", "00"}, result;
  int i;
  for (i = 0; i < 4; i++) {
    result = make_t(s, t[i]);
    result.erase(result.end() - 1);
    if (make_s(result) == s) {
      break;
    }
    if (i == 4 - 1) {
      result = "-1";
    }
  }
  for (i = 0; i < n; i++) {
    if (result == "-1") {
      break;
    }
    if (result.at(i) == '0') {
      result.at(i) = 'W';
    } else {
      result.at(i) = 'S';
    }
  }
  cout << result << endl;
  return 0;
}

string make_t(string s, string t) {
  int i;
  for (i = 1; i < s.length(); i++) {
    if (s.at(i) == 'o') {
      if (t.at(i) - '0') {
        t.push_back(t.at(i - 1));
      } else {
        t.push_back(t.at(i - 1) ^ 1);
      }
    } else {
      if (t.at(i) - '0') {
        t.push_back(t.at(i - 1) ^ 1);
      } else {
        t.push_back(t.at(i - 1));
      }
    }
  }
  return t;
}

string make_s(string t) {
  string result = "";
  if (t.at(1) == t.at(t.length() - 1) ^ t.at(0) - '0') {
    result.push_back('x');
  } else {
    result.push_back('o');
  }
  int i;
  for (i = 1; i < t.length() - 1; i++) {
    if (t.at(i - 1) == t.at(i + 1) ^ t.at(i) - '0') {
      result.push_back('x');
    } else {
      result.push_back('o');
    }
  }
  if (t.at(t.length() - 2) == t.at(0) ^ t.at(t.length() - 1) - '0') {
    result.push_back('x');
  } else {
    result.push_back('o');
  }
  return result;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
const int N=500010;
int tt;
deque <int> Q;
map <int,int> w[N];
int head[N],to[N*3],nxt[N*3],s[N*3],dis[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void lnk(int x,int y,int z,int u) {
    to[++tt]=y,nxt[tt]=head[x],s[tt]=z,head[x]=tt;
    to[++tt]=x,nxt[tt]=head[y],s[tt]=u,head[y]=tt;
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1,cnt=n;i<=m;i++) {
	int x=gi(),y=gi(),z=gi(),&X=w[x][z],&Y=w[y][z];
	if(!X) X=++cnt;
	if(!Y) Y=++cnt;
	lnk(X,Y,0,0),lnk(X,x,0,1),lnk(Y,y,0,1);
    }
    memset(dis,127,sizeof(dis));
    Q.push_back(1),dis[1]=0;
    while(!Q.empty()) {
	int x=Q.front();
	Q.pop_front();
	for(int i=head[x];i;i=nxt[i]) {
	    int y=to[i];
	    if(dis[y]>dis[x]+s[i]) {
		dis[y]=dis[x]+s[i];
		Q.push_back(y);
	    }
	}
    }
    if(dis[n]>1<<30) dis[n]=-1;
    cout<<dis[n];
    return 0;
}

Measured memory_bytes: 64384
#include <cstdio>
#include <algorithm>
using namespace std;
long long mod(long long a){
	return a%100000;
}
long long dp[101][101][101][2]={},ans=0;/*0が縦、1が横*/
int main(){
		while(1){
			for(int i=0;i<101;i++){
				for(int j=0;j<101;j++){
					for(int k=0;k<101;k++){
						for(int h=0;h<2;h++){
							dp[i][j][k][h]=0;
						}
					}
				}
			}
	int c,d;
		scanf("%d %d",&c,&d);
		if(c==0){
			break;
		}
	for(int i=2;i<101;i++){
		dp[1][i][i-1][0]=1;
	}
	for(int i=2;i<101;i++){
		dp[i][1][i-1][1]=1;
	}
	for(int i=2;i<c+1;i++){
		for(int j=2;j<d+1;j++){
			for(int h=1;h<max(i,j);h++){
				if(h!=1){
					dp[i][j][h][0]=mod(dp[i][j-1][h-1][0]);
					dp[i][j][h][1]=mod(dp[i-1][j][h-1][1]);
				}else{
					if(i==2 && j==2){
						dp[2][2][1][0]=1;
						dp[2][2][1][1]=1;
					}else{
						for(int y=2;y<=max(i,j-1);y++){
							dp[i][j][h][0]+=mod(dp[i][j-1][y][1]);
							dp[i][j][h][1]+=mod(dp[i-1][j][y][0]);
						}
					}
				}
			}
		}
	}
	for(int y=1;y<=max(c,d);y++){
		ans+=mod(dp[c][d][y][0])+mod(dp[c][d][y][1]);
		ans=mod(ans);
	}
	printf("%lld\n",mod(ans));
      ans=0;
	}
	return 0;
}

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

#define X first

#define Y second

#define pb push_back

#define mp make_pair

using namespace std;

int w, h, k;

char ch[810][810];

bool vis[810][810];



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

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



vector<pair<int, int> > pt;

queue<pair< pair<int, int>, int> > Q;

void bfs(int x, int y, int time)

{

	Q.push(mp(mp(x, y), 0));

	vis[x][y] = 1;

	while(!Q.empty())

	{

		pair< pair<int, int>, int> now = Q.front();

		pt.pb(now.X);

		if(now.Y == k) break;

		Q.pop();

		for(int i = 0; i < 4; i ++)

		{

			int x = now.X.X + xx[i];

			int y = now.X.Y + yy[i];

			if(vis[x][y]) continue;

			if(x <= 0 || y <= 0 || x > w || y > h) continue;

			if(ch[x][y] == '#') continue;

			vis[x][y] = 1;

			Q.push(mp(mp(x, y), now.Y + 1));

		}

	}

}



int main()

{

	cin >> w >> h >> k;

	for(int i = 1; i <= w; i ++)

		scanf("%s", ch[i] + 1);

	int stx, sty;

	for(int i = 1; i <= w; i ++)

		for(int j = 1; j <= h; j ++)

			if(ch[i][j] == 'S')

				{stx = i; sty = j; break;}



	if(stx == 1 || sty == 1 || stx == w || sty == h) {cout << 0 << endl; return 0;}

	//cout << stx << " " << sty << endl;

	vis[stx][sty] = 1;

	bfs(stx, sty, 0);

	while(!Q.empty())

	{

		pt.push_back(Q.front().X);

		Q.pop();

	}

	int n = pt.size(), dis = 1e7;

	for(int i = 0; i < n; i ++)

	{

		int x = pt[i].X;

		int y = pt[i].Y;

		dis = min(dis, x - 1);

		dis = min(dis, y - 1);

		dis = min(dis, w - x);

		dis = min(dis, h - y);

	}

	cout << 1 + ceil((double)dis / k);

	return 0;

}

Measured memory_bytes: 10480
<?php
$str = trim(fgets(STDIN));
$l = 0;
$r = strlen($str)-1;
$c = 0;
while($l < $r){
  if($str[$l] == $str[$r]){
    $l++;$r--;
  }elseif($str[$l] == "x"){
    $l++;
    $c++;
  }elseif($str[$r] == "x"){
    $r--;
    $c++;
  }else{
    echo -1;exit;
  }
}
echo $c;

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <=10; i++) {
  	if (1000*i >= n) {
    	cout << 1000*i - n;
      	break;
    }
  }
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>

using namespace std;

void Solution()
{
    int a, b;
    
    while(cin>>a>>b)
    {
        if(a > b)
        {
            cout<<"a > b"<<endl;
        }
        else if(a < b)
        {
            cout<<"a < b"<<endl; 
        }
        else if(a == b)
        {
            cout<<"a == b"<<endl;
        }
    }
}

int main()
{
    Solution();
}

Measured memory_bytes: 1152
N=int(input())
S=list(input())



n=S.count("R")*S.count("G")*S.count("B")
count=0
for l in range(N-2):
    for r in range(l+2,N):
        m=(l+r)/2
        if m%1.0!=0:
            continue
        m=int(m)
        tmp =[S[l], S[r], S[m]]
        if len(set(tmp))==3:
            count+=1
            
            

print(n-count)
            


Measured memory_bytes: 74088
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

int n, q;
char s[100000][11];
queue<P> x;

int main(){
	scanf("%d%d", &n, &q);
	rep(i, n){
		int t;
		scanf("%s%d", s[i], &t);
		x.push(P(i, t));
	}
	int t = 0;
	while(!x.empty()){
		P v = x.front();
		x.pop();
		if(v.second <= q){
			t += v.second;
			printf("%s %d\n", s[v.first], t);
		}
		else{
			t += q;
			v.second -= q;
			x.push(v);
		}
	}
	return 0;
}

Measured memory_bytes: 2008
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toLong)
  val abs = (1 to n.toInt).map { _ =>
    readLine.split(" ").map(_.toLong) match {
      case Array(a, b) => (a, b)
    }
  }

  var r = m
  var res = 0l
  for (ab <- abs.sortBy(_._1) if r > 0) {
    if (r <= ab._2) {
      res = res + ab._1 * r
      r = 0
    } else {
      res = res + ab._1 * ab._2
      r = r - ab._2
    }
  }
  println(res)

}


Measured memory_bytes: 78748
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int dx[7][3] = {{0,1,1},{0,0,0},{1,2,3},{-1,-1,0},{1,1,2},{0,1,1},{-1,0,1} };
  int dy[7][3] = {{1,0,1},{1,2,3},{0,0,0},{1,2,1},{0,1,1},{1,1,2},{1,1,0} };

  char ba[8][8];
  while(cin>>ba[0][0]) {
    REP(i,8)
      REP(j,8)
        if (i!=0||j!=0)
          cin >> ba[j][i];
    int f = -1;
    REP(y,8) {
      REP(x,8) {
        if (ba[x][y] == '1') {
          REP(i,7) {
            int j = 0;
            for(;j<3;j++) {
              int xx = x + dx[i][j];
              int yy = y + dy[i][j];
              if (xx<0||8<=xx||yy<0||8<=yy) break;
              if (ba[xx][yy] != '1')
                break;
            }
            if (j==3) {
              f = i;
              break;
            }
          }
          if (f>=0) break;
        }
        if (f>=0) break;
      }
      if (f>=0) break;
    }
    cout << (char)('A' + f) << endl;
  }
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/
/*
    2*x/arr[i] = (2p + 1) for all i.

    RHS is odd, hence LHS should be odd as well.
    Hence:
    1. 2*x and arr[i] must have same power of 2. 
        a. If 2*x has more then LHS will be even
        b. If arr[i]  has more then it won't divide 2*x
    Hence all the arr[i] should have same power of 2.
    2. lcm(arr[i]..) should divide 2*x
    3. 2*x/arr[i] should be odd.
*/

int p2(ull a) {
    int res = 0;
    while(a % 2 == 0) {
        res++; a /= 2;
    }
    return res;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();
    ull n,m; cin>>n>>m;
    vector<ull> arr(n);
    FOR(i, 0, n) {
        cin>>arr[i];
    }
    int cnt = p2(arr[0]);
    ull lc = arr[0];
    FOR(i, 1, n) {
        lc = (arr[i] / __gcd(arr[i], lc)) * lc;
        if(lc > 2*m || p2(arr[i]) != cnt) {
            cout<<0;
            return 0;
        }
    }
    ll res = 2*m/lc;
    res = res / 2 + (res % 2);
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a){
        cout << k << endl;
    } else if(k <= a+b){
        cout << a << endl;
    } else {
        cout << a-(k-a-b) << endl;
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(fst) (int)(fst).size()
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(fst) fst.begin(), fst.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int x, y;
    cin >> x >> y;
    string a;
    cin >> a;
    if (a==s) x--;
    else y--;
    cout << x << " " << y << "\n";
    return 0;
}

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

const int N = 1e5+1;
const int inf = 0x7fffffff;
ll c[6];
struct nd{int id;ll c;}a[6];
bool cmp(nd a,nd b){return a.c<b.c;}

int main()
{
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d;
	cin>>n;
	a[1].c=q*8,a[2].c=h*4,a[3].c=s*2,a[4].c=d;
	for(int i=1;i<=4;++i)a[i].id=i;
	sort(a+1,a+5,cmp);
	ll ans=0;
	ans+=n/2*a[1].c;
	n=n%2;
	if(!n){cout<<ans;return 0;}
	else
	{
		ans+=min(min(q*4,h*2),s);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int bfs(int h, int w, vector<string> &grid, int i, int j) {
  vector<vector<int>> visit(h, vector<int>(w, 0));
  queue<vector<int>> task;
  task.push({i, j});
  visit.at(i).at(j) = 1;
  int cnt = 0;
  while (task.size() > 0) {
    int sz = task.size();
    for (int i = 0; i < sz; i++) {
      int x = task.front().at(0), y = task.front().at(1);
      if (x + 1 < h && visit.at(x + 1).at(y) == 0
          && grid.at(x + 1).at(y) == '.') {
        task.push({x + 1, y});
        visit.at(x + 1).at(y) = 1;
      }
      if (x - 1 >= 0 && visit.at(x - 1).at(y) == 0
          && grid.at(x - 1).at(y) == '.') {
        task.push({x - 1, y});
        visit.at(x - 1).at(y) = 1;
      }
      if (y + 1 < w && visit.at(x).at(y + 1) == 0
          && grid.at(x).at(y + 1) == '.') {
        task.push({x, y + 1});
        visit.at(x).at(y + 1) = 1;
      }
      if (y - 1 >= 0 && visit.at(x).at(y - 1) == 0
          && grid.at(x).at(y - 1) == '.') {
        task.push({x, y - 1});
        visit.at(x).at(y - 1) = 1;
      }
      task.pop();
    }
    cnt++;
  }
  return cnt;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  priority_queue<int> ans;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') continue;
      ans.push(bfs(h, w, grid, i, j));
    }
  }
  cout << ans.top() - 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,d;
    cin>>n>>d;
    two_sat A(n);
    vec x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n)for(int j=i+1;j<n;j++){
        if(abs(x[i]-x[j])<d) A.add_clause(i,0,j,0);
        if(abs(x[i]-y[j])<d) A.add_clause(i,0,j,1);
        if(abs(y[i]-x[j])<d) A.add_clause(i,1,j,0);
        if(abs(y[i]-y[j])<d) A.add_clause(i,1,j,1);
    }
    if(A.satisfiable()){
        cout<<"Yes\n";
        auto B=A.answer();
        rep(i,B.size()){
            if(B[i]) cout<<x[i]<<"\n";
            else cout<<y[i]<<"\n";
        }
    }
    else cout<<"No";
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, A, B, C;
    cin >> N >> A >> B >> C;
    (A *= 570000004) %= MOD;
    (B *= 570000004) %= MOD;
    (C *= 570000004) %= MOD;
    C = (1 - C + MOD) % MOD;
    {
        auto n = MOD - 3, t = C;
        while(n){
            if(n & 1)(C *= t) %= MOD;
            (t *= t) %= MOD;
            n >>= 1;
        }
    }
    (A *= C) %= MOD;
    (B *= C) %= MOD;
    vector<unsigned long> ifr(N);
    ifr[0] = ifr[1] = 1;
    for(unsigned long i = 2; i < N; ++i)ifr[i] = (MOD - MOD / i) * ifr[MOD % i] % MOD;
    unsigned long ansA{0}, ansB{0}, Ap{1}, Bp{1};
    for(unsigned long i = 0, a = C * N, bin = 1; i < N; ++i){
        (ansA += a * bin % MOD * Ap) %= MOD;
        (ansB += a * bin % MOD * Bp) %= MOD;
        (a += C) %= MOD;
        (Ap *= A) %= MOD;
        (Bp *= B) %= MOD;
        (bin *= (N + i) * ifr[i + 1] % MOD) %= MOD;
    }
    cout << (ansA * Bp + ansB * Ap) % MOD << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


int main(){

    int n;
    cin >> n;

    cout << ((double)((n + 1) / 2)) / n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    string a;
    cin>>a;
    if(a=="ABC") cout<<"ARC"<<endl;
    
    else cout<<"ABC"<<endl;
    
    
}

Measured memory_bytes: 3616
S=(input().split("/"))
#print(S)

if int(S[0])>2019:
    print("TBD")
    exit()
elif int(S[0])==2019:
    if int(S[1])>4:
        print("TBD")
        exit()
    else:
        print("Heisei")
        exit()
else:
    print("Heisei")
    exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)

int main() {
	ll x; cin >> x;
	int i = 1;
	while (x > i*(i + 1) / 2) 	i++;
	cout << i << endl;
	return 0;
}

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

// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    ll N;
    cin >> N;
    ll ans;
    cin >> ans;
    for(int i=0;i<N-1;i++){
        ll a;
        cin >> a;
        ans = gcd(ans,a);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(long long N, long long A, long long B){
    ll p=N/(A+B);
    ll q=N%(A+B);
    cout<<(p*A+min(q,A))<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
}


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


int main(){
	int chuukan,kimatsu,sai,goukei;
	while(true){
		
		cin>>chuukan>>kimatsu>>sai;
		goukei = kimatsu+chuukan;
		if(goukei+sai==-3){
			break;
		}
		if(chuukan==-1||kimatsu==-1){
			cout<<"F"<<endl;
		}else if(goukei>=80){
			cout<<"A"<<endl;
		}else if(goukei>=65){
			cout<<"B"<<endl;
		}else if(goukei>=50){
			cout<<"C"<<endl;
		}else if(goukei>=30){
			if(sai>=50){
				cout<<"C"<<endl;
			}else{
				cout<<"D"<<endl;
			}
		}else{
			cout<<"F"<<endl;
		}

	}
}



Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    print(int(X+Y/2))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int ans = INF;

    int ab = max(x,y)*2;
    int res = max(x-ab/2,0LL)*a + max(y-ab/2,0LL)*b;
    chmin(ans,ab*c+res);
    ab = min(x,y)*2;
    res = max(x-ab/2,0LL)*a + max(y-ab/2,0LL)*b;
    chmin(ans,ab*c+res);
    chmin(ans,a*x+b*y);
    out(ans);

    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        char S;
        cin >> S;
        switch(S){
            case 'Y':
                cout << "Four" << endl;
                return 0;
            default :
                break;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
X,N=map(int, input().split())
a=list(map(int, input().split()))
d=0
u=0
i=1
if(N==0):
    print(X)
else:
    if X in a:
        while(d==0) and (u==0):
            if X-i in a:
                if X+i in a:
                    i +=1
                else:
                    u +=1
            else:
                d +=1
        if(d==1):
            print(X-i)
        elif(u==1):
            print(X+i)
    else:
        print(X)

Measured memory_bytes: 9216
/**
*    author:  Dooloper
*    created: 05.07.2020 20:59:46
**/

#include <bits/stdc++.h>

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  int ans = 0;
  cin >> n;
  n %= 1000;
  ans = 1000 - n;
  if (n==0) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    set<string> s;
    string tmp;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        s.emplace(tmp);
    }
    cout << s.size() << endl;

}

Measured memory_bytes: 19180
import string

def main(N):
    if N <= 26:
        return string.ascii_lowercase[N-1]
    if N % 26 == 0:
        return main(N//26 - 1) + string.ascii_lowercase[25]
    return main(N//26) + string.ascii_lowercase[N%26 - 1]

N = int(input())
print(main(N))
    

Measured memory_bytes: 9988
import sys

line = sys.stdin.readline().rstrip()

i = len(line)
while i > 0:
    if line[i-5:i] == 'dream':
        i -= 5
    elif line[i-5:i] == 'erase':
        i -= 5
    elif line[i-7:i] == 'dreamer':
        i -= 7
    elif line[i-6:i] == 'eraser':
        i -= 6
    else:
        print 'NO'
        sys.exit()
print 'YES'


Measured memory_bytes: 2820
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

int main() {
	ll A, B;

	cin >> A >> B;
	for (int i = 0; i <= 500000; i++) {
		int pa = floor((double)i * 1.08) - i, pb = floor((double)i * 1.1) - i;
		if (pa == A && pb == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 888
import math
def primes(x):
    if x < 2:
        return []
    ps = [i for i in range(x)]
    ps[1] = 0
    for p in ps:
        if p > math.sqrt(x): break
        if p == 0: continue
        for np in range(2 * p, x, p):
            ps[np] = 0
    return [p for p in ps if p != 0]


def prime_factors(ps, x):
    pfs = []
    for p in ps:
        i = 0
        while x % p == 0:
            x = x // p
            i += 1
        if i != 0:
            pfs.append((p,i))
    return pfs


def mod_comb(a,b,mod):
    #print(a,b)
    if a-b < b: return mod_comb(a,a-b,mod)
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a-i
        ans_div *= i+1
        ans_mul %= mod
        ans_div %= mod
    return (ans_mul * modpow(ans_div, mod-2, mod)) % mod

def modpow(a,b,mod):
    if b == 0: return 1
    if b % 2 == 0:
        h = modpow(a, b//2, mod)
        return (h * h) % mod
    else:
        return (a * modpow(a, b-1, mod)) % mod

if __name__ == '__main__':
    MOD = 1000000007
    words = lambda t : list(map(t, input().split()))
    n,m = words(int)
    ans = 1
    for i in range(2,m):
        if i*i > m:
            break
        cnt = 0
        while m % i == 0:
            m = m // i
            cnt += 1
        #print(i, cnt)
        if cnt != 0:
            ans *= mod_comb(n + cnt - 1,n-1,MOD)
            ans %= MOD
    if m != 1:
        ans *= mod_comb(n,n-1,MOD)
        ans %= MOD

    print(ans)


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

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    long H;
    scan(H);
    int d = "%b".format(H).length.to!int;
    auto ans = 2L^^d - 1;
    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256