akhauriyash/Code-Regression huggingface dataset:
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [x]: number[] = tmp[0].split(" ").map(int => parseInt(int));
    let result = x;
    while(true) {
      if (Main.isPrime(result)) {
        return `${result}`;
      }
      result++;
    }
  }
  static isPrime(x) {
    for (let i = 2, len = Math.floor(Math.sqrt(x)); i <= len; i++) {
      if (x % i == 0) {
        return false;
      }
    }
    return true;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 9420
n = int(input())
a = []
b = []
for s in range(n):
    x,y = map(int,input().split())
    a.append(x+y)
    b.append(x-y)
c = max(a) - min(a)
d = max(b) - min(b)
if c < d:
    c = d
print(c)

Measured memory_bytes: 100416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int count = 0;
  if(s[0] == '1')count += 1;
  if(s[1] == '1')count += 1;
  if(s[2] == '1')count += 1;
  cout << count << endl;
  
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
ls = [a,b,c]
five = 0
seven = 0
for data in ls:
  if data == 5:
    five += 1
  elif data == 7:
    seven += 1
if five == 2 and seven == 1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9072
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


def machine(x,y):
  if x=='T' and y=='F':
    return 'F'
  else:
    return 'T'


N = int(input())
Pn = list(map(str, sys.stdin.readline().rstrip().split()))

for i in range(1, N):
  Pn[i] = machine(Pn[i-1], Pn[i])

print(Pn[-1])


Measured memory_bytes: 7188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int H = in.nextInt();
            int N = in.nextInt();
            int[] A = in.nextIntArray(N);
            int sum = Arrays.stream(A).sum();
            out.println(H <= sum ? "Yes" : "No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 34400
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
ns = defaultdict(set)
for i in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add(v)
    ns[v].add(u)
    
    
def sub(u, p):
    if len(ns[u])==1 and p in ns[u]:
        return a[u]
    ub = 0
    mv = 0
    msum = 0
    for v in ns[u]:
        if p==v:
            continue
        val = sub(v, u)
        if val is None:
            return None
        mv = max(mv, val)
        msum += val
    lb = max(mv, msum//2)
    if not (lb<=a[u]<=msum):
#         print(u,lb, msum, mv)
        return None
    else:
        return a[u] - (msum-a[u])
if n==2:
    if a[0]==a[1]:
        print("YES")
    else:
        print("NO")
else:
    if len(ns[0])>1:
        ans = sub(0, -1)
    else:
        ans = sub(list(ns[0])[0], -1)

    if ans is None or ans!=0:
        print("NO")
    else:
        print("YES")

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

#define ll long long
#define f(i,a,n) for (int i=a;i<n;i++)
typedef pair<ll, ll> pa;
const ll mod=1000000007;
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll h[n + 1];
    f(i, 1, n + 1) {
        cin >> h[i];
    }
    ll ans = 1;
    ll curr = 1;
    f(i, 2, n + 1) {
        if (h[i] > h[i - 1]) {
            ans = max(ans, curr);
            curr = 1;
        } else {
            curr++;
        }
    }
    cout << max(ans, curr) - 1;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import math
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))
 
 
    def check(length :int) -> bool:
        cnt = 0
 
        for a in A_list:
            if a >= length:
                divide = math.ceil(a / length)
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)
 
 
    L = 0.1          # the minimum length
    R = max(A_list)  # the maximum length
 
    while (R - L) > 0.01:
        M = L + (R - L) / 2
 
        if check(M):
            R = M
        else:
            L = M
    
    
    ans = Decimal(str(M)).quantize(Decimal('1E-1'), rounding=ROUND_HALF_UP)
    ans = math.ceil(ans)

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 32508
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a[n];
  int x=10001;
  int zero=0;
  int po=0;
  int ne=0;
  int ans=0;
  int w[n-1][2];
  for(int i=0; i<n; ++i){
    cin>>a[i];
    if(a[i]==0) ++zero;
    else if(a[i]>0) ++po;
    else ++ne;
  }
  sort(a, a+n);

  if(po==0){
    w[0][0]=a[n-1];
    w[0][1]=a[0];
    a[n-1]=a[n-1]-a[0];

    REP(i, n-2){
      w[i+1][0]=a[n-1];
      w[i+1][1]=a[i+1];
      a[n-1]=a[n-1]-a[i+1];
    }
    ans=a[n-1];
  }
  else if(ne==0){
    REP(i, n-2){
      w[i][0]=a[0];
      w[i][1]=a[n-i-1];
      a[0]=-a[n-i-1]+a[0];
    }
    w[n-2][0]=a[1];
    w[n-2][1]=a[0];
    a[0]=-a[0]+a[1];
    ans=a[0];
  }
  else{
    int s=0;
    int j=n-1;
    while(a[j-1]>0){
      w[s][0]=a[0];
      w[s][1]=a[j];
      a[0]=a[0]-a[j];
      --j;
      ++s;
    }
    int k=0;
    while(j-k>0){
      w[s][0]=a[j];
      w[s][1]=a[k];
      a[j]=a[j]-a[k];
      ++k;
      ++s;
    }
    ans=a[j];
  }

  cout<<ans<<endl;
  REP(i, n-1){
    cout<<w[i][0]<<" "<<w[i][1]<<endl;
  }

  return 0;
}


Measured memory_bytes: 3072
import numpy as np
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [ input().split() for i in range(N)] 
for i in range(N):
    A[i] = [int(j) for j in A[i]]

B = np.array(B)
A = np.array(A)

sum = np.dot(B,A.T)
print(np.sum(sum>-C))

Measured memory_bytes: 12496
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n;
char inp[100];
int main(void) {
	scanf("%d %s", &n, inp);
	if (3200 <= n) printf("%s\n", inp);
	else printf("red\n");
}

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

int main(){
	ll n;cin>>n;ll ans=n*(n-1)/2;
	cout<<ans<<endl;
}

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

int main(int argc, char const *argv[])
{
    int A, B, H, M;
    double C;
    double dgree;
    cin >> A >> B >> H >> M;

    if (M * 2 * M_PI / 60 > (H * 2 * M_PI / 12 + M_PI * M / 360))
        dgree = M * 2 * M_PI / 60 - (H * 2 * M_PI / 12 + M_PI * M / 360);
    else
    {
        dgree = (H * 2 * M_PI / 12 + M_PI * M / 360) - M * 2 * M_PI / 60;
    }

    C = sqrt(A * A + B * B - 2 * A * B * cos(dgree));

    cout << fixed << setprecision(20) << C << endl;

    return 0;
}


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

int main(){
    long long N;
    cin >> N;
    cout << N * (N-1) / 2 << endl;
}

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

public class Main{
    public static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    public static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return (int) in.nval;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int k = nextInt(), n = nextInt(), max = Integer.MIN_VALUE, a[] = new int[k];
        a[0] = nextInt();
        for (int i = 1; i < n; i++) {
            a[i] = nextInt();
            int x = a[i] - a[i - 1];
            if (max < x)
                max = x;
        }
        max = Math.max(a[0] + k - a[n - 1], max);
        System.out.println(k - max);
    }

}


Measured memory_bytes: 28504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static int product4(int[] a){
		return a[0]*a[1]*a[2]*a[3];
	}

	public static int puyo(int[] a){
		int answer = a.length;
		boolean flag = true;
		while(flag&&answer>=4){
			for (int i=0;i<answer-3;i++){
				flag = false;
				if(a[i] == a[i+1] &&a[i] == a[i+2] &&a[i] == a[i+3]){
					int hit = a[i];
					int ren = 3;
					while(i+ren+1 < answer){
						if(a[i+ren+1] != hit){break;}
						ren++;
					}
					for(int j=i; j<answer-ren-1; j++){
						a[j] = a[j+ren+1];
					}
					answer -= ren+1;
					flag = true;
					break;
				}
			}
		}
		return answer;
	}

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int n = Integer.parseInt(br.readLine());
			if(n==0){break;}

			int[] cha = new int[n];
			for (int i=0; i<n; i++){
				cha[i] = Integer.parseInt(br.readLine());
			}
			int answer = n;
			for(int i=0;i<n-3;i++){
				int[] chain = new int[n];
				for(int j=0; j<n; j++){
					chain[j]=cha[j];
				}
				int pro = product4(Arrays.copyOfRange(chain, i, i+4));
				if(pro==2 || pro==3|| pro==8|| pro==24|| pro==27|| pro==54){
					int hit = chain[i];
					if (hit == chain[i+1]){
						chain[i+2] = chain[i+3] = hit;
					}else if(hit == chain[i+2]){
						chain[i+1] = hit;
					}else{
						chain[i] = chain[i+1];
					}
					answer = Math.min(answer, puyo(chain));
				}
			}
			System.out.println(answer);
		}
	}
}

Measured memory_bytes: 156256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = ((b-a+1+(a%2))/2)%2;
    for(int j=1;j<=40;++j) {
        ll tmp = 0LL;
        if(a & (1LL << j)) tmp += (1LL << (j+1)) - (a & ((1LL<<(j+1))-1LL));
        if(b & (1LL << j)) tmp += (b & ((1LL<<j)-1LL)) + 1LL;
        if(tmp % 2) ans += (1LL << j);

    }

    cout << ans << endl;
}


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


using namespace std;

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

string str[3];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= 2; i++)
        cin >> str[i];
    ll ans = 1;
    i = 0;
    while(i < n) {
        if(str[1][i] == str[2][i]) {
            if(i > 0) {
                if(str[1][i - 1] == str[2][i - 1])
                    ans *= 2;
            }
            else
                ans *= 3;
            i++;
        }
        else {
            if(i == 0)
                ans *= 6;
            else if(str[1][i - 1] == str[2][i - 1])
                ans *= 2;
            else
                ans *= 3;
            i += 2;
        }
        ans %= MOD;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n, k;
vector<ll> dp(1e6+1, -1);
vector<ll> v(1e5+1);

ll frog1(ll i) {
	if (i==n-1) return 0;
	if (dp[i]!=-1) return dp[i];
  	ll ans=frog1(i+1) + abs(v[i+1]-v[i]);
  	if (i+2<n) ans=min(ans, frog1(i+2) + abs(v[i+2]-v[i]));
  	return dp[i]=ans;
}

int main() {
	cin >> n;
	for (ll i=0; i<n; ++i) cin >> v[i];
	cout << frog1(0);
	return 0;
}



Measured memory_bytes: 14768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>

int gcm(int a,int b);

int main(){
  string a;
  cin >> a;
  string b,c;
  rep(i,a.size()){
    if(i%2 == 0){
      b.push_back('0');
      c.push_back('1');
      //cout << b << endl;
    }
    else{
      b.push_back('1');
      c.push_back('0');
      //cout << b << endl;
    }
  }
  //cout << b << endl;
  int asum = 0;
  int bsum = 0;
  rep(i,a.size()){
    if(a[i] == b[i]) asum++;
    else bsum++;
  }
  cout << min(asum,bsum) << endl;
}

int gcm(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcm(a%b,b);
}

Measured memory_bytes: 768
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

string s;

int main() {
    cin.sync_with_stdio(false);

    cin >> s;

    bool ok = 0;
    for (int i = 1; i < (int)s.size(); ++ i) {
        if (s[i - 1] == 'A' && s[ i ] == 'C')
            ok = 1;
    }

    cout << (ok == 1 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
from itertools import accumulate
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
P = [0] + list(map(int,readline().split()))
C = [0] + list(map(int,readline().split()))

check = [False]*(N+1)
data = []
for i in range(1,N+1):
    if check[i]:
        continue
    cnt = 0
    point = []
    n = i
    while True:
        if check[n]:
            break
        check[n] = True
        cnt += 1
        point.append(C[n])
        n = P[n]
    data.append((cnt,point))

S = len(data)
INF = 10**31
ans = -INF
for i in range(S):
    cnt,point = data[i]
    a = K // cnt
    b = K % cnt
    tt = -INF
    P = [0]+point+point
    SS = list(accumulate(P))
    sum_point = sum(point)
    if a == 0:
        for k in range(1,b+1):
            for i in range(cnt):
                t = SS[i+k]-SS[i]
                tt = max(t,tt)
        tmp = tt
    elif sum_point <= 0:
        for k in range(1,cnt):
                for i in range(cnt):
                    t = SS[i+k]-SS[i]
                    tt = max(t,tt)
        tmp = tt
    else: 
        tmp1 = sum_point * a
        tmp2 = sum_point * (a-1)
        tt1 = 0
        tt2 = 0
        for k in range(1,b+1):
            for i in range(cnt):
                t1 = SS[i+k]-SS[i]
                tt1 = max(t1,tt1)
        tmp1 += tt1

        for k in range(1,cnt):
            for i in range(cnt):
                t2 = SS[i+k]-SS[i]
                tt2 = max(t2,tt2)
        tmp2 += tt2

        tmp = max(tmp1,tmp2)

    ans = max(tmp,ans)
print(ans)
    

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

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

int main(){
  int n,x; cin >>n >>x;
  vector<int> t(n);
  rep(i,n) {
    cin >>t[i];
    t[i] = abs(t[i]-x);
  }
  int ans = t[0];
  rep(i,n){
    ans = gcd(ans,t[i]);
  }
  cout << ans << endl;
  return 0; 
}

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

int calc(int i){
    int x=0;
    while(i>0){
        x=x+i%10;
        i=i/10;
    }
    return x;
}
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int ans=0;
    int wa=0;
    for(int i=1;i<=N;i++) {
       wa= calc(i);
       if(A<=wa&&wa<=B) {
           ans = ans + i;
       }
    }
    cout<<ans;
}

Measured memory_bytes: 256
N=int(input())
S=input()
l=0
r=0
for s in S:
    if s=='(':
        l+=1
    else:
        if l>0:
            l-=1
        else:
            r+=1
if r>0:
    S='('*r+S
if l>0:
    S=S+')'*l
print(S)

Measured memory_bytes: 2940
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

#pragma GCC optimize("O3")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double M = h * 60.0 + m;
  const double PI = acos(-1);
  double r = (double)M / (60.0 * 12) * 2.0 * PI;
  double s = (double)m / (60.0) * 2.0 * PI;
  cout << sqrt(sq(a * cos(r) - b * cos(s)) + sq(a * sin(r) - b * sin(s)))
       << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 4112
/* You can't hack me! */
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef set<ll> sll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define sc scanf
#define pr printf
#define in(x) sc("%lld", &(x))
#define id(x) sc("%Lf", &(x))
#define os(x) cout<<x<<" "
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
const ll P=998244353;
const ll N=200010;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t=1;
    //cin>>(t);
    while(t--)
    {
        string s, t;
        cin>>s>>t;
        t.pop_back();
        //os(s); on(t);
        if(s==t) on("Yes");
        else on("No");
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main(){

    int n,m;
    while(cin>>n>>m,n){
        long long int ans = 0;
        char a[100][9];
        int b[100];
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
        }
        char x[1000][9];
        for(int i=0;i<m;i++){
            cin>>x[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                bool flg = false;
                for(int k=0;k<8;k++){
                    if(a[i][k]!='*'&&a[i][k]!=x[j][k])flg = true;
                }
                if(!flg)ans += b[i];
            }
        }
        cout<<ans<<endl;


    }
}

Measured memory_bytes: 1168
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;

int main()
{
	int n;
	while(cin>>n){
		if (n/10==9||n%10==9) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, y;
    cin >> n >> y;

    int a, b, c;
    rep(i, y / 10000 + 1)
    {
        rep(j, y / 5000 + 1)
        {
            int num = y / 1000 - 10 * i - 5 * j;
            if (0 <= num && num <= y / 1000 && i + j + num == n)
            {
                printf("%d %d %d\n", i, j, num);
                return 0;
            }
        }
    }

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


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int l,r;

    int ans = (N+1)/2;
    if(N%2){
        int l = N/2;
        while(l>=0 and s[l] == s[N/2]){
            l--;
        }
        int r = N/2;
        while(r<N and s[r] == s[N/2]){
            r++;
        }
        ans += min(N/2-l,r-N/2)-1;
    }else{
        const int L = N/2-1;
        const int R = N/2;
        int l = L;
        int r = R;
        if(s[L] == s[R]){
            while(l>=0 and s[l] == s[L]){
                l--;
            }
            while(r<N and s[r] == s[R]){
                r++;
            }
            ans += min(L-l,r-R);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <new>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef int64_t i64;

int main() {
	ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<bool> x(n), y(n);
  for(; m > 0; m--) {
    int a, b;
    cin >> a >> b; a--; b--;
    if(a == 0) {
      x[b] = true;
    } else if(b == n - 1) {
      y[a] = true;
    }
  }
  for(int i = 1; i + 1 < n; i++) {
    if(x[i] && y[i]) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

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

int main(void) {
    
    int n;
    string a, b, c;
    scanf("%d", &n);
    cin >> a;
    cin >> b;
    cin >> c;
    int cnt, ans = 0;
    for(int i=0; i<n; i++) {
        cnt = 0;
        if (a[i] == b[i]) cnt ++;
        if (a[i] == c[i]) cnt ++;
        if (b[i] == c[i]) cnt ++;
        if (cnt==0) ans +=2;
        else if (cnt==1) ans += 1;
    }

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


    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	X, A, B := getInt(), getInt(), getInt()

	ans := "safe"
	if A >= B {
		ans = "delicious"
	} else if A+X < B {
		ans = "dangerous"
	}
	out(ans)
}


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

int H, W, K, A[309][309], num;
int cnt[309];
char c[309][309];

void solve(int cl, int cr) {
    vector<int> P;
    for (int i = cl; i <= cr; i++) {
        for (int j = 1; j <= W; j++) {
            if (c[i][j] == '#') P.push_back(j);
        }
    }

    for (int i = 0; i < P.size(); i++) {
        int v1 = 1, v2 = W;
        if (i >= 1) v1 = P[i - 1] + 1;
        if (i < (int)P.size() - 1) v2 = P[i];

        num++;
        for (int j = cl; j <= cr; j++) {
            for (int k = v1; k <= v2; k++) A[j][k] = num;
        }
    }
}

int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> c[i][j];
            if (c[i][j] == '#') cnt[i]++;
        }
    }

    vector<int> vec;
    for (int i = 1; i <= H; i++) {
        if (cnt[i] >= 1) vec.push_back(i);
    }
    for (int i = 0; i < vec.size(); i++) {
        int v1 = 1, v2 = H;
        if (i >= 1) v1 = vec[i - 1] + 1;
        if (i < (int)vec.size() - 1) v2 = vec[i];

        solve(v1, v2);
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (j >= 2) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
import operator as op
from functools import reduce
from math import factorial
import sys

modulus = 1000000007

factorial = [1, 1]
for i in range(2, 2000001):
    factorial.append(factorial[-1] * i % modulus)

factorial_inv_rev = [pow(factorial[-1], 1000000005, modulus)]
for i in range(len(factorial)-1, 1, -1):
    factorial_inv_rev.append(factorial_inv_rev[-1] * i % modulus)

def ncr(n, r):
    if n==r or r==0:
        return 1
    else:
        numelator = factorial[n]
        denominator = factorial_inv_rev[-r] * factorial_inv_rev[r-n]
        return numelator * denominator % modulus

h, w, a, b = map(int, input().split())

points = [(i, j) for i, j in zip(range(h-a-1, -1, -1), range(b, w))]

former = [ncr(i+j, i) for i, j in points]
latter = [ncr(h-i-1+w-j-1, h-i-1) for i, j in points]

print(sum(f*l for f, l in zip(former, latter)) % modulus)

Measured memory_bytes: 181576
#include<cstdio>
#include<cstdlib>
int n,l[105],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&l[i]);
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(l[i]==l[j])continue;
			for(int k=j+1;k<=n;++k){
				if(l[i]==l[k]||l[j]==l[k])continue;
				if(l[i]+l[j]<=l[k])continue;
				if(l[j]+l[k]<=l[i])continue;
				if(l[i]+l[k]>l[j])ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> word(50);
  for (int i = 0; i < H; i++) {
    cin >> word.at(i);
  }
  vector<int> dh = {-1, 0, 0, 1};
  vector<int> dw = {0, -1, 1, 0};
  bool result = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int b = 0;
      if (word.at(i).at(j) == '.') continue;
      for (int k = 0; k < 4; k++) {
        const int i4 = i + dh.at(k);
        const int j4 = j + dw.at(k);
        if ((i4 < 0) || (i4 >= H)) continue;
        if ((j4 < 0) || (j4 >= W)) continue;

        if (word.at(i4).at(j4) == '#') {
          b++;
        }
        
      }
      if (b == 0) {
        result = false;
      }
    }
  }
  if (result) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
          
        
      
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/

const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve()
{
	ll n;
	cin >> n;
	ll all = mod_pow(10, n, MOD);
	ll oth = mod_pow(8, n, MOD);
	ll b = mod_pow(9, n, MOD);
	ll one = all - b;
	if(one<0){
		one += MOD;
	}
	ll c = all - oth;
	if(c<0){
		c += MOD;
	}
	c -= one;
	if(c<0){
		c += MOD;
	}

	ll ans = one - c;
	if (ans > 0)
	{
		ans %= MOD;
		cout << ans << endl;
	}
	else{
		ans += MOD;
		ans %= MOD;
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 3648
import sys
import itertools
input = sys.stdin.readline

N = int(input())
L = [list(input().strip()) for _ in range(N)]

m = {}

for v in L:
    if m.get(v[0]) == None:
        m[v[0]] = 0
    m[v[0]] += 1
    
l = [v for v in m.items() if v[0] in list("MARCH")]
    
ans = 0
for v in itertools.combinations(l, 3):
    ans += v[0][1] * v[1][1] * v[2][1]
    
print(ans)

Measured memory_bytes: 20408
#include <stdio.h>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int z;
		scanf("%d", &z);
		z--;
		v.push_back(z);
	}
	int now = 0, c = 0;
	for (; ;)
	{
		if (now == 1) {
			printf("%d\n", c);
			break;
		}
		if (c >= n) {
			printf("-1\n");
			break;
		}
		c++;
		now = v[now];
	}
}

Measured memory_bytes: 892
#D

def sixnine(m):
    ret=[]
    for n in [6,9]:
        tmp=1
        while True:
            tmp*=n
            if tmp<=m:
                ret.append(tmp)
            else:
                break
    ret.sort()
    return ret


N=int(input())
dp=[0 for i in range(N+1)]
for i in range(1,N+1):
    if i<=5:
        dp[i]=i
        continue
    sn=sixnine(i)
    if i in sn:
        dp[i]=1
        continue
    ans=10**19
    for k in sn:
        ans=min(ans,dp[k]+dp[i-k])
    dp[i]=ans
# print(dp)
print(dp[-1])

Measured memory_bytes: 3864
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if ((a <= b and b <= a+W) || (b <= a and a <= b+W)){
        cout << 0 << endl;
        exit(0);
    }
    cout << min(abs(W+a -b), abs(a-b-W)) << endl;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>

using std::endl;

#define ll long long int
#define FOR(a, s, n) for(int a = s; a < n; ++a)
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define MOD 1000000007
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
#define asn ans

ll Data[123456];

ll N, X;
ll ans = 0;

int main()
{

	IN >> N >> X;

	LEP(a, N)
	{
		IN >> Data[a];
	}

	LEP(a, N - 1)
	{
		if (Data[a] + Data[a + 1] > X)
		{
			ans += Data[a] + Data[a + 1] - X;
			if(X - Data[a] >= 0)
			Data[a + 1] = X - Data[a];
			else
			{

				Data[a] -= X - Data[a + 1];
				Data[a + 1] = 0;
			}
		}
	}

	OUT << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S,T;
    cin >> S >> T;
    bool ok = 1;
    if(S.size()+1 != T.size())ok = 0;
    REP(i,S.size()){
        if(S[i] != T[i])ok = 0;
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3636
char buf[10000000],out[11];
sz;
cnt[60];
main()
{
	read(0,buf,10000000);
	long N=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;buf[sz]>='0';)
	{
		long A=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		for(int i=0;A;i++)
		{
			cnt[i]+=A&1;
			A>>=1;
		}
	}
	int ans=0;
	for(int i=59;i>=0;i--)
	{
		ans=(ans*2+(N-cnt[i])*cnt[i])%1000000007;
	}
	int outsz=10;
	do{
		out[--outsz]=ans%10+'0';
	}while(ans/=10);
	write(1,out+outsz,10-outsz);
}


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

int main(void){
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		for(int i=1;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
		}
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i+1][j+k-1]==0) dp[i+1][j+k-1]+=dp[i][j];
						else if(k==1&&c[i+1][j+k-1]==2) dp[i+1][j+k-1]+=dp[i][j];
					}
				}
				if(c[i][j]==2){
					if(c[i+2][j]!=1) dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=1;i<=X;i++){
			if(c[Y-1][i]==2){
				ans+=dp[Y-1][i];
			}
		}
		for(int i=1;i<=X;i++){
			ans+=dp[Y][i];
		}
		printf("%lld\n",ans );
	}
}

Measured memory_bytes: 3072
#include <stdio.h>

int f(int n);

int main(void){
	int a[100000];
	int s;			//初項
	
	scanf("%d",&s);
	a[0]=s;
	
	int i;
	for(i=1;i<100000;++i){  
		a[i]=f(a[i-1]);
	}
	/*for(i=0;i<10;++i){		//a[i]確認用
		printf("%d ",a[i]);
	}*/
	
	int j;
	for(i=0;i<100000;++i){
		for(j=i+1;j<100000;++j){		
			if(a[i]==a[j]){
				printf("%d\n",j+1);
				return 0;
			}
		}
	}
	return 0;
}

int f(int n){
	
	if(n%2==0) return n/2;
	else if (n%2==1) return 3*n+1;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 128
	// https://atcoder.jp/contests/abc128/tasks
	final static int MOD = 10007;
	
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n];
		int evenCnt = 0;
		int res = 0;
		
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
			if (nums[i] % 2 == 0) {
				evenCnt++;
			}
		}
		
		while (evenCnt == n) {
			res++;
			evenCnt = 0;
			for (int i = 0; i < n; i++) {
				int newNum = nums[i] / 2;
				nums[i] = newNum;
				if (newNum % 2 == 0) {
					evenCnt++;
				}
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21332
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(max(h, N-h+1), 3501):
            if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
                w = N*h*n // (4*h*n - N*h - N*n)
                print(h, n, w)
                exit()

if __name__ == "__main__":
    main()

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

using namespace std;

using ll = unsigned long long;

string solve() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (c <= (a + b)) {
    return "No";
  }

  ll m = a * a + b * b + c * c;
  ll k = 2 * (a * b + b * c + c * a);
  if (m > k) {
    return "Yes";
  }else {
    return "No";
  }
}

int main() {
  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

if sum(A) < K:
    K = sum(A)

A.sort()
F.sort()
F = F[::-1]

left = 0
right = 10 ** 12
while left < right:
    mid = (left + right) // 2
    G = A - (mid // F)
    if G[G>0].sum() <= K:
        right = mid
    else:
        left = mid + 1

print(right)


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

char ma[1010][1010];
int jmap[1010][1010];
int omap[1010][1010];
int imap[1010][1010];

int main(void){
	int M, N, K;

	scanf("%d %d %d", &M, &N, &K);
	for(int i=0; i<M; i++){
		scanf("%s", ma[i]);
	}

	for(int i=0; i<M; i++){
		for(int j=0; j<N; j++){
			jmap[i][j] = 0;
			omap[i][j] = 0;
			imap[i][j] = 0;
		}
	}

	for(int i=1; i<=M; i++){
		for(int j=1; j<=N; j++){
			jmap[i][j] = jmap[i-1][j] + jmap[i][j-1] - jmap[i-1][j-1];
			omap[i][j] = omap[i-1][j] + omap[i][j-1] - omap[i-1][j-1];
			imap[i][j] = imap[i-1][j] + imap[i][j-1] - imap[i-1][j-1];

			if(ma[i-1][j-1] == 'J') jmap[i][j]++;
			else if(ma[i-1][j-1] == 'O') omap[i][j]++;
			else if(ma[i-1][j-1] == 'I') imap[i][j]++;
		}
	}

	for(int i=0; i<K; i++){
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);

		int jans = jmap[c][d] - jmap[c][b-1] - jmap[a-1][d] + jmap[a-1][b-1];
		int oans = omap[c][d] - omap[c][b-1] - omap[a-1][d] + omap[a-1][b-1];
		int ians = imap[c][d] - imap[c][b-1] - imap[a-1][d] + imap[a-1][b-1];

		printf("%d %d %d\n", jans, oans, ians);

	}

	return 0;
}

Measured memory_bytes: 13956
#include<bits/stdc++.h>
#define rg register
#define ll long long
using namespace std;
const int N=3e5+5,mod=1e9+7;
int n,m,T,k,ans,len;
int a[N],vis[N],dp[N];
int main()
{
    for(rg int i=1;i<=5;i++)
        cin>>a[i];
    cin>>k;
    sort(a+1,a+6);
    if(a[5]-a[1]<=k) puts("Yay!");
    else puts(":(");
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll a[440]; rep(i, N) cin >> a[i];
    ll b[440];
    b[0] = 0;
    rep(i, N) b[i + 1] = b[i] + a[i];
    ll dp[440][440];
    rep(i, N) dp[i][i] = 0;
    rep(i, N - 1) {
        dp[i][i + 1] = a[i] + a[i + 1];
    }
    Rep(len, 2, N) {
        rep(i, N - len) {
            dp[i][i + len] = INF;
            Rep(k, i, i + len) {
                dp[i][i + len] = min(dp[i][i + len], dp[i][k] + dp[k + 1][i + len] + b[i + len + 1] - b[i]);
            }
        }
    }
    cout << dp[0][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
N=int(input())
h=list(map(int,input().split()))

dp=[0,abs(h[0]-h[1])]
for i in range(N-2):
    dp+=[min(dp[-2]+abs(h[i]-h[i+2]),dp[-1]+abs(h[i+2]-h[i+1]))]

print(dp[-1])


Measured memory_bytes: 13928
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = s()
t = []
for i in range(len(S)):
    if S[i] == 'B':
        if t:
            t.pop(-1)
    else:
        t.append(str(S[i]))
print(''.join(t))

Measured memory_bytes: 9892
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n; scanf("%d", &n);
	int x = 0, y = 0, z = 0, a, b, c;
	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d", &a, &b, &c);
		int nx = max(y,z)+a, ny = max(x,z)+b, nz = max(x,y)+c;
		x = nx, y = ny, z = nz;
	}
	printf("%d\n", max(max(x, y), z));
	return 0;
}

Measured memory_bytes: 128