akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=(LL)1e9+7LL; 

int main(){
    int N;cin>>N;
    LL T;cin>>T;
    vector<LL>t(N);
    REP(i,N)cin>>t[i];
    LL res=0;
    FOR(i,1,N){
        res+=min(t[i]-t[i-1],T);
    }
    res+=T;
    cout<<res<<endl;
    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll A, B, C, D;
map<ll, ll> ma;

ll solve_sub(ll n)
{
	if (n == 0) return 0;
	if (ma.count(n)) return ma[n];
	ll res;
	if (n <= 3e9) res = n*D;
	else res = 1e18;

	for (ll i = -1; i <= 1; ++i)
	{
		ll x = n + i;
		if (x < 0 || x & 1) continue;
		ll y = x/2;
		if (y < n)
			res = min(res, abs(i)*D + A + solve_sub(y));
	}

	for (ll i = -2; i <= 2; ++i)
	{
		ll x = n + i;
		if (x < 0 || x % 3 != 0) continue;
		ll y = x/3;
		if (y < n)
			res = min(res, abs(i)*D + B + solve_sub(y));
	}

	for (ll i = -4; i <= 4; ++i)
	{
		ll x = n + i;
		if (x < 0 || x % 5 != 0) continue;
		ll y = x/5;
		if (y < n)
			res = min(res, abs(i)*D + C + solve_sub(y));
	}

	return ma[n] = res;
}

ll solve()
{
	ll N;
	cin >> N >> A >> B >> C >> D;
	ma.clear();
	return solve_sub(N);
}

int main(int argc, char **argv)
{
	ll T; cin >> T;
	REP(i, T)
	{
		std::cout << solve() << std::endl;
	}
}


Measured memory_bytes: 4332
n = int(input())
w = list(map(int, input().split()))

min = float('inf')
for i in range(len(w)):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    s = abs(s1 - s2)
    if s < min:
        min = s
print(int(min))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,t;
    cin >> n >> t;
    int minc = 2000;
    for (int i = 0; i < n; i++) {
        int ci,ti;
        cin >> ci >> ti;
        if (t >= ti) {
            minc = min(minc, ci);
        }
    }
    if (minc == 2000) cout << "TLE" << endl;
    else cout << minc << endl;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll MOD = 998244353;

int n, s, a[MAXN];
ll dp[MAXN], dp2[MAXN];

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> s;
    FOR(i,1,n) cin >> a[i];
    dp[0] = 1;
    FOR(i,1,n) {
        MS(dp2, 0);
        FORE(j,s,0) {
            if (j - a[i] < 0) break;
            dp2[j] = add(dp2[j], dp[j-a[i]]);
        }
        FOR(j,0,s) dp2[j] = add(dp2[j], mul(dp[j], 2));
        FOR(j,0,s) dp[j] = dp2[j];
    }
    cout << dp[s];
    return 0;
}


Measured memory_bytes: 3708
/*
[abc140] B - Buffet
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 20;

int N;
int A[MAX_N], B[MAX_N], C[MAX_N - 1];

ll solve() {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += B[A[i]];
        if (i < N - 1 && A[i + 1] == A[i] + 1) {
            ans += C[A[i]];
        }
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
 
int main() {
  int A, B, C; cin >> A >> B >> C;
  int result = 0;
  if (A==B) result = C;
  else if (A==C) result = B;
  else result = A;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Main {
    private static final long MOD = 1000000007;

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

        final Map<Integer, AtomicInteger> countMap = new HashMap<>();

        int num = m;
        for (int i = 2; i <= num; i++) {
            if (num % i == 0) {
                countMap.computeIfAbsent(i, counter -> new AtomicInteger())
                        .incrementAndGet();
                num /= i;
                i--;
            }
        }

        final List<Long> answerList = countMap.values().stream()
                .map(AtomicInteger::get)
                .map(value -> calculateCombination(value + n - 1, value))
                .collect(Collectors.toList());

        long answer = 1;
        for (final Long value : answerList) {
            answer = answer * value % MOD;
        }

        System.out.println(answer);

    }

    private static long calculateCombination(final long left, final long right) {
        BigInteger denominator = BigInteger.ONE;
        BigInteger numerator = BigInteger.ONE;

        for (long i = 0; i < right; i++) {
            denominator = denominator.multiply(BigInteger.valueOf(right - i));
            numerator = numerator.multiply(BigInteger.valueOf(left - i));
        }

        return (numerator.divide(denominator)).mod(BigInteger.valueOf(MOD)).longValue();
    }
}


Measured memory_bytes: 29140
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

const int INF = 1 << 30;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  pair<int,int> mi={INF,0},ma={-INF,0};
  
  rep(i,n){
    if(a[i] < mi.first) mi = {a[i],i};
    if(a[i] > ma.first) ma = {a[i],i};
  }
  
  pair<int,int> p; bool reverse = false;
  if(abs(mi.first) > abs(ma.first)){
    p = mi; reverse = true;
  }else p = ma;
  
  printf("%d\n",n+n-1);
  
  rep(i,n){
    printf("%d %d\n",p.second+1,i+1);
  }
  if(reverse){
    for(int i = n; i >= 2;i--){
      printf("%d %d\n",i,i-1);
    }
  }else{
    rep(i,n-1){
      printf("%d %d\n",i+1,i+2);
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int H = 1, W = 1;

int main()
{
    while (H != 0 && W != 0)
    {
        scanf("%d %d", &H, &W);
        for (int i = 1; i <= H; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if (i == 1 || i == H || j == 1 || j == W)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
                
            }
            printf("\n");
        }
        if (H != 0 && W != 0)
        {
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    char x, y;
    int exist[3] = {1,0,0};
    while( scanf(" %c,%c", &x, &y) != EOF ){
        swap(exist[x-'A'], exist[y-'A']);
    }
    for(int i = 0; i < 3; i++){
        if( exist[i] ){
            printf("%c\n", 'A'+i);
        }
    }
    return 0;
}

Measured memory_bytes: 968
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()
cnts = defaultdict(int)
ed = set()
for a in AA:
    cnts[a] += 1
    ed.add(a)

aa1 = [[i,0] for i in range(1,N+1)]
for e in ed:
    aa1[cnts[e]-1][1] += 1

aa2 = [0] # 種類数
aa3 = [0] # 実枚数
for t,n in aa1:
    aa2.append(aa2[-1] + n)
    aa3.append(aa3[-1] + n*t)

L = len(aa1)
tmpl_t = []
tmpl_c = []
for i,(t,n) in enumerate(aa1):
    tmp = n + aa3[i]//t
    tmp += aa2[-1] - aa2[i+1]
    tmpl_t.append(t)
    tmpl_c.append(tmp)
    # print(t,'回食べるとき，最大',tmp,'枚までいける')

tmpl_t.reverse()
tmpl_t.append(0)
tmpl_c.reverse()
# print(tmpl_t)
# print(tmpl_c)
ans = [0]*N
for i in range(1,N+1):
    idx = bisect.bisect_left(tmpl_c,i)
    if idx == 0:
        ans[i-1] = N//i
    else:
        ans[i-1] = tmpl_t[idx]

print('\n'.join(map(str,ans)))


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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

// #define mod (ll)(1e9 + 7)

template <ll ModVal>
struct ModInt {
  ll x;

  ModInt(ll _x = 0) : x((_x % ModVal + ModVal) % ModVal) {
  }

  ModInt operator-() const {
    return ModInt(-x);
  }
  ModInt& operator+=(const ModInt a) {
    x += a.x;
    if (x >= ModVal)
      x -= ModVal;
    return *this;
  }
  ModInt& operator-=(const ModInt a) {
    x = x + ModVal - a.x;
    if (x >= ModVal)
      x -= ModVal;
    return *this;
  }
  ModInt& operator*=(const ModInt a) {
    x *= a.x;
    x %= ModVal;
    return *this;
  }

  ll ext_gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
      x = 1;
      y = 0;
      return a;
    }
    ll tmp = a / b;
    ll d = ext_gcd(b, a - b * tmp, y, x);
    y -= tmp * x;
    return d;
  }

  // 逆元
  ModInt inv() {
    ll u, v;
    ext_gcd(x, ModVal, u, v);
    return ModInt(u);
  }

  ModInt inv(const ModInt a) {
    ll u, v;
    ext_gcd(a.x, ModVal, u, v);
    return ModInt(u);
  }

  ModInt& operator/=(const ModInt a) {
    return (*this) *= inv(a);
  }

  ModInt operator+(const ModInt a) const {
    ModInt retval(*this);
    return retval += a;
  }
  ModInt operator-(const ModInt a) const {
    ModInt retval(*this);
    return retval -= a;
  }
  ModInt operator*(const ModInt a) const {
    ModInt retval(*this);
    return retval *= a;
  }
  ModInt operator/(const ModInt a) const {
    ModInt retval(*this);
    return retval /= a;
  }

  ModInt pow(ll n) {
    ModInt ans(1);
    while (n) {
      if (n & 1)
        ans = ans * x;
      *this = (*this) * (*this);
      n = n >> 1;
    }
    return ans;
  }

  constexpr const ll& value() {
    return this->x;
  }
};

template <ll ModVal>
ostream& operator<<(ostream& os, const ModInt<ModVal>& a) {
  os << a.x;
  return os;
}

using mint = ModInt<mod>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll h, w;
  cin >> h >> w;
  vs a(h);
  rep(y, h) {
    cin >> a[y];
  }

  vector<vector<mint>> dp(h, vector<mint>(w));
  dp[0][0] = 1;
  rep(y, h) {
    rep(x, w) {
      if (x != w - 1 && a[y][x + 1] == '.') {
        dp[y][x + 1] += dp[y][x];
      }
      if (y != h - 1 && a[y + 1][x] == '.') {
        dp[y + 1][x] += dp[y][x];
      }
    }
  }

  cout << dp[h - 1][w - 1] << endl;

  return 0;
}


Measured memory_bytes: 9216
n, m = [int(elem) for elem in input().split()]

l = []
r = []
for i in range(0, m):
  tmp_l, tmp_r = [int(elem) for elem in input().split()]
  l.append(tmp_l)
  r.append(tmp_r)

p = max(l)
q = min(r)
res = q - p + 1
if res < 0:
  res = 0
print(res)

Measured memory_bytes: 10996
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#include <algorithm>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

using namespace std;
typedef long long ll;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;

	if((a==b && b!=c) || (a==c && b!=c) || (b==c && a!=c)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
// 还是会超时 
// 改成一边读入一边比较
//依旧会超时，因为有两重循环 

//将两重循环改成一重循环 
 
/*Maximum Profit
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.

Write a program which reads values of a currency Rt at a certain time t (t=0,1,2,...n?1), and reports the maximum value of Rj?Ri where j>i .

Input
The first line contains an integer n. In the following n lines, Rt (t=0,1,2,...n?1) are given in order.

Output
Print the maximum value in a line.

Constraints
2≤n≤200,000
1≤Rt≤109*/
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
	
	ll n;
	cin>>n;
	ll ma=-10000000000;
	ll mi= 10000000000;
	ll r;
	
	for(ll i=0;i<n;i++){
		cin>>r;
		ma = max(ma, r-mi);
		mi = min(mi, r);
	} 
	cout<<ma<<endl;
	
	return 0;
} 


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
int w[10001],h[10001],n;
int main(){
	while(cin >> n && n){
		rep(i,n) cin >> w[i];
		rep(i,n) cin >> h[i];
		sort(w,w+n,greater<int>());
		sort(h,h+n,greater<int>());
		rep(i,n){
			rep(j,n) if(h[j]) w[i]-- , h[j]--;
			if(w[i]){ cout << "No" << endl; goto f; }
		}
		cout << "Yes" << endl;
		f:;
	}
}

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

using namespace std;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double kaku1 = 30 * H;
    kaku1 += 0.5 * M;
    double kaku2 = 6 * M;
    double kaku3;

    if(kaku1 >= kaku2){
        kaku3 = kaku1 - kaku2;
    }else{
        kaku3 = kaku2 - kaku1;
    }
    
    if(kaku3 >= 180){
        kaku3 = 360 - kaku3;
    }

    const double PI=3.14159265358979323846264338327950288;
    
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(kaku3 * PI / 180));
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4144
n = int(input())
A = [100]*26
for _ in range(n):
  B = [0]*26
  for c in input():
	  B[ord(c)-ord('a')] += 1
  A = [min(a,b) for a, b in zip(A,B)]

ans = ''
for i, a in enumerate(A):
  ans += chr(i+ord('a')) *a
print(ans)

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

#define int long long
const int N = 1000005;

int n,a[N];

void dfs(int p,int lim) {
    if(p==n+1) {
        for(int i=1;i<=n;i++) cout<<(char)(a[i]+'a'-1);
        cout<<endl;
    }
    else for(int i=1;i<=lim;i++) {
        a[p]=i;
        dfs(p+1,lim+(i==lim));
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin>>n;
    dfs(1,1);
}



Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
    int N, X = 1, Y = 1, S = 0;
    scanf("%i", &N);
    for(X = 1; X <= 9; ++X)
    {
        for(Y = 1; Y <= 9; ++Y)
        {
            if((X * Y) == N)
            {
                X = 10;
                Y = 10;
                S = 1;
            }
        }
    }
    if(S == 1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}

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


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    N = int(input())
    print((N - 1) // 2 + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const int mxN = 1e5 + 7, mod = 1e9 + 7;
ll stairs[mxN];

void solve(){
	int n,m; cin >> n >> m;
	set<int> bad;
	FOR(m){
		int x; cin >> x;
		bad.insert(x);
	}
	stairs[0] = 1;
	FOR(i,n){
		if(bad.find(i) == bad.end()){
			stairs[i+1] += stairs[i]%mod; 
			stairs[i+2] += stairs[i]%mod;
		}
	}
	//debuga(stairs,n+1);
	cout << stairs[n]%mod;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 8340
//TravelingBudget.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();

        System.out.println(Math.min(a,b)+Math.min(c,d));
        sc.close();
    }
}

Measured memory_bytes: 21204
#include<iostream>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i++)
using namespace std;

int main(){
  int a,b,c,all,m=0;

  cin>>a>>b>>c>>all;
  REP(i,0,a){
    REP(j,0,b){
      REP(k,0,c){
        if((500*i)+(100*j)+(50*k)==all) m++;
      }
    }
  }
  cout<<m<<endl;

}


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

vector<int> prime(1, 2);
int len = 1;

int solve(int n){
  int ret = 0;
  for(int i=0; i<len-1; i++){
    for(int j=i; j<len; j++){
      if(prime[i] + prime[j] == n){
	ret++;
      }
    }
  }
  return ret;
}

int main(){
  int N = pow(2.0, 15.0);
  for(int i=3; i<N; i+=2){
    bool flag = true;
    for(int j=0; prime[j]*prime[j]<=i && j<prime.size(); j++){
      if(i % prime[j] == 0){
	flag = false;
	break;
      }
    }
    if(flag){
      prime.push_back(i);
      len++;
    }
  }

  int n;
  while(cin >> n){
    if(n == 0)break;
    cout << solve(n) << endl;
  }

  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define ll long long

using namespace std;

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
    return x * f;
}

void write(int x) {
    if(x < 0) {putchar('-'); write(-x); return ;}
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
    return ;
}

string s;

int main() {
    cin >> s;
    int len = s.size();
    if(len == 2) cout << s;
    else {
        for(int i = len - 1; i >= 0; --i) cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
mod = 10**9 + 7

ans = M
for i in range(M-1, M-N, -1):
    ans = ans*i % mod


# print(ans)
prev = 1
ansB = M-1


for i in range(1, N):
    tmp = (prev)*i % mod
    tmp2 = ansB - tmp % mod
    # print(tmp2)
    ansB = tmp * (M-i) % mod
    ansB += (tmp2)*(M-i-1) % mod
    # print(tmp, tmp2)
    # ansB = tmp + tmp2
    ansB %= mod
    prev = tmp2
    # print(ansB)

# print(ansB)

print((ans*ansB) % mod)


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	string A;
	cin >> A;
	ll n = A.size()*(A.size() - 1) / 2;
	ll flag[26] = {};
	rep(i, A.size()) {
		flag[A[i] - 'a']++;
	}
	rep(i, 26) {
		n -= flag[i] * (flag[i] - 1) / 2;
	}
	cout << n+1 << endl;

	return 0;
}

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

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 16;
const int M = (1LL<<N);

const int inf = 1e14;

int n;
int a[N][N];
int dp[M];
int val[M];

signed main()
{
    fast;
    
    cin >> n;
    
    f(i,n) f(j,n) cin >> a[i][j];
    
    f(i,(1LL<<n)) f(j,n) f(k,n)
               if((i&(1LL<<j)) && (i&(1LL<<k))) val[i]+=a[j][k];
    
    dp[0] = 0;
    
    f(i,(1LL<<n))
        for(int j=i;;j=(j-1)&i)
    {
        dp[i] = max(dp[i],dp[j] + val[i^j]);
        if(j==0)break;
    }
    cout << dp[(1LL<<n)-1]/2;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

if 0 in A:
    print(0)
    exit()

A.sort(reverse=True)
ans = A[0]

for i in range(1, N):
    if A[i] > INF:
        print(-1)
        exit()
    if A[i] == 1:
        break
    ans = ans * A[i]
    if ans > INF:
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 21636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(0);
	
	int a, b; cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		string s1 = s;
		reverse(s.begin(), s.end());
		ans += (s1 == s);
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

int main()
{
	int n;
	ll a, b, c, d;
	std::cin >> n >> a >> b >> c >> d;
	if(a > b)
		std::swap(a, b);
	bool valid = false;
	for(int i = 0; i <= n - 1; i++)
	{
		ll left = i;
		ll right = (n - 1) - i;
		ll l = a + c * right - d * left;
		ll r = a + d * right - c * left;
		if(l <= b && b <= r)
		{
			//std::cout << "found on " << i << ": (" << l << ", " << b << ", " << r << ")\n";
			//std::cout << "(" << left << ", " << right << ")\n";
			valid = true;
		}
	}
	if(valid)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxm = 1002;

int n, m, k, ans, v[maxm];

int get_ones(int x) {
    int res = 0;
    while (x > 0) {
        res += (x&1);
        x >>= 1;
    }
    return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n >> m >> k;
    
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            if (s[j] == '1') {
                v[j] |= (1 << i);
                ++tot;
            }
        }
    }

    if (tot <= k) {
        cout << 0 << endl;
        return 0;
    }

    ans = tot;

    int lim = 1 << (n-1);
    for (int i = 0; i < lim; ++i) {
        if (get_ones(i) >= ans)
            continue;

        int cnt = 0, cur = 0;
        vector<int> w;
        for (int j = 0; j < n; ++j) {
            cur |= (1 << j);

            if (i & (1 << j)) {
                w.push_back(cur);
                cur = 0;
            }
        }
        w.push_back(cur);

        int sz = w.size();
        vector<int> sum(sz);

        bool possible = true;

        for (int j = 0; j < m && possible; ++j) {
            bool ok = true;
            for (int t = 0; t < sz; ++t) {
                int tmp = get_ones(v[j] & w[t]);
                if (tmp > k) {
                    possible = false;
                    break;
                } else if (sum[t] + tmp > k) {
                    ok = false;
                    break;
                }
            }
            
            if (!ok) {
                ++cnt;
                for (int t = 0; t < sz; ++t)
                    sum[t] = get_ones(v[j] & w[t]);
            } else {
                for (int t = 0; t < sz; ++t)
                    sum[t] += get_ones(v[j] & w[t]);
            }
        }

        if (possible)
            ans = min(ans, get_ones(i) + cnt);
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    println("ACL".repeat(k))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 35692
#include <iostream>
#include <cmath>
using namespace std;
int p[5]={1,10,100,1000,10000};
int nrcif(int a)
{
    int cnt=0;
    while(a)
    {
        cnt++;
        a/=10;
    }
    return cnt;
}

int main()
{
    int a,b,sqr;
    cin>>a>>b;
    a=b+a*p[nrcif(b)];
    sqr=sqrt(a);
    if(sqr*sqr==a)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N, Q = map(int, input().split())
    s = input()
    T, D = [""] * Q, [""] * Q
    for i in range(Q):
        T[i], D[i] = input().split()

    ll, lr = -1, N
    while 1 < lr - ll:
        mid = cur = (ll+lr) // 2
        ok = False
        for i in range(Q):
            if s[cur] == T[i]:
                if D[i] == 'L':
                    cur -= 1
                else:
                    cur += 1

                if cur == -1:
                    ok = True
                    break
                elif cur == N:
                    break
        if ok:
            ll = mid
        else:
            lr = mid

    rl, rr = -1, N
    while 1 < rr - rl:
        mid = cur = (rl + rr) // 2
        ok = False
        for i in range(Q):
            if s[cur] == T[i]:
                if D[i] == 'L':
                    cur -= 1
                else:
                    cur += 1

                if cur == N:
                    ok = True
                    break
                elif cur == -1:
                    break
        if ok:
            rr = mid
        else:
            rl = mid

    print(max(rl-ll, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63564
#[allow(unused_imports)]
use std::io;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

#[allow(unused_macros)]
macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

struct Eratosthenes {
    t: Vec<bool>,
    primes: Vec<usize>,
}

impl Eratosthenes {
    pub fn new() -> Eratosthenes {
        Eratosthenes {
            t: Vec::new(),
            primes: Vec::new(),
        }
    }
}

fn eratosthenes(n: usize) -> Eratosthenes {
    let mut e = Eratosthenes::new();
    e.t.resize(n + 1, true);
    e.t[0] = false;
    e.t[1] = false;
    for i in 2..n + 1 {
        if !e.t[i] {
            continue;
        }
        let mut j = 2 * i;
        while j < n + 1 {
            e.t[j] = false;
            j += i;
        }
    }
    for i in 0..n + 1 {
        if e.t[i] {
            e.primes.push(i);
        }
    }
    e
}

fn main() {
    let e = eratosthenes(100000);
    let mut v = vec![0; 100001];
    v[0] = 0;
    for i in 1..100001 {
        v[i] = if e.t[i] && e.t[(i + 1) / 2] { 1 } else { 0 }
    }
    for i in 2..100001 {
        v[i] += v[i - 1];
    }
    // for i in 0..12 {
    //     println!("{}:{}", i, v[i]);
    // }

    from_line!(q: usize);
    for _ in 0..q {
        from_line!(l: usize, r: usize);
        println!("{}", v[r] - v[l - 1]);
    }
}


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

using namespace std;

int n , k , h[111111] , dp[111111];

int f(int idx) { // 현재 상황이 idx일때 남은 거리 최소 값 
	if (idx > n) return 1e9;
	if (idx == n) return 0;
	int &ret = dp[idx];
	if (ret != 1e9) return ret;
	
	for (int i = 1; i <= k; i++) ret = min(ret , f(idx+i)+abs(h[idx+i]-h[idx])); 
	return dp[idx] = ret;
}

int main() {
	for (int i = 0; i < 111111; i++) dp[i] = 1e9;
	scanf("%d %d" , &n , &k);
	for (int i = 1; i <= n; i++) scanf("%d" , &h[i]);	
	printf("%d" , f(1));
	
	return 0;
}

Measured memory_bytes: 10784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	for (int i = 0; i < (int)s.size() - 1; i++) {
		if (s[i] != s[i + 1]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> ans;
	if (n % 2) {
		for (ll i = 1; i < n; ++i) {
			for (ll j = i + 1; j < n; ++j) {
				if (i + j == n)continue;
				ans.push_back({ i,j });
			}
		}
		for (ll i = 1; i < n; ++i) {
			ans.push_back({ i,n });
		}
	}
	else {
		for (ll i = 1; i <= n; ++i) {
			for (ll j = i + 1; j <= n; ++j) {
				if (i + j == n + 1)continue;
				ans.push_back({ i,j });
			}
		}
	}
	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.first << " " << p.second << endl;
	}
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> v(n, 0);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        a[i] += i;
        a[i] %= n;
        ++ v[a[i]];
    }

    queue<int> q;
    for(int i=0; i<n; ++i){
        if(v[i] == 0)
            q.push(i);
    }

    int ans = n;
    while(!q.empty()){
        int i = q.front();
        q.pop();
        -- ans;
        -- v[a[i]];
        if(v[a[i]] == 0)
            q.push(a[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>

int main(void){
	char s[3];
  	char t[3];
  	scanf("%s", s);
  	scanf("%s", t);
  	
  	int i, count = 0;
  	for(i = 0; i < 3; i++){
    	if(s[i] == t[i])
          count++;
    }
  	printf("%d\n", count);
  
  
  	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
#define pld pair<pll,ll>
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
bool isprime[100000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{	
	ll h,w,n;
	cin>>h>>w>>n;
	ll x=max(h,w);
	if(n%x)
	{
		cout<<n/x+1;
	}	
	else
		cout<<n/x;
}	
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll tot = 0;
	rep(i, n) tot += max(0LL, a[i] - b[i]);
	ll tot1 = 0;
	rep(i, n) tot1 += max(0LL, (b[i] - a[i]) / 2);
	cout << ((tot1 >= tot) ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll N;
        cin >> N;
        string S;
        cin >> S;
        vector<vector<int>> ans(4, vector<int>(N));

        ans[0][0] = 0;
        ans[0][1] = 0;
        ans[1][0] = 0;
        ans[1][1] = 1;
        ans[2][0] = 1;
        ans[2][1] = 0;
        ans[3][0] = 1;
        ans[3][1] = 1;
        for(ll i=2; i<N; i++){
                for(int k=0; k<4; k++)
                        if(S[i-1] == 'o'){
                                if(ans[k][i-1] == 0) ans[k][i] = ans[k][i-2];
                                else ans[k][i] = (ans[k][i-2]+1)%2;
                        }
                        else{
                                if(ans[k][i-1] == 1) ans[k][i] = ans[k][i-2];
                                else ans[k][i] = (ans[k][i-2]+1)%2;
                        }
        }
        vector<bool> flag1(4), flag2(4);
        for(int i=0; i<4; i++){
                if(S[0] == 'o'){
                        if(ans[i][0] == 0 && ans[i][N-1] == ans[i][1]){ flag2[i]=true;}
                        else if(ans[i][0] == 1 && ans[i][N-1] != ans[i][1]){ flag2[i]=true;}
                }
                else{
                        if(ans[i][0] == 1 && ans[i][N-1] == ans[i][1]){ flag2[i]=true;}
                        else if(ans[i][0] == 0 && ans[i][N-1] != ans[i][1]){ flag2[i]=true;}

                }
        }
        for(int i=0; i<4; i++){
                if(S[N-1] == 'o'){
                        if(ans[i][N-1] == 0 && ans[i][N-2] == ans[i][0]){ flag1[i] = true;}
                        else if(ans[i][N-1] == 1 && ans[i][N-2] != ans[i][0]){ flag1[i] = true;}
                }
                else{
                        if(ans[i][N-1] == 1 && ans[i][N-2] == ans[i][0]){ flag1[i] = true;}
                        else if(ans[i][N-1] == 0 && ans[i][N-2] != ans[i][0]){ flag1[i] = true;}
                }
        }


        for(int k=0; k<4; k++){
                if(flag1[k] && flag2[k]){
                for(ll i=0; i<N; i++){
                        if(ans[k][i]==0) cout << "S";
                        else cout << "W";
                }break;
                }
        if(k==3) cout << -1;
        }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N, M;  cin >> N >> M;
	bool box[100001];   box[1] = true;   //true : 箱に赤い球が入っている可能性がある。
	int ball[100001];  for(int i = 1 ; i <= N ; i++) ball[i] = 1;

	for(int i = 0 ; i < M ; i++){
	 int x, y;  cin >> x >> y;
	 ball[x]--, ball[y]++;
	 if(box[x] == true)  box[y] = true;

	 if(ball[x] == 0)   box[x] = false;
	}

	int ans = 0;
	for(int i = 1; i <= N ; i++)
	 if(box[i])  ans += 1;

	cout << ans << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string opp;
  int P, W, G, Y = 0;
  string S;

  for (int i=0; i < N; i++) {
    cin >> S;
    
    if (S == "P") {
        P += 1;
    }
    else if (S == "W") {
        W += 1;
    }
    else if (S == "G") {
        G += 1;
    }
    else {
        Y += 1;
    }
  }
    
  if (Y == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;;
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        Integer array[] = new Integer[n];
        int alice = 0;
        int bob = 0;

        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
      
        sc.close();
        Arrays.sort(array,Collections.reverseOrder());

        for (int i = 0; i < array.length; i++) {
            if(i % 2 == 0) {
                alice += array[i];
            } else {
                bob += array[i];
            }
        }

        System.out.println(alice - bob);
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
    
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    int cnt = 0, ans = 0;
    for(auto& p: mp) if(p.se >= 2) cnt += p.se - 1;
    cnt = (cnt+1)/2 * 2;
    cout << n - cnt << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std; typedef long long ll; const ll INF=1e18, m=1e9+7;
typedef pair<int,int> P;

ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}

int main() {
  ll n,m; cin>>n>>m; n-=m;
  cout<<(100LL*n+1900LL*m)*mod_pow(2,m)<<endl;
}

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

#define ll long long int

int main()
{
	double s;
	cin >> s;
	double length = s / 3.0;
    s -= length;
    double breadth = s / 2.0;
    double height = s - breadth;

    double sum = length * breadth * height;
    printf("%.12f\n",abs(sum));
    return 0;
}


Measured memory_bytes: 256
N, m = gets.chomp.split(" ").map(&:to_i)
INF = 1 << 50
N_MAX = 1000
M_MAX = 2000
a = Array.new(N_MAX)
b = Array.new(M_MAX)
c = Array.new(M_MAX)

m.times do |i|
  aa, bb, cc = gets.chomp.split(" ").map(&:to_i)
  a[i] = aa
  b[i] = bb
  c[i] = cc * -1
end

dist = Array.new(N_MAX, INF)

dist[0] = 0

(N - 1).times do |loop|
  m.times do |i|
    next if dist[a[i] - 1] == INF
    if dist[b[i] - 1] > dist[a[i] - 1] + c[i] then
      dist[b[i] - 1] = dist[a[i] - 1] + c[i]
    end
  end  
end

ans = dist[N - 1]

negative = Array.new(N_MAX, false)

N.times do |loop|
  m.times do |i|
    next if dist[a[i] - 1] == INF
    if dist[b[i] - 1] > dist[a[i] - 1] + c[i] then
      dist[b[i] - 1] = dist[a[i] - 1] + c[i]
      negative[b[i] - 1] = true
    end
    
    if negative[a[i] - 1] then
      negative[b[i] - 1] = true
    end
  end
end

if negative[N - 1]
  puts "inf"
else
  puts ans * -1
end


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

int isPri( long x )
{
    long n;

    if( x == 2 ) return 1;
    if( x < 2 || x % 2 == 0 ) return 0;
    for( n = 3; n <= sqrt((double)x); n += 2 )
        if( x % n == 0 ) return 0;
    return 1;
}

int main()
{
  long n;
  cin >> n;
  
  if(isPri(n) == 1){
    cout << n - 1 << endl;
    return 0;
  }
  
  long i = 2, j = n, ans = 1000000000000;
  
  while(i * i <= n){
    if(n % i == 0){
      j = n / i;
      if(i + j - 2 < ans && i + j - 2 > 0)
        ans = i + j - 2;
    }
    i++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
// sort
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i< n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    map<string, int> mp;
    for(string x:s) mp[x]++;
    long long ans =0;
    for (auto p: mp){
        long long c = p.second;
        ans += c* ( c-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll h, w;
  cin >> h >> w;
  vector <vector <char>> v(h, vector <char> (w));
  set <ll> s; set <ll> t;
  rep(i, h) {
    bool flag = 1;
    rep(j, w) {
      cin >> v.at(i).at(j);
      if (v.at(i).at(j) == '#') flag = 0;
    }
    if (flag) s.insert(i);
  }
  rep(j, w) {
    bool flag = 1;
    rep(i, h) {
      if (v.at(i).at(j) == '#') flag = 0;
    }
    if (flag) t.insert(j);
  }
  rep(i, h) {
    if (s.count(i)) continue;
    rep(j, w) {
      if (t.count(j)) continue;
      cout << v.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll INF = 1e10;
typedef pair<ll,ll> P;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if (abs(a-b)%2 == 0) PRINT(abs(a-b)/2);
    else{
        if (n-a >= b-1){
            PRINT(a+abs(a-b)/2);
        }
        else{
            PRINT(n-b+1+abs(b-a-1)/2);
        }
    }
}


Measured memory_bytes: 256