akhauriyash/Code-Regression huggingface dataset:
N = int(input())
li = list(map(int,input().split()))
sum = 0
pre = abs(li[0])
count = 0
zero = 0
for i in li:
    if i == 0:
        zero += 1
    if i < 0:
        count += 1
    sum += abs(i)
    if pre > abs(i):
        pre = abs(i)
if count%2 == 1 and zero == 0:
    print(sum-pre*2)
else:
    print(sum)

Measured memory_bytes: 64752
s = input()

if s.count("R") == 3:
    print(3)
elif s.count("R") == 0:
    print(0)
elif s[0] == "R" and s[1] == "R":
    print(2)
elif s[1] == "R" and s[2] == "R":
    print(2)
else:
    print(1)

Measured memory_bytes: 8940
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
template <typename T, class Operator>
struct SegTree
{
	vector<T> tree;
	Operator op;
	T def;
	int s;
	SegTree(int size, T val, Operator opr)
	{
		s=size;
		op=opr;
		tree.resize(4*size,val);
		def=val;
	}

	void add(int pos, T value)
	{
		add(pos,value,0,s,0);
	}

	// [low, hi) は全体の範囲
	void add(int pos, T value, int low, int hi, int i)
	{
		while(1)
		{
			tree[i]=op(tree[i],value);
			if(low+1<hi){
				int mid=(low+hi)/2;
				if(pos<mid){
					i=2*i+1;
					hi=mid;
				}
				else
				{
					i=2*i+2;
					low=mid;
				}
			}
			else
			{
				break;
			}
		}
	}

	// [a,b) を取得
	T get(int a, int b)
	{
		return get(a,b,0,s,0);
	}

	T get(int a, int b, int low, int hi, int i)
	{
		if(hi<=a||b<=low||hi<=low){
			return def;
		}
		if(a<=low&&hi<=b){
			return tree[i];
		}
		int mid=(low+hi)/2;
		return op(get(a,b,low,mid,2*i+1),get(a,b,mid,hi,2*i+2));
	}

	// 補助関数
	bool check(int a, int b, int low, int hi, int i, int v)
	{
		if(hi<=a||b<=low||hi<=low){
			return true;
		}
		if(a<=low&&hi<=b){
			return tree[i]%v==0;
		}
		int mid=(low+hi)/2;
		return check(a,b,low,mid,2*i+1,v)&&check(a,b,mid,hi,2*i+2,v);
	}
};

struct Max
{
	int operator()(int a, int b){
		return max(a,b);
	}
};

const LL inf=1<<20;
int l[2000];
int r[2000];
int main(){
    std::string A,B;
    std::cin >> A >> B;
	int N=A.size();
	LL ret=inf;
	for(int k=0;k<2;k++){
		for(int i=0;i<N;i++){
			l[i]=inf;
			r[i]=inf;
			for(int j=0;j<N;j++){
				if(B[j]=='1'){
					if(i==j){
						l[i]=r[i]=0;
					}
					int d=abs(i-j);
					if(i<=j){
						r[i]=min(r[i],d);
						l[i]=min(l[i],N-d);
					}
					else{
						l[i]=min(l[i],d);
						r[i]=min(r[i],N-d);
					}
				}
			}
			//cerr << "bb " << l[i] << ", " << r[i] << endl;
		}
		for(int s=0;s<=N;s++){
			SegTree<int,Max> tree(N+1,0,Max());
			LL sum=s;
			for(int i=0;i<N;i++){
				if(A[i]==B[(i+s)%N])
				{
					continue;
				}
				sum++;
				if(r[i]<=s){
					continue;
				}
				if(r[i]==inf){
					sum=inf;
					break;
				}
				tree.add(l[i],r[i]-s);
				//cerr << i << ", " << l[i] << ", " << r[i] - s << endl;
			}
			LL v=inf;
			for(int i=0;i<N;i++){
				v=min(v,sum+2*(i+tree.get(i+1,N+1)));
			}
			ret=min(ret,v);
			//cerr << "aaa " << sum << ", " << v << endl;
		}
		reverse(A.begin(),A.end());
		reverse(B.begin(),B.end());
	}
	if(ret>=inf)
	{
		ret=-1;
	}
	cout << ret << endl;
	
    return 0;
}


Measured memory_bytes: 3696
#!/usr/bin/env python3
from bisect import bisect_left


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()

    # 負数、 0数、 正数
    Ns = 0
    Zs = bisect_left(A, 0)
    Ps = bisect_left(A, 1)

    # print(Ns, Zs, Ps)
    lneg = Zs-Ns
    lzer = Ps-Zs
    lpos = N-Ps
    # print(lneg, lzer, lpos)

    prod_neg = lneg * lpos
    prod_zero = lzer * (lneg+lpos)+lzer*(lzer-1)//2
    # prod_pos = lneg*(lneg-1)//2 + lpos*(lpos-1)//2
    # print(prod_neg, prod_zero, prod_pos)

    if prod_neg >= K:
        # 二分探索
        left = A[0]*A[-1]
        right = 0
        while right-left > 1:
            mid = (right + left)//2
            # しゃくとり法
            counter = 0
            ps = Ps
            for ns in range(Ns, Zs):
                while ps < N and A[ns]*A[ps] > mid-1:
                    ps += 1
                if ps == N:
                    break
                counter += N-ps
                # print("add: ", N-ps)
            # print("{} in [{}, {}] ==> {}".format(mid, left, right, counter))
            if counter < K:
                left = mid
            else:
                right = mid
        print(left)
    elif prod_zero + prod_neg >= K:
        print(0)
    else:
        KK = K-prod_neg-prod_zero
        # 二分探索
        left = 0
        right = max(A[0]**2, A[-1]**2)
        while right - left > 1:
            mid = (left + right)//2
            # しゃくとり法
            counter = 0
            end = N-1
            for start in range(Ps, N):
                while end >= start and A[start]*A[end] >= mid:
                    end -= 1
                if end <= start:
                    break
                counter += end-start
            start = 0
            for end in range(Zs-1, -1, -1):
                while end >= start and A[start]*A[end] >= mid:
                    start += 1
                if end <= start:
                    break
                counter += end-start
            # print("{} in [{}, {}] ==> {}".format(mid, left, right, counter))
            if counter < KK:
                left = mid
            else:
                right = mid
        print(left)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88148
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
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 gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}

ll insersionsort(vector<int> &a, int g) {
	ll res = 0;
	for (int i = g; i < a.size(); i++)
	{
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v) {
			swap(a[j + g], a[j]);
			j -= g;
			res++;
		}
		a[j + g] = v;
	}
	return res;
}
ll shellsort(vector<int> &a, vector<int> g) {
	ll cnt = 0;
	
	for (int gi : g) {
		cnt += insersionsort(a, gi);
	}
	return cnt;
}
void solv() {
	
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		a.push_back(v);
	}

	vector<int> g;
	for (int i = 1; i <= n; i *= 2)
	{
		g.push_back(i);
	}
	reverse(g.begin(), g.end());
	cout << g.size() << endl;
	for (int i = 0; i < g.size(); i++)
	{
		if (i > 0) cout << " ";
		cout << g[i];
	}
	cout << endl;
	cout << shellsort(a, g) << endl;
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << endl;
	}
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 7044
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func main() {
	N := readInt()
	A := make([]*big.Int, N)
	for i := 0; i < N; i++ {
		A[i] = big.NewInt(int64(readInt()))
	}

	t := new(big.Int)

	lcm := big.NewInt(1)
	for i := 0; i < N; i++ {
		t.GCD(nil, nil, lcm, A[i])
		lcm.Mul(lcm, A[i])
		lcm.Div(lcm, t)
	}

	result := big.NewInt(0)
	for i := 0; i < N; i++ {
		result.Add(result, t.Div(lcm, A[i]))
	}
	result.Rem(result, big.NewInt(m))

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 10596
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	string h;
	cin >> h;
	reverse(all(h));
	cout << h << endl;
}


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

long long add_modp(long long a, long long b, long long p){
    // a+b mod p
    return (a % p + b % p) % p;
}
//https://atcoder.jp/contests/abc147/submissions/8896778
long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}
 
long long pow_modp(long long a, long long n, long long p){
    // a^n mod p
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  const int max_A_pow = 60;//条件よりAの最大値は2の60乗
  vector<ll> num_bit(max_A_pow, 0);//各Aの値の2進数表現した時のkビット目が1である個数のベクトル
  const ll mod = pow(10, 9) + 7;
  //cout << mod << endl;
  //前提として，頭に入れるべきなのは，求める値ΣΣ{(A_ik)XOR(A_jk)}というのは N個のAを2つ選ぶ選び方の総数分だけXORした和です．
  
  //各Aの値を2進数で表現した時のkビット目が1である個数を数える
  for(int i=0; i<N; i++){
    ll A_bit = A.at(i); //A[i]をビットとして扱う(ビットシフトで扱う)
    ll focus_bit = 0; //2進数表現した時の注目している累乗 (focus_bitがk)
    while(A_bit){//A_bitをビットシフト出来なくなるまでループ
      if(A_bit & 1) num_bit.at(focus_bit)++;//A_bitが2で割り切れるなら+1する
      A_bit = A_bit >> 1;//注目数ビットを左に１つ移動するためにA_bitを右に1桁シフトする
      focus_bit++;//次のビットに注目     
    }
  }
  
  //num_bitがちゃんと数えれたか確認
  //for(int i=0; i<num_bit.size(); i++) cout << "num_bit[" << i << "]: " << num_bit.at(i) << endl;
  
  //2進数表現された各Aのkビット目だけに注目した時，ΣΣ{(A_ik)XOR(A_jk)} は b[k]×(N-b[k])
  //つまり, (kビット目が1の個数)*(kビット目が0の個数)   A_ikやA_jkは 各Aのkビット目の値
  //なぜなら，XORは異なれば1,同じなら0であり, (1の個数)C1*(0の個数)C1   (CはCombination)
  //例えば, 各Aのkビット目の0,1を並べたら，00100110となるとき 異なる数字の選び方は5C1 * 3C1
  ll ans = 0;
  for(int i=0; i<max_A_pow; i++){
    //ans += num_bit.at(i)*(N-num_bit.at(i)) * pow(2,i);//mod計算する↓↓
    ll first = mul_modp(num_bit.at(i), N-num_bit.at(i), mod);//num_bit.at(i)*(N-num_bit.at(i))
    ll second = pow_modp(2, i, mod);//pow(2, i)
    //cout << i << ": " << ans;
    ans =  add_modp(ans, mul_modp(first, second, mod), mod);
    //cout << "," << ans << endl;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   long long n;
   cin >> n;
   string ans;
   if(n==0){
       cout << 0 << endl;
       return 0;
   }
   for(int i = 0; n !=0; ++i){
       ans = to_string((int)abs(n)%2) + ans;
       if(n>0) n = -(n/2);
       else {
           if((-n)%2!=0) n = ((-n)/2)+1;
           else n = ((-n)/2);
       }
   }
   cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int digit_sum(int base, int x){
    int res=0;
    while(x>0){
        res+=x%base;
        x/=base;
    }
    return res;
}

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,s; cin>>n>>s;
    
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    
    int pl=2;
    while(pl*pl<=n){
        if(digit_sum(pl, n)==s){
            cout<<pl<<endl;
            return 0;
        }
        pl++;
    }
    
    int num=n/pl;
    int ans=INF;
    for(int i=1; i<=num; i++){
        int st=n/i,en=n/(i+1)+1,cr=digit_sum(st,n);
        if((s-cr)%i==0 and (s-cr)/i>=0 and (s-cr)/i<=st-en){
            chmin(ans,st-(s-cr)/i);
        }
    }
    
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
  
    public int dp(int[] arr,int[] dp,int n,int k,int index) {
    	if(dp[index]!=-1) {
    		return dp[index];
    	}
    	if(index==n-1) {
    		dp[n-1]=0;
    		return 0;
    	}
    	if(index==n-2) {
    		dp[n-2]=Math.abs(arr[n-1]-arr[n-2]);
    		return dp[n-2];
    	}
    	int min=Integer.MAX_VALUE;
    	for(int i=1;i<=k && index+i<n;i++) {
    		int temp=this.dp(arr, dp, n, k, index+i);
    		if(min>temp+Math.abs(arr[index]-arr[index+i])) {
    			min=temp+Math.abs(arr[index]-arr[index+i]);
    		}
    	}
    	dp[index]=min;
    	return dp[index];
    }
	public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] arr=new int[n];
        int[] dp=new int[n];
        for(int i=0;i<n;i++) {
        	arr[i]=sc.nextInt();
        	
        }
        Main mm=new Main();
        for(int i=0;i<n;i++) {
        	dp[i]=-1;
        }
        System.out.println(mm.dp(arr, dp, n,k, 0));
        
       }
    
    
}


Measured memory_bytes: 73188
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char **argv) {
    int array[5], k;
    int count = 0;

    cin >> array[0] >> array[1] >> array[2] >> array[3] >> array[4] >> k;

    for (int i = 0; i < 5; i++){
        for (int j = 0; j < 5; j++){
            if (abs(array[i] - array[j]) > k){
                count++;
            }
        }
    }

    if (count != 0){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		int value = b - a;
		int high = 0;

		for (int i = 1; i < value; i++) {
			high += i; 
		}

		System.out.println(high - a);

	}
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ensmallen l = l % 1000000007L

// main code

let n = Console.ReadLine() |> int
[1..n] |> Seq.fold (fun acc x -> ensmallen (acc * int64 x)) 1L |> Puts


Measured memory_bytes: 18516
n = int(input())
a = list(map(int, input().split()))

one = 0
two = 0
four = 0
for x in a:
    if x % 4 == 0:
        four += 1
    elif x % 2 == 0:
        two += 1
    else:
        one += 1

if one == 0 or (two == 0 and four+1 >= one) or (two >= 1 and four >= one) or (four+1 >= one+two):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62576
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N, K;
    scanf("%lld %lld", &N, &K);
    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i]--;
    }

    ll id = 0;
    vector<ll> check(N, -1);
    ll loopid, loopcount;
    for (ll i = 0; i < N; i++)
    {
        if (check[id] != -1)
        {
            loopid = id;
            loopcount = i - check[id];
            break;
        }

        check[id] = i;
        id = A[id];
    }

    id = 0;
    for (ll i = K; i >= 0; i--)
    {
        if (id == loopid)
        {
            i %= loopcount;
        }

        if (i != 0)
            id = A[id];
    }

    printf("%lld", id + 1);
}


Measured memory_bytes: 6500
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<stack>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define prt(x) printf("%d\n",x)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-10;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,string> pcc;
typedef pair<double,double> pbb;
char s[200005];
int main()
{
	int t;
	cin>>t;
	cin>>s;
	int c=0,ans=0;
	for(int i=0;i<t;i++)
	{
		if(s[i]=='R')
		c++;
	}
	for(int i=0;i<c;i++)
	{
		if(s[i]!='R')
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3824
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

btc_price = 380000.0

n = int(input())
asset = 0.0
for _ in range(n):
    x,u = input().split()
    if u == "JPY":
        asset += int(x)
    else:
        asset += float(x) * btc_price
print(asset)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll i,j,k,n,a=1;
int main()
{
  for(cin>>n,i=n;i>0;i--)for(j=sqrt(i);j>0;j--)if(j*j==i)return cout<<int(i), 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int cnt,i; 
        String line,chr;
        String[] str = new String[1000];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        chr = in.readLine(); cnt=0;
        while((line=in.readLine()) != null){
            if("END_OF_TEXT".equals(line)) break;
            str = line.split(" ",-1);
            for(i=0;i<str.length;i++){
                if(str[i].equalsIgnoreCase(chr)) cnt+=1;
            }
        }
        System.out.println(cnt);
        System.out.flush();
    }
}

Measured memory_bytes: 24232
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;

int gcd(int x, int y){
	if(y==0) return x;
	else return gcd(y, x % y);
}

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i){
		cin >> a[i];
	}
	vector<int> v(n+1, 0);
	for(int i=0; i<n; ++i){
		v[i+1] = gcd(v[i], a[i]);
	}
	int tmp=0, ans=0;
	for(int i=n-1; i>=0; --i){
		ans = max(ans, gcd(v[i], tmp));
		tmp = gcd(tmp, a[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
a,b,c,d,n,*A=`dd`.split.map &:to_i;e=f=1;a>c&&(a,c,e=c,a,-1);b>d&&(b,d,f=d,b,-1);V=[];A.each_slice(2){|x,y|(a..c)===x&&(b..d)===y&&V<<[x*e,y*f]};D=[F=1e9]*-~n;V.sort.map{|x,y|D[D.bsearch_index{|e|e>y}]=y};N=D.index{|e|e>=F};p 1e2*(c-a+d-b)-20*N+5*(N+(N>[c-a,d-b].min ? 1:0))*Math::PI

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

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

  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  vector<string> vv;
  for(int i = 1;i <= 5;i++){
    for(int j = 0;j < n - i + 1;j++){
      vv.push_back(s.substr(j, i));
    }
  }
  sort(vv.begin(), vv.end());
  vv.resize(unique(vv.begin(), vv.end()) - vv.begin());

  cout << vv[k - 1];
  return 0;
}


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

int main() {
	string a, b, c, n, x, y;
	cin >> n;
	for(int i = 0; i < 3; i++){
		if (n[i] == '1'){
			cout << 9;
		}else if(n[i] == '9'){
			cout << 1;
		}else{
			cout << n[i];
		}
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 764
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    if x[1][0]==1 and x[2][0]==1:
      flag=1
    if x[1][1]==1 and x[2][2]==1:
      flag=1
  if x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    if x[1][0]==1 and x[1][2]==1:
      flag=1
    if x[0][2]==1 and x[2][0]==1:
      flag=1
  if x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    if x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  #print(x)
else:
  print("No")

Measured memory_bytes: 3188
inf = 10**15
mod = 10**9+7

n,k = map(int, input().split())
a = list(map(int, input().split()))
firstkouho = []
roopkouho = []
visited = [False for i in range(n)]
tmp = 0
while visited[tmp] == False:
    visited[tmp] = True
    tmp2 = a[tmp] - 1
    tmp = tmp2
roopstart = tmp


tmp = 0
countstart = 0
while tmp != roopstart:
    firstkouho.append(tmp)
    tmp2 = a[tmp]-1
    tmp = tmp2
    countstart += 1

length = 1
roopkouho.append(roopstart)
if a[roopstart]-1 != roopstart:
    tmp = a[roopstart]-1
    while tmp != roopstart:
        roopkouho.append(tmp)
        length += 1
        tmp2 = a[tmp] - 1
        tmp = tmp2



if k < countstart:
    if countstart != 0:
        print(firstkouho[k]+1)
    else:
        print(1)
else:
    r = k-countstart
    print(roopkouho[r%length]+1)

Measured memory_bytes: 107120
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N = int(input())
P = list(map(int, input().split()))
a = [i*N for i in range(1, N+1)]
b = a[::-1]
for i, p in enumerate(P):
    a[p-1] += i
print(*a)
print(*b)


Measured memory_bytes: 6648
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int lb(vector<int>& Z, int z) {
	return lower_bound(Z.begin(), Z.end(), z) - Z.begin();
}

int ub(vector<int>& Z, int z) {
	return upper_bound(Z.begin(), Z.end(), z) - Z.begin();
}

int compress(vector<int>& z, vector<int>& z1, vector<int>& z2) {
	int n = z.size(), m = z1.size();
	vector<int> Z;
	for (int i = 0; i < n; i++)
		Z.push_back(z[i]);
	sort(Z.begin(), Z.end());
	Z.erase(unique(Z.begin(), Z.end()), Z.end());
	for (int i = 0; i < n; i++)
		z[i] = lb(Z, z[i]);
	for (int j = 0; j < m; j++) {
		z1[j] = lb(Z, z1[j]);
		z2[j] = ub(Z, z2[j]) - 1;
	}
	return Z.size();
}

int main() {
	int n, m; cin >> n >> m;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &x[i], &y[i]);
	vector<int> x1(m), y1(m), x2(m), y2(m);
	for (int j = 0; j < m; j++)
		scanf("%d%d%d%d", &x1[j], &y1[j], &x2[j], &y2[j]);
	int w = compress(x, x1, x2), h = compress(y, y1, y2);
	vector< vector<int> > sum(h + 1, vector<int>(w + 1));
	for (int i = 0; i < n; i++)
		sum[y[i] + 1][x[i] + 1]++;
	for (int y = 1; y <= h; y++)
		for (int x = 1; x <= w; x++)
			sum[y][x] += sum[y][x - 1] + sum[y - 1][x] - sum[y - 1][x - 1];
	for (int j = 0; j < m; j++) {
		int l = x1[j], u = y1[j], r = x2[j] + 1, d = y2[j] + 1;
		printf("%d\n", sum[d][r] - sum[d][l] - sum[u][r] + sum[u][l]);
	}
}

Measured memory_bytes: 106868
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int main(){
	string s;
	cin>>s;
	int a = (s[0]!=s[s.size()-1]);
	int b = s.size()%2;
	if((a+b)%2==0){
		cout<<"First"<<endl;
	}else{
		cout<<"Second"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n&&n){
        int s[n],p[n],q[n],r[n],c[n];
        for(int i=0;i<n;i++){
            cin>>s[i]>>p[i]>>q[i]>>r[i];
            c[i]=p[i]*4+q[i]*9+r[i]*4;
        }
        int P,Q,R,C;
        cin>>P>>Q>>R>>C;
        vector<int> vec;
        for(int i=0;i<n;i++){
            if(p[i]<=P&&q[i]<=Q&&r[i]<=R&&c[i]<=C){
                vec.push_back(s[i]);
            }
        }
        for(auto x:vec)cout<<x<<endl;
        if(vec.empty())cout<<"NA"<<endl;
    }
}


Measured memory_bytes: 3248
n = int(input())
s = [input() for i in range(n)]
count,a,b,ab = 0,0,0,0
for word in s:
  count += word.count("AB")
  if word[0] == "B" and word[-1] =="A":
    ab += 1
  elif word[0] == "B":
    b += 1
  elif word[-1] == "A":
    a += 1
  else:
    pass
if ab == 0:
  print(min([a,b])+count)
else:
  if a == 0 and b == 0:
    print(ab-1+count)
  elif a == 0 or b == 0:
    print(ab+count)
  else:
    print(ab+1+min([a-1,b-1])+count)

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

using namespace std;

int main()
{
    int n, h, w;
    int ans = 0;

    cin >> n >> h >> w;

    if (n < h || n < w) {
        ans = 0;
    }
    else {
        ans = ((n - h) + 1) * ((n - w) + 1);
    }

    cout << ans << endl;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999

//char型のポインタ(=配列と意味は同じ)をString型と定義([0]から数える)
typedef char* String;

//文字列の長さを求める関数
int string_len(String str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

//文字列を標準入力から読み込み、それをString型のメモリを確保し直してくれる関数
//S[0]~S[n-1]までが入力で、S[n]は0になる
String string_input(void){
    int i,len;
    char buf[100];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    //ここまでは文字列の長さがわからなかったから、一旦1000個分のメモリを用意しそこに入力させる
    
    len=string_len(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}



int main(void){
    String S=string_input();
    int len=string_len(S);

    int* A;
    NEW(A,len);
    for(int i=0;i<len;i++){
        A[i]=ctoi(S[i]);
    }

    long long ans=0;
    for(int i=0;i<(1<<(len-1));i++){
        long tmp=A[0];
        for(int j=0;j<len-1;j++){
            if(i&(1<<j)){//もしiに2^jが含まれていれば
                ans+=tmp;
                tmp=A[j+1];
            }
            else{
                tmp=tmp*10+A[j+1];
            }
        }
        ans+=tmp;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5,M=1e6+5;
ll a[N],n,ans,cnt[M];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];
    map<ll,ll> mp;for(ll i=1;i<=n;i++)mp[a[i]]++;
    for(auto &ele:mp)if(ele.second>1)cnt[ele.first]=1;
    n=0;for(auto &ele:mp)a[++n]=ele.first;
    for(ll i=1;i<=n;i++){
        ans+=(cnt[a[i]]==0);
        for(ll j=a[i];j<M;j+=a[i])cnt[j]=1;
    }
    cout<<ans;
}



Measured memory_bytes: 25392
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int a[500000],b[500000];
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
void primeFactors(int n,int p)  
{  
    
   if(n%2==0){ a[p]=2;}
    while (n % 2 == 0)  
    {  
        // cout << 2 << " ";
        
        // a[p]=2;
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
     if(n%i==0){ if(a[p]>0) b[p]=i;
         else a[p]=i;
     }
        while (n % i == 0)  
        {  
            // cout << i << " ";  
            n = n/i;  
        }  
    }  
    // if(n>2)
}
void solve(){
   int n,x;
   cin>>x>>n;
   vector<int> v(300);
   for(int i=0;i<n;i++){
       int p;
       cin>>p;
       v[100+p-1]++;
       
   }
   for(int i=100+x-1,j=100+x-1;i<200+x;i++,j--)
   {    if(v[j]==0){ cout<<j-100+1;return;}
       if(v[i]==0) {cout<<i-100+1;return;}
   }
}
int main()
{   ios::sync_with_stdio(0);
    int t;
    // cin>>t;
    t=1;
    cin.tie(0);
    cout.tie(0);
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int d,g;
    cin>>d>>g;
    vi p(d),c(d);
    rep(i,d){
        cin>>p[i]>>c[i];
    }
    int ans=inf;
    rep(i,1<<d){
        int s=0;
        int t=0;
        int x=0;
        rep(j,d){
            if(i&1<<j){
                s+=100*(j+1)*p[j]+c[j];
                t+=p[j];
            }
            else{
                x=j;
            }
        }
        if(s<g){
            int y=(g-s+100*(x+1)-1)/(100*(x+1));
            if(y<=p[x]){
                s+=y*100*(x+1);
                t+=y;
            }
        }
        if(s>=g){
            ans=min(ans,t);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

using namespace std;

void solve(long long D, long long  T, long long  S) {
	bool ans = D <= T * S;
	cout << (ans ? "Yes" : "No") << endl;
}

int main() {
    long long D;
	scanf("%lld", &D);
	long long T;
	scanf("%lld", &T);
	long long S;
	scanf("%lld", &S);
	solve(D, T, S);
	return 0;
}


Measured memory_bytes: 3708
x, y = map(int, input().split(" "))
 
total = 0
 
rewards = {1: 300000, 2: 200000, 3: 100000}

x1 = rewards[x] if (x <= 3) else 0
y1 = rewards[y] if (y <= 3) else 0
 
if (x == 1 and y ==  1):
  total += 400000
if (x1 != None):
  total += x1
if (y1 != None):
  total += y1
 
print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int N,M; cin>>N>>M;
  int k=0;
  if(N%2!=0){
    for(int i=0; i<M; i++){
      if(i*2<N/2){
        cout<<1+i<<" "<<(N+1)/2-i<<endl;
        k++;
      }
      else cout<<(N+1)/2+i-k+1<<" "<<N-i+k<<endl;
    }
  }
  else{
    for(int i=0; i<M; i++){
      if(i*2<(N-1)/2){
        cout<<1+i<<" "<<N/2-i<<endl;
        k++;
      }
      else cout<<N/2+1+i-k+1<<" "<<N-i+k<<endl;
    }
  }
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    reverse(all(s));
    ll t = 0, p = 1LL;
    map<ll, ll> mp;
    ll res = 0;
    mp[0]++;
    for (int i = 0; i < s.length(); i++) {
        t += (s[i] - '0') * p;
        p *= 10LL;
        p %= 2019;
        t %= 2019;
        res += mp[t];
        mp[t]++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3748
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 2e3 + 3, mod = (int) 1e9 + 7;
#define int long long
void sadd(int &x, int y) { x += y; x %= mod; }
int dp[N], odp[N], comb[N][N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for (int i = 0; i < N; ++i)
        for (int j = 0; j <= i; ++j)
            comb[i][j] = (i == j || j == 0)? 1: (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
    dp[0] = 1;
    for (int x = a; x <= b; ++x) {
        memcpy(odp, dp, sizeof dp);
        memset(dp, 0, sizeof dp);
        for (int sz = 0; sz <= n; ++sz) {
            int z = 1;
            for (int pick = 0; sz + pick * x <= n && pick <= d; ++pick) {
                if (pick >= c) {
                    sadd(dp[sz + pick * x], odp[sz] * z % mod * comb[n - sz][pick * x] % mod);
                }
                if ((pick + 1) * x - 1 < N)
                    z = z * comb[(pick + 1) * x - 1][x - 1] % mod;
            }
        }
        for (int sz = 0; sz <= n; ++sz) {
            sadd(dp[sz], odp[sz]);
        }
    }
    cout << dp[n] << endl;
}

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

int main(void){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int a[n][m];

    for(int i=0; i<m; ++i)
        cin >> b[i];

    for(int i=0; i<n; ++i)
        for(int j=0; j<m; ++j)
            cin >> a[i][j];

    int count = 0;

    for(int i=0; i<n; ++i){
        int s = 0;
        for(int j=0; j<m; ++j){
            s += a[i][j] * b[j];
        }
        s += c;

        if(s > 0)
            count++;
    }
    cout << count;
}


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

#define rep(i,st,en) for(int i=st;i<=en;i++)
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

typedef long long LL;
const LL MOD=1000000007;
map <char,int> m;

int main(){
    FAST_IO;
    int n,cnt=0;
    char s;
    cin>>n;
    rep(i,1,n){
        cin>>s;
        if(!m[s]) m[s]=1,cnt++;
    }
    if(cnt==3) cout<<"Three"<<endl;
    else if(cnt==4) cout<<"Four"<<endl;

    return 0;
}


Measured memory_bytes: 256
input = raw_input
def lsum(x):
    return A[x[0]] + B[x[1]] + C[x[2]]

def nextlist():
    global lx
    idx = 0
    m = lsum(lx[0])
    for i in range(len(lx)):
        s = lsum(lx[i])
        if m < s:
            m = s
            idx = i
    p = lx.pop(idx)
    wa.append(lsum(p))
    if p[0] > 0:
        if not [p[0]-1, p[1], p[2]] in lx:
            lx.append([p[0]-1, p[1], p[2]])
    if p[1] > 0:
        if not [p[0], p[1]-1, p[2]] in lx:
            lx.append([p[0], p[1]-1, p[2]])
    if p[2] > 0:
        if not [p[0], p[1], p[2]-1] in lx:
            lx.append([p[0], p[1], p[2]-1])

l1 = list(map(int, input().split(" ")))

X,Y,Z,K = l1[0],l1[1],l1[2],l1[3]
A = sorted(list(map(int, input().split(" "))))
B = sorted(list(map(int, input().split(" "))))
C = sorted(list(map(int, input().split(" "))))

wa = []
lx = [[X-1,Y-1,Z-1]]

for i in range(K):
    nextlist()

for l in wa:
    print(l)


Measured memory_bytes: 34204
import java.util.*;

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

		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0) break;

			int[][] map = new int[h*2-1][w*2+1];

			for(int i=0;i<h*2-1;i++){
				if(i % 2 == 0){ //c_ÌÇ
					map[i][0] = 1;
					for(int j=0;j<w-1;j++){
						map[i][j*2+1] = 0;
						map[i][j*2+2] = sc.nextInt() == 1 ? 1 : 0;
					}
					map[i][w*2-1] = 0;
					map[i][w*2] = 1;
				}
				else{ //¡_ÌÇ
					for(int j=0;j<w;j++){
						map[i][j*2] = 1;
						map[i][j*2+1] = sc.nextInt() == 1 ? 1 : 0;
					}
					map[i][w*2] = 1;
				}
			}

			PriorityQueue<State> open = new PriorityQueue<State>();
			HashSet<State> closed = new HashSet<State>();
			State st = new State(1,0,0);
			open.add(st);
			State ans = null;

			while(!open.isEmpty()){
				st = open.poll();
				if(closed.contains(st)) continue;
				closed.add(st);

				if(st.x == w*2-1 && st.y == h*2-2){
					ans = st;
					break;
				}

				open.addAll(st.nexts(map));
			}

			System.out.println(ans == null ? 0 : ans.cost+1);
		}
	}
}

class State implements Comparable<State>{
	int x,y;
	int cost;

	State(int x,int y,int cost){
		this.x = x;
		this.y = y;
		this.cost = cost;
	}

	public List<State> nexts(int[][] map){
		int[] dx = {1,-1,0,0};
		int[] dy = {0,0,1,-1};
		List<State> sts = new ArrayList<State>();

		for(int i=0;i<4;i++){
			int nx = x + 2*dx[i];
			int ny = y + 2*dy[i];
			int tx = x + dx[i];
			int ty = y + dy[i];

			if(nx>=0 && nx<map[0].length && ny>=0 && ny<map.length && map[ty][tx]==0 && map[ny][nx]==0){
				sts.add(new State(nx,ny,cost+1));
			}
		}

		return sts;
	}

	public boolean equals(Object o){
		State st = (State)o;
		return st.x == x && st.y == y;
	}

	public int hashCode(){
		return x * 10000 + y;
	}

	public int compareTo(State st){
		return this.cost - st.cost;
	}
}

Measured memory_bytes: 13000
#include <stdio.h>

int main(void){

int i=0,j,k;
int N,v;
int A[1000];

scanf("%d",&N);
for(i=0;i<N;i++){
	scanf("%d",&A[i]);
}

for(k=0;k<N;k++){
	printf("%d",A[k]);
		if(k<N-1){
			printf(" ");
		}
	}
printf("\n");

for(i=1;i<N;i++){
	v = A[i];
	j = i-1;
	while(j>=0 && A[j]>v){
		A[j+1]=A[j];
		j--;
		A[j+1] = v;
	}
	for(k=0;k<N;k++){
	printf("%d",A[k]);
		if(k<N-1){
			printf(" ");
		}
	}
	printf("\n");
}

return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <algorithm>

using namespace std;

int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

int main() {
	int n, a[100010], pref[100010], suff[100010], maxi = 0;
	scanf("%d", &n);
	pref[0] = 0;
	suff[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		pref[i] = gcd(a[i], pref[i - 1]);
	}
	for (int i = n; i > 0; i--)
		suff[i] = gcd(a[i], suff[i + 1]);
	for (int i = 1; i <= n; i++) {
		a[i] = gcd(pref[i - 1], suff[i + 1]);
		maxi = max(maxi, a[i]);
	}
	printf("%d\n", maxi);
	return 0;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    const auto a = Read(n);
    ll m;
    cin >> m;
    const auto b = Read(m);

    auto ans = vi();
    set_symmetric_difference(ALL(a), ALL(b), inserter(ans, ans.end()));

    DumpRow(ans);

    return 0;
}



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

int wa(int x){
  int wa_x = 0;
  while(x%10 == 0){
    x = x/10;
  }
  while(x%10 > 0){
    wa_x = wa_x + x%10;
    x = x/10;
  }
  wa_x = wa_x + x;
  return wa_x;
}

int main(){
  int N;
  cin >> N;
  int min = 100;
    for(int i=1;i<N;i=i+1){
    int A = i;
    int a = A;
    int wa_A = wa(a);
    
    int B = N - i;
    int b = B;
    int wa_B = wa(b);
    
    if(min > wa_A + wa_B)min = wa_A + wa_B;
  }
  cout << min << endl;
}


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

int main() {
    int n;
    cin>>n;
    string s;
    set<string>gacha;
    rep(i,n) {
        cin>>s;
        gacha.insert(s);
    }
    cout<<gacha.size()<<endl;
}

Measured memory_bytes: 19200
s = input()
ls = len(s)
t = input()
lt = len(t)
for i in range( ls - lt + 1 ):
  start = ls - lt - i
  for j in range(lt):
    if s[start + j] != t[j] and s[start + j] != '?':
      break
  else:
    ss = ''
    for k in range(start):
      if s[k] == '?':
        ss += 'a'
      else:
        ss += s[k]
    #for k in range(start,start+lt)
    ss += t
    for k in range(start+lt,ls):
      if s[k] == '?':
        ss += 'a'
      else:
        ss += s[k]
    print(ss)
    break
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007

int main() {
    int N, A; cin >> N >> A;
    vector<int> X(N);
    int mx = 0;
    for(int &x:X){
        cin >> x;
        mx = max(mx, x);
    }

    vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(N+1, vector<ll>(mx*N+1)));
    
    for(int j=0; j<=N; j++){
        dp[j][0][0] = 1;
    }
    
    
    for(int j=0; j<N; j++){
        for(int k=0; k<=j+1; k++){
            for(int s=0; s<=mx*N; s++){
                if(s-X[j]>=0 && k-1>=0) dp[j+1][k][s] = dp[j][k][s] + dp[j][k-1][s-X[j]];
                else dp[j+1][k][s] = dp[j][k][s];
            }
        }
    }
    
    ll ans = 0;
    for(int k=1; k<=N; k++){
        ans += dp[N][k][k*A];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 52224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
#include <cstring>

using namespace std;

typedef long long ll;

char s[1000];

int main() {
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		printf("x");
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
 
int main(void){
    int s = 0, m = 0, cnt = 0;
    for(int v, n; scanf("%d,%d", &v, &n) == 2; s += v * n, m += n, cnt ++) ;
    
    printf("%d\n%.0f\n", s, (double)m / (cnt?cnt:1) + 0.5);
 
    return 0;
}

Measured memory_bytes: 1212