akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = 310;

int N, K;
vector<ll> H;

vector<vector<ll>> dp;

ll dfs(int n, int k) {
  if (dp[n][k]!=-1) return dp[n][k];
  if (n<k) return dp[n][k] = LLINF;
  if (k==0) return dp[n][k] = 0;
  if (k==1) return dp[n][k] = H[n-1];
  ll result = LLINF;
  for (int i=k-1; i<n; i++) {
    result = min(result, dfs(i,k-1)+max((ll)0,H[n-1]-H[i-1]));
  }
  return dp[n][k] = result;
}

int main() {
  cin >> N >> K;
  dp.resize(N+1,vector<ll>(N+1,-1));
  rep(i,N) { int tmp; cin >> tmp; H.push_back(tmp); }
  // rep(i,N+1) { rep(j,N+1) cout << dfs(i,j) << " "; cout << endl; }
  ll result = LLINF; rep(i,N) result = min(result, dfs(i+1,N-K));
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            int op = 0;
            int cl = 0;
            for (char c : S.toCharArray()) {
                if (c == '(') {
                    op++;
                } else if (op > 0){
                    op--;
                } else {
                    cl++;
                }
            }

            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < cl; ++i) {
                ans.append('(');
            }
            ans.append(S);
            for (int i = 0; i < op; ++i) {
                ans.append(')');
            }

            out.println(ans.toString());
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21460
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 55;
const int mod = 1000000007;

string s[200010];
string a[200010];
unordered_map<string, int> mp;
unordered_map<string, bool> vis;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		++mp[a[i]];
		mx = max(mx, mp[a[i]]);
	}
	int tot = 0;
	for (int i = 1; i <= n; ++i) {
		if (mp[a[i]] == mx) {
		    if (vis[a[i]] == 1) continue;
			s[++tot] = a[i];
			vis[a[i]] = 1;
		}
	}
	sort(s + 1, s + tot + 1);
	for (int i = 1; i <= tot; ++i) {
		cout << s[i] << endl;
	}
	return 0;
}

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

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

using namespace std;

int main()
{
  int n;
  ll a[1000001];

  cin >> n;
  REP(i,n) {
    cin >> a[i];
  }
  sort(a,a+n);

  ll l = a[0], r = a[n-1];
  ll result = abs(r-l);
  int lp = 1, rp = n-2;
  while(lp <= rp) {
    int flg = 0;
    int tmp = abs(a[lp] - l);
    if(tmp < abs(a[lp] - r)) {
      tmp = abs(a[lp] - r);
      flg = 1;
    }
    if(tmp < abs(a[rp] - l)) {
      tmp = abs(a[rp] - l);
      flg = 2;
    }
    if (tmp < abs(a[rp] - r)) {
      tmp = abs(a[rp] - r);
      flg = 3;
    }


    result += tmp;
    switch (flg){
    case 0:
      l = a[lp];
      lp++;
      break;
    case 1:
      r = a[lp];
      lp++;
      break;
    case 2:
      l = a[rp];
      rp--;
      break;
    case 3:
      r = a[rp];
      rp--;
      break;
    default:
      break;
    }
  }
  cout << result << endl;

}


Measured memory_bytes: 3072
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
typedef long long ll;

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }
inline ll getLL(){ ll s; scanf("%lld", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const ll c = getLL();

  vector<ll> x(n);
  vector<ll> v(n);

  REP(i,n){
    x[i] = getLL();
    v[i] = getLL();
  }

  ll ans = 0;

  REP(_,2){
    typedef pair<ll, int> data;
    priority_queue<data> pq;

    {
      ll cur = 0;
      ll pos = c;
      for(int i = n - 1; i >= 0; i--){
        cur -= pos - x[i];
        cur += v[i];
        pq.push(data(cur, i));
        pos = x[i];
      }
    }

    {
      ll cur = 0;
      ll pos = 0;

      const data r = pq.top(); pq.pop();
      ll rcur = r.first;
      int ridx = r.second;

      REP(i,n){
        cur -= x[i] - pos;
        cur += v[i];
        pos = x[i];

        while(ridx <= i && pq.size()){
          const data d = pq.top(); pq.pop();
          rcur = d.first;
          ridx = d.second;
        }

        if(ridx <= i && pq.size() == 0){
          rcur = 0;
          ridx = -1;
        }

// printf("%d %d %lld %lld\n", i, ridx, cur, cur - x[i] + rcur);

        ans = max(ans, cur);
        ans = max(ans, cur - x[i] + rcur);
      }
    }

    REP(i,n) x[i] = c - x[i];

    reverse(x.begin(), x.end());
    reverse(v.begin(), v.end());
  }

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


Measured memory_bytes: 5972
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll T1,T2,A1,A2,B1,B2;
    cin>>T1>>T2;
    cin>>A1>>A2;
    cin>>B1>>B2;
    if(A1*T1+A2*T2==B1*T1+B2*T2){
        cout<<"infinity"<<endl;
    }else{
        ll ans=0;
        if(A1<B1){
            swap(A1,B1);
            swap(A2,B2);
        }
        ll dis=-(T1*(A1-B1)+T2*(A2-B2));
        if(dis<0){
            ans=0;
        }else{
            ll cnt=T1*(A1-B1)/dis;
            
            ans=(cnt)*2+1;
            if((T1*(A1-B1))%dis==0) ans--;
            
        }

        cout<<ans<<endl;
    }

}

Measured memory_bytes: 3604
a = input()
b = input()
if len(a) > len(b):
    print("GREATER")
elif len(a) < len(b):
    print("LESS")
else:
    for i in range(len(a)):
        if int(a[i]) > int(b[i]):
            print("GREATER")
            exit()
        elif int(a[i]) < int(b[i]):
            print("LESS")
            exit()
    print("EQUAL")

Measured memory_bytes: 3064
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int n;
int a[100][100] = {0};
int k[100] = {0};
int t = 1;
int d[100] = {0};
int f[100] = {0};

int kansu( int i ){
	if ( d[i] != 0 ) return 0;
	d[i] = t;
	t++;
	for ( int j = 0; j < k[i]; j++ ) {
		if ( kansu( a[i][j] ) == 1 ) t++;
	}
	f[i] = t;
	return 1;
}

int main(){
	cin >> n;
	int s;
	for ( int i = 0; i < n; i++ ) {
		cin >> s;
		cin >> k[i];
		for ( int j = 0; j < k[i]; j++ ) {
			cin >> s;
			a[i][j] = s-1;
		}
	}
	for ( int i = 0; i < n; i++ ) {
		if ( kansu(i) == 1 ) t++;
	}
	for ( int i = 0; i < n; i++ ) {
		cout << i+1 << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,a,n) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define INF 1000000000000 //10^12:∞
#define MOD 998244353//10^9+7:合同式の法


int main() {
    int n;
cin >> n;
rep(i,0,n){
cout << "ACL";
}
return 0;
}

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

string reverseStr(string target)
{
    string retStr = "";
    for (int i = target.length() - 1; i >= 0; i--) {
        retStr += target[i];
    }
    return retStr;
}

int main()
{
    string S;
    cin >> S;

    if (S != reverseStr(S)) {
        cout << "No" << endl;
        return 0;
    }
    int cnt = (S.length() - 1) / 2;
    string str = S.substr(0, cnt);
    if (str != reverseStr(str)) {
        cout << "No" << endl;
        return 0;
    }
    cnt = (S.length() + 3) / 2;
    str = S.substr(cnt - 1, S.length());
    if (str != reverseStr(str)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
    a[i]--;
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(a[a[i]] == i) ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}



Measured memory_bytes: 640
from itertools import product
N,*ABC=map(int,input().split())
L=[int(input()) for i in range(N)]
MP=10**9
for P in product([0,1,2,3],repeat=N):
    if {0,1,2}<=set(P):
        m=[0,0,0]
        for p,l in zip(P,L):
            if p!=3:m[p]+=l
        cost1=sum(abs(m-l) for m,l in zip(m,ABC))
        cost2=sum(1 for i in P if i!=3)-3
        MP=min(MP,cost1+cost2*10)
print(MP)

Measured memory_bytes: 3064
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

int main(int argc, char const* argv[])
{
    string S;
    cin >> S;
    ll ans[S.length()];
    rep(i,S.length()){
        ans[i] = 0;
    }
    ans[0] = 0;
    ans[S.length()-1] = 0;
    ll cnt = 0;
    for(int i = 0; i < S.length()-1 ; i++){
        if(S[i] == 'R'){
            cnt++;
        }
        if(S[i] == 'R' && S[i+1] == 'L'){
            ans[i] =  cnt/2 + cnt%2;
            ans[i+1] =  cnt/2;
            cnt = 0;
        }
        //else if(S[i] == 'L' && S[i-1] == 'R'){
        //    ans[i] =  cnt/2;
        //    cnt = 0;
        //}
        //else{
        //    ans[i] = 0;
        //}
    }
    cnt = 0;
    for(int i = S.length() -1; i > 0 ; i--){
        if(S[i] == 'L'){
            cnt++;
        }
        if(S[i] == 'L' && S[i-1] == 'R'){
            ans[i] += cnt/2 + cnt%2;
            ans[i-1] += cnt/2;
            cnt = 0;
        }
        //else if(S[i] == 'R' && S[i+1] == 'L'){
        //    ans[i] += cnt/2;
        //    cnt = 0;
        //}
        //else{
        //    ans[i] = 0;
        //}
    }

    rep(i,S.length()){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int N;
string S;

int main() {
    cin >> N >> S;

    int max = 0;
    int tmp = 0;
    rep(i, N) {
        if (S[i] == 'I') tmp++;
        else tmp--;

        if (max < tmp) {
            max = tmp;
        }
    }

    cout << max << endl;
}

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

typedef long long ll;

int main() {
    bool check = false;
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++) {
        int j = X-i;
        if (i*2+j*4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    map<int,int> mp;
    ll ans = 0;
    for (int i=0;i<N;i++){
        ans += mp[-A[i]+i+1];
        mp[A[i]+i+1]++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 21096
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    N = int(readline())
    c = Counter()

    for _ in range(N):
        s = input()
        c[s] += 1

    _, cnt = c.most_common(1)[0]

    res = []
    for key, val in c.items():
        if val == cnt:
            res.append(key)

    res.sort()

    for x in res:
        print(x)


if __name__ == '__main__':
    main()


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

struct town{
    ll x,y,id;
};

struct edge{
    ll u, v, cost;
};

bool comp_c(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
bool comp_x(const town& t1, const town& t2){
    return t1.x < t2.x;
}
bool comp_y(const town& t1, const town& t2){
    return t1.y < t2.y;
}

int sx, sy, tx, ty;
string ans;

int main(){
    cin >> sx >> sy >> tx >> ty;
    
    int dx = tx-sx, dy = ty-sy;

    for(int i = 0; i < dy; i++) ans += 'U';
    for(int i = 0; i < dx; i++) ans += 'R';
    for(int i = 0; i < dy; i++) ans += 'D';
    for(int i = 0; i < dx; i++) ans += 'L';
    
    ans += 'L';
    for(int i = 0; i < dy+1; i++)   ans += 'U';
    for(int i = 0; i < dx+1; i++)   ans += 'R';
    ans += 'D';
    ans += 'R';
    for(int i = 0; i < dy+1; i++)   ans += 'D';
    for(int i = 0; i < dx+1; i++)   ans += 'L';
    ans += 'U';

    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import itertools
import math


def solve(*args: str) -> str:
    n = int(args[0])
    XY = [tuple(map(int, xy.split())) for xy in args[1:]]

    ret = 0

    for P in itertools.permutations([i for i in range(n)], n):
        for i in range(1, n):
            xs, ys = XY[P[i-1]]
            xd, yd = XY[P[i]]
            ret += math.sqrt((xs-xd)**2+(ys-yd)**2)

    ret /= math.factorial(n)
    # return '{:.10f}'.format(ret)
    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  for (int i = 0; i < n; ++i) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

ll calc(int r, int c) {
  ll res = 0;
  for (int i = 0; i <= r; ++i) {
    res = (res + nCr(i + 1 + c, c)) % MOD;
  }
  return res;
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  init_fact(2 * (r2 + c2));
  ll ans = calc(r2, c2);
  ans = (ans - calc(r2, c1 - 1) + MOD) % MOD;
  ans = (ans - calc(r1 - 1, c2) + MOD) % MOD;
  ans = (ans + calc(r1 - 1, c1 - 1)) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;

int main() {
  int h, w, y1, x1, y2, x2;
  cin >> h >> w >> y1 >> x1 >> y2 >> x2;
  y1--, x1--, y2--, x2--;
  vector<string> s(h);
  for (auto &e : s) cin >> e;

  vector<vector<int>> d(h, vector<int>(w, INF));
  d[y1][x1] = 0;

  priority_queue<tuple<int, int, int>> q;
  q.push({0, y1, x1});
  while (!q.empty()) {
    auto [dyx, y, x] = q.top();
    q.pop();
    if (dyx > d[y][x]) continue;

    for (int dy = -2; dy <= 2; dy++) {
      auto yt = y + dy;
      if ((unsigned)yt >= h) continue;
      for (int dx = -2; dx <= 2; dx++) {
        auto xt = x + dx;
        if ((unsigned)xt >= w) continue;
        if (s[yt][xt] == '#') continue;

        int dt = d[y][x] + (abs(dy) + abs(dx) > 1 ? 1 : 0);
        if (dt < d[yt][xt]) {
          d[yt][xt] = dt;
          q.push({-dt, yt, xt});
        }
      }
    }
  }

  cout << (d[y2][x2] != INF ? d[y2][x2] : -1) << endl;
}


Measured memory_bytes: 9596
fun main(args: Array<String>) {
    var (x, n) = readLine()!!.split(" ").map { it.toInt() }
    val planePInput = readLine()
    val pList = if (planePInput.isNullOrEmpty()) {
        null
    } else {
        planePInput.split(" ").map { it.toInt() }
    }

    var distance = 0
    val forbiddenList: ArrayList<Int>
    if (pList == null) {
        println(x)
    } else {
        forbiddenList = pList as ArrayList<Int>
        while (true) {
            if (forbiddenList.contains(x - distance)) {
                if (forbiddenList.contains(x + distance)) {
                    distance++
                    continue
                } else {
                    println(x + distance)
                    break
                }
            } else {
                println(x - distance)
                break
            }
        }
    }
}

Measured memory_bytes: 36388
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef pair<int,string> pis;

/* global variables */

int n, m;
pis pats[MAX_N];

/* subroutines */

bool match(string pat, string lot) {
  for (int i = 0; i < 8; i++)
    if (pat[i] != '*' && pat[i] != lot[i]) return false;
  return true;
}

/* main */

int main() {
  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < n; i++)
      cin >> pats[i].second >> pats[i].first;

    int sum = 0;

    while (m--) {
      string lot;
      cin >> lot;

      for (int i = 0; i < n; i++)
	if (match(pats[i].second, lot)) {
	  sum += pats[i].first;
	  break;
	}
    }

    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

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



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


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

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

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector <int> data(N);
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	map <int, int>box;
	for (auto x : data)
	{
		box[x - 1]++;
		box[x]++;
		box[x + 1]++;

	}
	int ans = 0;
	for (auto x : box)
	{
		ans = max(ans, x.second);
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int[] A = new int[N];

	for(int i = 0; i < N; i++){
	    A[i] = scan.nextInt();
	}

	int min = Integer.MAX_VALUE;
	int max = Integer.MIN_VALUE;

	for(int i = 0; i < N; i++){
	    if(A[i] < min){
		min = A[i];
	    }
	    if(A[i] > max){
		max = A[i];
	    }
	}

	System.out.println(max-min);
    }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int T=0,H=0;
	for(int i=0;i<n;++i){
		string t,h; cin>>t>>h;
		if(t>h)T+=3;
		else if(h>t)H+=3;
		else ++T,++H;
	}
	cout<<T<<" "s<<H<<"\n"s;
}


Measured memory_bytes: 3232
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int N;
vector<int> a;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  a.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (a[i] == a[i - 1]) {
      ans++;
      a[i] = 0;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define dump(o) { cerr << #o << " " << o << endl; }
#define dumpc(o) { cerr << #o; for (auto &e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int a, b; cin >> a >> b;
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if (a < 0 && b < 0) {
		if (((b - a) % 2) == 0)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
	}
	else {
		cout << "Zero" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X = 0;
  cin >> X;
  int p;
  while (X >= 500) {
    X -= 500;
    p += 1000;
  }
  while (X >= 5) {
    X -= 5;
    p += 5;
  }
  cout << p << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[1002];
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    int t = 0;
    for(int i = 0; i < n; i++){
        if(a[i] * m * 4 >= s) t++;
    }
    if(t >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
    cout.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i<n;i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout<<'\n'

#define all(v) v.begin(),v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkpr make_pair
#define pq priority_queue


void printAr(int a[],int n)  // print the array
{
    for(int *i = a; i!=a+n; ++i)cout << *i << " ";
    cout << endl;
}

const int N = 6;
//int a[N],cum[N];
int n,k,m;
int a[N][N] = {};
bool is_one(int n,int p)
{
    return n & (1 << p);
}
int main()
{
    fastio;
    cin >> n >>m >> k;
    string s;
    repeat(n)
    {
        cin >> s;
        for(int j = 0; j < m; j++)
        {
            if(s[j]=='#')a[i][j]=1;
        }
    }

    int b[N][N],c[N][N];
    long long ans = 0LL;
    int cnt;
    for(int i = 0; i < 1<<n; i++)
    {
        cnt = 0;
        for(int u = 0 ; u < n; u++)
        {
            for(int v = 0; v < m; v++)b[u][v] = a[u][v];
        }
        for(int p = 0; p < n; p++)
        {
            if(is_one(i,p))
            {
               // cout << "i = " << i << " pos = " << p<< endl;
                for(int u = 0; u < m; u++)b[p][u] = 0;
            }
        }

        for(int j = 0; j < 1 << m; j++)
        {
            for(int u = 0 ; u < n; u++)
            {
                for(int v = 0; v < m; v++)c[u][v] = b[u][v];
            }
            for(int p = 0; p < m; p++)
            {
                if(is_one(j,p))
                {
                    for(int u = 0; u < n; u++)c[u][p] = 0;
                }
            }
            cnt = 0;
            for(int u = 0; u <n; u++)
            {
                for(int v = 0; v < m; v++)if(c[u][v]==1)cnt++;
            }
            if(cnt == k)ans++;
            //cout << "i = " << i << " j = " << j << endl;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define VISITED 1
#define UNVISITED 0
#define N 10010
using namespace std;
int main(){
	int n;
	cin>>n;
	int m = n-1;
	vector<vector<pair<int,int>>> gra(N);
	
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a-=1;
		b-=1;
		gra[a].emplace_back(b,0);
		gra[b].emplace_back(a,0);
	}
	priority_queue<int,vector<int>> prq;
	for(int j=0;j<n;j++){
		int t;
		cin>>t;
		prq.push(t);
	}
	int u = 0;
	queue<int> bfsq;
	bfsq.push(u);
	int flag[N];
	int weight[N];
	memset(weight,0,sizeof(weight));
	int no = prq.top();prq.pop();
	weight[u] = no;
	int ans=0;
	while(!bfsq.empty()){
		int u = bfsq.front();bfsq.pop();
		//int no = prq.top();prq.pop();
		flag[u]=VISITED;
		//weight[u] = no;
		
		for(int j=0;j<(int)gra[u].size();j++){
			int nx = gra[u][j].first;
			if(flag[nx]== UNVISITED){
				int no = prq.top();prq.pop();
				weight[nx] = no;
				ans+=no;
				bfsq.push(nx);
			}
		}
	}
	int sum = 0;
	
	int v = 0;
	queue<int> bfsq2;
	bfsq2.push(u);
	int flag2[N];
	//int weight[N];
	//memset(weight,0,sizeof(weight));
	while(!bfsq2.empty()){
		int v = bfsq2.front();bfsq2.pop();
		//int no = prq.top();prq.pop();
		flag2[v]=VISITED;
		//weight[u] = no;
		
		for(int j=0;j<(int)gra[v].size();j++){
			int nx = gra[v][j].first;
			if(flag2[nx]== UNVISITED){
				sum+= min(weight[v],weight[nx]);
				bfsq2.push(nx);
			}
		}
	}
	cout<<ans<<endl;
	for(int i =0;i<n-1;i++)cout<<weight[i]<<" ";
	cout<<weight[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1152
#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 ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, m, q;
vector<int> g[112345];
int d[112345][11];
int col[112345];
int ans[112345];

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	fill(d[0], d[n], -1);
	fill(ans, ans + n, -1);
	
	priority_queue<P> pq;
	
	cin >> q;
	REP(i, q) {
		int v, d, c;
		scanf("%d %d %d", &v, &d, &c);
		v--;
		col[i] = c;
		pq.push(P(i, pii(v, d))); 
	}
	
	while (!pq.empty()) {
		P now = pq.top(); pq.pop();
		
		int v = now.second.first;
		int nd = now.second.second;
		int nc = now.first;
		
		if (!chmax(d[v][nd], nc)) continue;
		chmax(ans[v], nc);
		
		if (nd > 0) {
			REP(i, g[v].size()) {
				int u = g[v][i];
				pq.push(P(nc, pii(u, nd - 1)));
			}
		}
	}
	
	REP(i, n) {
		if (ans[i] == -1) puts("0");
		else printf("%d\n", col[ans[i]]);
	}
	
	return 0;
}

Measured memory_bytes: 20076
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

int n, k;
set<int> se;
set<int>::iterator it;

void solve() {
	read(n); read(k);
	if (k * 2 > n + 1) {
		printf("-1\n");
		return;
	}
	int th = k + n * 2;
	for (int i = k + n; i < th; ++i) {
		se.insert(i);
	}
	for (int fi = k; fi < k + n; fi += 2) {
		it = se.upper_bound(th - fi);
		printf("%d %d %d\n", fi, *(--it), th);
		se.erase(it);
		++th;
	}
	for (int fi = k + 1; fi < k + n; fi += 2) {
		it = se.upper_bound(th - fi);
		printf("%d %d %d\n", fi, *(--it), th);
		se.erase(it);
		++th;
	}
}

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


Measured memory_bytes: 6912
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;main(){string s;cin>>s;for(int i=0;i<(int)s.size()-7;++i){string t=s.substr(i,8);sort(t.begin(),t.end());if(t=="AADINNUY"){s=s.substr(0,i)+"AIZUNYAN"+s.substr(i+8);i+=7;}}cout<<s<<endl;}

Measured memory_bytes: 1220
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new A().doIt();
//		new B().doIt();
//		new C().doIt();
//		new D().doIt();
	}
	class A{
		void doIt(){
			int A[] = new int[3];
			for(int i = 0;i < 3;i++)A[i] = Integer.parseInt(sc.next());
			int five = 0;
			int seven = 0;
			for(int i = 0;i < 3;i++) {
				if(A[i] == 5)five++;
				else if(A[i] == 7)seven++;
			}
			if(five == 2 && seven == 1)System.out.print("YES");
			else System.out.println("NO");
		}
	}class B{
		void doIt(){
			
		}
	}
	class C{
		void doIt(){
			
		}
	}
	class D{
		void doIt(){
			
		}
	}
}


Measured memory_bytes: 21460
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

#a = list(map(int, input().split()))


n,a,b = list(map(int, input().split()))
c = min(max(n-a,n-b),max(a-1,b-1))


if((a-b)%2==0):
    print(min(c,abs(a-b)//2))
else:
    d = a-1 + 1 + (b-a-1)//2
    e = n-b + 1 + (b-a-1)//2
    print(min(d,e,max(n-a,n-b),max(a-1,b-1)))


Measured memory_bytes: 66156
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n;
  cin >> n;
  ll x = 26, d = 1;
  while(x<n) x=x*26+26, ++d;
  ll m = 0;
  rep(i,d-1) m=m*26+26;
  n-=m+1; 
  string ans = "";
  rep(_,d){
    ans += 'a'+max(n,0LL)%26;
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
}


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

int main() {
  int N,A,B;
  int p1,p2,x;
  cin >> N >> A >> B;
  p1 = A*N;
  p2 = B;
  if (p1 < p2) {
    x = p1;
  }
  else if (p2 < p1) {
    x = p2;
  }
  cout << x << endl;
}

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

#define int long long 

signed main() {
	int test = 1;
  	while(test--) {
    	int n;
      	cin >> n;
      
      	int a[n], store[n], tot = 0;
      	for(int i = 0; i < n; i++) {
          	cin >> a[i], tot += a[i];
        }

        int ans = 0;
        for(int i = 1; i < n; i++) {
        	int k = max(- a[i] + a[i - 1], 0LL);
        	ans += k;
        	a[i] += k;
        }

        cout << ans << '\n';
    }
  	return 0;
}

Measured memory_bytes: 5188
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<double,double> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

struct Edge{
    int from, to;
    double cost;
    Edge(int from, int to,double cost): from(from), to(to), cost(cost){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator < (const Edge &e, const Edge &f){
    return e.cost < f.cost;
}

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

double MST(const Graph &g){
    int sz = g.size();
    UF uf(sz);
    priority_queue<Edge> q;
    for(int i=0;i<sz;i++)for(int j=0;j<(int)g[i].size();j++) q.push(g[i][j]);

    double res=0;
    while(!q.empty()){
        Edge e=q.top();q.pop();
        if(!uf.find(e.from,e.to)){
            res+=e.cost;
            uf.unite(e.from,e.to);
        }
    }
    return res;
}

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

    int n,m;cin>>n>>m;
    vector<P> v(n);
    for(int i=0;i<n;i++){
        double x,y;cin>>x>>y;
        v[i]=P(x,y);
    }
    double sum=0;
    Graph g(n);
    for(int i=0;i<m;i++){
        int st,gt;cin>>st>>gt;
        st--;gt--;
        double sx=v[st].first,sy=v[st].second,gx=v[gt].first,gy=v[gt].second;
        double d=(sx-gx)*(sx-gx)+(sy-gy)*(sy-gy);
        d=sqrt(d);
        g[st].push_back(Edge(st,gt,d));
        sum+=d;
    }
    cout<<fixed<<setprecision(10)<<sum-MST(g)<<endl;
}


Measured memory_bytes: 4828
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int a=0,b=0,c=0,num=1;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        if(a!=b)num++;
        if(a!=c&&b!=c)num++;
        System.out.println(num);
    }
}


Measured memory_bytes: 21588
W,H,x,y,r = map(int,input().split())

if x<0 or W<x :
    print ("No")
elif y<0 or H<y:
    print ("No")
elif x+r>W or x-r<0 or y+r>H or y-r<0  :
    print("No")
else :
    print("Yes")



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

int main(){
  string S;
  cin>>S;
  for(int i=0;i<3;i++){
    if(S.at(i)=='1')
      S.at(i)='9';
    else
      S.at(i)='1';
  }
  cout<<S<<endl;
}


Measured memory_bytes: 256
n=str(input())
l=len(n)

while int(n)>9:
    nn=list(n)
    nbox=list(map(int,nn))
    n=str(sum(nbox))
if int(n)==9:
    print('Yes')
elif int(n)==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12168
N = int(input())
list = input().split()

num_list = []
for c in list:
    n = int(c)
    num_list.append(n)

state = True

i = 0

while state:
    j = 0
    for n in num_list:
        if n % 2:
            state = False
        else:
            del num_list[j]
            n /= 2
            n = int(n)
            num_list.insert(j,n)
        j += 1
        if j == N and state:
            i += 1
print(i)


Measured memory_bytes: 3064
#include <stdio.h>

char S[200020];

int main()
{
	scanf ("%s",S);
	int s = 0, l = 0;
	for (int i=0;S[i];i++){
		if (S[i] == 'S') s++;
		else{
			if (s == 0) l++;
			else s--;
		}
	}
	l += s;
	printf ("%d\n",l);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define li long int
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define search(x,y,z) binary_search(x,y,z)
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define pp push
#define po pop
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define vv(x) vector<vector<x> >
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	fastio;
	/*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif*/
	
	string s;
	cin>>s;
	string p="";
	forf(i,0,s.size())
	{	if(s[i]=='1')
			p+='9';
		else if(s[i]=='9')
			p+='1';
		else
			p+=s[i];
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n,c=0;
	string s[110];
	cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> s[i][0];
		if (s[i][0]=='Y') {
			c = 1;
		}
	}
	if (c==1) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int A,B;
  int P,Q,R;
  cin>>A>>B;
  cin>>P>>Q>>R;

  double ans=B;
  double rest=B*P-(B-A)*Q;
  ans+=rest/(Q+R);
  cout<<fixed<<setprecision(10)<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  rep(i, max(a, b)) {
    cout << min(a, b);
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		Set<Integer> set = new HashSet<>();

		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			set.add(a);
		}

		if(n == set.size()) {
			System.out.println("YES");

		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 100576
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	int(1e9) + 10
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
int n, cur;
vi ans, arr, d;
vvi adj;
void dfs(int v, int par = -1){
	trace(v);
	int temp1 = cur;
	int ind = lower_bound(all(d), arr[v]) - d.begin();
	if(ind == cur+1) cur++;
	int temp2 = d[ind];
	d[ind] = arr[v];
	ans[v] = cur;
	trav(to, adj[v]){
		if(to == par) continue;
		dfs(to, v);
	}
	d[ind] = temp2;
	cur = temp1;
}
void solve() {
	cin >> n;
	cur = 0;
	arr.resize(n), adj.resize(n), ans.resize(n), d.resize(n+1, INF);
	d[0] = -INF;
	forn(i, n) cin >> arr[i];
	graph(adj, n-1);
	dfs(0);
	trav(k, ans) cout << k << '\n';
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 30752
#include<stdio.h>
int main(){
    unsigned long ulW_D_inact[100][100];    /* 行列Ａの格納用変数 */
    unsigned long act[100];           /* 行列Ｂの格納用変数 */
    unsigned long ans[100];           /* 積の格納用変数 */
    unsigned short row, col;          /* 行列の要素数の格納用変数 */
    unsigned short i, j;              /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 100;i++){
        for(j = 0;j < 100;j++){
            ulW_D_inact[i][j] = 0;
        }
        act[i] = 0;
        ans[i] = 0;
    }

    /* 行列の要素数の入力 */
    scanf("%d %d", &row, &col);

    /* 行列Ａの入力 */
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            scanf("%d", &ulW_D_inact[i][j]);
        }
    }

    /* 行列Ｂの入力 */
    for(i = 0;i < col;i++){
        scanf("%d", &act[i]);
    }

    /* ＡとＢの積の計算 */
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            /* i番目の積の計算 */
            ans[i] += ulW_D_inact[i][j] * act[j];
        }
    }
    /* 積の出力 */
    for(i = 0;i < row;i++){
        /* i番目の積の出力 */
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2096
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String a = nextString();
		String b = nextString();
		String tmp = a+b;
		int ab = Integer.parseInt(tmp);

		int x = 1;
		while((int)Math.pow(x,2)<=ab){
			if((int)Math.pow(x,2)==ab){
				System.out.println("Yes");
				return;
			}
			x++;
		}
		System.out.println("No");

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 20052
#include<iostream>
#include<algorithm>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;

using namespace std;

template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	dump(arr,1,a);
}

int dp[1001][1001]={};

int main(){
	string s1,s2;
	cin >> s1 >> s2;

	int len1=s1.size(), len2=s2.size();

	rep(i,len1+1) dp[i][0] = i;
	
	rep(j,len2+1) dp[0][j] = j;
	
	repi(i,1,len1+1){
		repi(j,1,len2+1){
			dp[i][j] = min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+(s1[i-1]!=s2[j-1]));
		}
	}
	cout << dp[len1][len2] << "\n";
	
	return 0;
}


Measured memory_bytes: 7136
//ABC076A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	double r, g;
	cin >> r >> g;
	double ans = 2*g-r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  cout<<max(n+a,max(n*a,n-a));
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3492
c11, c12, c13 = [int(x) for x in input().split(' ')]
c21, c22, c23 = [int(x) for x in input().split(' ')]
c31, c32, c33 = [int(x) for x in input().split(' ')]

for b1 in range(0, 101):
    for b2 in range(0, 101):
        for b3 in range(0, 101):
            if (c11 - b1 == c12 - b2 == c13 - b3) and (c21 - b1 == c22 - b2 == c23 - b3) and (c31 - b1 == c32 - b2 == c33 - b3):
                print('Yes')
                exit()

print('No')

Measured memory_bytes: 3064