akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  [y1,m1,d1,y2,m2,d2] <- getl $ split toInt
  when (y1 > 0 && m1 > 0 && d1 > 0 && y2 > 0 && m2 > 0 && d2 > 0) $ do
    print $ solve (y1,m1,d1) (y2,m2,d2)
    main

solve :: YMD -> YMD -> Int
solve (y1,m1,d1) (y2,m2,d2) = ytod y1 y2 + yday (y2,m2,d2) - yday (y1,m1,d1)

leapyear :: Int -> Bool
leapyear y
  | y `mod` 400 == 0 = True
  | y `mod` 100 == 0 = False
  | y `mod` 4 == 0 = True
  | otherwise = False

yday :: YMD -> Int
yday (y,m,d)
  | leapyear y = d + (sum . take m) ms2
  | otherwise = d + (sum . take m) ms1
  where
    ms1 = [0,31,28,31,30,31,30,31,31,30,31,30]
    ms2 = [0,31,29,31,30,31,30,31,31,30,31,30]

ytod :: Int -> Int -> Int
ytod y1 y2 = (sum . map (\x -> if leapyear x then 366 else 365)) [y1 .. y2 - 1]

toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

type YMD = (Int,Int,Int)

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
struct union_find{
    vector<int> par;
    vector<int> rank;
    union_find(int sz){
        par.resize(sz);
        rank.assign(sz,0);
        for(int i=0; i<sz; ++i) par[i]=i;
    }
    int find(int a){
        if(par[a]==a) return a;
        else return par[a] = find(par[a]);
    }
    void unite(int a,int b){
        int root_a,root_b;
        root_a = find(a),root_b = find(b);
        if(rank[root_a]>rank[root_b]){
            par[root_b] = root_a;
        }else if(rank[root_a]<rank[root_b]){
            par[root_a] = root_b;
        }else{
            rank[root_a]++;
            par[root_b] = root_a;
        }
    }
    bool same(int a,int b){return find(a)==find(b);}
};
vector<vector<int>> eList, rList; // 隣接リスト
vector<int> used;
vector<int> order; // 訪問順

void dfs(int x){
    used[x] = 1;
    for(int v: eList[x]){
        if(used[v] == 0) dfs(v);
    }
    order.push_back(x); // 帰りがけの訪問順を記録する
}

void rdfs(int x, vector<int> &ret){
    used[x] = 2;
    ret.push_back(x);
    for(int v: rList[x]){
        if(used[v] == 1) rdfs(v, ret);
    }
}

int main(){
    int n; // 頂点数
    int m; // 辺数
    cin >> n >> m;
    eList.resize(n);
    rList.resize(n);
    for(int i=0; i<m; ++i){
        int s, t;
        cin >> s >> t;
        eList[s].push_back(t);
        rList[t].push_back(s);
    }

    used.assign(n, 0);
    //order = vector<int>();
    for(int i=0; i<n; ++i){ // DFSをして番号をつける
        if(used[i]==0) dfs(i);
    }

    vector<vector<int>> result; // 強連結成分である頂点集合を格納する
    for(int i=n-1; i>=0; --i){ // 番号の大きな頂点から、辺を逆にしてDFS
        if(used[order[i]] == 1){
            result.emplace_back();
            rdfs(order[i], result.back());
        }
    }

    union_find uf(n);
    for(auto i : result){
        int tmp=i.front();
        for(auto j : i) uf.unite(tmp,j);
    }

    int q; cin >> q;
    for(int i=0; i<q; ++i){
        int u, v;
        cin >> u >> v;
        cout << uf.same(u,v) << endl;
    }
    
}


Measured memory_bytes: 4812
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
#define EPS 1e-6
#define N 10

int main(void){
	int a, v1=0, v2=0;
	vi x(N);
	while (cin>>a){
		char c;
		x[0] = a;
		for (int i=1; i<N;i++){
			cin>>c>>a;
			x[i] = x[i-1]+a;
		}
		cin>>c>>v1>>c>>v2;

		double r=1.0*x[N-1]*v1/(v1+v2);
		for (int i=0; i<N; i++)
			if (r<x[i] || fabs(r-x[i])<EPS){
				cout<<i+1<<endl;
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 1192
s=input()
a=0
b=["A","C","G","T"]
k=0
for i in range(len(s)):
    if s[i] in b:
        k+=1
        if i==len(s)-1 and k>a:
            a=k
    else:
        if k>a:
            a=k
        k=0

print(a)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
int main(){
    int x;cin>>x;
    cout<<8-(x-400)/200<<endl;
    return 0;
}


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

int main() {
    string alphabets = {'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'};
    char C;
    cin >> C;
    for (long long i = 0; i < 26; ++i) {
        if (alphabets[i] == C) {
            cout << alphabets[i + 1] << endl;
        }
    }
    return 0;
}


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

int main() {
	cin.sync_with_stdio(false);
	int N, L;
	cin >> N >> L;
	vector<string>S(N);
	for (int i = 0;i < N;i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int i = 0;i < N;i++) {
		cout << S[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<ll> b(n + 1);
    map<ll, int> mp;
    for (int i = 1; i <= n; i++)
    {
        b[i] = i - a[i];
        mp[a[i] + i]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ll cur = b[i];
        ans += mp[cur];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 29056
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);


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

	int size = s.size();

	bool ans = false;

	rep(i, 0, size) {

		string box = s;
		rep(j, 0, size) {
			
			if (j == size - 1) {
				s[0] = box[j];

			}
			else {
				s[j + 1] = box[j];
			}

		}

		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;


}
	

Measured memory_bytes: 256
n,m=map(int,input().split())
sgn=[0 for i in range(n)]
penal=[0 for i in range(n)]
pp=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)-1
    if s=='AC':
        if sgn[p]==0: pp+=penal[p]
        sgn[p]=1
    else:
        penal[p]+=1



print(sum(sgn),pp)

Measured memory_bytes: 4656
a, b, c, d = map(int,input())
A = str(a)
B = str(b)
C = str(c)
D = str(d)
if a+b+c+d == 7:
    print(A+'+'+B+'+'+C+'+'+D+'=7')
elif a-b+c+d == 7:
    print(A+'-'+B+'+'+C+'+'+D+'=7')
elif a+b-c+d == 7:
    print(A+'+'+B+'-'+C+'+'+D+'=7')
elif a+b+c-d == 7:
    print(A+'+'+B+'+'+C+'-'+D+'=7')
elif a-b-c+d == 7:
    print(A+'-'+B+'-'+C+'+'+D+'=7')
elif a-b+c-d == 7:
    print(A+'-'+B+'+'+C+'-'+D+'=7')
elif a+b-c-d == 7:
    print(A+'+'+B+'-'+C+'-'+D+'=7')
elif a-b-c-d == 7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')

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

using namespace std;

const int MAXD = 10;
const int MAXP = MAXD * 100;

int cache[MAXD][MAXP];
char cached[MAXD][MAXP];

array<int, MAXD> p, c;

int solve(int rem, int d)
{
  if (d < 0 || !rem) return 0;

  int& res = cache[d][rem-1];
  if (cached[d][rem-1]) return res;
  cached[d][rem-1] = 1;
  res = 0;

  int mx = min(rem, p[d]);
  for (int solved = 0; solved <= mx; ++solved)
  {
    res = max(res, solved*(100*(d+1)) + (solved == p[d] ? c[d] : 0) + solve(rem-solved, d-1));
  }
  return res;
}

int main(int argc, char* argv[])
{

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int D;
  int G;
  cin >> D >> G;

  int all = 0;
  for (int i = 0; i < D; ++i)
  {
    cin >> p[i] >> c[i];
    all += p[i];
  }

  int lo = 1;
  int hi = all;
  while (lo <= hi)
  {
    int mid = (lo + hi) / 2;
    int score = solve(mid, D-1);
    if (score >= G)
    {
      hi = mid - 1;
    }
    else
    {
      lo = mid + 1;
    }
  }

  cout << lo << "\n";

  return 0;
}


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

E_num=S.count('E')
W_num=0
ans=n
for i in range(n):
  if S[i]=='E':
    E_num-=1
    ans=min(ans,E_num+W_num)
  else:
    ans=min(ans,E_num+W_num)
    W_num+=1
print(ans)

Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<cmath>
#define DN 100005
#define x first
#define y second
using namespace std;
int n,f,g,viz[DN],nr,poz,p,p1,p2;
typedef pair<pair<int,int>,int> pii;
pii a[DN],b[DN];
long long rez,rez2;
void solve(pii a[DN],int &p,int type,long long &rez)
{
    while(viz[a[p].y])
        p++;
    viz[a[p].y]=1;
    if(poz>=a[p].x.x&&poz<=a[p].x.y)
        return;
    f=a[p].x.x;
    if(type==0)
        f=a[p].x.y;
    rez+=abs(f-poz);
    poz=f;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x.x>>a[i].x.y;
        a[i].y=i;
        b[i]=a[i];
        swap(b[i].x.x,b[i].x.y);
        a[i].x.x=-a[i].x.x;
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)
    {
        a[i].x.x=-a[i].x.x;
        swap(b[i].x.x,b[i].x.y);
    }
    poz=0;
    nr=n;
    p=p1=p2=1;
    while(nr--)
    {
       p=1-p;
       if(p==0)
        solve(b,p1,0,rez);
        else
            solve(a,p2,1,rez);
    }
    rez+=abs(poz);
    poz=0;
    nr=n;
    p=p1=p2=1;
    for(int i=1;i<=n;i++)
        viz[i]=0;
    while(nr--)
    {
       p=1-p;
       if(p==1)
        solve(b,p1,0,rez2);
        else
            solve(a,p2,1,rez2);
    }
    rez2+=abs(poz);
    cout<<max(rez2,rez);
}


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

int main()
{
    string S, T;
    int ssize, tsize;
    bool flag = false;
    cin >> S >> T;
    ssize = S.size();
    tsize = T.size();
    
    for(int i = ssize - tsize; i >= 0; i--) {
        int j = 0;
        while(j < tsize && (S[i + j] == '?' || S[i + j] == T[j])) j++;
        if(j == tsize) {
            for(j = 0; j < tsize; j++) {
                S[i + j] = T[j];
            }
            flag = true;
            break;
        }
    }
    for(int i = 0; i < ssize; i++) {
        if(S[i] == '?') S[i] = 'a';
    }
    if(flag) cout << S << endl;
    else cout << "UNRESTORABLE" << endl;

    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int n;cin>>n;
    vector<ll > v(n,0),d(n,0);
    rep(i,n)cin>>v[i],d[i]=v[i];
    if(n%2)for(int i=n-5;i>=0;i-=2)rep(j,3){
        d[i+j]=v[i+j];
        if(j==0) d[i+j]+=max({d[i+j+2], d[i+j+3], d[i+j+4]});
        if(j==1) d[i+j]+=max({d[i+j+2], d[i+j+3]});
        if(j==2) d[i+j]+=d[i+j+2];
    }
    if(n%2==0)for(int i=n-4;i>=0;i-=2)rep(j,2){
        d[i+j]=v[i+j];
        if(j==0) d[i+j]+=max({d[i+j+2], d[i+j+3]});
        if(j==1) d[i+j]+=d[i+j+2];
    }
    ll s=-1e16;
    if(n%2) rep(i,min(n,3))s=max(s,d[i]);
    else    rep(i,min(n,2))s=max(s,d[i]);
    cout<<s;

	return 0;
}
 



Measured memory_bytes: 6364
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        
        String s = r.readLine();
        int x = Integer.parseInt(s);
        x = x*x*x;
        
        System.out.println(x);
    }
}

Measured memory_bytes: 24220
N=int(input())
A=list(map(int,input().split()))

A.sort()

dp=[False]*(10**6*2)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6*2-1:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)

Measured memory_bytes: 35492
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int count = 0;

    while(B <= A){
        B *= 2;
        count++;
    }

    while(C <= B){
        C *= 2;
        count++;
    }

    if(count <= K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b,k;std::cin>>a>>b>>k;
    if(b-a+1<=2*k){
        for(int i=a;i<=b;i++){
            std::cout<<i<<std::endl;
        }
    }else{
        for(int i=a;i<=a+k-1;i++){
            std::cout<<i<<std::endl;
        }
        for(int i=b-k+1;i<=b;i++){
            std::cout<<i<<std::endl;
        };
    }
}

Measured memory_bytes: 256
n,q = map(int,input().split())
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    tree[a].append(b)

ans = [0 for i in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

#入力

stack = [0]
while len(stack) > 0:
    now = stack.pop()
    for i in tree[now]:
        ans[i] += ans[now]
        stack.append(i)

for i in range(n):
    print(ans[i],end=" ")
print()

Measured memory_bytes: 91408
#create date: 2020-07-05 13:34

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    g = [list() for _ in range(n)]
    to = list()
    for i in range(n-1):
        a, b = na()
        a -= 1; b -= 1
        g[a].append(b)
        to.append(b)
    l = [-1] * n
    l[0] = 10**10
    q = deque([0])
    while q:
        v = q.popleft()
        vcolor = l[v]
        for i, w in enumerate(g[v]):
            q.append(w)
            if i < vcolor:
                l[w] = i
            else:
                l[w] = i + 1

    print(max(l[1:])+1)
    for i in to:
        print(l[i]+1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 23736
package main

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

func mainFn() {
	n := getInt()
	ls := getIntSlice(n)
	lsRev := make([]int, n)
	copy(lsRev, ls)
	sort.Ints(ls)
	sort.Sort(sort.Reverse(sort.IntSlice(lsRev)))

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			p, q := min(ls[i], ls[j]), max(ls[i], ls[j])
			x, y := q-p, q+p

			l := sort.Search(len(ls), func(i int) bool { return ls[i] > x })
			r := n - sort.Search(len(lsRev), func(i int) bool { return lsRev[i] < y })

			sum := r - l
			if (i >= l) && (i <= r) {
				sum--
			}
			if (j >= l) && (j <= r) {
				sum--
			}
			sum = max(0, sum)
			ans += sum
		}
	}

	ans /= 3
	puts(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

// -----------------------------------------

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// scanner.Buffer(make([]byte, buf), buf)
	scanner.Split(bufio.ScanWords)
	mainFn()
	writer.Flush()
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func puts(a ...interface{}) {
	if _, err := fmt.Fprintln(writer, a...); err != nil {
		panic(err)
	}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i=0;i<n;i++)
	{
		cin >> l.at(i);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				int li=l.at(i),
				    lj=l.at(j),
				    lk=l.at(k);
				if(li==lj||li==lk||lj==lk)
				{
					continue;
				}
				if(li+lj>lk&&li+lk>lj&&lj+lk>li)
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common

#N = int(input())
#N,M= map(int,input().split())
#P = list(map(int,input().split()))

S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)

one=[1,0]*10**5
zero=[0,1]*10**5

o=0
z=0
for i in range(len(S)):
    if one[i] != int(S[i]):
        o+=1
    if zero[i] != int(S[i]):
        z+=1

print(min(o,z))


Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C;cin >> A >> B >> C;
  if(A>C)swap(A,C);
  if(B>C)swap(B,C);
  YESNO(A==5&&B==5&&C==7);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    string s;
    cin >> s;
    
    if( s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    if( s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    if( s == "Rainy"){
        cout << "Sunny" << endl;
    }
    
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;
// 24ñÅ³ÉàÇé
class Dice{
private:
	int yoko;
	int tate;
	int round;
public:
	vector<int> colored;
	Dice(const vector<int> &v){
		init();
		for(int i=0;i<8;i++)colored.push_back(v[i]);
	}
private:
	// _CXÌú»
	void init(){
		yoko=0;
		tate=0;
		round=0;
	}
public:
	// _CXÌñ]
	void rotate(){
		if(round<4){
			round++;
			// z²ðSÉñ]
			int tp[8];
			for(int i=0;i<4;i++){
				tp[(i+1)%4]=colored[i];
				tp[(i+1)%4+4]=colored[i+4];
			}
			for(int i=0;i<8;i++)colored[i]=tp[i];
		}
		if(round>=4){
			round=0;
			// àÇÁÄ«½çA¡ÌXbgðñ]³¹é
			if(yoko<4){
				yoko++;
				int tp[8];
				tp[0]=colored[4];
				tp[1]=colored[5];
				tp[4]=colored[7];
				tp[5]=colored[6];
				tp[2]=colored[1];
				tp[3]=colored[0];
				tp[7]=colored[3];
				tp[6]=colored[2];
				for(int i=0;i<8;i++)colored[i]=tp[i];
			}
			// àÇÁÄ«½çAcÌXbgðñ]³¹é
			if(yoko>=4){
				if(tate<4){
					int loop=1;
					if(tate==1)loop=2;
					while(loop--){
						tate++;
						int tp[8];
						tp[7]=colored[3];
						tp[4]=colored[0];
						tp[6]=colored[7];
						tp[5]=colored[4];
						tp[2]=colored[6];
						tp[1]=colored[5];
						tp[3]=colored[2];
						tp[0]=colored[1];
						for(int i=0;i<8;i++)colored[i]=tp[i];
					}
				}
				if(tate>=4){
					round=0;
					tate=0;
					yoko=0;
				}
			}
		}
	};
};

int main() {
	int cs[8];
	string s;
	while (getline(cin, s)) {
		map<string,int> idxs;
		int idx=0;
		istringstream iss(s);
		for(int i=0;i<8;i++){
			string ts;
			iss>>ts;
			if(idxs.find(ts)==idxs.end())idxs[ts]=idx++;
			cs[i]=idxs[ts];
		}
		set<vector<int> > svs;
		int cnt=0;
		do{
			vector<int> init;
			for(int i=0;i<8;i++)init.push_back(cs[i]);
			Dice d(init);
			// ¡Ìhèûªp^[ÌÇê©Éêv·é©`FbN
			if(svs.find(d.colored)==svs.end()){
				cnt++;
				for(int i=0;i<24;i++){
					svs.insert(d.colored);
					d.rotate();
				}
			}
		}while(next_permutation(cs,cs+8));
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
int n,k,i,j;
cin>>n;
cin>>k;
int x=((n-2)*(n-1))/2;
    if(x<k){
        cout<<-1<<endl;
        return 0;
    }
    vector<pair<int,int> > v;
    for(i=1;i<=n-1;i++){
        v.pb({i,n});
    }
    while(x>k){
        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                v.pb({i,j});
                x--;
                if(x==k)
                    break;
            }
            if(x==k)
                break;
        }
    }
    cout<<v.size()<<endl;
    for(i=0;i<v.size();i++){
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}


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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
	bool all_visited = true;

	for (int i = 0; i < N; ++i) {
		if (visited[i] == false)
			all_visited = false;
	}
	if (all_visited) {
		return 1;
	}

	int ret = 0;

	for (int i = 0; i < N; ++i) {
		if (graph[v][i] == false) continue;
		if (visited[i])continue;

		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}

	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		graph[a-1][b-1] = graph[b-1][a-1] = true;
	}
	
	bool visited[nmax];
	for (int i = 0; i < N; ++i)
		visited[i] = false;

	visited[0] = true;

	cout << dfs(0, N, visited) << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
MAX = 10 ** 5 + 1
f = [True] * (MAX)
c = [0] * (MAX + 1)
for i in range(2, MAX):
    if f[i]:
        for j in range(i + i, MAX, i):
            f[j] = False
for i in range(3, MAX, 2):
    if f[i] and f[(i + 1) // 2]:
        c[i] += 1
for i in range(3, MAX):
    c[i] += c[i - 1]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(c[r] - c[l - 1])



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

int main() {
  
  int N;
  cin >>N;
  
  vector<int>V(N);
  vector<int>C(N);
  vector<int>div(N);
  
  for(int i = 0 ; i < N ; i++){
  	cin >> V.at(i);
  }
 
  for(int i = 0 ; i < N ; i++){
  	cin >> C.at(i);
  } 
  
  int max = 0;

  for(int i = 0 ; i < N ; i++){
	
    if(V.at(i) - C.at(i)>=0){
    	max += V.at(i) - C.at(i);
    }  
  }
  
  
 // sort(div.begin(),div.end());
  
  cout << max << endl;
  
  return 0;
  
 }


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

#define fast ios::sync_with_stdio(0); cin.tie(0)

int f_cost(vector<int> nums) {
  int ans = 1<<30;
  
  for(int i = -100; i <= 100; i++) {
    int tmp = 0;
    for(int j = 0; j < nums.size(); j++)
      tmp += (nums[j]-i) * (nums[j]-i);
    if(tmp < ans)
      ans = tmp;
  }
  return ans;
}


int main(){
  fast;
  int cases, num;
  vector<int> nums;
  cin>>cases;
  while(cases--) {
    cin>>num;
    nums.push_back(num);
  }
  cout<<f_cost(nums)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(0,i,n)cin>>a[i];
    vector<ll>l,r;
    l.resize(n+1);
    r.resize(n+1);
    l[0]=0,r[0]=0;
    rep(0,i,n){
        l[i+1]=max(l[i],a[i]);
        ll x=n-1-i;
        r[i+1]=max(r[i],a[x]);
    }
    rep(0,i,n)cout<<max(l[i],r[n-1-i])<<endl;
}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
#define ll long long
int sum=0;
int n;
bool check(ll x)
{
    bool flag3=0;
    bool flag5=0;
    bool flag7=0;
    int b;
    while (x)
    {
        b = x%10;
        x/=10;
        if (b==3) flag3=1;
        if (b==5) flag5=1;
        if (b==7) flag7=1;
    }
    return (flag3&flag5&flag7);
}
void find(ll x)
{
    if (x>n) return;
    sum+=check(x);
    find(x*10+3);
    find(x*10+5);
    find(x*10+7);
}

int main()
{
    cin>>n;
    find(0);
    cout<<sum<<endl;
    return 0;
}






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

int main()
{
  int n;
  int p[25] = {0};
  int count = 0;
  cin >> n;
  cin >> p[0];
  cin >> p[1];
  for (int i = 2; i < n; i++)
  {
    cin >> p[i];
    if (p[i - 1] > p[i -2] && p[i - 1] <= p[i]) {
      count++;
    } else if (p[i -1] > p[i] && p[i -1] <= p[i - 2]) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N;
vector<pair<int, ll>> tree[100005];
int color[100005];

void dfs(int v, int from, ll dist) {
	color[v] = dist % 2;
	for (auto p : tree[v]) {
		if (p.first == from) continue;
		dfs(p.first, v, dist + p.second);
	}
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N;
    REP(i, N - 1) {
    	ll x, y, w;
    	cin >> x >> y >> w;
    	tree[x].push_back({y, w});
    	tree[y].push_back({x, w});
    }
    dfs(1, 0, 0);
    FOR(i, 1, N) {
    	cout << color[i] << "\n";
    }
    

}


Measured memory_bytes: 9856
N, M = map(int, input().split())
lst = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lst[a].append(b)
    lst[b].append(a)
for l in lst:
    print(len(l))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<utility>
#include<vector>
using namespace std;
const int maxn = 1e5 + 233;
vector<int> g[maxn],tmp;
int a[maxn],vis[maxn];
int n,m,ans = 0,cur = 0;
void dfs(int x)
{
//	cout<<"!"<<x<<endl;
	vis[x] = cur;
	tmp.push_back(x);
	for(int i=0;i<g[x].size();i++)
	{
		int y = g[x][i];
		if(!vis[y])dfs(y);
	}
	return ;
}
void cal()
{
	for(int i=0;i<tmp.size();i++)
	{
		int x = tmp[i];
//		cout<<x<<" ";
		if(vis[a[x]]==cur)ans++;
	}
//	cout<<endl;
	tmp.clear();
	return;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)
	if(!vis[i])
	{
		cur++;
		dfs(i);
		cal();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9212
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int x, t;
  cin >> x >> t;
  cout << max(x - t, 0) << endl;
}



Measured memory_bytes: 256
import numpy as np

N, K = map(int, input().split())
H = list(int(x) for x in input().split())

dp = np.full(N, np.inf)
dp[0] = 0
H = np.array(H)

for i in range(1, N):
    j = max(0,i-K)
    dp[i] = min(dp[j:i] + np.abs(H[i] - H[j:i]))

print(int(dp[N-1]))

Measured memory_bytes: 22824
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    ll N;
    cin >> N;
    vector<ll> A(N), ans(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum ^= A[i];
    }

    rep(i, N) {
        ans[i] = sum ^ A[i];
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6240
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
double x[10], y[10];

double sqr( double x )
{ return x*x; }

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> x[i] >> y[i];

  std::vector<ll> vs( N );

  std::iota( all(vs), 0 );

  double ans = 0;

  do
  {
    double sum = 0;

    rep( i, vs.size()-1 )
      sum += sqrt( sqr(x[vs[i+1]]-x[vs[i]])+sqr(y[vs[i+1]]-y[vs[i]]) );

    ans += sum;
  } while( std::next_permutation( all(vs) ) );

  rep( i, N )
    ans /= i+1;

  printf( "%.12f\n", ans );

  return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 998244353;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n), d(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> d[i];
    }

    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i1, int i2){
        return x[i1] > x[i2];
    });

    stack<int> st;
    vector<ll> dp(n, 1);
    for (int i : ids) {
        while (!st.empty() && x[st.top()] < x[i] + d[i]) {
            (dp[i] *= dp[st.top()]) %= MOD;
            st.pop();
        }
        st.push(i);
        ++dp[i];
    }

    ll ans = 1;
    while (!st.empty()) {
        (ans *= dp[st.top()]) %= MOD;
        st.pop();
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define mod 1000000007
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	ll a, b;
	cin >> a >> b;
	lb k = a, p = b;
	cout << a / b << " " << a % b <<  " " << fixed << set(10) <<k / p << endl;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll a,b,c;
  while(cin>>a>>b>>c){
    if(a==-1&&b==-1&&c==-1)break;

    char grade;
    if(a==-1||b==-1||a+b<30)grade='F';
    else if(a+b<50){
      grade='D';
      if(c>=50)grade='C';
    }else if(a+b<65)grade='C';
    else if(a+b<80)grade='B';
    else grade='A';

    out(grade);
  }

  return 0;
}



Measured memory_bytes: 3112
/**
 *    created by : PawPaw       
**/

#include<bits/stdc++.h>
using namespace std;

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LL long long
#define N 100001
#define PB push_back
#define MP make_pair

int ans[N];
vector<pair<int, int>> adj[N];

void dfs(int u, int befColor){
  int color = 1;
  for(auto v : adj[u]){
    if(ans[v.second] == -1){
      if(color == befColor) color++;
      ans[v.second] = color;
      dfs(v.first, color);
      color++;
    }
  }
}

int solve(){
  int n, total = 0, a, b;
  cin >> n;
  fill(ans, ans+N, -1);
  F(i, 0, n-2){
    cin >> a >> b;
    adj[a].PB(MP(b, i));
    adj[b].PB(MP(a, i));
    total = max(total, max((int)adj[a].size(), (int)adj[b].size()));
  }

  dfs(1, -1);
  cout << total << '\n';
  F(i, 0, n-2){
    cout << ans[i] << '\n';
  }
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

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

  fun();

  return 0;
}

Measured memory_bytes: 7680
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll S[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
              1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll K;
  cin >> K;
  cout << S[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  D,T,S=map(int,pin().split())
  if S*T>=D:
    print("Yes")
  else:
    print("No")
  return 
main()

Measured memory_bytes: 9160
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int H, W, A, B;
    cin >> H >> W >> A >> B;

    int x = H - 2 * B;
    vector< string > ans(H, string(W, '0'));
    rep (i, x)
    {
        for (int j = A; j < W; ++j)
        {
            ans[i][j] = '1';
        }
    }

    char c = '0';
    int offset = 0;
    for (int i = x; i < H; ++i)
    {
        offset ^= 1;
        rep (j, A)
        {
            ans[i][j] = c + (char)offset;
        }
        for (int j = A; j < W; ++j)
        {
            ans[i][j] = c + (char)(offset ^ 1);
        }
    }

    rep (i, H)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,a=0,b=0,c=0,d=0;
cin>>n;
string s;
for(int i=0;i<n;i++)
{cin>>s;
if(s=="AC")
    a++;
else if(s=="WA")
    b++;
else if(s=="TLE")
    c++;
else if(s=="RE")
    d++;
}
cout<<"AC x "<<a<<"\nWA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d;;
}

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

int f[1500];
int main() {
	int v, d;
	while (~scanf("%d%d", &v, &d)) {
		f[0] = 1; f[1] = 2;
		for (int i = 2; i <= v; i++)f[i] = (f[i - 1] + f[i - 2]) % MOD;
		int cnt = 0;
		sort(f + 1, f + v + 1);
		for (int i = 1; i <= v; i++) {
			if (i == 1)cnt++;
			else if (f[i] - f[i - 1] >= d)cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3228
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm>


using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
  return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

ll solve(string &S, int K) {
    ll N = S.size();
    string T = S.substr(0, K);

    vector<ll> accD(K + 1), accM(K + 1), accC(K + 1);
    for (int i = 0; i < K; i++) {
        accD[i + 1] = accD[i] + (T[i] == 'D');
        accM[i + 1] = accM[i] + (T[i] == 'M');
        accC[i + 1] = accC[i] + (T[i] == 'C');
    }

    ll dmc = 0, d = 0, m = 0, nd = 0;
    for (int i = 0; i < K; i++) {
        if (T[i] == 'M') {
            dmc += accD[i] * (accC[K] - accC[i + 1]);
            d += accD[i];
            m++;
        }
        if (T[i] == 'D') {
            nd++;
        }
    }

    for(int i = K; i < N; i++) {
        ll out = i - K;
        ll in = i;
        
        if (S[out] == 'D') {
            d -= m;
            nd--;
        } else if (S[out] == 'M') {
            m--;
        }
        if (S[in] == 'D') {
            nd++;
        } else if (S[in] == 'M') {
            m++;
            d += nd;
        } else if (S[in] == 'C') {
            dmc += d;
        }
    }

    return dmc;
}

void solve() {
    ll N;
    string S;
    cin >> N >> S;
    ll Q;
    cin >> Q;
    vector<ll> K(Q);
    for (int i = 0; i < Q; i++) {
        cin >> K[i];
    }

    for (int q = 0; q < Q; q++) {
        cout << solve(S, K[q]) << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 31400
s = input()
i = len(s)
while i > 0:
    if s[i-5:i] == 'dream' or s[i-5:i] == 'erase':
        i -= 5
    elif s[i-6:i] == 'eraser':
        i -= 6
    elif s[i-7:i] == 'dreamer':
        i -= 7
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A,B,K;
    cin >> A >> B >> K;
    if(K <= A){
        cout << A-K << " " << B << endl;
    }else if(K <= A+B){
        cout << 0 << " " << B-(K-A) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256