akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;


int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	
	string s;
	cin >> s;
	for (int i = 0; i < s.length() - 1; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}	
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
	int n;
	int m;
	int s[5];
	int c[5];
	int b[3];
	int f=0;
	int g=0;
	int i=0;
	int sum=0;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>s[i]>>c[i];
		if(s[i]==1 && c[i]==0)g=1;
	}
	for(i=0;i<3;i++){
		b[i]=0;
	}
	for(i=0;i<m;i++){
		if(b[s[i]-1]==0){
			b[s[i]-1]=c[i];
		}else{
			if(b[s[i]-1]!=c[i]){
				f=1;
				break;
			}
		
		}
	}
	if(n==3 && b[0]==0 && g==1) f=1;
	if(n==2 && b[0]==0 && g==1) f=1;
	if(f==1){
		cout<<-1;
	}else{
		if(n==3){
			sum=b[0]*100+b[1]*10+b[2];
		}
		if(n==2){
			sum=b[0]*10+b[1];
		}
		if(n==1){
			sum=b[0];
		}
		if(n==3 && sum<100) sum=sum+100;
		if(n==2 && sum<10)  sum=sum+10;
		cout<<sum;
	}
}
	
	

Measured memory_bytes: 256
import sys
from itertools import accumulate
read = sys.stdin.read

N, T, *A = map(int, read().split())
a_maximum = list(list(accumulate(A[::-1], max))[::-1])
a = [j - i for i, j in zip(A, a_maximum[1:])]
minimum = max(a)

print(a.count(minimum))

Measured memory_bytes: 14436
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a < b)
		printf("a < b\n");
	if(a > b)
		printf("a > b\n");
	if(a == b)
		printf("a == b\n");
		
	return 0;
}

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

int main() {
  int A;
  cin >> A;
  vector<int> C(A);

  for (int i=0;i<A;i++){
    cin >> C.at(i);
  }

  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());

  int al,bo;al=0;bo=0;

  for (int i=0;i<A;i=i+2){
  al=al+C.at(i);
  }
  for (int i=1;i<A;i=i+2){
  bo=bo+C.at(i);
  }

  cout << al-bo << endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left
def resolve():
    n = int(input())
    A = list(map(int,input().split()))
    E = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = map(int,input().split())
        u -= 1; v -= 1
        E[u].append(v)
        E[v].append(u)

    C = [INF] * (n + 1)
    res = -1
    ans = [None] * n
    change = [None] * n # 行きがけでの変更

    # DFS
    stack = [(0, -1)] # v, p
    while stack:
        v, p = stack.pop()
        if v >= 0:
            idx = bisect_left(C, A[v])
            res = max(res, idx)
            ans[v] = res + 1
            change[v] = (idx, C[idx])
            C[idx] = A[v]
            for nv in E[v]:
                if nv == p:
                    continue
                stack.append((~nv, v))
                stack.append((nv, v))
        else:
            v = ~v
            idx, prev = change[v]
            if prev == INF:
                res -= 1
            C[idx] = prev

    print(*ans, sep='\n')
resolve()

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

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b)
{
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll b, c, n;
    string ans;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];
    b = a[0];
    for(ll i = 1; i < n; i++) b = b^a[i];
    if(b==0)ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
# from sys import exit
R, G, B, N = [int(n) for n in input().split()]
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
ans = 0
for i in range(3001):
    for j in range(3001):
        le = N - i*R - j*G
        if (le) % B == 0 and le >= 0:
            ans += 1
print(ans)


Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int d;
    cin >> s >> d;
    int n = sz(s);

    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(d, vector<ll>(2)));
    dp[0][0][0] = 1;

    REP(i, n) REP(j, d) REP(k, 10) {
        int nd = s[i] - '0';
        int r = (j + k) % d;
        dp[i + 1][r][1] += dp[i][j][1];
        dp[i + 1][r][1] %= MOD;
        // border
        if (k == nd) {
            dp[i + 1][r][0] += dp[i][j][0];
            dp[i + 1][r][0] %= MOD;
        }
        // under
        if (k < nd) {
            dp[i + 1][r][1] += dp[i][j][0];
            dp[i + 1][r][1] %= MOD;
        }
    }
    // REP(i, n + 1) {
    //     cout << i << ": " << endl;
    //     printvv(dp[i]);
    // }

    // 0 の分がカウントされているので1引く
    ll ans = dp[n][0][0] + dp[n][0][1] - 1;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 55424
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }
    int n;
    cin >> n;
    cout << n * 2 * M_PI << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3768
n, m = map(int, input().split())
cities = []
for i in range(m):
    p, y = map(int, input().split())
    cities.append([i, p, y])

cities.sort(key=lambda x: (x[1], x[2]))
now_p = cities[0][1]

j = 1
for i, l in enumerate(cities):
    if now_p != l[1]:
        now_p = cities[i][1]
        j = 1

    l.append(j)
    j += 1

cities.sort(key=lambda x: x[0])
for city in cities:
    print(str(city[1]).zfill(6)+str(city[3]).zfill(6))

Measured memory_bytes: 35652
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<max(0LL,a-2*b);
    return 0;
}


//252908XL

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

int main()
{
  string S;
  cin>>S;
  int x=0, y=0;
  for(int i=0; i<3; i++)
  {
    if(S[i]=='A')
      x++;
    else
      y++;
  }
  if(x==3||y==3)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> >
#define vb vector<bool> 
#define vvb vector<vector<bool> >
#define INF 1145141919810
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
using namespace std;

int main(){
	string a,b,c; cin>>a>>b>>c;
	if(a[a.size()-1] == b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;

int main() {
   int n;
   cin >> n;  
   cout << n/3 << endl;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
if (A-B)%2 == 0:
    ans = abs(A-B)//2
else:
    ans = min(min(A-1,B-1)+1+(abs(A-B)-1)//2,min(N-A,N-B)+1+(abs(A-B)-1)//2)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
int main() {
	// 入力
    string  s;
    int K;
    cin >> s >> K;
 
	
    set<string> s_sub; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < s.length(); ++i)s_sub.insert(s.substr(i, 1)); // 挿入します

    if (s.length()>=2){
        for (int i = 0; i < s.length()-1; ++i)s_sub.insert(s.substr(i, 2));
    }
    if (s.length()>=3){
        for (int i = 0; i < s.length()-2; ++i)s_sub.insert(s.substr(i, 3));
    }
    if (s.length()>=4){
        for (int i = 0; i < s.length()-3; ++i)s_sub.insert(s.substr(i, 4));
    }
    if (s.length()>=5){
        for (int i = 0; i < s.length()-4; ++i)s_sub.insert(s.substr(i, 5));
    }
    //for (int i = 0; i < s.length()-2; ++i)s_sub.insert(s.substr(i, 3));
    //for (int i = 0; i < s.length()-3; ++i)s_sub.insert(s.substr(i, 4));
    //for (int i = 0; i < s.length()-4; ++i)s_sub.insert(s.substr(i, 5));
    //for (int i = 0; i < s.length-1; ++i)s_sub.insert(s.substr(i, 3));
    //for (int i = 0; i < s.length-1; ++i)s_sub.insert(s.substr(i, 4));
    //for (int i = 0; i < s.length-1; ++i)s_sub.insert(s.substr(i, 5));
    //sort(s_sub, s_sub + len(s)*5);
    
    //for(auto x : s_sub) {
    //    cout << x << endl;     // 要素を順に表示
    //}
    auto itr = s_sub.begin();
    for(int i = 0; i < K-1; ++i)
        ++itr;
    cout << *itr << endl; 
    // cout << ans << endl;
}


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

using namespace std;

int main(){
int k=0;
string S;
cin >> S;
for(int i=0;i<(int)S.size();i++){
if(S[i]=='C' && k==0) k++;
if(S[i]=='F' && k==1) k++;
}
if(k==2) cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
int A[100001];
int prime[100000];
bool is_prime[100001];
bool is_2017[100001];
int S[100001];
int Q;

void sieve(int n){
  int p = 0;
  for (int i=0; i <= n; i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for (int i = 2; i <= n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j=2*i; j <= n; j+=i) is_prime[j] = false;
    }
  }
}

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

  sieve(110000);
  rep(i, 110000){
    is_2017[i] = false;
    if (is_prime[i] && is_prime[(i+1)/2]){
      is_2017[i] = true;
    }
  }
  rep(i, 100000){
    if (is_2017[i+1]){
      S[i+1] = S[i]+1; 
    } else S[i+1] = S[i];
  }

  cin >> Q;
  int a, b;
  rep(i, Q){
    cin >> a >> b;
    cout << S[b] - S[a-1] << "\n";
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll l, r;
    cin >> l >> r;
    ll mod = 2019;

    if(r - l >= 2018) cout << 0 << endl;
    else{
        ll res = 10000;
        for(ll x = l; x <= r; x++){
            for(ll y = x; y <= r; y++){
                if(y <= x) continue;
                ll tmp = (x * y) % mod;
                res = min(res, tmp);
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll x,y;
    cin>>x>>y;
    ll a=x;
    int cnt=0;
    while(a<=y){
        a*=2;
        ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def run():
    N = int(input())
    N10 = pow(10, N, mod)
    N9 = pow(9, N, mod)
    N8 = pow(8, N, mod)
    ans = N10 - 2 * N9 + N8
    ans %= mod
    print(ans)


if __name__ == "__main__":
    run()


Measured memory_bytes: 9184
#include <stdio.h>

int main(void){

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

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int x;
  cin>>x;
  cout<<x*360/__gcd(x,360)/x<<endl;
  return 0;
}

Measured memory_bytes: 3536
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(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;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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


	printf("%.10f\n", 2 * N * M_PI);


	return 0;
}


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

using namespace std;

int main()
{
	long long n,a,b,blue,rem;
	blue=0;
	cin>>n>>a>>b;
	if(a+b==n)
	{
		cout<<a;
	}
	else if(a+b<n)
	{
		blue=(n/(a+b))*a;
		rem=n%(a+b);
		if(a>=rem)
		{
			blue+=rem;
		}
		else
		{
			blue+=a;
		}
		cout<<blue;
	}
	else if(a+b>n)
	{
		rem=n;
		if(a>=rem)
		{
			blue+=rem;
		}
		else
		{
			blue+=a;
		}
		cout<<blue;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args ) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    if(X >= 30) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

struct edge {
    lli to;
    lli w;
};

vector<edge> G[100001];
lli done[100001]; // 0は未訪問、1 で奇数、2で偶数


void rec(lli cur) {
    REP(i,0,G[cur].size()) {
        edge e = G[cur][i];
        if (e.w % 2 == 0) {
            if (done[e.to] != 0)
                continue;
            done[e.to] = done[cur];
            rec(e.to);
        }
        else {
            if (done[e.to] != 0)
                continue;
            done[e.to] = done[cur] + 1;
            rec(e.to);
        }
    }
    return;
}
int main() {
    lli n;
    cin1(n);
    REP(i,0,n-1) {
        lli u, v, w;
        cin >> u >> v >> w;
        if (w % 2 == 0)
            w = 2;
        else
            w = 1;
        edge e1 = {v, w};
        edge e2 = {u, w};
        G[u].push_back(e1);
        G[v].push_back(e2);
    }

    done[1] = 1;
    rec(1);
    REPE(i,1,n) {
        cout << done[i] % 2 << endl;
    }
}


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

a=[int(input()) for _ in range(n)]
#a(n+1)!=0の時、a(n+1)=a(n)+1である

cnt=0

if a[0]!=0:
    print(-1)
    exit()
#print(" ".join(list(map(str,a))))
for ii in range(1,n):
    i=n-ii
    if a[i]==0:
        continue
    elif a[i]<=a[i-1]:
        cnt+=a[i]
    elif a[i]==a[i-1]+1:
        cnt+=1
    elif a[i]>a[i-1]+1 or  a[i]>i:
        print(-1)
        exit()
    #print(b)
    #print(" "*(i+1),"^",cnt)

print(cnt)

    
"""
t: 0 1 1 0 1 2 2 1 2
s: 0 0 0 0 0 0 0 0 0
1: 0 0 1 0 0 0 0 0 0
2: 0 1 1 0 0 0 0 0 0
3: 0 1 1 0 0 0 0 1 0
4: 0 1 1 0 0 0 0 1 2
5: 0 1 1 0 0 1 0 1 2

"""





Measured memory_bytes: 88008
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
int main() {
	string a, b, c;
	while (cin >> a) {
		if (a == "0")break;
		cin >> b >> c;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(c.begin(), c.end());
		ll cnt[51][2] = {};
		cnt[0][0] = 1;
		int len = a.length();
		rep(i, len) {
			ll cnt1 = 0; ll cnt2 = 0;
			rep(x, 10) {
				rep(y, 10) {
					rep(z, 10) {
						if (a[i] != '?'&&a[i]-'0' != x)continue;
						if (b[i] != '?'&&b[i]-'0' != y)continue;
						if (c[i] != '?'&&c[i]-'0' != z)continue;
						if (i == len - 1 && (x == 0 || y == 0 || z == 0))continue;
						if (x + y == z)cnt1++;
						if (x + y == 10 + z)cnt2++;
					}
				}
			}
			cnt[i + 1][0] += cnt[i][0] * cnt1; cnt[i + 1][0] %= MOD;
			cnt[i + 1][1] += cnt[i][0] * cnt2; cnt[i + 1][1] %= MOD;
			cnt1 = 0; cnt2 = 0;
			rep(x, 10) {
				rep(y, 10) {
					rep(z, 10) {
						if (a[i] != '?'&&a[i]-'0' != x)continue;
						if (b[i] != '?'&&b[i]-'0' != y)continue;
						if (c[i] != '?'&&c[i]-'0' != z)continue;
						if (i == len - 1 && (x == 0 || y == 0 || z == 0))continue;
						if (x + y +1== z)cnt1++;
						if (x + y +1== 10 + z)cnt2++;
					}
				}
			}
			cnt[i + 1][0] += cnt[i][1] * cnt1; cnt[i + 1][0] %= MOD;
			cnt[i + 1][1] += cnt[i][1] * cnt2; cnt[i + 1][1] %= MOD;
		}
		cout << cnt[len][0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include<cstdio>
int main()
{
    char s[20];
    scanf("%s", s + 1);
    for(int i = 1; i <= 12; i++)
    {
        putchar(s[i]);
        if(i == 4)
            putchar(' ');
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	string S;
	cin>>S;
	if(S=="SUN") cout<<7;
	if(S=="MON") cout<<6;
	if(S=="TUE") cout<<5;
	if(S=="WED") cout<<4;
	if(S=="THU") cout<<3;
	if(S=="FRI") cout<<2;
	if(S=="SAT") cout<<1;
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MOD = (int) 1e9 + 7;
const int MAXN = (int) 1e6;

int fact[MAXN + 1], invfact[MAXN + 1];

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1)
            ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline int comb(int n, int k) {
    return (1LL * fact[n] * ((1LL * invfact[k] * invfact[n - k]) % MOD)) % MOD;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
    if(x < 0)
        x += MOD;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    fact[0] = 1;
    for(i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
    int ans = 0, val = 0, sum = 0;
    for(i = (n + 1) / 2; i <= n - 1; i++) {
        sum += val;
        mod(sum);
        val = (1LL * ((1LL * comb(i - 1, n - i - 1) * fact[i]) % MOD) * fact[n - i - 1]) % MOD - sum;
        mod(val);
        ans = (ans + 1LL * val * i) % MOD;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 
map<ll,int>mp;

int main()
{
	fastIO;
	ll n; cin >> n;
	ll ans = 0;
	for(ll i = 2; i * i <= n; ++i) {
		if(n % i == 0) {
			ll j = n / i;
			//cout << "z" << " " << i << " " << j << endl;
			while(j > i) {
				if(j % i == 0) j /= i;
				else j %= i;
			}
			if(j / i == 1 || j % i == 1) {
				//cout << "z" << " " << j << " " << i << endl;
				ans++;
				mp[i]++;
			}
		}
	}	
	ll m = n - 1;
	for(ll i = 2; i * i <= m; ++i) {
		if(m % i == 0) {
			//cout << "x" << " " << i << " " << m / i << endl;
			if(!mp[i]) {
				ans++; 
				mp[i]++;
			}
			if(!mp[m / i]) {
				mp[m / i]++;
				ans++;
			}
		}
	}	
	if(n == 2) ans = -1;
	cout << ans + 2 << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: [Chars; h],
    }
    let mut dp = Vec::with_capacity(k + 1);
    let mut ans = 0;
    for i in 0..(1 << w) {
        dp.clear();
        dp.resize(k + 1, 0);
        dp[0] = 1;
        for s in s.iter() {
            let cnt = s.iter().enumerate().filter(|p| i >> p.0 & 1 == 1 && *p.1 == '#').count();
            for i in (cnt..=k).rev() {
                dp[i] += dp[i - cnt];
            }
        }
        ans += dp[k];
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=-1;
void Main(){
    int k;
    cin >> k;
    ll now = 0, sm = 7;
    For(i,1,2000000){
        now += sm;
        now %= k;
        sm = (sm * 10) % k;
        if(now == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace kozaiyApp
{
    public class KagamiMochi
    {
        static void Main()
        {
            int ans = 0;
            int N = int.Parse(Console.ReadLine());
            int[] d = new int[N];
            int[] Mochi = Enumerable.Repeat<int>(1000, N).ToArray();

            for (int i = 0; i < N; i++)
            {
                d[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(d);

            for (int i = 0; i < N; i++)
            {
                if (0 > Array.BinarySearch(Mochi, d[i]))
                {
                    int index = Array.IndexOf(Mochi, 1000);
                    Mochi[index] = d[i];
                }
            }

            
            if (0 > Array.IndexOf(Mochi, 1000))
            {
                ans = d.Length;
            }
            else
            {
                ans = Array.IndexOf(Mochi, 1000);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11228
#include <cstdio>
#include <algorithm>

int main()
{
  long long n, a, b, x;
  scanf("%lld %lld %lld %lld", &n, &a, &b, &x);
  
  long long ans = 0;
  for (int i = 1; i < n ; ++i)
  {
    int last = x;
    scanf("%lld", &x);
    ans += std::min((x - last) * a, b);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll d[3003][3003][4];

int main() {
    ios::sync_with_stdio(false);
    int n, m, k, a[3003][3003] = {}, u, v, w;
    cin >> n >> m >> k;
    while (k--) cin >> u >> v >> w, a[u][v] = w;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
        for (int l = 0; l <= 3; l++) {
            d[i][j][1] = max(d[i][j][1], d[i - 1][j][l] + a[i][j]);
            d[i][j][l] = max({d[i][j][l], d[i - 1][j][l], d[i][j - 1][l]});
            if (l) d[i][j][l] = max(d[i][j][l], d[i][j - 1][l - 1] + a[i][j]);
        }
    }
    cout << max({d[n][m][0], d[n][m][1], d[n][m][2], d[n][m][3]});
}


Measured memory_bytes: 319788
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String a = "";
	for(int i = 0; i < s.length(); i++) {
		switch(s.charAt(i)) {
		case '0':
			a += "0";
			break;
		case '1':
			a += "1";
			break;
		case 'B':
			if(a.length() > 0) {
				a = a.substring(0, a.length() - 1);
			}
			break;
		}
	}
	System.out.println(a);
}
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	rep(i, N)
		ans += (i + 1) * (N - i); // 頂点
	rep(i, N - 1) {
		ll u, v;
		cin >> u >> v;
		if (u > v)
			swap(u, v);
		ans -= u * (N - v + 1); // 辺
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n,cnt;
    cin>>n;
    for(int i=6;i>-1;i--)
    {

      if((int)(n/pow(10,i))!=0)
        {cnt=i+1;
        //cout<<n/pow(10,i)<<endl;
        break;
        }
    }
    switch(cnt)
    {
      case 1:cout<<n;
            break;
      case 2:cout<<"9";
            break;
      case 3:cout<<n-90;
            break;
    case 4:cout<<"909";
            break;
    case 5:cout<<n-9090;
            break;
    case 6:cout<<"90909";
            break;
    }
    //cout<<cnt;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		final String FIVE  = "5";
		final String SEVEN = "7";
		
		Scanner scanner = new Scanner(System.in);		
		String input = scanner.nextLine();
		scanner.close();
		
		String[] arrStr = (input.split(" ",0));

		int fivCnt = 0;
		int sevCnt = 0;
		
		for(String num : arrStr) {
			if(num.equals(FIVE)) {
				fivCnt ++;
			} else if(num.equals(SEVEN)) {
				sevCnt ++;
			}
		}
		
		String res;
		if(fivCnt == 2 && sevCnt == 1) {
			res = "YES";
		}else {
			res= "NO";
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21716
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <iostream>

using namespace std;

template <typename T>
struct Graph {
    struct Edge {
        int to;
        T cost;
    };
    using P = pair<T, int>;
    
    vector<vector<Edge>> G;
    int N;
    const T INF;
    vector<T> d;

    Graph(int n, T inf)
    : N(n), INF(inf) {
        G.resize(N);
        d.resize(N);
    }

    void Add(int u, int v, T cost){
        G[u].emplace_back(Edge{v, cost});
    }

    void dijkstra(int s){
        priority_queue<P, vector<P>, greater<P>> que;
        for(auto& c : d) c = INF;
        d[s] = 0;
        que.emplace(P(0, s));

        while(!que.empty()){
            P p = que.top();
            que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(const auto& e : G[v]){
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.emplace(P(d[e.to], e.to));
                }
            }
        }
    }
};

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s, --t;

    constexpr int64_t X = 1000000000000000;

    Graph<int64_t> gs(n, 1000000000000000);
    Graph<int64_t> gt(n, 1000000000000000);
    for(int i = 0; i < m; ++i){
        int u, v;
        int64_t a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        gs.Add(u, v, a);
        gs.Add(v, u, a);
        gt.Add(u, v, b);
        gt.Add(v, u, b);
    }

    gs.dijkstra(s);
    gt.dijkstra(t);

    vector<int64_t> ans(n);
    ans[n-1] = gs.d[n-1] + gt.d[n-1];
    for(int i = n-2; i >= 0; --i){
        ans[i] = min(ans[i+1], gs.d[i] + gt.d[i]);
    }
    for(const auto& c : ans){
        cout << X - c << endl;
    }
}


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

using namespace std;

const int limit = 100010;
using edge = struct {int to; int w;};
vector<edge> tree[limit];
vector<int> color(limit, -1);

void dfs(int v, int p, int w){
    color[v] = w%2;
    for (auto &e : tree[v])
    {
        if (e.to == p)
        {
            continue;
        }
        dfs(e.to, v, w + e.w);
    }
}

void solve() {
    int N;
    cin >> N;
    for (int i = 0; i < N-1; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c %= 2;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    dfs(0, -1, 0);

    for (int i = 0; i < N; i++)
    {
        cout << color[i] << endl;
    }
    
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 10972
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

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

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	a, b, c := readInt(), readInt(), readInt()

	fmt.Println(max(c-a+b, 0))
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll i = 0;
    ll n;
    cin >> n;
    for (ll j=0;j<n;j++){
        ll tmp;
        cin >> tmp;
        if(tmp == i+1){
            i = i+1;
        }
    }
    ll ans = n-i;
    if(ans == n)cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long x,k,d,o,p;
	cin >> x >> k >> d;
	x = abs(x);
	o = x /d;	
	p = x % d;
	if(o <= k){
		if((k - o) % 2 == 0)	cout << p << endl;
		else					cout << d - p << endl;		
	}
	else{
		cout << x - d * k << endl;
	}
	return 0;
}
	

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
   long int a,b[4]={0},c,x,y=0,flag=0,i,j,count,sum,max;
  char k[100*99];
   scanf("%ld\n",&a);
   gets(k);
   for(i=0;i<a+(a-1);i++)
   {
       
       if(k[i]=='P')
       {
           b[0]=1;
       }
       if(k[i]=='W')
       {
         b[1]=1;
       }
       if(k[i]=='G')
       {
           b[2]=1;
       }
       if(k[i]=='Y')
       {
           b[3]=1;
       }
      
   }
   
   if(b[0]+b[1]+b[2]+b[3]==4)
   {
       printf("Four");
   }else{
       printf("Three");
   }
   
     return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
      cin >> v[i];
  }
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i=0; i<v.size()-1; i++) {
      cout << v[i] << " ";
  }
  cout << v[v.size()-1] << endl;
}


Measured memory_bytes: 3112
def MI():return map(int,input().split())
def LI():return list(MI())

x,y,a,b,c=MI()
p=sorted(LI())[::-1][:x]
q=sorted(LI())[::-1][:y]
r=sorted(LI())[::-1]

u=sorted(p+q+r)[::-1][:x+y]
print(sum(u))


Measured memory_bytes: 22548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	string a;
	string b;
	cin>>a;
	cin>>b;
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for(int i=a.size();i<100;i++)
	{
		a+='0';
	}
	for(int i=b.size();i<100;i++)
	{
		b+='0';
	}
	cerr<<a<<endl;
	cerr<<b<<endl;
	for(int i=99;i>=0;i--)
	{
		if(a[i]>b[i])
		{
			cout<<"GREATER"<<endl;
			return 0;
		}else if(a[i]<b[i]){
			cout<<"LESS"<<endl;
			return 0;
		}
	}
	cout<<"EQUAL"<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

const int N = 1e5 + 5;

vector<int> divisors[N];

void buildDivisors() {
  for (int i = 1; i < N; ++i) {
    for (int j = i; j < N; j += i) {
      divisors[j].push_back(i);
    }
  }
}

int cnt[N];
int n , k;

int addDivisors(int x) {
  int res = 0;
  for (int div : divisors[x]) {
    if (cnt[div] == 0) {
      ++res;
    }
    ++cnt[div];
  }
  return res;
}

int removeDivisors(int x) {
  int res = 0;
  for (int div : divisors[x - k]) {
    --cnt[div];
    if (cnt[div] == 0) {
      --res;
    }
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  cin >> n >> k;

  if (k == 0) {
    cout << 1LL * n * n << endl;
    return 0;
  }

  Long res = 0;
  int cnt_unique_divs = 0;

  buildDivisors();

  for (int i = 1; i < k; ++i) {
    cnt_unique_divs += addDivisors(i);
  }

  for (int i = k; i <= n; ++i) {
    cnt_unique_divs += addDivisors(i);
    cnt_unique_divs += removeDivisors(i);

    res += n - cnt_unique_divs;
  }

  cout << res << endl;

}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X, Y;
  cin >> X >> Y;
  ll res = 1;
  while (X <= Y) {
    X *= 2;
    res++;
  }
  cout << --res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<vector<float>> point(N, vector<float>(2, 0));
	float sum_dis = 0;
	float ave_dis = 0;
	float dis;
	int count = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> point[i][0] >> point[i][1];
		for (int j = 0; j < i; j++)
		{
			dis = sqrtf(pow(point[i][0] - point[j][0], 2) + pow(point[i][1] - point[j][1], 2));
			sum_dis += dis;
			count++;
		}
	}
	ave_dis = sum_dis * (N - 1) / count;
	cout << ave_dis << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define cps2(x, y) sort(all(x), y), (x).erase(unique(all(x)), end(x))
#define mem(x, y) memset(& x, y, sizeof(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 2e5 + 123;
int n, q, fen[2][n0];
ll ans;

void upd(int c, int x, int y) {
	for (; x >= 0; x = (x & (x + 1)) - 1)
		fen[c][x] = min(fen[c][x], y);
}

int get(int c, int x) {
	int res = n;
	for (; x <= n; x |= (x + 1))
		res = min(res, fen[c][x]);
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n >> q;
	for (int i = 0; i <= n; i++) fen[0][i] = fen[1][i] = n;
	ans = (ll)(n - 2) * (n - 2);
	while (q--) {
		int t, x;
		cin >> t >> x;
		if (t == 1) {
			int r = get(0, x) - 1;
			upd(1, r, x);
			ans -= r - 1;
		}	else {
			int r = get(1, x) - 1;
			upd(0, r, x);
			ans -= r - 1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 5168
<?php

fscanf(STDIN, "%d%d%d", $a,$b,$c);
$k = trim(fgets(STDIN));

$i = 0;
while($a >= $b){
    $b *= 2;
    $i++;
}

while($b >= $c){
    $c *= 2;
    $i++;
}

if($i > $k){
    echo 'No';
}else{
    echo "Yes";
}


Measured memory_bytes: 16160
n, d = map(int, input().split())
x, y = [], []
for i in range(n):
  a, b = map(int, input().split())
  x.append(a)
  y.append(b)

count = 0
for xi, yi in zip(x, y):
  if xi**2 + yi**2 <= d**2:
    count += 1

print(count)

Measured memory_bytes: 24928
#
# abc059 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """atcoder beginner contest"""
        output = """ABC"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """resident register number"""
        output = """RRN"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """k nearest neighbor"""
        output = """KNN"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """async layered coding"""
        output = """ALC"""
        self.assertIO(input, output)


def resolve():
    s = list(input().split())
    ans = s[0][0]+s[1][0]+s[2][0]
    print(ans.upper())


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

vector<string> vec;
int n,m;

// n<23
int sol1(string s="", int x = 0){
  if(x==n){
    rep(i,m) if(s[i]=='1') return -INF;
    return 0;
  }
  if(x==0){
    s = string(m,'0');
  }
  int ret = sol1(s, x+1);

  // use
  rep(i,m){
    if(s[i]==vec[x][i]) s[i]='0';
    else s[i]='1';
  }
  ret = max(ret, sol1(s, x+1) + 1);

  return ret;
}

// m<23
int sol2(){
  vector<int> v(n);
  rep(i,n){
    int x = 0;
    rep(j,m) x = x*2 + vec[i][j]-'0';
    v[i] = x;
  }

  map<int,int> ma;
  ma[0] = 0;
  rep(i,n){
    auto nm = ma;
    for(auto x : ma){
      nm[x.fi^v[i]] = max(nm[x.fi^v[i]], x.se+1);
    }
    swap(nm, ma);
  }
  return ma[0];
}

int main(){
  while(cin>>n>>m, n|m){
    vec.clear();
    vec.resize(n);
    rep(i,n) cin>>vec[i];

    if(n<=10 && m<=10){
      int r1 = sol1();
      int r2 = sol2();
      assert(r1==r2);
      cout << r1 << endl;
    }
    else if(n<23){
      cout << sol1() << endl;
    }
    else if(m<23){
      cout << sol2() << endl;
    }
    else assert(n*m<=500);
  }

  return 0;
}

Measured memory_bytes: 39844
#include <iostream>
using namespace std;
int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if(a + W >= b && b + W >= a){
    cout << 0;
  } else {
    if (a + W < b){
      cout << (b - (a + W));
    } else {
      cout << (a - (b + W));
    }
  }
  cout << endl;
}

Measured memory_bytes: 256