akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{



	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n        = Integer.parseInt(scanner.nextLine());
		String[] tmp = scanner.nextLine().split(" ");
		int t        = Integer.parseInt(tmp[0]);
		int a        = Integer.parseInt(tmp[1]);
		String[] atm = scanner.nextLine().split(" ");
		int[] list   = new int[n];
		double ans   = Integer.MAX_VALUE;
		int count    = 0;
		for(int i = 0; i < n; i++) {

			list[i]     = Integer.parseInt(atm[i]);
			double temp = t - 0.006 * list[i];


			if(ans > Math.abs(a - temp)) {

				count = i + 1;
				ans = Math.abs(a - temp);
			}

		}

		System.out.println(count);

	}
}

Measured memory_bytes: 36948
n = int(input())
num_list = [ int(input()) for i in range(n) ]

ans = num_list[0] // 2
num_list[0] %= 2

for i in range(1,n):
    m = min(num_list[i-1], num_list[i])
    ans += m
    num_list[i-1], num_list[i] = num_list[i-1] - m, num_list[i] - m
    ans += num_list[i] // 2
    num_list[i] %= 2

print(ans)

Measured memory_bytes: 50008
def LIS(n, a):
	lis = 0
	dp = [0] * n
	dp[0] = a[0]
	for i in range(1, n):
		cur = a[i]
		if cur < dp[0]:
			dp[0] = cur
		elif cur > dp[lis]:
			lis += 1
			dp[lis] = cur
		else:
			idx = find_pos(cur,0,lis,dp)
			dp[idx] = cur
	return lis + 1

def find_pos(target, floor, ceiling, dp):
	while floor < ceiling:
		guess_idx = int(floor+(ceiling-floor)/2)
		guess_val = dp[guess_idx]
		if guess_val == target:
			return guess_idx
		if guess_val < target:
			floor = guess_idx + 1
		else:
			ceiling = guess_idx - 1
	if dp[floor] < target:
		return floor + 1
	return floor

n = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
print(LIS(n, a))



Measured memory_bytes: 10208
#include<iostream>
using namespace std;
int main()
{
int i,n,z,t,f=0;
cin>>n;
for(i=n;;i++)
{f=0;
for(t=2;t<=n/2;t++)
{
if(i%t==0)
{f=1;
goto x;}
}
x:
if(f==0)
{z=i;
goto y;}
}
y:
cout<<i;
return 0;
}

Measured memory_bytes: 256
program name

    implicit none
    integer a,b,c,x
    integer an,bn,cn,counter
    read*, a
    read*, b
    read*, c
    read*, x
    counter = 0
    do an = 0, a, 1
        do bn = 0, b, 1
            do cn = 0, c, 1
                if ( an*500+bn*100+cn*50==x ) then
                    counter = counter + 1
                end if
            end do
        end do
    end do

print*, counter
end program

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()

anums = getList()
bnums = getList()
ans = 0
okay = [0 for i in range(n)]
update = True
while(update):
    update = False
    for i in range(n):
        if not okay[i]:
            if i == n - 1:
                j = 0
            else:
                j = i + 1
            h = i - 1
            a,b,c, tgt = bnums[h], bnums[i], bnums[j], anums[i]
            # print(a,b,c)
            if b > max(a, c):
                if tgt > b:
                    print(-1)
                    sys.exit()
                if tgt != b:
                    dec = math.ceil((b - (max(a, c, tgt)) ) / (a+c))
                    bnums[i] -= dec * (a+c)
                    ans += dec
                    update = True
                    if anums[i] == bnums[i]:
                        okay[i] = 1
    # print(coll, anums, bnums)

print(ans)

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	for (cin >> N; N; N--) {
		int a;
		cin >> a;
		if (a & 1) {
			cout << "first\n";
			return 0;
		}
	}
	cout << "second\n";
	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    G = [list(ST().split()) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if G[i][j] == "snuke":
                print(chr(ord("A")+j) + str(i+1) ) 
if __name__ == '__main__':
    main()


Measured memory_bytes: 64492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
 int n;
  cin>>n;
  ll ans=0;
  map<string,int> mp;
  rep(i,n){
   string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
    ans += (mp[s]-1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

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

    int n, m;
    while (cin >> n >> m, n) {
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        vector<int> b(m);
        rep(j, m) cin >> b[j];

        int sma = accumulate(all(a), 0);
        int smb = accumulate(all(b), 0);

        const int INF = 999999;
        int ansa = INF;
        int ansb = INF;
        rep(i, n) {
            rep(j, m) {
                if (sma - a[i] + b[j] == smb - b[j] + a[i] && a[i] + b[j] < ansa + ansb) {
                    ansa = a[i];
                    ansb = b[j];
                }
            }
        }

        if (ansa < INF) {
            cout << ansa << " " << ansb << endl;
        } else {
            cout << -1 << endl;
        }


    }
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
int solve(vector<int>V,int k){
    int res=0,l=0,r=0,s=V.size();
    while(true){
        while(r<s-1&&V[r+1]-V[l]<k)r++;
        r=min(r,s-1);
        res+=r-l;
        //cout<<V[l]<<':'<<V[r]<<endl;
        l++;
        if(l==s)break;
    }
    return res;
    
}
signed main(void){
    int n,k;cin>>n>>k;
    int V[200010];
    V[0]=0;
    rep(i,n){
        int a;cin>>a;
        V[i+1]=V[i]+a;
    }
    rep(i,n+1)V[i]=(V[i]-i+k*100000)%k;
    //rep(i,n+1)cout<<V[i]<<' ';
   // cout<<endl;
    vector<P>G(n+1);
    rep(i,n+1)G[i]=make_pair(V[i],i);
    sort(all(G));
    int now=0,ans=0;
    while(now<n+1){
        vector<int>V0;
        while(now<n+1){
            V0.push_back(G[now].S);
            if(G[now].F!=G[min(n,now+1)].F)break;
            now++;
        }
        //for(auto x:V0)cout<<x<<' ';
       // cout<<endl;
        now++;
        ans+=solve(V0,k);
    }
    cout<<ans<<endl;
    
    
}
        


Measured memory_bytes: 8176
n=int(input())
a=[0]*n
for ii in range(n):
  a[ii]=int(input())
import copy
a0=copy.copy(a)
a0.sort(reverse=True)
for ii in range(n):
  if a[ii]==a0[0]:
    print(a0[1])
  else:
    print(a0[0])

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll N;
    cin >> N;
    bool ans = false;
    for(ll i = 0; i <= 100; i++){
        for(ll j = 0; j <= 100; j++){
            if(4 * i + 7 * j == N) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll H, N; cin >> H >> N;
    vector<vector<ll>> dp(N+1, vector<ll>(H+1, infl));
    dp[0][0] = 0;
    rep(i,0,N) {
        ll a, b; cin >> a >> b;
        rep(j,0,H+1) {
            if (j > a) dp[i+1][j] = min(dp[i][j], min(dp[i][j-a] + b, dp[i+1][j-a] + b));
            else dp[i+1][j] = min(dp[i][j], dp[i][0] + b);
        }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 78592
#include <cstdio>

int n, m;
int card[201], tmp[201];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= 2*n; i++) card[i] = i;
	for(int u = 0; u < m; u++){
		int k; scanf("%d", &k);
		for(int i = 1; i <= 2*n; i++) tmp[i] = card[i];
		if(k == 0){
			for(int i = 1; i <= 2*n; i++){
				if(i%2) card[i] = tmp[(i+1)/2];
				else card[i] = tmp[i/2+n];
			}
		} else{
			for(int i = 1; i <= 2*n; i++){
				if(i+k <= 2*n) card[i] = tmp[i+k];
				else card[i] = tmp[i-2*n+k];
			}
		}
	}
	for(int i = 1; i <= 2*n; i++) printf("%d\n", card[i]);
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		long k = scanner.nextLong();
		long[] a=new long[n+1];
		long[] b=new long[m+1];
		a[0] = 0;
		b[0] = 0;

		for(int i=1 ; i<=n ; i++) {
			a[i] = scanner.nextLong() + a[i-1];
		}
		for(int i=1 ; i<=m ; i++) {
			b[i] = scanner.nextLong() + b[i-1];
		}

		int j = m;
		int count = 0;
		for(int i=0 ; i<=n ; i++) {
			if(a[i] > k) {
				break;
			}
			while(a[i] + b[j] > k) {
				j--;
			}
			count = Math.max(count,i+j);
		}

		System.out.println(count);

		scanner.close();

	}

}


Measured memory_bytes: 61808
#include <bits/stdc++.h>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1)
            res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n;
map<pll, int> num;
pll now[200200];

int main() {

    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; ++i) {
        long long x, y, g;
        scanf("%lld%lld", &x, &y);
        if (!x || !y) {
            if (!x && !y)
                ++cc;
            else if (!x)
                ++aa;
            else if (!y)
                ++bb;
            --i, --n;
            continue;
        }
        g = __gcd(abs(x), abs(y));
        if (x < 0)
            x = -x, y = -y;
        x /= g, y /= g;
        num[now[i] = make_pair(x, y)]++;
    }

    int ans = (fsp(2, aa) + fsp(2, bb) - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        if (!num[now[i]])
            continue;
        pll tmp = make_pair(-now[i].second, now[i].first);
        if (tmp.first < 0)
            tmp.first *= -1, tmp.second *= -1;
        int x = num[now[i]], y = num[tmp];
        num[now[i]] = num[tmp] = 0;
        int t = (fsp(2, x) + fsp(2, y) - 1) % mod;
        ans = 1ll * ans * t % mod;
    }

    ans = (ans - 1 + cc) % mod;
    if (ans < 0)
        ans += mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 31764
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;




int main(){
    int a,b;
    cin >> a >> b;
    
    double f = 1.000000*a/b;
    
    cout << fixed;
    cout << a/b <<" " << a%b <<" "<<setprecision(12) << f << endl;
    
    
}









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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(all(a), greater<ll>());
    ll sup = n;
    ll inf = 0;
    ll meyasu = a.at(p-1);
    while(sup - inf > 1){
        ll mid = (sup + inf)/2;
        if(meyasu - a.at(mid) > m){
            sup = mid;
            continue;
        }
        ll tmp = m*(p-1) + m*(n - mid);
        for(i = p-1;i < mid;++i){
            tmp += a.at(mid) + m - a.at(i);
        }
        if(tmp < m*v) sup = mid;
        else inf = mid;
    }
    cout << sup << endl;
    return 0;
}

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

using namespace std;

int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	// ios_base::sync_with_stdio(false);
	// cin.tie(0);

	string str;
	cin >> str;

	int answer=700;
	for (int i=0;i<3;i++)
	{
		if (str[i]=='o')
		{
			answer += 100;
		}
	}
	cout << answer;


	return 0;
}

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

using namespace std;

const int N = 2222, MOD = 1e9 + 7;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int n, k;
int dp[N + 1][N + 1];
int calc(int d)
{
    int rem = n - k - (d - 1);
    return ((dp[k - 1][d - 1]) % MOD * (dp[rem + d][d]) % MOD) % MOD;
}
main() {
    n = readInt(), k = readInt();
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        dp[i][i] = 1;
        dp[i][0] = 1;
        for (int j = 1; j < i; j++) {
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
            dp[i][j] %= MOD;
        }
    }
//    cout << dp[3][1] << "\n";
    for (int i = 1; i <= k; i++) {
        cout << calc(i) % MOD << "\n";
    }
}


Measured memory_bytes: 37376
a, b, c = map(int, input().split())
k = int(input())

t = max(a, b, c)

u = t * (2 ** k)

if t == a:
    print(u + b + c)
elif t == b:
    print(u + a + c)
elif t == c:
    print(u + a + b)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	ll N; cin >> N;
	ll* A = new ll[N];
	ll m = 0;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum = sum ^ A[i];
		m = m | A[i];
	}

	ll filter = m - sum;

	set<ll, greater<ll>> st;
	for (int i = 0; i < N; i++) {
		ll a = A[i] & filter;
		for (auto itr = st.begin(); itr != st.end(); itr++) {
			a = min(a, a ^ *itr);
		}
		if (a != 0) {
			st.insert(a);
		}
	}

	ll s = filter;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		s = min(s, (s ^ *itr) & filter);
	}
	cout << sum + (filter - s) * 2 << endl;

	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

struct UnionFindTree{
    vector<int>par,sz,uku;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
		uku.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
			uku[i]=i&1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
		uku[x]+=uku[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;
int G[777][777];

bitset<777>dp;

signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;a--;b--;G[a][b]=G[b][a]=1;
	}

	UnionFindTree uf(2*N);
	rep(i,N){
		for(int j=i+1;j<N;j++){
			if(G[i][j])continue;
			uf.unite(i*2,j*2+1);
			uf.unite(i*2+1,j*2);
		}
	}

	rep(i,N)if(uf.areSame(i*2,i*2+1)){
		cout<<-1<<endl;
		return 0;
	}

	vpint v;
	rep(i,N){
		bool ok=true;
		for(int j=0;j<i;j++)if(uf.areSame(i*2,j*2)||uf.areSame(i*2,j*2+1))ok=false;
		if(!ok)continue;
		int a=uf.uku[uf.find(i*2)];
		int b=uf.sz[uf.find(i*2)]-a;
		v.pb({a,b});
	}

	dp[0]=1;
	rep(i,v.size()){
		dp=(dp<<v[i].fi)|(dp<<v[i].se);
	}

	int ans=1001001001;
	rep(i,N+1){
		if(dp[i])chmin(ans,i*(i-1)/2+(N-i)*(N-i-1)/2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4608
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n] <- readInt
  a <- readInt
  print $ solve a

solve a = f (zip a [1 ..]) as 0 `div` 2
  where
    as = V.fromList a

f [] avs acc = acc
f ((a, index):as) avs acc
  | avs V.! (a - 1) == index = f as avs (acc + 1)
  | otherwise = f as avs acc


Measured memory_bytes: 20220
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=list(SI())
a=int(s[0])
ops=["+","-"]
for i in product(ops,repeat=3):
    ans=a
    for j in range(3):
        if i[j]=="+":
            ans+=int(s[j+1])
        else:
            ans-=int(s[j+1])
    if ans==7:
        u=i
        #print(i)
        break
print(s[0],end="")
for i in range(3):
    print(u[i]+s[i+1],end="")
print("=7")


            


    
    



    
    


    
    

Measured memory_bytes: 9392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  unordered_map<char,ll> mp;
  int N;
  cin >> N;
  string tmps;
  int M,A,R,C,H;
  M = A = R = C = H = 0;
  rep(i,N){
    cin >> tmps;
    mp[tmps[0]]++;
  }
  M = mp['M'];
  A = mp['A'];
  R = mp['R'];
  C = mp['C'];
  H = mp['H'];
  vector<ll> MARCH = {M,A,R,C,H};
  ll ans = 0;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++){
        ans += MARCH[i]*MARCH[j]*MARCH[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n,m,x = map(int, input().split())
a = []
c = []
for i in range(n):
    arr = list(map(int,input().split()))
    c.append(arr[0])
    a.append(arr[1:])
ans = 123456789
val = 1<<n
for mask in range(val):
    level = [0 for i in range(m)]
    cost = 0
    for i in range(n):
        if((mask>>i)&1):
            cost+=c[i]
            for j in range(m):
                level[j]+=a[i][j]
    ok = True
    for i in range(m):
        if(level[i] < x):
            ok = False
    if(ok):
        ans = min(cost, ans)
if(ans==123456789):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68572
#include <stdio.h>
char str[1000000];
int main(){
	int j,i;
	int n,m,count,ans;
	while(1){
		count=0;
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		scanf("%d",&m);
		//for(i=0;i<m;i++){
		//	printf("%d",i);
		//}
		//printf("\n");
		scanf("%s",str);
		for(j=0;(m-n*2)>j;j++){
			ans=-1;
			if(str[j]=='I'){
				
				for(i=0;i<n;i++){
					if(str[j+2*i+1]=='O'&&str[j+2*i+2]=='I'){
					}else{
						ans=i;
						break;
					}
				}
				
				if(ans==-1){
					count++;
				}else{
					j+=2*i;
				}
			}
			//printf("%d",ans);
			//printf(" %d %d\n",j,count);
		}
		printf("%d\n",count);
	}
}
				
		

Measured memory_bytes: 2008
def main():
    import sys 
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    c1 = [0]*60
    c0 = [0]*60
    mod = 10**9+7

    for i in l:
        for j in range(60):
            if (i >> j) & 1:
                c1[j] += 1
            else:
                c0[j] += 1

    ans = 0
    ni = 1
    for i in range(60):
        ans += (c1[i]*c0[i]*ni)%mod
        ans %= mod
        ni = ni*2%mod
    print(ans%mod)
if __name__ == "__main__":
    main()


Measured memory_bytes: 123132
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s[n];
  int m[n][26] = {};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < s[i].size(); j++) {
      m[i][s[i][j] - 'a']++;
    }
  }
  string t = "";
  for (int i = 0; i < 26; i++) {
    int cn = 50;
    for (int j = 0; j < n; j++) {
      cn = min(cn, m[j][i]);
    }
    t += string(cn, i + 'a');
  }
  cout << t << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int a[2][101];
  rep(i, 2) rep(j, n) cin >> a[i][j];

  int dp[2][101];
  memset(dp, -1, sizeof(dp));
  function<int(int, int)> dfs = [&](int i, int j) {
    int& res = dp[i][j];
    if(~res) return res;
    if(i == 1 && j == n-1) return res = a[i][j];
    if(i+1 < 2) chmax(res, dfs(i+1, j)+a[i][j]);
    if(j+1 < n) chmax(res, dfs(i, j+1)+a[i][j]);
    return res;
  };
  cout << dfs(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  map<int, ll> mp;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  repit(itr, mp){
    k -= itr->second;
    if(k <= 0){
      cout << itr->first << endl;
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 4224
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
const LL INF = 1LL << 60;
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
const LL N=100010;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
LL dp[11000];
int main() {
    int h, n;
    cin >> h >> n;
    vector<PII> ab(n); 
    REP(i,n){
        int a, b;cin >> a >> b;
        ab[i]=MP(a,b);
    }
    REP(i,11000){
        dp[i]=INF;
    }
    dp[h]=0;
    int l=h;
    while(l>=0){
        REP(i,n){
            int nh=max(0,l-ab[i].first);
            dp[nh]=min(dp[nh], dp[l]+ab[i].second);
        }
        l--;
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 3696
#include<stdio.h>
int dp[1001],n,m,i,j,a[1001],max;
int main()
{
    scanf("%d %d",&n,&m);
    while((m!=0)&&(n!=0))
    {
        max=-1;
        for(i=1;i<=n;i=i+1)
        {
            scanf("%d",&a[i]);
            for(j=1;j<i;j=j+1)
            {
                if(a[i]+a[j]<=m)
                    if(a[i]+a[j]>max)
                      max=a[i]+a[j];
            }
        }
        if(max!=-1)
          printf("%d\n",max);
        else
          printf("NONE\n");
       scanf("%d %d",&n,&m);
    }
    return 0;
}



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

int main() {
  ll mod=1e9+7;
  ll vec[105];
  vec[0]=1,vec[1]=1;
  for(int i=2;i<105;i++){
    vec[i]=vec[i-1]+vec[i-2];
  }
  ll pair[101][101][2];
  for(int i=2;i<101;i++){
    for(int j=0;j<i;j++){
      if(j==0){
        pair[i][j][0]=vec[i];
        pair[i][j][1]=vec[i+1];
        continue;
      }
      if(j==1){
        pair[i][j][0]=vec[i+1];
        pair[i][j][1]=2*vec[i+1]-vec[i];
        continue;
      }
      pair[i][j][0]=pair[i-1][j-1][1];
      pair[i][j][1]=pair[i-1][j-1][1]+pair[i-1][j-1][0];
    }
  }
  int q;
  cin>>q;
  ll x,y,z=1;
  ll w=0;
  ll o,p,r;
  for(int i=0;i<q;i++){
    cin>>x>>y;
    if(x>y){
      swap(x,y);
    }
    if(y==1){
      cout<<"1 1"<<endl;
      continue;
    }
    for(int j=0;j<98;j++){
      if(vec[j]>x||vec[j+1]>y){
        z=j-1;
        break;
      }
    }
    cout<<z<<" ";
    if(z==1){
      cout<<(x%mod*y%mod)%mod<<endl;
      continue;
    }
    w=0;
    for(int j=0;j<z;j++){
      o=pair[z][j][0];
      p=pair[z][j][1];
      if(o>x||p>y){
        continue;
      }
      r=y-p;
      r/=o;
      w+=r+1;
      w%=mod;
      if(x>=p){
        r=x-p;
        r/=o;
        w+=r+1;
        w%=mod;
      }
    }
    cout<<w<<endl;
  }
}


Measured memory_bytes: 4224
import sys
import heapq
from collections import deque
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')



N=int(input())
p=list(map(int,input().split()))	
pp=deque(p)
pp.appendleft(0)

q=sorted(range(len(pp)),key=lambda k:pp[k])
qq=deque(q)
qq.popleft()

print(*qq)

Measured memory_bytes: 15268
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;




int main(void) {
  ll N;
  cin >> N;
  ll i;
  ll a[MAX];
  P p[MAX];
  
  for(i=0; i<N; i++) {
    ll t;
    cin >> t;
    p[i].first=t;
    p[i].second=i;
  }
  sort(p, p+N);
  
  for(i=0; i<N; i++) {
    ll idx=p[i].second;
    a[idx]=i;
  }
  
  ll ans=0;
  for(i=0; i<N; i+=2) {
    if(i%2!=a[i]%2) ans++;
  }
  
  pt(ans);
}


Measured memory_bytes: 2560
while True:
  w, h = map(int, input().split())
  if w == 0:
    break

  mp = [[0] + list(input()) + [0] for _ in range(h)]
  mp.insert(0, [0] * (w + 2))
  mp.append([0] * (w + 2))
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] == ".":
        mp[y][x] = 0
      else:
        mp[y][x] = int(mp[y][x])

  last_id = 10
  vec = ((0, 1), (0, -1), (1, 0), (-1, 0))
  
  def update(last_id, target, x, y):
    if mp[y][x] != target:
      return
    mp[y][x] = last_id
    for dx, dy in vec:
      update(last_id, target, x + dx, y + dy)
  
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if 1 <= mp[y][x] <= 9:
        update(last_id, mp[y][x], x, y)
        last_id += 1

  node_num = last_id - 10

  edges = [set() for _ in range(node_num)]
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y - 1][x] != mp[y][x] and mp[y - 1][x] != 0 and mp[y][x] != 0:
        edges[mp[y][x] - 10].add(mp[y - 1][x] - 10)

  for x in range(1, w + 1):
    if mp[h][x] != 0:
      root = mp[h][x] - 10
      break
  
  center = [0] * node_num
  ground = [None] * node_num
    
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] != 0:
        target = mp[y][x] - 10
        center[target] += (x + 0.5) / 4
        if mp[y + 1][x] in (0, target + 10):
          continue
        if ground[target] == None:
          ground[target] = [x, x + 1]
        else:
          ground[target][0] = min(ground[target][0], x)
          ground[target][1] = max(ground[target][1], x + 1)

  for x in range(1, w + 1):
    if mp[h][x] == root + 10:
      if ground[root] == None:
        ground[root] = [x, x + 1]
      else:
        ground[root][0] = min(ground[root][0], x)
        ground[root][1] = max(ground[root][1], x + 1)

  total_center = [None] *  node_num
  def get_total_center(node):
    mom = center[node]
    wei = 1
    for to in edges[node]:
      to_wei, to_pos = get_total_center(to)
      mom += to_wei * to_pos
      wei += to_wei

    total_center[node] = mom / wei
    return wei, total_center[node]
  
  get_total_center(root)

  for gr, cen in zip(ground, total_center):
    l, r = gr
    if not (l < cen < r):
      print("UNSTABLE")
      break
  else:
    print("STABLE")



Measured memory_bytes: 5656
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define int ll
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5, LG = 61;

int X[N], Y[N], PAR[LG][N];

int GetPar(int v, ll h) {
	for (int i = 0; i < LG; i++) if ((1LL << i) & h) v = PAR[i][v];
	return v;
}

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> X[i];
	for (int i = 0; i < n - 1; i++) Y[i] = X[i + 1] - X[i], PAR[0][i] = i;
	int m; cin >> m;
	ll k; cin >> k;
	for (int i = 0; i < m; i++) {
		int a; cin >> a; a--;
		swap(Y[a - 1], Y[a]);
		swap(PAR[0][a - 1], PAR[0][a]);
	}
	for (int pw = 1; pw < LG; pw++) for (int i = 0; i < n - 1; i++) PAR[pw][i] = PAR[pw - 1][PAR[pw - 1][i]];
	int last = X[0];
	for (int i = 0; i < n - 1; i++) {
		cout << last << endl;
		int p = GetPar(i, k);
		last += X[p + 1] - X[p];
	}
	cout << last << endl;

	return 0;
}

Measured memory_bytes: 52776
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	int n = s.size();
	// keisan
	if(n%2 != 0){
		cout << "No";
		return 0;
	}else{
		for(int i=0;i<n;i=i+2){
			if(s[i] != 'h' || s[i+1] != 'i'){
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
		return 0;
	}
	// syutsuryoku
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a[4],b[4];
	while(1){
		if(not (cin >> a[0] >> a[1] >> a[2] >> a[3])) break;
		if(not (cin >> b[0] >> b[1] >> b[2] >> b[3])) break;
		int hit = 0;
		int blow = 0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i]) hit++;
			for(int j=1;j<=3;j++) if(a[i]==b[(i+j)%4]) blow++;
		}
		cout << hit << " " <<  blow << endl;
	}
}

Measured memory_bytes: 1160
N = int(input()) #1行目のNを取得する
list = list(map(int, input().split()))
i=0
j=1
k=2
kosuu=0

while i<=N-3:
  while j<=N-2:
    while k<=N-1:
      x=list[i]
      y=list[j]
      z=list[k]
      if x+y>z and y+z>x and z+x>y and x!=y and y!=z and z!=x:
        kosuu+=1
      k+=1
      
    j+=1
    k=j+1
  i+=1
  j=i+1
  k=j+1
print(kosuu)

Measured memory_bytes: 67676
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i = a:i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

int main (){
  int n;
  while (cin >> n){
    int A[n];
    int ans = 0;
    REP(i,n){
      cin >> A[i];
    }
    bool b = true;
    while(b){
      REP(i,n){
	if(A[i] % 2 == 0){
	  A[i] /= 2;
	}else{
	  b = false;
	  break;
	}
      }
      if(b) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
 
bool is_leap_year(int y);
int  get_leap_years(int list[], int begin, int end);
 
int main(void)
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない
 
    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので
 
    while (true) {
        int year_begin, year_end;
 
        //読み込み
        scanf("%d %d", &year_begin, &year_end);
 
        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }
 
        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);
 
        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }
 
        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
 
    }
}

int  get_leap_years(int list[], int begin, int end)
{
    int j = 0;
    for (int year = begin; year <= end; year++) {
    if (is_leap_year(year)) {
    list[j] = year;
    j++;
    }
    }
    return j;
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true;
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<char> s(n);
    cin>>s; 
    if(count(ALL(s),'Y')>0) {
        cout<<"Four"<<endl;
    } else {
        cout<<"Three"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);

    int ans=0;

    if(n<10)ans=n;
    else if(n>=10&&n<100)ans=9;
    else if(n>=100&&n<1000)ans=9+(n-99);
    else if(n>=1000&&n<10000)ans=909;
    else if(n>=10000&&n<100000)ans=909+(n-9999);
    else ans=90909;
    printf("%d",ans);
}



Measured memory_bytes: 128
(defun calc (r d xi)
  (- (* r xi) d))

(defun rec (r d xi c)
  (if (> c 9)
    nil
    (append (list (calc r d xi)) (rec r d (calc r d xi) (1+ c)))))

(format t "~{~a~^~%~}~%" (rec (read) (read) (read) 0))


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

const double PI=acos(-1.0);

int main() {
    int n;
    cin >> n;
    
    int a[2][n + 1];
    a[0][0] = 0, a[1][0] = 0;
    for(int i = 0; i < 2; i++) {
        for(int j = 1; j < n + 1; j++) {
            int x;
            cin >> x;
            a[i][j] = x + a[i][j - 1];
        }
    }

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

f = (0..n).map { 0 }

(1..100).each do |x|
  (1..100).each do |y|
    (1..100).each do |z|
      v = x * x + y * y + z * z + x * y + y * z + z * x
      f[v] += 1 if v <= n
    end
  end
end

(1..n).each { |i| puts f[i] }


Measured memory_bytes: 14424
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n, m, x;
	cin >> n >> m >> x;
	int A = 0, B = 0;
	rep(i, m) {
		int a;
		cin >> a;
		if (a < x)
			A++;
		else
			B++;
	}
	cout << min(A, B) << endl;
}


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

using namespace std;

const int N = 1e5 + 5;

char s[N];

int main() {
  int n, a, b;
  scanf("%d %d %d %s", &n, &a, &b, s);
  int all = 0, luar = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      if (all + 1 <= a + b) {
        all++;
        puts("Yes");
      } else {
        puts("No");
      }
    } else if (s[i] == 'b') {
      if (all + 1 <= a + b && luar + 1 <= b) {
        all++;
        luar++;
        puts("Yes");
      } else {
        puts("No");
      }
    } else {
      puts("No");
    }
  }
  
  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 3e2 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll dp[2][MAXN][MAXN];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	ll n = s.size();
	s = '!' + s;
	ll k;
	cin >> k;
	ll ii, t, ans = 1;
	for(int i = 1; i <= n; i++){
		ii = i & 1;
		//debug(i);
		memset(dp[ii], 0, sizeof dp[ii]);
		for(int j = n; j > i; j--){
			if(s[i] == s[j]) t = 2;
			else t = 0;
			
			dp[ii][j][0] = max({dp[1 - ii][j][0], dp[1 - ii][j + 1][0] + t, dp[ii][j + 1][0]});
			for(int l = 1; l <= k; l++){
				dp[ii][j][l] = max({dp[1 - ii][j][l], dp[1 - ii][j + 1][l] + t, dp[ii][j + 1][l]});
				dp[ii][j][l] = max(dp[ii][j][l], dp[1 - ii][j + 1][l - 1] + 2);
				ans = max(ans, dp[ii][j][l] + (i + 1 < j ? 1 : 0));
			}
			ans = max(ans, dp[ii][j][0] + (i + 1 < j ? 1 : 0));
		}
	}
	cout << ans;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 1792
n = int(input())
s = input()
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      a = s.find(str(i))
      if a==-1:
        continue
      b = s.find(str(j), a+1)
      if b==-1:
        continue
      c = s.find(str(k), b+1)
      if c==-1:
        continue
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pli;

const int N=10;
const int M=55;
ll cnt[N][M];
int v[N][M];

void init(){
    for(int i=0;i<N;i++){
        v[i][0]=i,cnt[i][0]=0;
        for(int j=1;j<M;j++){
            cnt[i][j]=2*cnt[i][j-1]+1;
            v[i][j]=2*v[i][j-1];
            if(v[i][j]>=10) v[i][j]-=9,cnt[i][j]++;
        }
    }
}

void calAns(pli& ans,int num,ll len){
    ll& curcnt=ans.first;
    int& curv=ans.second;
    for(int i=0;i<M;i++){
        if((len>>i)&1){
            curcnt+=cnt[num][i]+1;
            curv+=v[num][i];
            if(curv>=10) curv-=9,curcnt++;
        }
    }
}

void solve(){
    init();
    pli ans=pli(0LL,0);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int d;
        ll c;
        scanf("%d%lld",&d,&c);
        calAns(ans,d,c);
    }
    printf("%lld\n",ans.first-1);
}

int main(){

    solve();
    return 0;
}

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

signed main(){
  string S,ans="No";
  cin>>S;
  int A[3];
  rep(i,3)A[i]=0;
  rep(i,3){
    A[S[i]-'a']+=1;
  }
  if(A[0]==1&&A[1]==1&&A[2]==1)ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256