akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> ans(2*h, vector<char>(w));
    rep(i,h){
        rep(j,w){
            char C;
            cin >> C;
            ans[i * 2][j] = C;
            ans[i * 2 + 1][j] = C;
        }
    }
    rep(i,2*h){
        rep(j,w){
            cout << ans[i][j];
        }
        cout << endl;
    }
    

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func calc2(s1 int64, h, w int) int64 {
	e := h / 2
	e = maxInt(1, e-1)
	ans := int64(math.MaxInt64)
	for h2 := e; h2 < h && h2 <= e+2; h2++ {
		h3 := h - h2
		s2 := int64(h2) * int64(w)
		s3 := int64(h3) * int64(w)
		max := maxInt64(maxInt64(s1, s2), s3)
		min := minInt64(minInt64(s1, s2), s3)
		ans = minInt64(ans, max-min)
	}
	return ans
}

func calc(h, w int) int64 {
	d := w / 3
	ans := int64(math.MaxInt64)
	d = maxInt(1, d-1)
	for w1 := d; w1 < w && w1 <= d+3; w1++ {
		h1 := h
		s1 := int64(h1) * int64(w1)
		w2 := w - w1
		ans = minInt64(ans, calc2(s1, w2, h))
		ans = minInt64(ans, calc2(s1, h, w2))

	}
	return ans
}

func main() {
	defer stdout.Flush()
	h := readInt()
	w := readInt()

	if w%3 == 0 || h%3 == 0 {
		println(0)
		return
	}

	ans := minInt64(calc(h, w), calc(w, h))

	println(ans)
}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


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

char hstr( string &s )
{
	if( s.size() == 0 ) {
		return 0;
	}

	char h = s[ 0 ];
	s.erase( s.begin() );

	return h;
}

int main()
{
	string sa, sb, sc;
	cin >> sa >> sb >> sc;

	char h = hstr( sa );
	char cp = 'A';
	while( h != 0 ) {
		if( h == 'a' ) {
			h = hstr( sa );
			cp = 'A';
		}
		else if( h == 'b' ) {
			h = hstr( sb );
			cp = 'B';
		}
		else if( h == 'c' ) {
			h = hstr( sc );
			cp = 'C';
		}
	}

	cout << cp << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,k = map(int,input().split())

mod = 10 ** 9 + 7

roots = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    roots[a-1].append(b-1)
    roots[b-1].append(a-1)

li = [-1] * n
li[0] = k
ans = 1
stack = [0]

while stack:
    label = stack.pop(-1)
    count = 1
    li2 = []
    for i in roots[label]:
        if li[i] == -1:
            stack.append(i)
            li2.append(i)
        else:
            count += 1
    for i in li2:
        li[i] = k - count
        count += 1

for i in li:
    ans *= max(i,0)
    ans %= mod

print(ans)


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

int main(void){
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ((r <= x && x <= W - r) && (r <= y && y <= H - r)) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 1124
#include<stdio.h>
int main(){
    int c=0,n,l=0,i,j;
    scanf("%d",&n);
    for(i=105;i<=n;i+=2){
        l=0;
        for(j=3;j<i;j++){
            if(i%j==0) l++;
        }
        if(l==6) c++;
    }
    printf("%d\n",c);
    return 0;
}


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

void insert_sort(long int *num,long int n,long int g,long int *cnt);
int main(){
        long int cnt[1];
        long int num[1000000];
        long int n;
        long int i;
        long int m[1000000];
        long int count=0;
        long int k;
        int yn=0;
        cnt[0]=0;

        cin>>n;
        for(i=0;i<n;i++){
                cin>>num[i];
        }
        m[0]=n-1;
        while(yn==0){
                yn=1;
                insert_sort(num,n,m[count],cnt);
                count++;
                m[count]=m[count-1]/2;

                for(i=0;i<n-1;i++){
                        if(num[i]>num[i+1]){
                                yn=0;
                                break;
                        }   
                }
     
        }
        cout<<count<<endl;
        for(i=0;i<count;i++){
                cout<<m[i];
                if(i<count-1){
                        cout<<" ";
                }else{
                        cout<<endl;
                }
        }
        cout<<cnt[0]<<endl;
        for(i=0;i<n;i++){
                cout<<num[i]<<endl;
        }
        return 0;
}

void insert_sort(long int *num,long int n,long int g,long int *cnt){
        long int i;
        long int j;
        long int k;
        long int tmp;
        long a;
        a=cnt[0];
        for(i=g;i<n;i++){
                tmp=num[i];
                j=i-g;
                while((j>=0)&&(tmp<num[j])){
                        num[j+g]=num[j];
                        j-=g;
                        cnt[0]++;
                }
                num[j+g]=tmp;
        }
}

Measured memory_bytes: 10820
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>

using namespace std;

constexpr int INF = 1000000;
int D, G, p, c;
vector<int> ps;
vector<int> cs;

//残りの問題はd以上( d, d+1, ..., D-1 )で残りスコアs以上を出すのに解くべき最小の問題数 無理ならINF
//flagがfalseなら残りの問題は完全に解くことになる（中途半端に解く問題はできるだけ配点の高いものを1種類とけば良い）

int solver( int d, int s, bool flag ){
    if(s<=0) return 0;
    if(d==D) return INF;        
    if(d<D){
        int t(0);
        int ans(INF);
        if(flag){
            //解かない
            ans = min( ans, solver(d+1, s, flag) );
            //完全に解く
            t = (d+1)*ps[d] + cs[d];
            ans = min( ans, ps[d] + solver(d+1, s-t, flag) );
            //中途半端に解く
            for(int i=1;i<ps[d];++i){
                t = (d+1)*i;
                ans = min( ans, i+solver(d+1, s-t, false) );
            }
        }else{
            //完全に解く
            t = (d+1)*ps[d] + cs[d];
            ans = min( ans, ps[d] + solver(d+1, s-t, flag) );
        }
        return ans;
    }
}

int main(){

    cin >> D >> G;
    G /= 100;

    for(int i=0;i<D;++i){
        cin >> p >> c;
        c /= 100;
        ps.emplace_back(p);
        cs.emplace_back(c);
    }

    cout << solver(0, G, true) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string ch[10];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int H,W,K;
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)
	{
		cin>>ch[i];
	}
	int ans=100000000;
	for(int i=0;i<(1 << (H-1));i++)
	{
		vector<int> cut;
		cut.push_back(0);
		int res=0;
		for(int j=0;j<H-1;j++)
		{
			if((i&(1<<j))>0){
				res++;
				cut.push_back(j+1);
			}
		}
		cut.push_back(H);
		int row=res+1;
		vector<int> cnt(row);
		for(int j=0;j<row;j++)
		{
			cnt[j]=0;
		}
		for(int j=0;j<W;j++)
		{
			vector<int> add(row);
			for(int q=0;q<row;q++)
			{
				add[q]=0;
			}
			int t=0;
			for(int q=0;q<H;q++)
			{
				if(q==cut[t+1])t++;
				add[t]+=int(ch[q][j]-'0');
			}
			bool ok=true;
			for(int q=0;q<row;q++)
			{
				cnt[q]+=add[q];
				if(cnt[q]>K)ok=false;
			}
			if(ok)continue;
			res++;
			for(int q=0;q<row;q++)
			{
				cnt[q]=add[q];
			}
			ok=true;
			for(int q=0;q<row;q++)
			{
				if(cnt[q]>K)ok=false;
			}
			if(!ok){
				res=1000000000;
				break;
			}
		}
		ans=min(ans,res);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A = [int(input()) for i in range(m)]
B = [0 for i in range(10**5+10)]
for i in range(len(A)):
    B[A[i]] = 1

mod = 10**9 + 7

DP = [1,1]
if B[1] == 1:
    DP[1] = 0
for i in range(2,n+1):
    if B[i] == 0:
        DP.append((DP[i-1]+DP[i-2])%mod)
    else:
        DP.append(0)
    if i >= 3:
        DP[i-3]=0
print(DP[n])

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

int main(){
    int x;
    cin >> x;
    int num_500, res_500;
    num_500 = x / 500;
    res_500 = x % 500;
    int num_5;
    num_5 = res_500 / 5;

    int ans = num_500 * 1000 + num_5 * 5;

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  string s;
  cin >> s;
  
  string ans = "";
  for(int i = 0; i < s.size(); i++){
    char c = s[i];
    if(c == '0') ans.push_back('0');
    else if(c == '1') ans.push_back('1');
    else if(c == 'B'){
      if(ans.size() >= 1) ans.pop_back();
      else;
    }else;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
//#define S set<int>

int N, S[100010], K;
int s[100010], n;
int ans;

void solve()
{
    n = 0;
    if (S[0] == 1) {
        s[0] = 0;
        n++;
    } else {
        s[0] = 0;
        s[1] = 0;
        n += 2;
    }
    FOR(i, 1, N)
    {
        if (S[i] != S[i - 1]) {
            s[n] = i;
            n++;
        }
    }
    s[n] = N;
    n++;
    if (K * 2 + 1 >= n) {
        ans = N;
        return;
    }
    for (int i = 0; i + K * 2 + 1 < n; i += 2) {
        ans = max(ans, s[i + K * 2 + 1] - s[i]);
    }
}

signed main()
{
    cin >> N >> K;
    FOR(i, 0, N)
    {
        char c;
        cin >> c;
        S[i] = c - '0';
    }
    solve();
    int T[100010];
    FOR(i, 0, N)
    {
        T[i] = S[i];
    }
    FOR(i, 0, N)
    {
        S[i] = T[N - i - 1];
    }
    solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    N = int(input())
    q = deque(["a"])
    cnt = 1
    answer = []
    while cnt <= N:
        d = q.popleft()

        if len(d) == N:
            answer.append(d)
        cnt = max(cnt, len(d))
        b = 0
        for i in range(cnt):
            if ord(d[i]) > b:
                b = ord(d[i])

        for i in range(ord("a"), b + 2):
            q.append(d + chr(i))
    answer.sort()
    print(*answer, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 63548
#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 < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x = min(N, B - 1);
  cout << floor(A * x / B) - A * floor(x / B) << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    string s, t;
    cin >> s;
    cin >> t;
    int same = N;
    bool flag;
    for(int i=N;i>0;--i){
        flag = true;
        for(int j=0;j<i;++j){
            if(s[N + j - same] != t[j]){
                flag = false;
                break;
            }
        }
        if(flag) break;
        else --same;
    }

    cout << 2*N - same << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI avl;
VI psm;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,m;
  cin>>n>>m;
  avl.resize(m+3);
  psm.resize(m+3);
  in l,r;
  in S=1;
  while((S+1)*(S+1)<m)
    ++S;
  in nxt;
  in a,b;
  forn(zz,n){
    cin>>l>>r;
    for(in i=1;i<=S;++i){
      if(r/i!=(l-1)/i)
	++avl[i];
    }
    nxt=S+1;
    for(in k=S+4;k>=1;--k){
      a=(l-1)/k+1;
      b=r/k;
      a=max(a,nxt);
      if(a>b)
	continue;
      ++psm[a];
      --psm[b+1];
      nxt=b+1;
    }
  }
  for(in i=1;i<=m;++i){
    psm[i]+=psm[i-1];
    avl[i]+=psm[i];
    cout<<avl[i]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll               long long int
#define fi           first
#define    make_pair    mp
#define   vll vector<ll>
#define se            second
#define sz       size()
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define allr(v)          v.rbegin(),v.rend()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}

int main()
{
     fast;
     int q=1;
     //cin>>q;
     while(q--)
     {
         ll x=0,y,a,m,n,b,d,i,j,k,l,c=0,ans=0;
           cin>>k;
           string s ;
           cin>>s;
           j=s.sz;
           if(j>k)
           {
               for(i=0;i<k;i++)
                 cout<<s[i];
               cout<<"..."<<endl;
           }
            if(k>=j)
            {
                for(i=0;i<j;i++)
                   cout<<s[i];
            }

     }

   return 0;
}



Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int cost[12][12];
int n,a,b,c;
int s,min_cost;


int main(){
	
	while(scanf("%d",&n),n!=0){
		memset(cost,255,sizeof(cost));
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			cost[a][b]= (cost[a][b]==-1) ? c : min(cost[a][b],c);
			cost[b][a]=cost[a][b];
		}
		for(int i=0;i<=10;i++)
			cost[i][i]=0;
		for(int k=0;k<=10;k++)
			for(int i=0;i<=10;i++)
				for(int j=0;j<=10;j++)
					if(cost[i][k]!=-1&&cost[k][j]!=-1){
						cost[i][j]= (cost[i][j]==-1) ? cost[i][k]+cost[k][j] : min(cost[i][j],cost[i][k]+cost[k][j]);
						cost[j][i]=cost[i][j];
					}
		s=-1;min_cost=-1;
		for(int i=0;i<=10;i++){
			int temp=0;
			for(int j=0;j<=10;j++)
				temp= (cost[i][j]==-1) ? temp : temp+cost[i][j];
			if(s==-1||temp<min_cost&&temp>0){
				min_cost=temp;
				s=i;
			}
		}
		printf("%d %d\n",s,min_cost);
	}
	return 0;
}


Measured memory_bytes: 2568
a, b, c, x, y = map(int, input().split())
ans = x * a + y * b
if x > y:
    ans = min(ans, (x - y) * a + y * c * 2)
else:
    ans = min(ans, (y - x) * b + x * c * 2)
ans = min(ans, max(x, y) * c * 2)
print(ans)


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

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

  return 0;
}

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

int main(){
    int N;
    vector<int> d;
    cin>>N;

    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        d.push_back(x);
    }
    sort(d.begin(),d.end());
    int min=d.at(0), max=d.at(N-1);

    vector<int> a;

    if(N>2){
    for(int i=1;i<N-1;i++){
        int x=d.at(i);
        if(x<0){
            a.push_back(max);
            max-=x;
            
        }
        else{
            a.push_back(min);
            min-=x;
            
        }
    }
    }
    long int ans=max-min;
    cout<<ans<<endl;

    if(N>2){
        for(int i=1;i<N-1;i++){
            cout<<a.at(i-1)<<' '<<d.at(i)<<endl;
        }
    }

    cout<<max<<' '<<min<<endl;

    


}

Measured memory_bytes: 2808
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define EPS 1e-5
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],b[N];

LL l,r,mid,ans;

IL bool Check(LL x){
	reg LL i=0,s=0,p=0;
	for (i=1;i<=n;i++){
		if (a[i]<=x)	continue;
		p=(LL)(a[i]/x);
		if (a[i]>p*x)	s+=p;
		else s+=p-1;
	}
	if (s<=k)	return 1;
	else return 0;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	scanf("%lld%lld",&n,&k);
	for (i=1;i<=n;i++)	scanf("%lld",&a[i]);
	for (i=1;i<=n;i++)	a[i]*=2;
	sort(a+1,a+1+n);
	a[0]=0;
	for (i=1;i<=n;i++)	a[0]+=a[i];
/*	if (a[0]<=k){
		cout<<"0"<<endl;
		return 0;
	}
	if (a[0]-n <=k ){
		cout<<"1"<<endl;
		return 0;
	}*/
	if (!k){
		printf("%lld\n",a[n]/2);
		return 0;
	}
	l=1;	r=a[n]*2;
	while (l<=r){
		mid=(l+r)>>1;
		if (Check(mid))	ans=mid,r=mid-1;
		else l=mid+1;
	}
	while (ans>1 && Check(ans-1))	ans--;
	while (!Check(ans))	ans++;
	if (ans&1)	cout<<(ans+1)/2<<endl;
	else cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 5212
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n,ans=0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	for(int m=1;m<=n;m++){
		int compteur=0;
		
		for(int d=1;d<=m;d++){
			if(m%d==0){
				compteur++;
			}
		}
		
		if(compteur==8 && m%2==1) ans++;
	}
	cout << ans << '\n';
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rad 334
using namespace std;
int R[100005];
int K;
int X,T,A,TI;
int Q;
int sens=-1;
int ind=0;
pair<int,int> a,b;
int main()
{
    cin>>X>>K;
    a.first=b.first=0;
    a.second=b.second=X;
    for(int i=1;i<=K;i++)cin>>R[i];
    cin>>Q;
    for(int i=1;i<=Q;i++)
    {
        cin>>T>>A;
        while(ind<K&&R[ind+1]<T)
        {
            a.first+=sens*(R[ind+1]-TI);
            a.second+=sens*(R[ind+1]-TI);
            b.first+=max(0,-a.first);
            b.second-=max(0,a.second-X);
            a.first=max(0,a.first);a.first=min(X,a.first);
            a.second=max(0,a.second);a.second=min(X,a.second);
            sens*=-1;
            TI=R[ind+1];
            ind++;
        }
        a.first+=sens*(T-TI);
        a.second+=sens*(T-TI);
        b.first+=max(0,-a.first);
        b.second-=max(0,a.second-X);
        b.first=min(b.first,b.second);
        a.first=max(0,a.first);a.first=min(X,a.first);
        a.second=max(0,a.second);a.second=min(X,a.second);
        TI=T;
        cout<<min(max(A,b.first),b.second)-b.first+a.first;
        cout<<"\n";
    }
    return 0;
}


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

vector<int> add(vector<int> a,vector<int> b){
  vector<int> res(a.size());
  for(int i=0;i<(int)a.size();i++)
    res[i]=a[i]+b[i];
  return res;
}

vector<int> sub(vector<int> a){
  vector<int> res(a.size());
  for(int i=0;i<(int)a.size();i++)
    res[i]=-a[i];
  return res;
}


int change(char ch){
  int res;
  if('A'<=ch&&ch<='Z'){
    res= ch-'A';
  }else{
    res= 26+ch-'a';
  }
  return res;
}

int N;
char mp[55][55];
int t[55][55];

struct edge{
  int to;
  int cap;
  vector<int> cost;
  int rev;

  edge( int a,int b, vector<int> c,int d){
    to=a;
    cap=b;
    cost=c;
    rev=d;
  }
};

#define MAX_V 205

vector<edge> G[MAX_V];
vector<int> h[MAX_V];
vector<int> dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,vector<int> cost){
  G[from].push_back( edge(to,cap,cost,G[to].size() ) );
  G[to].push_back(   edge(from,0, sub(cost) ,G[from].size()-1 ) );
}

typedef pair< vector<int> , int > P;

vector<int> min_cost_flow(int s,int t,int f){
  vector<int> res(60,0);
  
  fill( h, h+MAX_V, vector<int>(60,0) );
  while(f>0){
    priority_queue< P , vector<P> , greater<P> > Q;
    fill(dist,dist+MAX_V, vector<int>(60,9999) );
    dist[s]= vector<int>(60,0);
    Q.push(P( dist[s] ,s));
    while(!Q.empty()){
      P p=Q.top();Q.pop();
      int v=p.second;
      if(dist[v]<p.first)continue;
      
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0){

          vector<int> tmp = add(dist[v],e.cost);
          tmp=add(tmp,h[v]);
          vector<int> tmp2 = sub(h[e.to]);
          tmp = add(tmp, tmp2);

          
          if(dist[e.to]>tmp){
            dist[e.to]=tmp;
            prevv[e.to]=v;
            preve[e.to]=i;
            Q.push(P(dist[e.to],e.to));
          }
        }
      }
    }

    
    for(int v=0;v<MAX_V;v++)h[v]=add(h[v],dist[v]);
    
    f--;
    res=add(res,h[t]);
    
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap--;
      G[v][e.rev].cap++;
    }
  }
  return res;
}

int main(){
  
  cin>>N;
  int si=N+N;
  int ti=N+N+1;

  map< int , char > dm;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      char ch;
      cin>>ch;
      dm[ change(ch) ] = ch;
      mp[i][j]=ch;
    }
  }

    
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      t[i][j]=G[i].size();
      vector<int> tmp(60,1000);
      tmp[ change(mp[i][j]) ]--;
      add_edge(i,N+j,1,tmp);
    }
  }

  for(int i=0;i<N;i++){
    vector<int> tmp(60,0);
    add_edge(si,i,1,tmp);
    add_edge(N+i,ti,1,tmp);
  }

  vector<int> vec = min_cost_flow(si,ti,N);

  string ans="";


  
  for(int i=0;i<60;i++){
    vec[i]=1000*N-vec[i];
    for(int j=0;j<vec[i];j++){
      ans+= dm[i];
    }
  }
  assert((int)ans.size()==N);
  sort(ans.begin(),ans.end());
  cout<<ans<<endl;
  /*
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      edge e=G[i][ t[i][j] ];
      if(e.cap==0)ans+=mp[i][j];
    }
  }

  sort(ans.begin(),ans.end());
  cout<<ans<<endl;
  */
  return 0;
}

Measured memory_bytes: 4832
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int V[]=new int[N];
		int z=0,y=0;
		while(z<N){
			V[z]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<N){
			y=stdIn.nextInt();
			V[z]=V[z]-y;
			z++;
		}z=N-1;y=0;
		Arrays.sort(V);
		while(z>=0){
			if(V[z]<=0)
				break;
			y+=V[z];
			z--;
		}
		System.out.println(y);
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
int main(void)
{
    int i, j;
    
    for ( i = 1 ; i < 10; i++) {
        for (j = 1; j < 10; j++) {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 17;
int dp[1 << N][N], a[N][N], c[1 << N][N], q[N], qq[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        u--;
        v--;
        a[u][v] = c;
        a[v][u] = c;
    }
    for (int i = 0; i < (1 << n); i++){
        for (int j = 0; j < n; j++){
            for (int l = 0; l < n; l++){
                if (i & (1 << l)){
                    c[i][j] += a[j][l];
                    //cout << i << " " << j << " " << l << " " << c[i][j] << " " << a[0][3] << endl;
                }
            }
        }
    }
    for (int mask = 0; mask < (1 << n); mask++){
        for (int j = 1; j < n; j++){
            dp[mask][j] = 1e9;
        }
    }
    for (int mask = 0; mask < (1 << n); mask++){
        for (int submask = mask; submask; submask = (submask - 1) & mask){
            int x = 0;
            int b = 0;
            int bb = 0;
            for (int i = 0; i < n; i++){
                if ((1 << i) & submask){
                    x += c[mask ^ submask][i];
                    q[b] = i;
                    b++;
                }
            }
            for (int i = 0; i < n; i++) if ((1 << i) & (mask ^ submask)){
                qq[bb] = i;
                bb++;
            }
           // cout << "x = " << x << endl;
            for (int ii = 0; ii < b; ii++){
                int i = q[ii];

                for (int jj = 0; jj < bb; jj++){
                    int j = qq[jj];
                    if (a[i][j] != 0)
                    dp[mask][i] = min(dp[mask][i], dp[mask ^ submask][j] + x - a[i][j]);
                }
            }
        }
    }
    cout << dp[(1 << n) - 1][n - 1];
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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

    int n;
    cin >> n;
    cout << pow(n, 3);


    return 0;
}


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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DABS {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, Z, W;
	    in >> N >> Z >> W;
	    vector<int> a(N);
	    REP(i,0,N) in >> a[i];

	    vector<int> candidates;
	    candidates.emplace_back(abs(a.back() - W));

	    if (N > 1) {
            // when Y = a.back()
            candidates.emplace_back(abs(a[N-1] - a[N-2]));
	    }
	    out << *max_element(all(candidates)) << "\n";
	}
};


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


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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    ll k;
    cin >> a >> b >> c >> k;
    int sum = a + b + c;
    ll kp = k / 2;
    a = kp * sum + a, b = kp * sum + b, c = kp * sum + c;
    if(k % 2 == 1){
        int ap = b + c;
        int bp = a + c;
        int cp = a + b;
        if(abs(ap - bp) > 1e18) cout << "Unfair" << endl;
        cout << ap - bp << endl;
    }else{
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N;

  scanf("%d", &N);

  int YY = N / 100;
  int MM = N % 100;

  if(0 < YY && YY <= 12 && 0 < MM && MM <= 12) printf("AMBIGUOUS\n");
  else if(0 < YY && YY <= 12 && 0 <= MM) printf("MMYY\n");
  else if(0 < MM && MM <= 12 && 0 <= YY) printf("YYMM\n");
  else printf("NA\n");

  return 0;
}


Measured memory_bytes: 128
INK = [
  [[0, 0, 0, 0, 0],
   [0, 0, 1, 0, 0],
   [0, 1, 1, 1, 0],
   [0, 0, 1, 0, 0],
   [0, 0, 0, 0, 0]],
  [[0, 0, 0, 0, 0],
   [0, 1, 1, 1, 0],
   [0, 1, 1, 1, 0],
   [0, 1, 1, 1, 0],
   [0, 0, 0, 0, 0]],
  [[0, 0, 1, 0, 0],
   [0, 1, 1, 1, 0],
   [1, 1, 1, 1, 1],
   [0, 1, 1, 1, 0],
   [0, 0, 1, 0, 0]]
]

d = Array.new(10).map{Array.new(10,0)}
while n = gets do
  x, y, size = n.split(",").map(&:to_i)
  5.times do |i|
    5.times do |j|
      if -1 < x + i - 2 && x + i - 2 < 10 && -1 < y + j - 2 && y + j - 2 < 10 then
        d[x+i-2][y+j-2] = (d[x+i-2][y+j-2].to_i + INK[size-1][i][j].to_i).to_i
      end
    end
  end
end
max = 0
zero = 0
10.times do |i|
  zero = zero + d[i].count(0)
  max = (d[i] << max).max
end
puts zero
puts max

Measured memory_bytes: 6120
N=int(input())
w_list=list(map(int, input().split()))
total=sum(w_list)
w_sum_list=[0]*len(w_list)
ans_list=[0]*len(w_list)
for i in range(len(w_list)):
    #print(i)
    if i==0:
        #print(w_list[i])
        w_sum_list[i]=w_list[i]
    else:
        w_sum_list[i]=w_sum_list[i-1]+w_list[i]
    ans_list[i]=abs(total-2*w_sum_list[i])
print(min(ans_list[:-1]))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
  double a,b,h,m;
  cin >>a>>b>>h>>m;
  while (h>12){
    h-=12;
  }
  double sixty = 60.0;
  double twelve = 12.0;
  double hour = (h*sixty+m)/twelve/sixty;
  double min = m/sixty;
  double hour_x, hour_y, min_x, min_y;
  hour_x = a*cos(2*M_PI*hour);
  hour_y = a*sin(2*M_PI*hour);
  min_x = b*cos(2*M_PI*min);
  min_y = b*sin(2*M_PI*min);
  long double answer = sqrt((hour_x-min_x)*(hour_x-min_x)+(hour_y-min_y)*(hour_y-min_y));
  cout << setprecision(10) << answer <<endl;
  return 0;
}

Measured memory_bytes: 4160
p xs ys z = all (<z) xs && all (z<=) ys

bta True = "No War"
bta False = "War"

main = do
  [n,m,x,y] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getLine :: IO [Int]
  ys <- map read . words <$> getLine :: IO [Int]
  putStrLn . bta . any (p xs ys) $ [x+1..y]


Measured memory_bytes: 1020
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <cmath>
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " "  <<  X << " " <<Y << endl;
   
}

Measured memory_bytes: 256
a = Array.new(3) { gets.split.map(&:to_i) }.flatten
n, *b = $stdin.read.split.map(&:to_i)

yn = [
  [0, 1, 2], [3, 4, 5], [6, 7, 8],
  [0, 3, 6], [1, 4, 7], [2, 5, 8],
  [0, 4, 8], [2, 4, 6]
].any? { |ii| (a.values_at(*ii) - b).empty? }

puts yn ? :Yes : :No


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

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

    int N;
    cin >> N;

    ll max_A = 0;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        max_A = max(max_A, A);
        if (A == max_A) ans = A+B;
    }

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

Measured memory_bytes: 256
N,C=map(int,input().split())
D=[]
for i in range(C):
    Dlist=list(map(int,input().split()))
    D.append(Dlist)
c=[[0]*(10**6) for i in range(3)]
x=[]
X=[]
for i in range(N):
    x=list(map(int,input().split()))
    X.append(x)
for i in range(N):
    for j in range(N):
        x=X[i][j]
        c[(i+j)%3][x-1]+=1
def func(res):
    for i in range(C):
        for j in range(C):
            if i!=j:
                for k in range(C):
                    if i!=k and j!=k:
                        total=0
                        for l in range(C):                           
                            total+=D[l][i]*c[0][l]
                            total+=D[l][j]*c[1][l]
                            total+=D[l][k]*c[2][l]
                        if total<res:
                            res=total
    return res
y=10**20
res=func(y)
print(res)

Measured memory_bytes: 29044
#include <iostream>

using namespace std;

int main()
{
	int a;
	int b;

	cin >> a >> b ;

	if(a>b)
	{
		cout << "a > b" << endl;
	}

	else if(a<b)
	{
		cout << "a < b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}

	return 0;
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  long long ac = a*c;
  long long ad = a*d;
  long long bc = b*c;
  long long bd = b*d;
  
  long long aaa = max(ac,ad);
  long long bbb = max(bc,bd);
  
  long long ans = max(aaa,bbb);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k, s = ns()
    res = [0 for i in range(n)]

    for i in range(n):
        if i < k:
            res[i] = s
        else:
            if s == 10**9:
                res[i] = 10**9-1
            else:
                res[i] = 10**9

    print(*res, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 8660
n = int(input())
music = [list(input().split()) for i in range(n)]
x = input()
#print(music)
ans=0
for i in range(n):
    if x in music[i]:
        ans = i
music = music[ans+1:]
#print(music)
total = 0
for j in music:
    total += int(j[1])
print(total)

Measured memory_bytes: 38496
"use strict";
const App2 = (arg: any) => {
  const Input = arg.trim().split("\n");
  const A: number = parseInt(Input[0].split(" ")[0], 10);
  const B: number = parseInt(Input[1].split(" ")[0], 10);
  const C: number = parseInt(Input[2].split(" ")[0], 10);
  const X: number = parseInt(Input[3].split(" ")[0], 10);

  let count = 0;
  for (let a = 0; a <= A; a++) {
    for (let b = 0; b <= B; b++){
      for (let c = 0; c <= C; c++){
        let sum:number = (a * 500) + (b * 100) + (c * 50);
        if (sum === X && sum % 5 === 0) count++;
      }
    }
  }
  console.log(count);

};

App2(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import numpy as np

N, A, B = list(map(int, input().split()))
V = np.array(list(map(int, input().split())))
V.sort()
V[:] = V[::-1]

def fac(n):
    return 1 if n<=1 else n*fac(n-1)
        
def nCr(n, r):
    return fac(n) // fac(n-r) // fac(r)

d = V[A-1]
# unless all equal, we only need A
if d == V.max():
    # count how many d
    d_eq_cnt = np.count_nonzero(V == d)
    res = nCr(d_eq_cnt, A)
    res_sum = res
    for k in range(1, min(B, d_eq_cnt) + 1 - A):
        res = res * (d_eq_cnt - (A+k-1)) // (A+k)
        res_sum += res
    print(V[:A].mean())
    print(res_sum)
    
    
else:
    # count how many d
    d_eq_cnt = np.count_nonzero(V == d)
    d_lq_cnt = np.count_nonzero(V > d)
    print(V[:A].mean())
    print(nCr(d_eq_cnt, A - d_lq_cnt))



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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


int n;
P p[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		p[i] = make_pair(a,b);
	}
	
	sort(p,p+n);
	
	cout << p[n-1].first + p[n-1].second << endl;
	
	return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
S=[]
C=[]
for i in range(M):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)
not_ans=0
ans = 0
C_check = []
S_check = []
for i in range(M):
    j = (N-S[i])
    if S[i] in S_check:
        index = S_check.index(S[i])
        if C[i]!=C[index]:
            not_ans = '-1'
            break
        continue
    if S[i] < N:
        if S[i]==1 and C[i]==0:
            not_ans = '-1'
            break
    if N < S[i]:
        not_ans = '-1'

    ans += 10**j*C[i]
    S_check.append(S[i])

if not 1 in S_check:
    ans += 10**(N-1)

if N==1 and M==0:
    ans = 0




if not_ans=='-1':
    print(not_ans)
else:
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf();


int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}

Measured memory_bytes: 256
x=int(input())
dic={}
for i in range(1,120):
  dic[i**5]=i
for i in range(1,120):
  a=i**5
  if a>x:
    if a-x in dic.keys():
      print(str(i)+' '+str(dic[a-x]))
      break
  elif a<x:
    if x-a in dic.keys():
      print(str(i)+' -'+str(dic[x-a]))
      break
  else:
    if a in dic.keys():
      print(str(i)+' 0')
      break

Measured memory_bytes: 9212
def main2():
    r = int(input())

    stick = [int(v) for v in input().split()]
    stick = sorted(stick, reverse=True)

    line = []
    tmp = -1
    for i in range(0, len(stick), 1):
        if tmp == stick[i]:
            line.append(stick[i])
            tmp = -1
        else:
            tmp = stick[i]
        if len(line) == 2:
            print(line[0] * line[1])
            exit()
    print(0)

main2()

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

int main(){
  int a;
  cin >> a;
  
  int i = 0;
  string j;
  while (i < a){
    cin >> j;
    if(j == "Y"){
      cout << "Four" <<endl;
      break;
    }else{
      if(i == a-1){
        cout << "Three" << endl;
      }
      i++;
      continue;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
MIN = int(1e6)
p = []
for i in range(N):
  MIN = min(MIN, P[i])
  p.append(MIN)
cnt = 0
for i in range(N):
  if p[i] >= P[i]:
    cnt += 1
print(cnt)

Measured memory_bytes: 26012
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    var (A, B, C) = nextLongList()
    var cnt = 0
    while (A % 2 == 0L && B % 2 == 0L && C % 2 == 0L) {
        val a = A / 2
        val b = B / 2
        val c = C / 2
        A = a + b
        B = b + c
        C = c + a
        cnt++
        if (A == B && B == C) {
            println(-1)
            return
        }
    }
    println(cnt)
}

Measured memory_bytes: 36504
n,m=map(int,input().split())
#union-find
par=[-1]*(n+1)
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def size(x):
    oya=find(x)
    return -par[oya]
def unite(x,y):
    if find(x)==find(y):
        return False
    else:
        if size(y)>size(x):
            y,x=x,y  #xを大きい親にしておくか
        oya_x=find(x)
        oya_y=find(y)
        par[oya_x]-=size(oya_y)  #xの大きさをyにしておく
        par[oya_y]=oya_x  #yの親をxに
        return True

def is_same(x,y):
    return find(x)==find(y)
for _ in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)
ans_set=set()
for i in range(1,n+1):
    ans_set.add(find(i))
print(len(ans_set))

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  string ans;
  
  if(s=="Sunny") ans = "Cloudy";
  else if(s=="Cloudy") ans = "Rainy";
  else if(s=="Rainy") ans = "Sunny";

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


Measured memory_bytes: 3520
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 305
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
const int pri=998244353;
char p[N];
int n,ans,s[N][N],tmp[N][N];
int main()
{
	re(n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",p+1);
		for(int j=1;j<=n;++j)	
			s[i][j]=p[j]-'a';
	}
	for(int i=1;i<=n;++i)
	{
		memcpy(tmp,s,sizeof s);
		for(int j=1;j<=n;++j)
			for(int k=1;k<=n;++k)
				s[j][k]=tmp[j%n+1][k];
		bool ok=1;
		for(int j=1;j<=n;++j)
			for(int k=1;k<=n;++k)
				if(s[j][k] != s[k][j])
					ok=0;
		if(ok)ans+=n;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    ll a[n][3];
    for(int i=0 ; i<n ; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    ll dp[n][3];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(int i=1 ; i<n ; i++)
    {
        dp[i][0] = max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
        dp[i][1] = max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
        dp[i][2] = max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 8260
a, b, m = gets.split.map(&:to_i)
refs = gets.split.map(&:to_i)
micros = gets.split.map(&:to_i)
coupons = []
m.times { coupons << gets.split.map(&:to_i) }
mins = [refs.min + micros.min]

coupons.each do |a, b, minus|
  mins << refs[a - 1] + micros[b - 1] - minus
end

puts mins.min


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BUnevenNumbers solver = new BUnevenNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BUnevenNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            if (n < 9 && n >= 0) {
                ans += n;
            }
            if (n >= 9) {
                ans += 9;
            }
            if (n >= 100 && n < 999) {
                ans += n - 99;
            }
            if (n >= 999) {
                ans += 900;
            }
            if (n >= 10000 && n < 99999) {
                ans += n - 9999;
            }
            if (n >= 99999) {
                ans += 90000;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 22740
/*
 * Author : Remilia Scarlet
 */

// #pragma comment(linker, "/STACK:102400000,102400000")

#include <bits/stdc++.h>

#define For(i,l,r) for(int _r=r,i=l;i<=_r;++i)
#define rep(i,l,r) for(int _r=r,i=l;i<_r;++i)
#define dto(i,r,l) for(int _l=l,i=r;i>=_l;--i)
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define oo (c=getchar())
#define SZ(V) (int(V.size()))
#define ALL(V) V.begin(),V.end()

using namespace std;

typedef double db;
typedef long long LL;
typedef pair<int ,int> PII;
typedef vector<int> VI;
typedef complex<db> cpx;
typedef vector<PII> VII;
// typedef __int128 bigint;

int ran(){return (rand()<<15)+rand();}

int IN(){
	int x=0;char c;
	for(;oo<48 && c^'-' || c>57;);bool f=c=='-';if(f)oo;
	for(;c>47 && c<58;oo)x=(x<<1)+(x<<3)+c-48;return f?-x:x;
}
void print(int x,char en='\n'){
	printf("%d",x);if(en)putchar(en);
}

int main(int argc, char* argv[]){
	int n,m;
	n=  IN();m = IN();
	LL ans = (n-m)*100+m*1900;
	ans *=1ll<<m;
	printf("%lld\n",ans);
}


Measured memory_bytes: 256