akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
ifstream f("A.in");

int main()
{
    int A,B,C,K;
    long long ans=0;
    cin>>A>>B>>C>>K;
    if(A>=K) ans=K;
    else
    {
        K-=A;
        ans=A;
        if(B<K)
        {
            K-=B;
            if(C>=K) ans-=K;
            else ans-=C;

        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace AtCoder
{
  class Program
  {
    void _()
    {
      var D = Split.Int();

      var c = new int[26+1];
      for (int i = 1; i <= 26; i++)
        c[i] = Split.Int();

      //
      for (int i=1;i<=365;i++)
      {
        int hi = 0;
        int his = 0;
        for (int ii=1;ii<26;ii++)
        {
          var tmp = Split.Int();
          if (tmp > his)
          {
            his = tmp;
            hi=ii;
          }
        }
        Console.WriteLine(hi);
      }  
    }

    static void Main(string[] args)
    {
      new Program()._();
    }
  }
}
static class Split
{
  public static string String()
  {
    if (_ss.Count == 0)
    {
      var s = Console.ReadLine();
      if (s == null)
        return null;

      _ss = s.Split(_delim).ToList();
    }

    var ret = _ss[0];
    _ss.RemoveAt(0);
    return ret;
  }

  public static int Int()
  {
    var str = String();
    return int.Parse(str);
  }
  public static long Long()
  {
    var str = String();
    return long.Parse(str);
  }

  static List<string> _ss = new List<string>();
  static char[] _delim = new[] { '\t', ' ' };
}

Measured memory_bytes: 28828
#include<stdio.h>
int main(void)
{
  int num, numcoin, i, j ,resporn;
  scanf("%d%d%d",&num,&numcoin,&resporn);
  int coin[num+1], root1=0,root2=0;
  i=0;
   scanf("%d",&j);
  while(i<=num)
  {
   
    if(j==i)
    {
      coin[i]=1;
      scanf("%d",&j);
    }
    else coin[i]=0;
    i++;
  }
  for(i=resporn; i>=0; i--)
  {
    if (coin[i]==1) root1++;
  }
  for(i=resporn; i<=num; i++)
  {
    if (coin[i]==1) root2++;
  }
  if (root1<root2) printf("%d", root1);
  else printf("%d", root2);
  return 0;
}


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

const int MAX_N = 402;
int N;
int a[MAX_N];
ll dp[MAX_N][MAX_N];
ll psum[MAX_N];

ll go(int le, int ri)
{
	if(le >= ri) return 0;
	ll& res = dp[le][ri];
	if(res != -1) return res;
	res = 1e15;
	for(int k=le+1;k<=ri;++k){
		res = min(res, go(le,k-1)+go(k,ri));
	}
	res += psum[ri+1]-psum[le];
	return res;
}

void solve()
{
	for(int i=1;i<=N;++i) psum[i]=psum[i-1]+a[i-1];
	memset(dp, -1, sizeof(dp));
	ll ans = go(0, N-1);
	cout << ans << '\n';
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int H, W; cin >> H >> W;
	char C[2010][2010];
	int left[2010][2010];
	int right[2010][2010];
	int up[2010][2010];
	int down[2010][2010];
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cin >> C[i][j];
		}
	}
	for (int i = 0; i <= H + 1; ++i) {
		for (int j = 0; j <= W + 1; ++j) {
			left[i][j] = 0;
			right[i][j] = 0;
			up[i][j] = 0;
			down[i][j] = 0;
		}
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (C[i][j] == '#') {
				left[i][j] = 0;
			}
			else {
				left[i][j] = left[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1; i <= W; ++i) {
		for (int j = 1; j <= H; ++j) {
			if (C[j][i] == '#') {
				up[j][i] = 0;
			}
			else {
				up[j][i] = up[j - 1][i] + 1;
			}
		}
	}
	for (int i = H; i >= 1; --i) {
		for (int j = W; j >= 1; --j) {
			if (C[i][j] == '#') {
				right[i][j] = 0;
			}
			else {
				right[i][j] = right[i][j + 1] + 1;
			}
		}
	}
	for (int i = W; i >= 1; --i) {
		for (int j = H; j >= 1; --j) {
			if (C[j][i] == '#') {
				down[j][i] = 0;
			}
			else {
				down[j][i] = down[j + 1][i] + 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (C[i][j] == '#') {
				continue;
			}
			int sum;
			sum = (left[i][j - 1] + right[i][j + 1] + up[i - 1][j] + down[i + 1][j]);
			ans = max(ans, sum+1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 67328
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			String str=n+"";
			StringBuffer sb=new StringBuffer(str);
			String rev=sb.reverse().toString();
			int a=n-1;
			int b=n+1;
			for(;;)
			{
				if(str.equals(rev))
					break;
				str=a+"";
				sb=new StringBuffer(str);
				rev=sb.reverse().toString();
				if(str.equals(rev))
					break;
				str=b+"";
				sb=new StringBuffer(str);
				rev=sb.reverse().toString();
				if(str.equals(rev))
					break;
				a--;
				b++;
			}
			System.out.println(str);
		}
	}
	
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

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

int main(){
    int N,M = 0;
    int K,A = 0;
    cin>>N>>M;
    vector<int> X(M,0);
    for(int i = 0;i < N;i++){
        cin>>K;
        
        for(int j =0;j < K;j++){
            cin>>A;
            A--;
            X[A]++;
        }
    }
    int res = 0;
        for(int i =0;i < M;i++){
            if(X[i] == N ){
               res++; 
            }
        }
    
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String wk = "";

		try {
			scanner = new Scanner(System.in);
			wk = scanner.next();

			System.out.println(wk.replaceAll(",", " "));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numK = 0;
		int s = 0;

		try {
			scanner = new Scanner(System.in);
			numK = scanner.nextInt();
			s = scanner.nextInt();

			int startK = 0;
			if (numK <= s / 3) {
				startK = numK;
			}
			int res = 0;
			for (int i = 0; i <= numK; i++) {
				for (int j = 0; j <= numK; j++) {
					if (s - i - j < 0) {
						break;
					}
					startK = s - i - j;
					for (int k = startK; k <= numK; k++) {
						if (i + j + k == s) {
							res++;
							break;
						}
					}
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23124
n=int(input())
s=[0]*n
for i in range(n):
  s[i]=int(input())
s.sort()
ans=sum(s)
temp=0
if ans%10==0:
  for i in range(n):
    if s[i]%10==0:
      temp=temp+1
    else:
      print(ans-s[i])
      break
  if temp==n:
    print(0)
else:
  print(ans)

Measured memory_bytes: 3064
import bisect

a,b,q = map(int,input().split())
shrine = [-10**12, 10**12]
for _ in range(a):
    s = int(input())
    shrine.append(s)
shrine.sort()

temple = [-10**12, 10**12]
for _ in range(b):
    t = int(input())
    temple.append(t)
temple.sort()

for _ in range(q):
    x = int(input())
    sx = bisect.bisect_right(shrine,x)
    tx = bisect.bisect_right(temple,x)
    ans = 10**12
    for i in [shrine[sx-1], shrine[sx]]:
        for j in [temple[tx-1], temple[tx]]:
            case_1 = abs(i-x)+abs(i-j)
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
    print(ans)

Measured memory_bytes: 89688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(mx,0);
  rep(i,n+5){
    a[i] = i;
  }
  vector<ll> r(mx,0);
  rep(i,n+2){
    r[i+1] = a[i] + r[i];
  }
  mint ans = 0;
  for(int i=k; i<=n+1; i++){
    ll tmp = r[n+1] - r[n+1-i] - r[i] + 1;
    ans += tmp;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 6420
public class Hello {
    public static void Main() {
        
        var input_line = System.Console.ReadLine();
        
        if(input_line == "hi" || input_line == "hihi" || input_line == "hihihi" || input_line == "hihihihi" || input_line == "hihihihihi")
        {
            System.Console.WriteLine("Yes");
        }
        else
        {
            System.Console.WriteLine("No");
        }
        
    }
}

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

using namespace std;

int main()
{
 long long int i,n;
 cin>>n;
 vector<long long int> a(n),b(n),c(n);
 for (i=0;i<n;i++){
  cin>>a[i]>>b[i]>>c[i];
 }
 for (i=1;i<n;i++){
  a[i]+=max(b[i-1],c[i-1]);
  b[i]+=max(a[i-1],c[i-1]);
  c[i]+=max(a[i-1],b[i-1]);
 }
 i=max(a[n-1],b[n-1]);
 cout<<max(i,c[n-1]);
 return 0;
}

Measured memory_bytes: 2560
n = int(input())
s = input()

alphabets = 'abcdefghijklmnopqrstuvwxyz'

ans = 0

for i in range(n):
  tmp = 0
  for c in alphabets:
    if c in s[:i] and c in s[i:]:
      tmp += 1
  ans = max(ans, tmp)
  
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(("" + (a+b)).length());
        }
    }
}

Measured memory_bytes: 20420
n = int(input())
#a, b = map(int,input().split())
al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
mod = 10**9+7
cuml = [al[0]]
for i in range(n-2):
    cuml.append((cuml[i]+al[i+1]) % mod)
ans = 0
for i in range(1, n):
    ans = (ans+cuml[i-1]*al[i]) % mod
print(ans)


Measured memory_bytes: 31716
from collections import deque
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def calc_idx(x, y):
        if x > y:
            x, y = y, x
        return x + y*(y-1)//2

    # create graphs & calc indegree
    n_game = n * (n-1) // 2
    edge = [[] for i in range(n_game)]
    indegree = [0] * n_game
    for i in range(n):
        ai = list(map(int, input().split()))

        for j in range(1, n-1):
            g1 = calc_idx(i, ai[j-1]-1)
            g2 = calc_idx(i, ai[j]-1)
            edge[g1].append(g2)
            indegree[g2] += 1


    ans = 0
    cand = deque([(i, 1) for i in range(n_game) if indegree[i] == 0])
    n_ts = 0
    while len(cand) > 0:
        u, day = cand.popleft()
        ans = max(ans, day)
        n_ts += 1
        for v in edge[u]:
            indegree[v] -= 1
            if indegree[v] == 0:
                cand.append((v, day+1))

    if n_ts != n_game:
        ans = -1

    print(ans)

if __name__ == '__main__':
    main()


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


int main() {
	
	int n;
	cin >> n;
	vector<int> p(n),q(n);
	for(auto &i : p){
		cin >> i;
	}
	for(auto &i : q){
		cin >> i;
	}
	vector<int> c(n);
	for(int i=0; i<n; i++) c.at(i) = i+1;
	int a=0, b=0, j=1;
	do{
		if(c==p) a = j;
		if(c==q) b = j;
		j++;
	}while(next_permutation(c.begin(),c.end()));
	
	cout << abs(a-b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,0,n-1){
        cout<<s[i]<<t[i];
    }
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
def solve(n, m, c):
    dp = [0] + [float("inf")] * n
    for i in range(1, n + 1):
        added_val = float("inf")
        for coin in c:
            added_val = min(added_val, dp[i - coin]) if 0 <= i - coin else added_val
        dp[i] = min(dp[i], added_val + 1)
    print(dp[n])

if __name__ == "__main__":
    n, m = map(int, input().split())
    c = list(map(int, input().split()))
    solve(n, m, c)


Measured memory_bytes: 7296
#include <iostream>

 

using namespace std;

 

int main()
{
    int a ,b, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a==0 && b==0)
            break;
            
        if(a > b)
        {
            a = a+b;
            b = a-b;
            a = a-b;
        }
        cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define MAX 25
#define NIL -1

struct Node {int p, l, r;};
Node T[MAX];
int n, D[MAX], H[MAX];

int getSibling(int id) {
    if (T[id].p == NIL) return NIL;
    if (T[T[id].p].l != id && T[T[id].p].l != NIL) return T[T[id].p].l;
    if (T[T[id].p].r != id && T[T[id].p].r != NIL) return T[T[id].p].r;
    return NIL;
}

void print(int id) {
    cout << "node " << id << ": ";
    cout << "parent = " << T[id].p << ", ";
    cout << "sibling = " << getSibling(id) << ", ";
    int deg = 0;
    if (T[id].l != NIL) deg++;
    if (T[id].r != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[id] << ", ";
    cout << "height = " << H[id] << ", ";

    if (T[id].p == NIL) cout << "root";
    else if (T[id].l == NIL && T[id].r == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

void setDepth(int id, int depth) {
    D[id] = depth;
    if (T[id].r != NIL) setDepth(T[id].r, depth+1);
    if (T[id].l != NIL) setDepth(T[id].l, depth+1);
}

int setHeight(int id) {
    int h1 = 0, h2 = 0;
    if (T[id].r != NIL) h1 = setHeight(T[id].r) + 1;
    if (T[id].l != NIL) h2 = setHeight(T[id].l) + 1;
    return H[id] = max(h1, h2);
}

int main() {
    cin >> n;
    // 初期化
    for (int i = 0; i < n; i++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        T[left].p = T[right].p = id;
    }

    int rootId;
    for (int i = 0; i < n; i++) {
        // 親が存在しないNodeがroot
        if (T[i].p == NIL) rootId = i;
    }
    setDepth(rootId, 0);
    setHeight(rootId);

    for (int i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 3088
//Name: Card Game
//Level: 2
//Category: 確率,Probability,全探索
//Note:

/*
 * ゲイツの出す手札の順番は固定し、ジャッキーの出し方を全探索する。
 *
 * オーダーは O(N! ×N)。
 */
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

void solve() {
    array<int,9> as, bs;
    for(int i = 0; i < 9; ++i) {
        cin >> as[i];
    }
    for(int i = 0; i < 9; ++i) {
        cin >> bs[i];
    }

    int awin = 0;
    int total = 0;
    sort(begin(bs), end(bs));
    do {
        int asum = 0, bsum = 0;
        for(int i = 0; i < 9; ++i) {
            if(as[i] > bs[i]) asum += as[i]+bs[i];
            else bsum += as[i]+bs[i];
        }
        if(asum > bsum) ++awin;
        ++total;
    } while(next_permutation(begin(bs), end(bs)));
    double prob = (double)awin / total;
    cout << prob << ' ' << 1-prob << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> b(n-1);
    cin >> b;
    ll ans = 0;

    vector<ll> c(n+1);
    c[0] = b[0];
    c[n] = b[n-2];

    for (ll i = 0; i < n-1; i++)
    {
        c[i+1] = b[i];
    }
    


    for (ll i = 1; i < n+1; i++)
    {
        ans+= min(c[i],c[i-1]);
    }
    
    cout << ans ;

}


Measured memory_bytes: 256
import itertools
a=input().split()
#print(len(a))

dict={}
for i in range(len(a)):
  dict[i]=int(a[i])
#print(dict)

ans=1000
b=list(itertools.permutations([0, 1, 2]))
for i in range(len(b)):
  x=abs(dict[b[i][2]]-dict[b[i][1]])+abs(dict[b[i][1]]-dict[b[i][0]])
  if x < ans:
    ans = x

print(ans)

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

int N, mna[200005], mxa[200005], mnb[200005], mxb[200005], mna0[200005], mxa0[200005], mnb0[200005], mxb0[200005];
pair<int, int> P[200005];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		P[i] = make_pair(min(x, y), max(x, y));
	}
	sort(P, P + N);
	int mn0 = 1000000000, mx0 = 0, mn1 = 1000000000, mx1 = 0;
	for (int i = 0; i < N; i++) {
		mn0 = min(mn0, P[i].first);
		mx0 = max(mx0, P[i].first);
		mn1 = min(mn1, P[i].second);
		mx1 = max(mx1, P[i].second);
		mna[i] = mn0;
		mnb[i] = mn1;
		mxa[i] = mx0;
		mxb[i] = mx1;
	}
	mn0 = 1000000000;
	 mx0 = 0; mn1 = 1000000000; mx1 = 0;
	 for (int i = N - 1; i >= 0; i--) {
		mn0 = min(mn0, P[i].first);
		mx0 = max(mx0, P[i].first);
		mn1 = min(mn1, P[i].second);
		mx1 = max(mx1, P[i].second);
		mna0[i] = mn0;
		mnb0[i] = mn1;
		mxa0[i] = mx0;
		mxb0[i] = mx1;
	}
	/*
	long long ans1 =  abs((long long)(mx0 - mn1) * (mx1 - mn0));
	long long ans2 = (long long)(mx0 - mn0) * (mx1 - mn1);*/
	long long ans = 2000000000000000000ll;
	
	for (int i = 0; i <= N; i++) {
		int a = max(((i == 0) ? 0 : mxa[i - 1]), ((i == N) ? 0 : mxb0[i])) - min(((i == 0) ? 1000000000 : mna[i - 1]), ((i == N) ? 1000000000 : mnb0[i]));
		int b = max(((i == 0) ? 0 : mxb[i - 1]), ((i == N) ? 0 : mxa0[i])) - min(((i == 0) ? 1000000000 : mnb[i - 1]), ((i == N) ? 1000000000 : mna0[i]));
		ans = min(ans, (long long)a * b);
	}
	for (int i = 0; i < N; i++) swap(P[i].first, P[i].second);
	sort(P, P + N);
	mn0 = 1000000000;
	 mx0 = 0; mn1 = 1000000000; mx1 = 0;
	for (int i = 0; i < N; i++) {
		mn0 = min(mn0, P[i].first);
		mx0 = max(mx0, P[i].first);
		mn1 = min(mn1, P[i].second);
		mx1 = max(mx1, P[i].second);
		mna[i] = mn0;
		mnb[i] = mn1;
		mxa[i] = mx0;
		mxb[i] = mx1;
	}
	mn0 = 1000000000;
	 mx0 = 0; mn1 = 1000000000; mx1 = 0;
	 for (int i = N - 1; i >= 0; i--) {
		mn0 = min(mn0, P[i].first);
		mx0 = max(mx0, P[i].first);
		mn1 = min(mn1, P[i].second);
		mx1 = max(mx1, P[i].second);
		mna0[i] = mn0;
		mnb0[i] = mn1;
		mxa0[i] = mx0;
		mxb0[i] = mx1;
	}
	for (int i = 0; i <= N; i++) {
		int a = max(((i == 0) ? 0 : mxa[i - 1]), ((i == N) ? 0 : mxb0[i])) - min(((i == 0) ? 1000000000 : mna[i - 1]), ((i == N) ? 1000000000 : mnb0[i]));
		int b = max(((i == 0) ? 0 : mxb[i - 1]), ((i == N) ? 0 : mxa0[i])) - min(((i == 0) ? 1000000000 : mnb[i - 1]), ((i == N) ? 1000000000 : mna0[i]));
		ans = min(ans, (long long)a * b);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 8064
A = int(input())
B = int(input())
C = int(input())
X = int(input())
c = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50 == X:
                c += 1
print(c)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int[] count = new int[26];
        char c;
        String str;
        for (int i = 0; i < 26; i++) 
            count[i] = 0;
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            str = sc.next();
            for(int i = 0; i < str.length(); i++) {
                c = str.charAt(i);
                if (c >= 'A' && c <= 'z') {
                    if (c >= 'a' && c <= 'z') {
                        count[c - 'a']++;
                    } else {
                        count[c - 'A']++;
                    }
                }
            }
        }
        for (int i = 0; i < 26; i++) 
            System.out.println((char)(i + 'a') + " : " + count[i]);
    }
}


Measured memory_bytes: 26472
exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

m1,d1 = inp
m2,d2 = inp
puts (m1 == m2)? 0 : 1



Measured memory_bytes: 5052
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& j: v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os <<j;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

void solve() {
    int n;
    cin >> n;
    string c;
    cin >> c;

    vi a(n, 0);
    vi b(n, 0);
    for (int i=1; i<n; i++) {
        if (i % 2 == 0) {
            a[i] = a[i/2] + 1;
        }
        b[i] = b[i-1] + a[i];
    }


    int cnt = 0;
    for (int i=0; i <n; i++) {
        if (c[i] == '2') {
            if (b[n-1] - b[i] - b[n-1-i] == 0) {
                cnt++;
            }
        }
    }
    if (cnt % 2) {
        cout << 1;
        return;
    }


    for (int i=0; i <n; i++) {
        if (c[i] == '2') {
            cout << 0;
            return;
        }
    }


    cnt = 0;
    for (int i=0; i <n; i++) {
        if (c[i] == '3') {
            if (b[n-1] - b[i] - b[n-1-i] == 0) {
                cnt++;
            }
        }
    }
    if (cnt % 2) {
        cout << 2;
    } else {
        cout << 0;
    }
}

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


    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
int main()
{
  string S, T; cin >> S >> T;
  if (S == T.substr(0, T.size() - 1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
def solve():
    from sys import stdin
    f_i = stdin
    
    ans = ""
    
    while True:
        a, b = map(int, f_i.readline().split())
        
        if a == 0 and b == 0:
            break
        
        if a < b:
            a, b = b, a
        
        # Euclidean Algorithm
        cnt = 1
        while a % b != 0:
            cnt += 1
            a, b = b, a % b
        
        ans += f"{b} {cnt}\n"
    
    print(ans, end='')

solve()


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s; cin >> s;
	cout << s.substr(0, 3) << endl;

	return 0;
}


Measured memory_bytes: 3644
#### ABC 085 C - Otoshidama
N, Y = map(int,input().split())

list_a = []
list_b = []
for a in range(N+1):
    for b in range(N+1):
        c = N - a - b
        if c >= 0:
            k = 10000 * a + 5000 * b + 1000 * c
            list_a.append(k)
            if Y == k:
                list_b.append(a)
                list_b.append(b)
                list_b.append(c)
        
if Y in list_a:
    print(str(list_b[0])+' '+str(list_b[1])+' ' + str(list_b[2])+' ')
if Y not in list_a:
    print('-1 ' + '-1 ' + '-1')

Measured memory_bytes: 87976
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var bar = ReadLine();
            var stk = new Stack<long>();
            var dct = new Dictionary<long, long>();
            for(var i=0;i<bar.Length;++i)
            {
                if (bar[i] == '\\')//下がる
                {
                    stk.Push(i);
                }
                else if (bar[i] == '/')
                {
                    if (stk.Any())
                    {
                        var pre = stk.Pop();
                        var l = i - pre;
                        dct[pre] = i;
                    }
                }
                else if (bar[i] == '_')
                { }
            }
            var max = -1L;
            var lnum = new List<long>();
            var sum = 0L;
            for (var i = 0; i < bar.Length; ++i)
            {
                if (dct.ContainsKey(i))
                {
                    max = Math.Max(dct[i], max);
                    sum += dct[i] - i;
                }
                if (i == max)
                {
                    lnum.Add(sum);
                    sum = 0;
                }
            }
            WriteLine(lnum.Sum());
            var str = ($"{lnum.Count} " + string.Join(" ", lnum)).Trim();
            WriteLine(str);
        }
    }
}



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

using std::pair;
using std::vector;

char str[100010];

void MAIN() {
    scanf("%s", str);
    int n = strlen(str);
    vector<int> cnt(26, 0);
    vector<bool> exist(26);
    std::priority_queue<pair<int, int>, vector<pair<int, int> >, std::greater<pair<int, int> > > q[26];
    for(int i = 0; i < n; ++ i) {
        int x = str[i] - 'a';
        ++ cnt[x];
        //printf("%c %d\n", str[i], 2 * cnt[x] - i);
        if(!exist[x]) {
            q[x].push(std::make_pair(2 * cnt[x] - i, i));
            exist[x] = true;
        } else {
            auto top = q[x].top();
            if(2 *cnt[x] - i - top.first > -1) {
                printf("%d %d\n", top.second + 1, i + 1);
                return ;
            }
            q[x].push(std::make_pair(2 * cnt[x] - i, i));
        }
    }
    puts("-1 -1");
}

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


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

#define rep(var, start, end)  for(int var = start; var <= end; ++var)
#define drep(var, start, end) for(int var = start; var >= end; --var)

using namespace std;

int main() {

    int N, Y;

    cin >> N >> Y;

    rep(x, 0, N) {
        rep(y, 0, N - x){
            if ((x * 10000 + y * 5000 + (N - x - y) * 1000) == Y) {
                cout << x << ' ' << y << ' ' << N - x - y << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(n)for(ll i=0;i<n;i++)
#define M make_pair
#define F first
typedef long long ll;
using namespace std;
int main(){
    ll n,k,s,t,a[50];cin>>n>>k>>s>>t;
    REP(n)cin>>a[i];
    map<pair<ll,ll>,ll> p[50];
    REP(n){
        for(ll j=k-2;j+1;j--){
            for(const auto&l:p[j]){
                p[j+1][M(l.F.F&a[i],l.F.second|a[i])]+=l.second;
            }
        }
        p[0][M(a[i],a[i])]=1;
    }
    n=0;
    REP(k)n+=p[i][M(s,t)];
    cout<<n;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=3e3+5;

int cache[N][N];
string s,t;
int n,m;

int dp(int pos1,int pos2)
{
     if(pos1==n || pos2==m)
          return 0;
     
     int &ans=cache[pos1][pos2];
     if(ans!=-1)
          return ans;
     
     if(s[pos1]==t[pos2])
          return ans=1+dp(pos1+1,pos2+1);
     else 
          return ans=max(dp(pos1+1,pos2),dp(pos1,pos2+1));
}

void path(int i,int j)
{
     if(i==n || j==m)
          return;
     if(s[i]==t[j])
     {
          cout<<s[i];
          path(i+1,j+1);
          return;
     }
     int ans=dp(i,j);
     if(ans==dp(i+1,j))
          return path(i+1,j);
     return path(i,j+1);     
}

int32_t main()
{
	IOS;
     
     memset(cache,-1,sizeof cache);
     
     cin>>s>>t;
     n=s.size();
     m=t.size();
     
     int len=dp(0,0);
     path(0,0);
     
	return 0;
}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

ll gcd(ll p, ll q)
{
  if (p % q == 0)
    return q;
  return gcd(q, p % q);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll l = lcm(c, d);
  ll ans = b - a;
  ans -= b / c;
  ans -= b / d;
  ans += b / l;
  ans += a / c;
  ans += a / d;
  ans -= a / l;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());

		String[] strings = new String[2];
		strings = s.split("\\s+");

		BigDecimal d1 = new BigDecimal(strings[0]);
		BigDecimal d2 = new BigDecimal(strings[1]);

		BigDecimal average = (d1.add(d2).divide(new BigDecimal(2)));
		BigDecimal ans = average.setScale(0, BigDecimal.ROUND_UP);

		System.out.println(ans);

	}
}


Measured memory_bytes: 21332
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 2e5 + 5;

int n;
int go[N];

void solve() {
  cin >> n;
  ll k; cin >> k;
  for(int i = 1; i <= n; i++) {
    int x; cin >> x;
    go[i] = x;
  }
  int p = 1;
  int who = -1;
  set <int> s;
  while(true) {
    p = go[p];
    if(s.count(p)) {
      who = p;
      break;
    }
    s.insert(p);
  }
  int old = who;
  vector <int> cyc;
  cyc.push_back(who);
  while(true) {
    who = go[who];
    if(who == old) break;
    cyc.push_back(who);
  }
  int cur = 1;
  while(true) {
    cur = go[cur];
    k--;
    if(cur == old) {
      break;
    }
    if(k == 0) {
      print(cur);
      return;
    }
  }
  int m = cyc.size();
  cout << cyc[k % m] << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


Measured memory_bytes: 13744
#include <cstdio>           // printf(), scanf()
#include <vector>
#include <set>
#include <algorithm>        // min()

using namespace std;
static const int MAX_V = 100000;

vector<int> G[MAX_V];
bool visited[MAX_V];
int prenum[MAX_V];
int parent[MAX_V];
int lowest[MAX_V];
int V;
int timer;

void
dfs(int u, int prev)
{
	prenum[u] = lowest[u] = timer;
	timer++;
	visited[u] = true;

	for (unsigned int i = 0; i < G[u].size(); ++i)
	{
		int v = G[u][i];
		if (!visited[v])
		{
			parent[v] = u;
			dfs(v, u);
			lowest[u] = min(lowest[u], lowest[v]);
		}
		else if (v != prev)
			lowest[u] = min(lowest[u], prenum[v]);
	}
}

void
art_points()
{
	for (int i = 0; i < V; ++i)
		visited[i] = false;

	timer = 1;
	dfs(0, -1);

	set<int> ap;
	int np = 0;
	for (int u = 1; u < V; ++u)
	{
		int p = parent[u];
		if (p == 0)
			np++;
		else if (prenum[p] <= lowest[u])
			ap.insert(p);
	}

	if (np > 1)
		ap.insert(0);

	for (set<int>::iterator it = ap.begin(); it != ap.end(); ++it)
		printf("%d\n", *it);
}

int
main(int argc, char** argv)
{
	int E;

	scanf("%d %d", &V, &E);
	for (int i = 0; i < E; ++i)
	{
		int s, t;
		scanf("%d %d", &s, &t);
		G[s].push_back(t);
		G[t].push_back(s);
	}

	art_points();
	return 0;
}

Measured memory_bytes: 4952
#include<stdio.h>

int main(){

  int x,y,temp,z;

  scanf("%d%d",&x,&y);

  if(y>x){ // x>yを前提とする。
    temp = x;
    x = y;
    y = temp;
  }

  while(x%y != 0 ){
    temp = y;
    y =x%y;
    x = temp;    
  }

  printf("%d\n",y);
  return 0;
}
  

  



Measured memory_bytes: 2048
d,g=map(int,input().split())
pc=([list(map(int,input().split())) for i in range(d)])

sc=0
l=[]
for i in range(2**d):
  bag=[0]*d
  #print("pattern {}: ".format(i), end="")
  for j in range(d):
    if ((i>>j) & 1):
      bag[j]=100*(j+1)
  else:
    #print(bag)
    sc=0
    inc=0
    #完全に解く問題のスコアのみ加算
    for ii in range(d):
      #0はスキップ
      if bag[ii] == 0:
        continue
      sc+=bag[ii]*pc[ii][0]+pc[ii][1]
      inc+=pc[ii][0]
      if sc>=g:
        l.append(inc)
        break
      
    for index,ii in enumerate(reversed(bag)):
      #さっき加算したのでスキップ
      if ii != 0:
        continue
      #中途半端に解く問題のスコアを加算
      else:
        for _ in range(1,pc[index][0]):
          sc+=100*(d-index)
          inc+=1
          if sc>=g:
            l.append(inc)
            #中途半端は一度のみなので加算したらループを抜ける
        break

print(min(l))
  

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

ll dp[1000001];
ll dp2[1000001];

int main() {

    for (int i=1; i<=1000000; ++i) {
        dp[i] = dp2[i] = i;
        for (int n=1;;++n) {
            int p = n*(n+1)*(n+2)/6;
            if (i < p) break;
            dp[i] = min(dp[i], dp[i-p]+1);
            if (p%2) {
                dp2[i] = min(dp2[i], dp2[i-p]+1);
            }
        }
    }

    int n;
    while (cin >> n and n) {
        cout << dp[n] << " " << dp2[n] << endl;
    }

}

Measured memory_bytes: 18704
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)
l, r = -1, 10 ** 12 + 1
while r - l > 1:
    m = (l + r) // 2
    cnt = 0
    for i in range(n):
        cnt += max(0, a[i] - (m // f[i]))
    if cnt <= k:
        r = m
    else:
        l = m
print(r)

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

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

/*
class Node {
public:
  int num;
  int index;
  bool operator<(const Node& b) const {
    if(num < b.num) return (num < b.num);
    else return index > b.index;
  }

  Node(){
    num=0; index=0;
  }
  Node(int n, int i) : num(n), index(i){
  }
};
*/

string match = "CODEFESTIVAL2016";

int main(){
;
  string s;
  cin >> s;
  bool flag1 = false , flag2 = false;

  rep(i, s.size()){
    if(s[i] == 'C') flag1 = true;
    if(s[i] == 'F' && flag1) flag2 = true;
  }

  if(flag1 && flag2) cout << "Yes" << endl;
  else cout << "No" <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    //vector<char>s;
    int temp=-1,sum=0,count=0;
    string s;
    
    cin >> s;
    
    
    count = s.size()/2;
    
    
    if(s.size()==1)
        cout << '0' <<endl;
    else if(s.size() ==2){
        if(s[0]==s[1])
            cout << '1' << endl;
        else
            cout << '0' << endl;
    }else{// size>=3
        int j=0;
        while(count>0){
            
            if(s[j]==s[j+1] && s[j]=='0'){
                s[j+1]='1';
                sum++;
            }else if (s[j]==s[j+1] && s[j]=='1'){
                s[j+1]='0';
                sum ++;
            }
            if((j+2)<s.size()){
                if(s[j+1]==s[j+2] && s[j+1]=='0'){
                    s[j+2]='1';
                    sum++;
                }else if (s[j+1]==s[j+2] && s[j+1]=='1'){
                    s[j+2]='0';
                    sum ++;
                }
            }
            
            j= j+2;
            count--;
        }
        cout << sum << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 512
N = list(input())
N_r = list(reversed(N))

if N_r[0] == '2' or N_r[0] == '4' or N_r[0] == '5' or N_r[0] == '7' or N_r[0] == '9':
    print('hon')
elif N_r[0] == '0' or N_r[0] == '1' or N_r[0] == '6' or N_r[0] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if (s[0]!='A') {cout<<"WA"<<endl;return 0;}
  if ((int)s[1]-(int)'Z'<=0) {cout<<"WA"<<endl;return 0;}
  int c=0;
  for (int i=2;i<s.size()-1;i++){
    if(s[i]=='C') {c++;continue;}
    if ((int)s[i]-(int)'Z'<=0) {cout<<"WA"<<endl;return 0;}
  }
  if ((int)s[s.size()-1]-(int)'Z'<=0) {cout<<"WA"<<endl;return 0;}
  if(c==1) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}


Measured memory_bytes: 256
def f(m, s, g):
    v, t = {s}, set()
    for i in m:
        for j in v:
            t.update((j+i, j-i))
        v, t = t, set()
    return g in v
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
if f(m[::2][1::], m[0], x) and f(m[1::2], 0, y):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

ll gcd(ll a, ll b){
   if (a%b == 0){
    return(b);
   }
   else{
    return(gcd(b, a%b));
   }
}

int main(){
  ll N,a;cin>>N;
  set <ll> s;
  REP(i,0,N+1){
    cin>>a;
    s.insert(a);
  }
  vector<ll> vec(s.begin(),s.end()),dif(N);
  REP(i,0,vec.size()-1){
    dif[i]=vec[i+1]-vec[i];
  }
  ll ans = dif[0];
  REP(i,1,dif.size()){
    ans=gcd(ans,dif[i]);
  }
  print(ans)

}


Measured memory_bytes: 6528
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
    long long N,K;
    cin >> N >> K;

    long long keta=0;
    while(N!=0){
        N = N/K;
        keta++;
    }

    cout << keta << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
using namespace std;

void solve() {
  int N, K;
  cin >> N >> K;

  vector<int> H(N);
  for (int &h : H) {
    cin >> h;
  }

  vector<int> dp(N + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int p = 1; p <= K && i + p < N; p++) {
      dp[i + p] = min(dp[i + p], dp[i] + abs(H[i] - H[i + p]));
    }
  }

  cout << dp[N - 1] << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1024
program integer_product
  implicit none
  integer :: n, p2(200000) = 0, p5(200000) = 0, i, j, m
  integer :: map(-30:30, -30:30) = 0
  integer(8) :: a
  character(16) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    m = len_trim(s)
    do j = 1, m
      if (s(j:j) == '.') then
        p2(i) = j - m
        p5(i) = j - m
        s(j:m - 1) = s(j + 1:m)
        s(m:) = ''
        exit
      end if
    end do
    read(s,*) a
    do while (mod(a, 2_8) == 0)
      a = a / 2
      p2(i) = p2(i) + 1
    end do
    do while (mod(a, 5_8) == 0)
      a = a / 5
      p5(i) = p5(i) + 1
    end do
    map(p2(i), p5(i)) = map(p2(i), p5(i)) + 1
  end do
  a = 0
  do i = 1, n
    map(p2(i), p5(i)) = map(p2(i), p5(i)) - 1
    a = a + sum(map(-p2(i):, -p5(i):))
  end do
  write(*,'(i0)') a
end program integer_product

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M; cin >> N >> M ;
  ll ans = -1;
  for(ll i=1;i*i<=M;i++){
    if(M%i!=0) continue;
    if(double(i)<=double(M)/double(N)+EPS) chmax(ans,i);
    if(double(M/i)<=double(M)/double(N)+EPS) chmax(ans,M/i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256