akhauriyash/Code-Regression huggingface dataset:
n,m = map(int, input().split())
x = [int(i) for i in input().split()]

x_sort = sorted(x)
check = []
for i in range(len(x)-1):
    check.append(abs(x_sort[i+1] - x_sort[i]))

check_sorted = sorted(check)
ans = 0
if (m-n) >= 0:
    for i in check_sorted[0:m-n]:
        ans += i
    print(ans)
else:
    print(0)

Measured memory_bytes: 13832
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll h,w,n;
int main(){FAST;
cin>>h>>w>>n;
cout<<min((n+h-1)/h,(n+w-1)/w);
return 0;
}

Measured memory_bytes: 256
def prob_d():
    n = int(input())
    a_list = [int(a) for a in input().split()]
    even_sum = sum(a_list[2::2])
    odd_sum = sum(a_list[1::2])
    sum_list = even_sum + odd_sum + a_list[0]
    ans = ""
    for i in range(n):
        if i % 2 == 0:
            ans += str(sum_list - odd_sum * 2)
            if i != n-1:
                odd_sum -= a_list[i+1]
                odd_sum += a_list[i]
        else:
            ans += str(sum_list - even_sum * 2)
            if i != n-1:
                even_sum -= a_list[i+1]
                even_sum += a_list[i]
        if i != n-1:
            ans += " "
    print(ans)

prob_d()

Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(ll i = s; i < n; i++)
ll n, x;
ll in[105];
ll ans;
int main(){
	cin>>n>>x;
	rep(i,0,n)scanf("%d", &in[i]);
	sort(in, in+n);
	ll sum = 0;
	rep(i,0,n-1){
		if(sum+in[i]>x)break;
		else {
			ans++;
			sum+=in[i];
		}
	}
	if(x==sum+in[n-1])ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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 nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    map<string,ll> ma;
    string S;
    rep(i,N){
        cin >> S;
        ma[S]++;
    }
    cout << "AC x " << ma["AC"] << "\nWA x " << ma["WA"] << "\nTLE x " << ma["TLE"] << "\nRE x " << ma["RE"] << "\n";
}


Measured memory_bytes: 3568
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')

sys.setrecursionlimit(100000)

N, X = in_nn()

blen = [0] * (N + 1)
blen[0] = 1
for i in range(N):
    blen[i + 1] = blen[i] * 2 + 3

pcount = [0] * (N + 1)
pcount[0] = 1
for i in range(N):
    pcount[i + 1] = pcount[i] * 2 + 1


def count(L, X):

    if L == 0:
        return 1

    if X == 1:
        return 0

    ret = 0
    if X <= blen[L] // 2:
        ret += count(L - 1, X - 1)
    else:
        ret += pcount[L - 1] + 1
        if X > blen[L] // 2 + 1:
            X -= blen[L] // 2 + 1
            X = min(X, blen[L - 1])
            ret += count(L - 1, X)

    return ret


def main():

    ans = count(N, X)
    print(ans)


if __name__ == '__main__':
    main()


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

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

using namespace std;

int main(){
  string s;cin>>s;
  int result=0;
  rep(i,s.size()-1){
    if((i+1)%2!=0)continue;
    if(s.substr(0, (i+1)/2) == s.substr((i+1)/2, (i+1)/2))result = max(result, (i+1));
  }

  cout<<result;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

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

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BBitterAlchemy {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, x;
	    in >> n >> x;
	    vector<int> m(n);
	    ll sum = 0, cnt = 0;
	    for(int i=0; i<n; i++){
	        in >> m[i];
	        sum += m[i];
	        cnt++;
	    }

	    sort(m.begin(), m.end());

	    while(sum <= x){
	        if(sum + m[0] <= x) {
                sum += m[0];
                cnt++;
            }else break;
	    }

	    out << cnt << endl;
	}
};


int main() {
	BBitterAlchemy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  long long a[100];
  cin >> N;
  
  a[0] = 2;
  a[1] = 1;
  
  for(int i = 2; i <= N; i++){
    a[i] = a[i-1] + a[i-2];
  }
  
  cout << a[N] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int a,b,c;
void solve(){
    cout<<c<<" "<<a<<" "<<b<<endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A,B = [],[]
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
if A == B:
    print(0)
    exit()
ans = 10**9+10
for i in range(N):
    if B[i] < A[i]:
        ans = min(ans,B[i])
print(sum(B) - ans)
        


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a;
		a=a*a;
		n>>=1;
	} 
	return ans;
}
int main(){
	int n;
	ll x,y;
	scanf("%d%lld%lld",&n,&x,&y);
	for(int i=2;i<=n;i++){
		 ll a,b,c=0,d=0;
		 scanf("%lld%lld",&a,&b);
		 if(a>=x&&b>=y) {
		 	x=a,y=b;
		 	continue;
		 }
		 if(a<x){
		 	c=(x+a-1)/a;
		 }
		 if(b<y){
		 	d=(y+b-1)/b;
		 }
		 ll mx=max(c,d);
		 x=a*mx,y=b*mx; 
		 //printf("x=%lld,y=%lld\n",x,y);
	}
	printf("%lld\n",x+y);
	return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<algorithm>
#define L long long
#include<string.h>
#include <math.h>
#define N 100009
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f;

LL h[N];
LL n, a, b;

bool judge(LL mid)
{
    LL ans = mid;
    for(int i = 1; i <= n; i++)
    {
        LL tm = h[i] - b*mid;
        if(tm > 0)
        {
            LL cnt = tm / (a - b) + (tm % (a - b) == 0 ? 0 : 1);
            ans -= cnt;
            if(ans < 0) return false;
        }
    }
    return true;
}

int main()
{
    scanf("%lld%lld%lld", &n, &a, &b);
    for(int i = 1; i <= n; i++) scanf("%lld", &h[i]);
    LL l = 0, r = INF;
    LL ans = INF;
    while(l <= r)
    {
        LL mid = (l + r)>>1;
        if(judge(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<ll>arr(n);
	for(int i=0; i<n; i++)
	 cin>>arr[i];
	sort(arr.begin(),arr.end());
	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++){
				if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]){
					if(arr[i]+arr[j]>arr[k])
					 ans++;
				}
			}
		}
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3656
N,A,B=map(int,input().split())
X=list(map(int,input().split()))

ANS=0

for i in range(1,N):
    if (X[i]-X[i-1])*A>=B:
        ANS+=B
    else:
        ANS+=(X[i]-X[i-1])*A
    
print(ANS)

Measured memory_bytes: 15020
n,q = map(int, input().split())
s = input()
# lr = [list(map(int, input().split())) for i in range(q)]

idx = [0] * n

# idx = [idx[i-1]+int(s[i-1:i+1] == "AC") for i in range(1, n)]
for i in range(1,n):
    idx[i] = idx[i-1] + (s[i-1:i+1] == "AC")


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



Measured memory_bytes: 9668
#include <stdio.h>

int n;
int p;
int maxp;
int dist[10005];
int d1, d2;

int main()
{
    
    while (scanf("%d", &n), n != 0) {
        for (int i = 0; i <= 10000; i++) {
            dist[i] = 0;
        }

        maxp = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d", &p, &d1, &d2);

            dist[p] = d1 + d2;

            if (dist[p] > dist[maxp]) {
                maxp = p;
            }
        }

        printf("%d %d\n", maxp, dist[maxp]);
    }
    
    return 0;
}



Measured memory_bytes: 2040
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    N = Number(input.split("\n")[0]);
    a=new Array;
    a[0]= input.split("\n")[1].split(" ").map(Number);
    a[1]= input.split("\n")[2].split(" ").map(Number);
    
    answer = 0;
   

    for(i=0;i<N;i++){
        tmpanswer = 0;
        //境目を選ぶ
        for(j=0;j<N;j++){
            if(j <= i){
                tmpanswer += a[0][j];
            }
            if(j >= i){
                tmpanswer += a[1][j];
            }
        }
        answer = Math.max(answer,tmpanswer)
    }


    console.log(answer);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    int okA = 0, okB = 0;
    for (auto c : S) {
        if (c == 'a') {
            if (okA + okB < A+B) {
                cout << "Yes" << endl;
                okA++;
            } else {
                cout << "No" << endl;
            }
        } else if (c == 'b') {
            if (okA + okB < A+B && okB < B) {
                cout << "Yes" << endl;
                okB++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>


  struct Dice {
    int dice_1;
    int dice_2;
    int dice_3;
    int dice_4;
    int dice_5;
    int dice_6;
  };

  void direct(char c, struct Dice *d) {
    int tmp;

    switch(c) {
      case 'N':
        tmp = d->dice_1;
        d->dice_1 = d->dice_2;
        d->dice_2 = d->dice_6;
        d->dice_6 = d->dice_5;
        d->dice_5 = tmp;
        break;
      case 'W':
        tmp = d->dice_1;
        d->dice_1 = d->dice_3;
        d->dice_3 = d->dice_6;
        d->dice_6 = d->dice_4;
        d->dice_4 = tmp;
        break;
      case 'S':
        tmp = d->dice_1;
        d->dice_1 = d->dice_5;
        d->dice_5 = d->dice_6;
        d->dice_6 = d->dice_2;
        d->dice_2 = tmp;
        break;
      case 'E':
        tmp = d->dice_1;
        d->dice_1 = d->dice_4;
        d->dice_4 = d->dice_6;
        d->dice_6 = d->dice_3;
        d->dice_3 = tmp;
        break;
    }
    return;
  }

int main() {
  int n = 0, i;
  struct Dice dice;
  scanf("%d%d", &dice.dice_1, &dice.dice_2);
  scanf("%d%d", &dice.dice_3, &dice.dice_4);
  scanf("%d%d\n", &dice.dice_5, &dice.dice_6);

  char c [100];

  scanf("%s", c);

  n = strlen(c);

  for (i = 0; i < n; i++) {
    direct(c[i], &dice);
  }

  printf("%d\n", dice.dice_1);
  return 0;

}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll V[N];
    rep(i, N) cin >> V[i];

    //i:検索中の荷物Indexをいれたか(>=1)
    //j:入れた荷物の個数
    //k:入れた荷物の個数
    //値:合計価値
    ll dp[51][51];
    ll count[51][51];
    rep(i, N + 1) {
        rep(j, N + 1) {
            dp[i][j] = -1;
            count[i][j] = 0;
        }
    }
    dp[0][0] = 0;
    count[0][0] = 1;
    ll maxValue = 0;
    ll countAtMax = 1;

    rep(i, N) {
        rep(j, N) {
            if (dp[i][j] < 0) {
                continue;
            }
            ll oldValue = dp[i + 1][j];
            ll nextValue = dp[i][j];
            if (nextValue > oldValue) {
                dp[i + 1][j] = nextValue;
                count[i + 1][j] = count[i][j];
            } else if (nextValue == oldValue) {
                count[i + 1][j] += count[i][j];
            }
            oldValue = dp[i + 1][j + 1];
            nextValue = dp[i][j] + V[i];
            if (nextValue > oldValue) {
                dp[i + 1][j + 1] = nextValue;
                count[i + 1][j + 1] = count[i][j];
                if (j >= A - 1 && j <= B - 1) {
                    if (nextValue * countAtMax > (j + 1) * maxValue) {
                        countAtMax = (j + 1);
                        maxValue = nextValue;
                    }
                }
            } else if (nextValue == oldValue) {
                count[i + 1][j + 1] += count[i][j];
            }
        }
    }
    //最大値の場所をマーク
    ll totalCount = 0;
    loop(j, A, B + 1) {
        if (dp[N][j] * countAtMax == maxValue * j) {
            totalCount += count[N][j];
        }
    }
    double maxAvg = (double)maxValue / (double)countAtMax;
    printf("%0.8lf\n", maxAvg);
    cout << totalCount << 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 RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int N;
  cin >> N;
  vi H(N);
  rep(i,N) cin >> H[i];
  int ma=0;
  int ans=0;
  rep(i,N){
    if(H[i]>=ma){
      ans++;
      ma=H[i];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> A(4,0);
    REP(i,N){
        char c; cin >> c;
        switch (c){
            case 'P':
                A[0]++;
                break;
            case 'W':
                A[1]++;
                break;
            case 'G':
                A[2]++;
                break;
            case 'Y':
                A[3]++;
                break;
        }
    }

    if(count(ALL(A), 0) == 1) cout << "Three" << endl;
    else cout << "Four" << endl;

    return 0;
}

Measured memory_bytes: 3600
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

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

map<char, char> inv;
map<char, int> len;
int h, w, n, Sr, Sc;
string s, t;

void read_input() {
	cin >> h >> w >> n;
	cin >> Sr >> Sc;
	cin >> s >> t;
}

void prep() {
	inv['U'] = 'D';
	inv['D'] = 'U';
	inv['R'] = 'L';
	inv['L'] = 'R';

	len['U'] = Sr - 1;
	len['D'] = h - Sr;
	len['L'] = Sc - 1;
	len['R'] = w - Sc;
}

bool can_go(char d) {
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == d)
			cnt++;
		if (cnt > len[d])
			return true;
		if (t[i] == inv[d] && -cnt < len[inv[d]])
			cnt--;
	}
	return false;
}

void solve() {
	if (can_go('U') || can_go('D') || can_go('R') || can_go('L'))
		cout << "NO";
	else
		cout << "YES";
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	prep();
	solve();
}



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

int main(){
    int A,B,C,K;

    cin >> A >> B >> C >> K;

    int i;
    int result=0;
    int temp=K-A;
    if(temp>=0){
        result+=A;
    }
    else{
        result+=K;
    }
    
    if(temp>0){
        temp-=B;
    }
    if(temp>0){
        result+=(-1)*temp;
    }
 
    cout << result << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,m,a[333][333],pw[666],cnt,pos,cur,upper;
/*long long Guass(long long Row,long long Column)
{
    long long row=1,col=1,max_r;
    for(row=1;row<=Row&&col<=Column;row++,col++)
    { 
        max_r=row;
        for(long long i=row+1;i<=Row;i++)
            if(abs(a[i][col])>abs(a[max_r][col]))
                max_r=i;
        if(a[max_r][col]==0)
        {
            row--;
            continue;
        }
        if(max_r!=row)
            for(long long i=col;i<=Column;i++)
                swap(a[row][i],a[max_r][i]);

        for(long long i=row+1;i<=Row;i++)
        {
            if(a[i][col]!=0)
            {

                for(long long j=col;j<=Column;j++)
                    a[i][j]^=a[row][j];
            }
        }
    }
	return Column-row+1;
}*/
void gauss()
{
	upper=1;
	for (long long i=1;i<=m;i++)
	{
		pos=-1;
		for (long long j=upper;j<=n;j++)
		{
			if (a[j][i])
			{
				pos=j;
				break;
			}
		}
		if (~pos)
		{
			for (long long j=1;j<=m;j++) swap(a[upper][j],a[pos][j]);
			for (long long j=upper+1;j<=n;j++)
			{
				if (a[j][i])
				{
					for (long long k=i;k<=m;k++)
					{
						a[j][k]^=a[upper][k];
					}
				}
			}
			upper++;
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (long long i=1;i<=n;i++)
	{
		for (long long j=1;j<=m;j++)
		{
			scanf("%lld",&a[i][j]);
		}
	}
	pw[0]=1;
	for (long long i=1;i<=600;i++) pw[i]=pw[i-1]*2%mod;
	gauss();
	cur=pw[m-upper+1];
	printf("%lld\n",((pw[n+m-1]-pw[n-1]*cur)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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 dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;

int main()
{
	string s;
	ll k = 0;
	ll ans=0;
	cin >> s;
	cin >> k;
	

	for (ll i = 0; i < k; i++) {
		if (s[i] == '1') {
			ans = 1;
		}
		else {
			ans = s[i] - '0';
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def gcm(a,b):
  a,b = max(a,b),min(a,b)
  while b != 0:
    a,b = b,a%b
  return a
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = max(a)
g = a[0]
for i in a[1:]:
  g = gcm(g,i)
if m >= k and (m-k)%g == 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 62576
#!/usr/bin/env python3
from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

    ctr = Counter(Aij for Ai in A for Aij in Ai)
    print(sum(ctr[n] * c[n][1] for n in range(10)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [[int(next(tokens)) for _ in range(9 - 0 + 1)] for _ in range(9 - 0 + 1)]  # type: "List[List[int]]"
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, c, A)


if __name__ == '__main__':
    main()


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

int main()
{
    int N, K;
    cin >> N >> K;
    long long ans = 0;
    for (int b = K + 1; b <= N; b++)
    {
        ans += (b - K) * (N / b);
        ans += max(0, N % b + 1 - K);
        if (K == 0)
        {
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
//

int main() {
    int m, k;
    cin >> m >> k;

    int max = (1 << m) -1;
    if(k > max) {
        cout << -1 << endl;
    }
    else if(k == 0) {
        for(int i = 0; i <= max; i++) {
            cout << i << " " << i << " ";
        }
        cout << endl;
    }
    else {
        vi res, tmp;
        for(int i = 0; i <= max; i++) {
            if(i != k) {
                res.pb(i);
                tmp.pb(i);
            }
        }
        res.pb(k);
        int idx = res.size()-1;

        reverse(all(tmp));
        for(auto val : tmp)
        res.pb(val);
        res.pb(k);

        int x = 0;
        for(int i = idx; i < (int)res.size(); i++) {
            x = x ^ res[i];
        }

        if(x != k) {
            cout << -1 << endl;
        }
        else {
            for(auto r : res)
                cout << r << " ";
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {




        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());


            double ans = 0;
            double ypb = 380000.0;

            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                double x = double.Parse(str[0]);
                string u = str[1];

                if(u == "JPY")
                {
                    ans += x;
                }
                else
                {
                    ans += x * ypb;
                }

            }

            Console.WriteLine($"{ans:f8}");

        }
    }
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	//cout<<"snuke\n";	
 	ll i,j,k,a,b,c,x,y,z;
 	sc(a);sc(b);sc(x);
 	c=a;
 	if(a>x){
 		printf("NO\n");
 		return 0;
 	}
 	j=x-a;
 	if(j>b){
 		printf("NO\n");
 		return 0;
 	}
 	printf("YES\n");
}

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

int main() {

	int h, w;
	cin >> h >> w;

	string board[100];
	for(int i=0; i<h; i++){
		cin >> board[i];
	}

	for(int i=0; i<w+2; i++) cout << '#';
	cout << endl;

	for(int i=0; i<h; i++){
		cout << '#';
		for(int j=0; j<w; j++){
			cout << board[i][j];
		}
        cout << '#' << endl;
	}
	for(int i=0; i<w+2; i++) cout << '#';
	cout << endl;

	return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
    int N, Y;
    cin >> N >> Y;
    rep(i, N + 1) rep(j, N + 1) {
        int k = N - i - j;
        if (k < 0) continue;
        long long t = 10000LL * i + 5000LL * j + 1000LL * k;
        if (t == Y) {
            printf("%d %d %d\n", i, j, k);
            return 0;
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


int main(){
  ll n, m;
  cin >> n >> m;
  int nextcircleno = 0;
  vector<int> circleno(n+1,0); // 0番目は空き (index+1 -> circleno)
  unordered_map<int, unordered_set<int>> circlemap; // circleno -> index+1
  int a, b;
  rep(i,m) {
    cin >> a >> b;
    const int cnoA = circleno[a];
    const int cnoB = circleno[b];
    if (cnoA != 0 && cnoB != 0) {
      if (cnoA == cnoB) {
        // 同じサークル同士
      } else {
        // 別々だと思っていたサークルを合体させる
        int fromcircleno = cnoB;
        int tocircleno = cnoA;
        if (circlemap[fromcircleno].size() > circlemap[tocircleno].size()) {
          std::swap(fromcircleno, tocircleno);
        }
        const auto& fromset = circlemap[fromcircleno];
        circlemap[tocircleno].insert(fromset.begin(), fromset.end());
        for (const auto& elem : fromset) {
          circleno[elem] = tocircleno;
        }
        circlemap.erase(fromcircleno);
      }
    } else if (cnoA == 0 && cnoB != 0) {
      circleno[a] = cnoB;
      circlemap[cnoB].emplace(a);
    } else if (cnoA != 0 && cnoB == 0) {
      circleno[b] = cnoA;
      circlemap[cnoA].emplace(b);
    } else {
      ++nextcircleno;
      circleno[a] = nextcircleno;
      circleno[b] = nextcircleno;
      circlemap[nextcircleno].emplace(a);
      circlemap[nextcircleno].emplace(b);
    }
  }

  ll maxmember = 0;
  if (circlemap.size() == 0) {
    maxmember = 1; // サークルがないので1つのグループに収める
  } else {
    for(const auto& p : circlemap) {
      const int membernum = p.second.size();
      if (maxmember < membernum) {
        maxmember = membernum;
      }
    }
  }
  cout << maxmember << endl;
  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;

    string board[50];

    for (int i = 0; i < h; ++i) cin >> board[i];

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

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (board[i][j] == '#') continue;

            int num = 0;
            for (int d = 0; d < 8; ++d) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 or h <= ni) continue;
                if (nj < 0 or w <= nj) continue;
                if (board[ni][nj] == '#') num++;
            }

            board[i][j] = char(num + '0');

        }
    }

    for (int i = 0; i < h; i++) cout << board[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;long long a,b,c,d,e,w,h,ans=1e10;
int main(){
   
   cin>>w>>h;
   for(int i=0;i<=h/2;i++)
   {
   	 a=w*i,b=w/2*(h-i);
   	 d=w*h-a-b;
   	 ans=min(max(a,max(b,d))-min(a,min(b,d)),ans);
   	 a=w*i,c=(h-i)/2*w;
   	 e=w*h-a-c;
   	  ans=min(max(a,max(c,e))-min(a,min(c,e)),ans);
   }
    for(int i=0;i<=w/2;i++)
   {
   	 a=h*i,b=h/2*(w-i);
   	 d=w*h-a-b;
   	 ans=min(max(a,max(b,d))-min(a,min(b,d)),ans);
   	 a=h*i,c=(w-i)/2*h;
   	 e=w*h-a-c;
   	  ans=min(max(a,max(c,e))-min(a,min(c,e)),ans);
   }
  cout<<ans;
	return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.in", "r", stdin);
    int n0 = 0, n1 = 0, n2 = 0, n, x;
    cin >> n;
    while(n--)
    {
        cin >> x;
        if(x % 4 == 0)
            n2++;
        else if(x % 2 == 0)
            n1++;
        else n0++;
    }
    if((n1 != 0 && n2 >= n0) || (n1 == 0 && n2 >= n0 - 1))
        cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  long long N;
  long long K;
  cin >> N >> K;
  
  vector<long long> A(N);
  
  for(long long i = 0LL;i < N;++i){
    cin >> A[i];
  }
  
  sort(A.begin(),A.end());
  
  reverse(A.begin(),A.end());
  
  long long num = 0LL; 
  
  for(long long i = 0LL;i < N;++i){
    if(K > 0LL){
      K = K - 1LL;
    }
    else{
      num = num + A[i];
    }
  }
  
  cout << num << endl;
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    if (S[K-1] == 'A') S[K-1] = 'a';
    if (S[K-1] == 'B') S[K-1] = 'b';
    if (S[K-1] == 'C') S[K-1] = 'c';
    cout << S << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

string s;
ll K;
int main(void){
    cin >> s;
    cin >> K;
    ll len = s.length();
    ll count=0;
    if(s[0] != s[len-1]){
        char n = s[0];
        for (int i=1;i<len;i++){
            if(n==s[i]){
                count++;
                if(i==len-1) break;
                n=s[i+1];
                i++;
            }else n=s[i];
        }
        cout << K*count << endl;
    }else{
        ll st=0, en=len-1;
        while(s[0] == s[st]) st++;
        while(s[0] == s[en]) en--;
        ll r = st+len-1-en;

        string s1 = s.substr(st, en-st+1);
        char n = s1[0];
        ll len1 = s1.length();
        for (int i=1;i<len1;i++){
            if(n==s1[i]){
                count++;
                if(i==len1-1) break;
                n=s1[i+1];
                i++;
            }else n=s1[i];
        }

        if (st<=en) cout << K*count + st/2 + (len-1-en)/2 + (K-1)*(r/2) << endl;
        else cout << len * K / 2 << endl;

    }

    return 0;
}



Measured memory_bytes: 256
N = int(input())
table = [[int(i) for i in input().split()] for N in range(N)]

a = -1
b = 10**10
c = -10**10
d = 10**10
for i in range(N):
    p = table[i][0]
    q = table[i][1]
    if a < p+q:
        a = p+q
    if b > p+q:
        b = p+q
    if c < p-q:
        c = p-q
    if d > p-q:
        d = p-q

print(max(a-b,c-d))


Measured memory_bytes: 102336
x1, y1, x2, y2 = [int(i) for i in input().split()]

def rotate(x1, y1, x2, y2):
    return x2 - (y2 - y1), y2 + (x2 - x1)

x3, y3 = rotate(x1, y1, x2, y2)
x4, y4 = rotate(x2, y2, x3, y3)
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    int n, p[210000];
    int a[210000] = {};
    int cnt = 0;

    cin >> n;
    rep(i, n) cin >> p[i];
    a[0] = p[0];

    for(int i = 1; i < n; i++){
        a[i] = min(p[i], a[i-1]); //p[i]までの最小
    }
    rep(i, n){
        if(a[i] == p[i]) cnt += 1;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define NIL -1
#define N 100000

int getDepth(int);

struct Node{
  int p;
  int l;
  int r;
  int s;
  int h;
}Node;

struct Node Three[N];

int getDepth(int u){
  int d = 0;

  for(; Three[u].p != NIL; d++){
    u = Three[u].p;
  }

    return d;
  
}

void setHeight(int n){
  int d,i,j;

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

    if(Three[i].r == NIL && Three[i].l == NIL){
      Three[i].h = 0;

      for(j = i,d = 1; j != NIL; d++){
	j = Three[j].p;

	if(Three[j].h < d) Three[j].h = d;
      }
    }
  }
}

int main(){

  int i, j;
  int n = 0;
  int v = 0;
  int d = 0;
  int c = 0;
  int l = 0;

  scanf("%d",&n);

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

    Three[i].p = NIL;
    Three[i].l = NIL;
    Three[i].r = NIL;
    Three[i].s = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&d,&c);

    if(d != NIL && c == NIL){
      Three[v].l = d;
      Three[d].p = v;
    }

    if(c != NIL && d == NIL){
      Three[v].r = c;
      Three[c].p = v;
    }

    if(d != NIL && c != NIL){
      Three[v].l = d;
      Three[d].p = v;
      Three[v].r = c; 
      Three[c].p = v;
      Three[d].s = c;
      Three[c].s = d;
    }
  }
  
  for(i = 0; i < n; i++){

    printf("node %d: parent = %d, sibling = %d, ",i,Three[i].p,Three[i].s);
    if(Three[i].r == NIL && Three[i].l == NIL){
      printf("degree = 0, ");
    }
    else if(Three[i].r == NIL || Three[i].l == NIL){
      printf("degree = 1, ");
    }
    else{
      printf("degree = 2, ");
    }

    setHeight(n);

    printf("depth = %d, height = %d,",getDepth(i),Three[i].h);

    if(Three[i].p == NIL){
      printf(" root\n");
    }
    else if(Three[i].l == NIL && Three[i].r == NIL){
      printf(" leaf\n");
    }
    else{
      printf(" internal node\n");
    }
  }

  return 0;
}

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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

bool func(string str){
    int i;
    for(i=0;i<str.size();i++) if(str[i]=='C') break;
    for(;i<str.size();i++) if(str[i]=='F') break;
    return i<str.size();
}

int main()
{
    string str;
    cin >> str;
    if(func(str)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int H,W; cin>>H; cin>>W;
  vector<pair<int,int> > vp ;

  vector<vector<int> >  mat (H,vector<int>(W,0));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
       cin>>mat[i][j];
    }
  }  

  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if(i%2 == 0)
      {
        vp.emplace_back(i,j);
      }
      else
      {
        vp.emplace_back(i,W - 1 -j);
      }
    }
  }
  vector<tuple<int,int,int,int> > vt;
  for (int i = 0; i < vp.size() - 1; i++)
  {
    int X,Y,nX,nY;
    tie(X,Y) = vp[i];
    tie(nX,nY) = vp[i+1];
    if(mat[X][Y]%2 == 1)
    {
      mat[nX][nY]++;
      vt.emplace_back(X,Y,nX,nY);
    }
  }
  cout<<vt.size()<<endl;;
  for (auto &&x : vt)
  {
    int A,B,C,D;
    tie(A,B,C,D) = x;
    A++;B++;C++;D++;
    cout<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
  }
  
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 14316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
	cin>>a[i];
    }
    ll res = 1e12;
    
    ll sum = 0,l = 0;
    for(ll i=0;i<n;i++)sum+=a[i];
    for(ll i=0;i<n;i++){
	l += a[i];
	sum -= a[i];
	res = min( res , abs( l - sum ) );
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
k,n=map(int,input().split())
a = list(map(int, input().split()))

d=[0]*n
d[0]=k-(a[n-1]-a[0])
for i in range(1,n):
    d[i]=a[i]-a[i-1]
print(k-max(d))

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

int main() {
  int n;
  int x, y;
  cin >> n;
  x = int(n / 1.08);
  y = int(n / 1.08) + 1;
  if (int(x * 1.08) == n){
    cout << x << endl;}
  else if (int(y * 1.08) == n) {
    cout << y << endl;}
  else {
    cout << ":(" << endl;}
}

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

#define N 200050

//100000000 0 0 0 0 0 0    dai

int main(void){
    // Your code here!

int a[N]={0};
int n=0;
int tall=0;
long long ans=0;

scanf("%d",&n);

for(int i=0; i<n; i++) scanf("%d",&a[i]);

tall=a[0];

for(int i=1; i<n; i++) {
if( tall>a[i] ){
    ans+=tall-a[i];
    
}     
//else continue;
else if( tall<=a[i] ) tall=a[i];

}
printf("%lld\n",ans);

return 0;    
}


Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int 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");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
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


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	vi pre(n, 0);
	pre[0] = a[0];
	zip(i, 1, n)
	pre[i] = pre[i - 1] + a[i];

	int ans = 0;
	int tot = pre[n - 1];

	zip(i, 0, n - 1)
	{
		int x = a[i];
		int y = tot - pre[i];
		ans += (x % mod * (y % mod)) % mod;
		ans = ans % mod;
	}
	cout << ans << en;

	return 0;
}




Measured memory_bytes: 6348