akhauriyash/Code-Regression huggingface dataset:
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 100000000000
#define LL long long
using namespace std;
map<LL , LL> m;
long long N, M, K, ans,A,B,a[5],b[5];

string s;

int main() {
	A = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		
		if (a[i] % 10 > 0) {
			b[i] = a[i] + (10 - (a[i] % 10));
			A = max(A, 10 - (a[i] % 10));
		}
		else {
			b[i] = a[i];
		}
	}

	for (int i = 0; i < 5; i++) {
		ans += b[i];
	}
	cout << ans-A << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  double sum = 0;
  rep(i, n) sum += vec.at(i);
  int count = 0;
  rep(i, n) {
    if (vec.at(i) >= sum / (4.0 * m)) count++;
  }
  if (count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int n;
    cin >> n;
    for(int i=0;i<30;i++){
        for(int j=0;j<15;j++){
            if(n==4*i+7*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
cost = [0]*n
cost[1] = abs(h[1]-h[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]))
print(cost.pop())

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

int main(void)
{
    int N, M, K;
    cin >> N >> M >> K;

    for (int n = 0; n <= N; n++)
    {
        for (int m = 0; m <= M; m++)
        {
            int val = M*n + N*m - 2*(n*m);
            if(val == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }
    
    cout << "No"<< endl;

    return 0;
}


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

using namespace std;

int main(void)
{
    int64_t N = 0;
    int64_t A = 0, B = 0;

    cin >> N >> A >> B;

    int64_t x = N / (A + B);
    int64_t y = N % (A + B);

    int64_t ans = 0;
    ans += x * A;
    
    if(y > A)
    {
        ans += A;
    }
    else
    {
        ans += y;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
printChessLine :: Int -> Int -> Int -> Int -> String
printChessLine h hh w ww
  | w == 0 = "\n"
  | (mod (ww - w) 2) == 0 && (mod (hh - h) 2) == 0 = "#" ++ printChessLine h hh (w - 1) ww
  | (mod (ww - w) 2) == 1 && (mod (hh - h) 2) == 0 = "." ++ printChessLine h hh (w - 1) ww
  | (mod (ww - w) 2) == 0 && (mod (hh - h) 2) == 1 = "." ++ printChessLine h hh (w - 1) ww
  | (mod (ww - w) 2) == 1 && (mod (hh - h) 2) == 1 = "#" ++ printChessLine h hh (w - 1) ww

printChess h hh w ww
  | h == 0 = ""
  | otherwise = printChessLine h hh w ww ++ printChess (h - 1)  hh w ww

main = do
  hw <- getLine
  if hw == "0 0"
    then
      return []
    else do
      let lhw = map (read :: String -> Int) $ words hw
      putStrLn $ printChess (lhw !! 0) (lhw !! 0) (lhw !! 1) (lhw !! 1)
      main

Measured memory_bytes: 4080
import numpy as np
N, D = map(int, input().split())
XY = []
cnt = 0
for i in range(N):
    XY.append(list(map(int, input().split())))

for i in XY:
    r = np.sqrt(i[0]**2 + i[1]**2)
    if r <= D:
        cnt += 1

print(cnt)


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int result = -1;
    REP(X, N + 1) {
        if ((int)(X * 1.08) == N) {
            result = X;
            break;
        }
    }
    if (result == -1) {
        cout << ":(" << endl;
    } else {
        cout << result << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#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 rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#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);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vector<vector<bool>> done;
int main(){
    ll a=lin(),b=lin(),x=lin();
    if(a>0)cout<<b/x-(a-1)/x<<endl;
    else cout<<b/x+1<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a_list=[input() for _ in range(n)]
b_list=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        f=True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][j+l]!=b_list[k][l]:
                    f=False
                    break
            if not f:
                break
        if f:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62

int main() {
	ll n,d;
	cin>>n>>d;
	ll ch[12][12];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<d;j++){
			cin>>ch[i][j];
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			long double cnt=0;
			for(ll k=0;k<d;k++){
				cnt+=pow(ch[i][k]-ch[j][k],2);
			}
			long double now=cnt;
			for(ll k=0;k<=400;k++){
				if(now==k*k){
					ans++;
					break;
				}
			}
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    string S;
    string T;

    cin >> S;
    cin >> T;


    int length = S.length();

    if(T.compare(0, length, S) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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


int main(){
  while(true){
    int n, x;
    cin >> n >> x;
    if(n == 0 && x == 0){break;}
    int cnt = 0;
    for(int i = 1; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        for(int k = j+1; k < n+1; k++){
          if(i + j + k == x){cnt++;}
        }
      }
    }
    cout << cnt << endl;
  }
}


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


int main(){
  int N,S = 0;
  cin >> N;
  vector<int> a(N+2,0);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  rep(i,N+1) {
    S += abs(a[i] - a[i + 1]);
  }
  for (int i = 1; i <= N; i++) {
    cout << S + abs(a[i-1] - a[i + 1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] i = Console.ReadLine().Split();
            int w = int.Parse(i[0]),
                h = int.Parse(i[1]),
                x = int.Parse(i[2]),
                y = int.Parse(i[3]),
                r = int.Parse(i[4]);
            string arranged = "Yes";

            if (x < r || x > w-r)
            {
               arranged = "No";
            }
            else if (y < r || y > h-r)
            {
               arranged = "No";
            }
            Console.WriteLine(arranged);
        }
    }
}


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

int main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	scanf("%d",&n);
	vector<double> dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		double p_heads;
		scanf("%lf",&p_heads);
		for(int j=i+1;j>=0;--j)
		{
			dp[j]=(j==0?0:dp[j-1]*p_heads)+dp[j]*(1-p_heads);
			//printf("%lf %d ",dp[j],j);
		}
		//printf("\n");
	}

	double ans=0;
	for(int h=0;h<=n;++h)
	{
		int t=n-h;
		if(h>t){
			//cout<<dp[h]<<" ";
			ans+=dp[h];
		}
	}
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int h,w;
  char s[5];
  scanf("%d%d",&h,&w);
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      scanf("%s",s);
      if(s[0]=='s'&&s[1]=='n'&&s[2]=='u'&&s[3]=='k'&&s[4]=='e') {printf("%c%d",j+64,i);return 0;}
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int ans=0;
  for(;;){
    int c=0;
    for(int i=1;i<s.size()-1;i++){
      if(s[i-1]!=s[i+1]){
        c=1;
        s.erase(i,1);
        ans++;
        break;
      }
    }
    if(c==0||s.size()==2){
      break;
    }
  }
  if(ans%2==1)cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>


int main(void)
{
	int n,m,tmpa,tmpb;
	scanf("%d %d\n",&n,&m);
	int a[n],b[n];
	for(int i=0;i<n;++i)
	{
		a[i]=0;
		b[i]=0;
	}
	for(int i=0;i<m;++i)
	{
		scanf("%d %d \n",&tmpa,&tmpb);
		if(tmpa==1)a[tmpb]=1;
		if(tmpb==n)b[tmpa]=1;
	}
	for(int i=0;i<n;++i){
		if(a[i]&b[i]){
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 1664
# AOJ 0122 Summer of Pyonkichi
# Python3 2018.6.21 bal4u
# 深さ優先探索

move = [[-1, -2], [0, -2], [1, -2], \
        [2, -1], [2, 0], [2, 1], \
        [1, 2], [0, 2], [-1, 2], \
        [-2, 1], [-2, 0], [-2, -1]]

while True:
	px, py = list(map(int, input().split()))
	if px == 0 and py == 0: break
	n = int(input())
	arr = [[[0 for ___ in range(10)] for __ in range(10)] for _ in range(10)]
	xy = list(map(int, input().split()))
	for i in range(n):
		x = xy.pop(0)
		y = xy.pop(0)
		for nx in range(x-1, x+2):
			for ny in range(y-1, y+2):
				if nx >= 0 and ny >= 0 and nx <= 9 and ny <= 9: arr[i][nx][ny] = 1
	Q = []
	Q.append([px, py, 0])
	f = True
	while f and len(Q):
		x, y, k = Q.pop()
		for i in range(12):
			nx, ny = x + move[i][0], y + move[i][1]
			if nx >= 0 and ny >= 0 and nx <= 9 and ny <= 9 and arr[k][nx][ny]:
				if k+1 < n: Q.append([nx, ny, k+1])
				else:
					print("OK")
					f = False
					break
	if f: print("NA")


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

int a[200010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", a + i);
	for(int i = n - 1; i >= 0; i -= 2)
		printf("%d ", a[i]);
	for(int i = n % 2; i < n; i += 2)
		printf("%d ", a[i]);
	printf("\n");
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  char s;
  cin >> s;
  char c[4] = { 'A', 'C', 'G', 'T' };
  for (int i = 0; i < 4; i++) {
	  if (s == c[i]) {
		  s = c[3 - i];
		  break;
		}
	}
  cout << s << endl;
  return 0;
}


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

int main(){
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    a1*=t1;
    b1*=t1;
    a2*=t2;
    b2*=t2;
    if(a1+a2<b1+b2){
        swap(a1,b1);
        swap(a2,b2);
    }
    if(a1+a2==b1+b2){cout<<"infinity"<<endl; return 0;}
    if(a1>b1){cout<<0<<endl; return 0;}
    ll c=b1-a1;
    ll d=(a1+a2)-(b1+b2);
    ll ans=(c/d+1)*2-1;
    if(c%d==0)ans--;
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

void solve() {
    lli a = 0, atob = 0, b = 0;
    lli n;
    cin >> n;
    lli A, B;
    cin >> A >> B;
    for (int i = 1; i <= n; ++i) {
        lli x;
        cin >> x;
        if (x <= A) a++;
        else if (x > A and x <= B) atob++;
        else if (x > B) b++;
    }

    cout << min(a, min(atob, b)) << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    solve();

    return 0;
}

Measured memory_bytes: 256
N, X = map(int,input().split())

def keisan(n,x):
    if n == 1:
        if x <= 1:
            return 0
        elif 2 <= x <= 4:
            return x-1
        else:
            return 3
    if x <= 1:
        return 0
    elif 1 < x <= 2**(n+1) - 2:
        return keisan(n-1,x-1)
    elif x == 2**(n+1) - 1:
        return 2**n
    else:
        return 2**n + keisan(n-1,x-(2**(n+1)-1))

print(keisan(N,X))


Measured memory_bytes: 38256
#include<stdio.h>

int main(void)
{
int a,c,b,d,k;
  
  scanf("%d %d %d %d",&a,&b,&c,&k);
  
  if(k<=a) d=k;
  else if(k<=a+b) d=a;
  else d=a-(k-a-b);
  
  printf("%d",d);

return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll x; cin >> x;
    ll first = 100;
    ll count = 0;
    while(first < x){
        first = first * 1.01;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3624
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int N, K;
double P[1000000];
double H[1000000];
int main()
{
	cin >> N >> K;
	rep(i, N) {
		cin >> P[i];
		H[i] = (P[i] + 1) / 2;
	}
	double sum = 0;
	rep(i, K) {
		sum += H[i];
		
	}
	//rep(i,N)cout << H[i] << " ";
	//cout << endl;
	//cout << sum << endl;
	double ans = sum;
	rep(i, N) {
		if (i + K >= N)break;
		sum -= H[i];
		sum += H[i + K];
		chmax(ans, sum);
		//cout << sum << endl;
	}
	printf("%.7f", ans);
	

}


Measured memory_bytes: 5888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, k;
  cin >> n >> k;
  if (k * 2 - 1 > n) {
    cout << -1 << '\n';
    return 0;
  }
  vector<pair<long long, long long>> ans(n);
  for (int i = 0; i < n; i++) {
    if (i * 2 < n) {
      ans[i].first = k + i;
      ans[i].second = k + n + n / 2 + i;
    } else {
      ans[i].first = k + i;
      ans[i].second = k + n + i - (n + 1) / 2;
    }
    //cerr << ans[i].first << " " << ans[i].second << endl;
  }
  //cerr << "end\n";
  sort(ans.begin(), ans.end(), [](const pair<long long, long long>& x, const pair<long long, long long>& y) { return x.first + x.second < y.first + y.second;});
  for (int i = 0; i < n; i++) {
    //assert(ans[i].first + ans[i].second < k +  n * 2 - 1 + i);
    cout << ans[i].first << " " << ans[i].second << " " << k + n * 2 + i << '\n';
  }
  return 0;
}

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

int main(void){
    int x,y;
    cin>>x>>y;
    int g[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    cout<<(g[x]==g[y] ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
W = [ [] for _ in range(N) ]
used = [-1] * N

for i in range(N-1):
    u,v,w = map(int,input().split(" "))
    W[u-1].append(( v-1, w))
    W[v-1].append((u-1, w))

used[0] = 0
lst = [ 0 ]
while len(lst) != 0:
    newList = []
    for v in lst:
        for (nx, w) in W[v]:
            if used[nx] == -1:
                if w % 2 == 0:
                    used[nx] = used[v]
                else:
                    used[nx] = (used[v] + 1) % 2
                newList.append(nx)
    lst = newList

for ans in used:
    print(ans)


Measured memory_bytes: 70688
package main

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

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	var answers []int
	ans := 0
	latest := 0
	
	for i := 0; i < n; i++ {
		scanner.Scan()
		num, _ := strconv.Atoi(scanner.Text())
		
		if latest >= num {
			ans++
		} else {
			answers = append(answers, ans)
			ans = 0
		}
		
		latest = num
		
		if i == n-1 {
			answers = append(answers, ans)
		}
	}
	
	ans = 0
	
	for _, num := range answers {
		if num > ans {
			ans = num
		}
	}
	
	fmt.Println(ans)
}


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

int main() {
  
  int A, B;
  cin >> A >> B ;
  
  if (A != 2 && B != 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
return 0;
}

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

Measured memory_bytes: 3636
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

vs split(string str, string delim) {
	vs result;
	int pos;

	while((pos = str.find_first_of(delim)) != str.npos) {
		if(pos > 0) {
			result.push_back(str.substr(0, pos));
		}
		str = str.substr(pos+1);
	}
	if(str.length() > 0) {
		result.push_back(str);
	}

	return result;
}

int main() {
	vs str;
	string s;
	while(cin >> s) {
		str.push_back(s);
	}

	int size = str.size()/2 + 1;
	vvi field(size, vi(size));
	REP(i, str.size()) {
		vs num = split(str[i], ",");
		
		int sy = min(i, size-1);
		int sx = max(0, i-size+1);
		REP(j, num.size()) {
			field[sy-j][sx+j] = toInt(num[j]);
		}
	}

	vvi dp(size, vi(size));
	REP(i, size) {
		REP(j, size) {
			if(i == 0 && j == 0) {
				dp[i][j] = field[i][j];
			} else if(i == 0) {
				dp[i][j] = dp[i][j-1] + field[i][j];
			} else if(j == 0) {
				dp[i][j] = dp[i-1][j] + field[i][j];
			} else {
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]) + field[i][j];
			}
		}
	}

	cout << dp[size-1][size-1] << endl;
	return 0;
}

Measured memory_bytes: 1284
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

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

struct frac{
	ll a, b;
	void pr(){
		ll g = gcd(a, b);
		a /= g;
		b /= g;
	}
	bool operator == (const frac &p) const{
		return (ll)(a * p.b) == (ll)(b * p.a);
	}
	bool operator < (const frac &p) const{
		return (ll)(a * p.b) < (ll)(b * p.a);
	}
};

frac add(frac q, frac p){
	ll l = lcm(q.b, p.b);
	q.a *= (l / q.b);
	p.a *= (l / p.b);
	frac now = (frac){q.a + p.a, l};
	now.pr();
	return (frac)now;
}

frac sub(frac q, frac p){
	p.a = -p.a;
	ll l = lcm(q.b, p.b);
	q.a *= (l / q.b);
	p.a *= (l / p.b);
	frac now = (frac){q.a + p.a, l};
	now.pr();
	return (frac)now;
}

frac mul(frac q, frac p){
	frac ret = (frac){q.a * p.a, q.b * p.b};
	ret.pr();
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	frac in = (frac){4, n};
	repn(i, 1, 3501) repn(j, 1, 3501){
		frac a = (frac){1, i};
		frac b = (frac){1, j};
		frac c = add(a, b);
		if(c < in){
			frac res = sub(in, c);
			if(res.a == 1 && res.b > 0){
				cout << i << " " << j << " " << res.b << endl;
				return 0;
			}
		}
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 100010
vector<ll> g[N];
ll col[N];
ll cnt;
bool nibu;
void dfs(ll x,ll c){
	if(~col[x]){
		if(c!=col[x])nibu=0;
		return;
	}
	cnt++;
	col[x]=c;
	for(auto y:g[x])dfs(y,c^1);
}
ll n,m;
int main(){
	cin>>n>>m;
	rep(i,m){
		ll a,b; cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i,n)col[i]=-1;
	ll nonone=0;
	ll sei=0,nisei=0;
	rep(i,n)if(col[i]==-1){
		cnt=0;
		nibu=1;
		dfs(i,0);
		if(cnt>1){
			nonone+=cnt;
			sei++;
			if(nibu)nisei++;
		}
	}
	ll ans=n*n-nonone*nonone;
	ans+=sei*sei+nisei*nisei;
	cout<<ans<<endl;
}





Measured memory_bytes: 11520
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int a,b,c;
  cin >> a >> b >> c;

  cout << min(c, b / a) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static BigDecimal MAX = new BigDecimal(1_000_000_000_000_000_000L);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = Long.valueOf(sc.next().replace(".", ""));
        long ans = a * b / 100;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 36076
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 400
#define MAXM 100000
#define INF 2000000000
#define INF2 1000000000000000000LL
#define LL long long
LL sumcost,C[MAXM],val[MAXN],ans,d[MAXN];
int Adj[MAXN],V[MAXM],nxt[MAXM],W[MAXM],c=1;
void AddEdge(int u,int v,int w,LL cost)
{
	c++;V[c]=v,W[c]=w,C[c]=cost,nxt[c]=Adj[u];Adj[u]=c;
	c++;V[c]=u,W[c]=0,C[c]=-cost,nxt[c]=Adj[v];Adj[v]=c;
}
int tg[MAXN],h[MAXN],id,S,T,F,n,m;
int dfs(int u,int in)
{
	tg[u]=id;
	if(u==T)
	{
		F+=in;
		return in;
	}
	for(int i=h[u];i;i=nxt[i])
		if(tg[V[i]]!=id&&W[i]>0&&d[V[i]]+C[i]==d[u])
		{
			int nf=dfs(V[i],min(in,W[i]));
			if(nf)
			{
				W[i]-=nf,W[i^1]+=nf,h[u]=i;sumcost+=C[i]*nf;
				return nf;
			}
		}
	h[u]=0;
	return 0;
}
bool Find()
{
	LL k=-INF2;
	for(int u=S;u<=T;u++)
		if(tg[u]==id)
			for(int i=Adj[u];i;i=nxt[i])
				if(tg[V[i]]!=id&&W[i]>0)
					k=max(k,d[V[i]]+C[i]-d[u]);
	if(k==-INF2) return 0;
	for(int u=S;u<=T;u++) if(tg[u]==id) d[u]+=k;
	return 1;
}
void ZKW()
{
	for(int i=S;i<=T;i++) d[i]=0;
	F=0,sumcost=0;
	do
	{
		id++;
		for(int i=S;i<=T;i++) h[i]=Adj[i];
		while(dfs(S,INF)) id++;
	}while(Find());
}
void Min(int &x,int y)
{
	if(y<x) x=y;
}
void Max(int &x,int y)
{
	if(y>x) x=y;
}
int a[MAXM],b[MAXM],t[MAXM],p[MAXN][4],x[MAXN],y[MAXN];
void Solve(int tot)
{
	memset(Adj,0,sizeof Adj);c=1;
	for(int i=1;i<=tot;i++) p[i][0]=p[i][2]=1,p[i][1]=p[i][3]=100;
	for(int i=1;i<=m;i++)
	{
		if(b[i]>=tot) continue;
		if(t[i]&1) Min(p[tot-b[i]][t[i]],a[i]-1);
		else Max(p[b[i]+1][t[i]],a[i]+1);
	}
	for(int i=2;i<=tot;i++)
	{
		Max(p[i][0],p[i-1][0]);
		Max(p[i][2],p[i-1][2]);
	}
	for(int i=tot-1;i>=1;i--)
	{
		Min(p[i][1],p[i+1][1]);
		Min(p[i][3],p[i+1][3]);
	}
	S=1,T=2*tot+2*n+2;
	int k=tot*2+1;
	for(int i=1;i<=tot;i++)
		AddEdge(S,i*2,1,0),AddEdge(i*2+1,T,1,0);
	for(int i=1;i<=n;i++) AddEdge(k+i,k+n+i,1,val[i]);
	for(int i=1;i<=tot;i++)
		for(int j=1;j<=n;j++)
		{
			if(p[i][0]<=x[j]&&x[j]<=p[i][1]) AddEdge(i*2,k+j,1,0);
			if(p[i][2]<=y[j]&&y[j]<=p[i][3]) AddEdge(k+n+j,i*2+1,1,0);
		}
	ZKW();
	if(F==tot) ans=max(ans,sumcost);
}
int main()
{
	char s[5];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%lld",&x[i],&y[i],&val[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%s%d%d",s,&a[i],&b[i]);
		if(s[0]=='L') t[i]=0;
		else if(s[0]=='R') t[i]=1;
		else if(s[0]=='D') t[i]=2;
		else t[i]=3;
	}
	for(int i=1;i<=n;i++)
		Solve(i);
	printf("%lld\n",ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
void findAns()
{
    string s, t;
    cin >> s >> t;

    int dp[s.size() + 1][t.size() + 1];

    for (int i = 0; i <= s.size(); i++)
    {
        for (int j = 0; j <= t.size(); j++)
        {
            if (i == 0 or j == 0) dp[i][j] = 0;
            else if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans = "";
    int i = s.size();
    int  j = t.size();
    while (i > 0 and j > 0)
    {
        if (s[i - 1] == t[j - 1]) ans += s[i - 1], i--, j--;
        else if (dp[i - 1][j] > dp[i][j - 1])i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}
int main()
{


    FAST;

    // ll int t;
    // cin >> t;
    // while (t--)
    findAns();

    return 0;
}

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


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




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

using namespace std;

int main(void) {
    string s, t;
    cin >> s;
    cin >> t;

    bool ok;
    for(long i=s.size()-t.size(); i>=0; i--) {
        ok = true;
        for(long j=0; j<t.size(); j++)
            ok &= (s[i+j] == '?') || (s[i+j] == t[j]);

        if(!ok) continue;

        for(long j=0; j<t.size(); j++)
            s[i+j] = t[j];
        break;
    }
    if(!ok) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(long i=0; i<s.size(); i++)
        if(s[i] == '?') s[i] = 'a';

    cout << s << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static long a, b, h[];
	
	/*rより小さいenough()をみたす値の最大値を返す
	 * なければー１を返す*/
	public static long halflower(long r, long l) {		
		long m;
		
		while(l < r) {
			m = (r + l) / 2;
			if(r - l <= 1) {
				if(enough(m + 1))return m + 1;
				else return m;
			}
			else {
				if(enough(m))r = m;
				else l = m;
			}
		}
		
		if(enough(0))
		return 0;
		else return -1;
	}
	
	
	public static boolean enough(long t) {
		long count = 0, tmp = 0;
		int n = h.length;
		
		for(int i = 0; i < n; ++i) {
			tmp = h[i] - b * t;
			if(tmp > 0)count += (long)Math.ceil((double)tmp / (double)(a - b));
		}
		if(count <= t)return true;
		else return false;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n;
		long count;
		n = sc.nextInt();
		a = sc.nextLong();
		b = sc.nextLong();
		h = new long[n];
		for(int i = 0; i < n; ++i)h[i] = sc.nextLong();
		sc.close();
		
		Arrays.sort(h);
		count = halflower((long)Math.ceil((double)h[n - 1] / (double)b), 0);
		
		
		System.out.println(count);
	}

}


Measured memory_bytes: 64040
n, w = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

# dp[i][j] := i番目までの品物の中から重さがjを超えないように選んだときの、価値の総和の最大値
dp = [[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        weight = info[i][1]
        value = info[i][0]
        if j < weight:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-weight] + value)
print(dp[n][w])



Measured memory_bytes: 25516
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char[] c=sc.next().toCharArray();
        int k=0;
        for(int i=0, s=0;i<c.length;++i){
            if(i==0 || c[i]!=s){
                s=c[i];
                k++;
            } else if(++i<c.length){
                s=0;
                k++;
            }
        }
        System.out.println(k);
    }
}


Measured memory_bytes: 26568
#include <stdio.h>

int main(){
	int a[5],b[5] = {0,0,0,0,0},max = 0,x = -1,sum = 0;
	for(int i = 0;i < 5;i++){
		scanf("%d",&a[i]);
		if(a[i] % 10 != 0){
			if((a[i]+10) / 10 * 10 - a[i] > max){
				max = (a[i]+10) / 10 * 10 - a[i];
				x = i;
			}
		}
	}
	b[x] = 1;
	for(int i = 0;i < 5;i++){
		if(a[i] % 10 == 0) sum += a[i];
		else{
			if(b[i] != 1) sum += (a[i]+10) / 10 * 10;
			else sum += a[i];
		}
	}
	printf("%d",sum);
	return 0;
}


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

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

Measured memory_bytes: 3612
/*#include <iostream>
using namespace std;
int main() {
	char X,Y;
	cin >> X;
	cin >> Y;
	if (X > Y) {
		cout << ">";
		return 0;
	}
	if (X < Y) cout << "<";
	else cout << "=";

	return 0;
}	*/
/*
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>p;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	sort(p.begin(), p.end());
	int suma= 0;
	bool b =true;
	for (int i = N-1; i >=0; i--) {
		if (b) {
			suma += p[i];
			b = false;
		}
		else {
			suma -= p[i];
			b = true;
		}
	}

	cout << suma;

	return 0;
*/

/*
	#include <iostream>
	#include <algorithm>
	#include <vector>
	using namespace std;

	int main() {
		int N;
		cin >> N;
		vector < int>t;
		int suma = 0;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			suma += a;
			if (a % 10 != 0) {
				t.push_back(a);
			}
		}

		int minElement = *std::min_element(t.begin(), t.end());

		
		if (suma % 10 == 0 && !t.empty()) {
			suma -= minElement;
			cout << suma << endl;

		}
		else if (t.empty()) {
			cout << 0 << endl;
		}
		else cout << suma << endl;
		
		return 0;
	}	*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		++m[a];
	}
	int cont = 0;
	for (std::map<int, int>::iterator itp = m.begin(); itp != m.end(); ++itp) {
		if (itp->first != itp->second) {
			
			if (itp->first < itp->second) cont = cont + (itp->second-itp->first);
			else 
			{
			 cont += itp->second;
			
			}
				
		}
	}
	cout << cont << endl;
	
	return 0;
}

Measured memory_bytes: 8012
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(A);
		System.out.println(Math.abs(A[0] - A[N-1]));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;

const int INF = 1001001001;

int c[10][1005];

int main()
{
	fast;
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	forn(i, h) cin >> s[i];
	int ans  = INF;
	forn(div, 1 << (h - 1)) {
		int g = 0;
		vector<int> id(h);
		forn(i, h) {
			id[i] = g;
			if (div >> i & 1) g++;
		}
		g++;
		forn(i, g) forn(j, w) c[i][j] = 0;
		forn(i, h) forn(j, w) c[id[i]][j] += (s[i][j] - '0');

		int num = g - 1;
		vector<int> now(g);
		auto add = [&](int j) {
			rep(i, g) now[i] += c[i][j];
			rep(i, g) if (now[i] > k) return false;
			return true;
		};
		rep(j, w) {
			if (!add(j)) {
				num++;
				now = vector<int>(g);
				if (!add(j)) {
					num = INF;
					break;
				}
			}
		}
		ans = min(ans, num);
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  multiset<int> S;
  rep(i, n) {
    S.insert(a[i]);
    auto itr = S.find(a[i]);
    if (itr != S.begin()) S.erase(--itr);
  }
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 5376
# coding: utf-8
# Your code here!

num=[]
while True:
    num.append(list(map(int,input().split(" "))))
    if num[-1]==[-1,-1,-1]:
        num=num[:-1]
        break

def saiten(lst):
    tmp=""
    if lst[0]== -1 or lst[1]== -1:
        tmp="F"
    elif lst[0]+lst[1]>=80:
        tmp="A"
    elif lst[0]+lst[1]>=65:
        tmp="B"
    elif lst[0]+lst[1]>=50:
        tmp="C"
    elif lst[0]+lst[1]>=30:
        if lst[2]>=50:
            tmp="C"
        else:
            tmp="D"
    else:
        tmp="F"
    return tmp
ans=[saiten(i)for i in num]
for i in ans:
    print(i)


Measured memory_bytes: 5612
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 1e5+10;

//head

int n;
int a[N][3];
int dp[N][3];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) rep(j, 3) cin >> a[i][j];
  rep(i, n) {
    rep(j, 3) rep(k, 3) {
      if(j == k) continue;
      chmax(dp[i+1][j], dp[i][k] + a[i][j]);
    }
  }

  cout << *max_element(dp[n], dp[n]+3) << endl;
}

Measured memory_bytes: 5916
N = int(input())
A =[]
ma = 0
se = 0
for i in range(N):
  a = int(input())
  A.append(a)
  ma = max(ma,a)
b = sorted(A)
ma = b[N-1]
se = b[N-2]
for i in range(N):
  if A[i]==ma:
    print(se)
  else:
    print(ma)

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

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

int main() {
  int n; cin >> n;
  
  long long int ans = 0;
  int minus = 0;
  int minimum = 2e9;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int temp; cin >> temp;
    if (temp < 0) {minus++; temp *= -1;}
    minimum = min(minimum, temp);
    ans += temp;
  }
  
  if (minus % 2 == 1) ans -= 2 * minimum;
  
  cout << ans << endl;
  
}

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

using namespace std;
 
void solve() {
    string s;
    cin >> s;

    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }

    cout << s << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


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


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

using namespace std;

int main (void)
{
    long long int A;
    double B;

    scanf("%lld",&A);
    scanf("%lf",&B);

    printf("%lld", (A*(long long int)(100*B + 0.1)/100));

//    cout<<A*B<<endl;
//    printf("%lld", (A*(long long int)(100*B+0.5))/100);

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

void showSet(set<int> &st)
{
  for (auto& e : st) cerr << e << ' ';
}

int main()
{
  int N;
  cin >> N;
  vector<ll> a(N);
  vector<int> aidx(N);
  REP(i, N) {
    cin >> a[i];
    aidx[a[i] - 1] = i;
  }

  set<int> st;
  st.insert(N);

  vector<int> m(N);
  REP(i, N) {
    auto itr = st.upper_bound(aidx[i]);
    st.insert(aidx[i]);
    m[aidx[i]] = *itr;
  }
  SHOWVEC(m, m.size());

  vector<ll> S(N + 1, 0);
  for (int i = N - 1; i >= 0; i--) {
    S[i] = a[i] * (m[i] - i) + S[m[i]];
  }

  ll ans = 0;
  REP(i, N) ans += S[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
int n,x[100],y[100],i;
long double d;
int main(void){
  cin>>n;
  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<n;i++)cin>>y[i];
  for(i=0;i<n;i++)d+=abs(x[i]-y[i]);
  printf("%Lf\n",d);
  d=0;
  for(i=0;i<n;i++)d+=pow(x[i]-y[i],2);
  printf("%Lf\n",sqrt(d));
  d=0;
  for(i=0;i<n;i++)d+=pow(abs(x[i]-y[i]),3);
  printf("%Lf\n",cbrtl(d));
  d=0;
  for(i=0;i<n;i++)d=d>fabs(x[i]-y[i])?d:fabs(x[i]-y[i]);
  printf("%Lf\n",d);
  return 0;
}



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

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

    int n;
    cin >> n;
    cout << (n+1) / 2 - 1 << endl;

    return 0;
}

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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll ans = 0;
    rep(i, N) {
        if (A[i] >= B[i]) {
            // モンスターの方が多いか同じ場合
            ans += B[i];
            A[i] = A[i] - B[i];
            B[i] = 0;
        } else {
            // 倒せる数の方が多い場合
            ans += A[i];
            B[i] = B[i] - A[i];
            A[i] = 0;
            if (A[i+1] >= B[i]) {
                ans += B[i];
                A[i+1] = A[i+1] - B[i];
                B[i] = 0;
            } else {
                ans += A[i+1];
                B[i] = B[i] - A[i+1];
                A[i+1] = 0;
            }
        }
        // cout << "i = " << i << endl;
        // rep(j, N+1) cout << A[j] << " ";
        // cout << endl; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout<<min(a,b)+min(c,d);
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;
const ll h = 2e10+1;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) {
        res[n] = 1;
    }
    return res;
}



int main(){
  ll N,P; cin>>N>>P;

  if ( N == 1){
    cout<<P<<endl;
    return 0;
  }
  map<ll,ll> m;
  m = prime_factor(P);
  ll ans = 1;
  for(ll i = 2; i*i <= P; i++){
    if(m[i]/N){
      ans *= modpow(i,m[i]/N,MOD);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 62720
from datetime import datetime
while 1:
 try:y,m,d=map(int,input().split())
 except:break
 dt = (datetime(y,m,d)-datetime(1868,9,8)).days
 if dt<0:print('pre-meiji')
 elif dt<16030:print('meiji',y-1867,m,d)
 elif dt<21291:print('taisho',y-1911,m,d)
 elif dt<43951:print('showa',y-1925,m,d)
 else:print('heisei',y-1988,m,d)


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

constexpr double fou = 20 - 5 * 3.1415926535897932384626433832, ff = 10 * 3.1415926535897932384626433832 - 20;
long long int x[4], N, a, b, my, My, dp[364364], n, d;
vector<pair<long long, long long>> fs;
vector<long long> v;

int main(){
    scanf("%lld%lld%lld%lld%lld", x, x + 1, x + 2, x + 3, &N);
    if(*x > x[2]){swap(*x, x[2]); swap(x[1], x[3]);}
    my = min(x[1], x[3]);
    My = x[1] + x[3] - my;
    d = 1 - 2 * (x[1] > x[3]);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &a, &b);
        if(*x <= a && a <= x[2] && my <= b && b <= My){
            fs.push_back({a, b * d});
        }
    }
    if(*x != x[2] && x[1] != x[3]){
        sort(fs.begin(), fs.end());
        fill(dp, dp + 364364, 114514893);
        for(auto p : fs){
            *lower_bound(dp, dp + N, p.second) = p.second;
        }
        n = lower_bound(dp, dp + N, 114514893) - dp;
        if(n == min(x[2] - *x, My - my) + 1)printf("%.15f", (x[2] - *x + My - my) * 100 - fou * (n - 1) + ff);
        else printf("%.15f", (x[2] - *x + My - my) * 100 - fou * n);
    }else{
        printf("%.15f", (x[2] - *x + My - my) * 100 + (ff * fs.size()));
    }
    return 0;
}


Measured memory_bytes: 7148