akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int x = 0;
        for(int i = 1; true; i++){
            x = sc.nextInt();
            if(x == 0){
                break;
            }
            System.out.println("Case " + i + ": " + x);
        }
    }
}


Measured memory_bytes: 41268
#include<iostream>
using namespace std;
#define KMAX 17
#define VMAX 300
 
static const int K[17] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289};
int T[KMAX][VMAX+1];
 
main(){
    for ( int j = 0; j <= VMAX; j++ ) T[0][j] = 1;
    for ( int i = 0; i < KMAX; i++ ) T[i][0] = 1;
    for ( int i = 1; i < KMAX; i++ ){
    for ( int j = 1; j < K[i]; j++ ) T[i][j] = T[i-1][j];
    for ( int j = K[i]; j <= VMAX; j++ ){
        T[i][j] = T[i-1][j] + T[i][j-K[i]];
    }
    }
    int n;
    while( cin >> n && n ) cout << T[KMAX-1][n]  << endl;
}

Measured memory_bytes: 0
Input = input().split()
N = int(Input[0])
K = int(Input[1])
S = list(input())

if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'

S = "".join(S)

print(S)

Measured memory_bytes: 3060
import kotlin.math.min

fun main() {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    var r = 0
    var l = Int.MAX_VALUE
    s.forEach {
        if (it == '(') {
            r++
        } else {
            r--
        }
        l = min(r, l)
    }
    if (l > 0) {
        l = 0
    }
    val rs = ")".repeat(r - l)
    val ls = "(".repeat(-l)
    println("$ls$s$rs")
}


Measured memory_bytes: 35400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int V[N], C[N];
  for(int i=0;i<N;i++) cin >> V[i];
  for(int i=0;i<N;i++) cin >> C[i];
  vector<int> sum(N);
  int gokei = 0;
  for(int i=0;i<N;i++){
    sum.at(i) = V[i] - C[i];
    if(sum.at(i) > 0) gokei += sum.at(i);
  }
  cout << gokei << endl;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    
    ans = int(N * 100 / 108)
    if int(ans * 1.08) == N:
        print(ans)
    elif int((ans + 1) * 1.08) == N:
        print(ans + 1)
    else:
        print(':(')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int n;
    cin(n);

    if (n % 2 == 1) {
        print("No");
        return 0;
    }

    string s;
    cin(s);

    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
        print("Yes")
    } else {
        print("No");
    }
    return 0;
}

Measured memory_bytes: 3616
N = int(input())
data = list(map(int, input().split()))
data.sort()
ans = []
N -= 1
while N > 0:
    if data[N] == data[N - 1]:
        ans.append(data[N])
        N -= 1
    N -= 1
    if len(ans) >= 2:
        break

if len(ans) < 2:
    print(0)
else:
    print(ans[0] * ans[1])



Measured memory_bytes: 20020
use std::io;


/// https://beta.atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_a
fn main() {
    let s = read_one::<String>()
        .chars().filter(|&c| c == '1')
        .count();
    println!("{}", s);

}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
function main(input) {
  var inputs = input.trim().split('\n');
  inputs = inputs[0].split(' ');
  var A = inputs[0] - 0;
  var B = inputs[1] - 0;
  var H = inputs[2] - 0;
  var M = inputs[3] - 0;

  var minutes = 60 * H + M;
  var radA = minutes / 60 * 30;
  var radB = M * 6;
  radB = radB == 0 ? 360 : radB;

  if (radA == radB) {
    console.log(Math.max(A, B));
  } else if (radA > radB) {
    var rad = (radA - radB) * Math.PI / 180;
    var pA = [A, 0];
    var pB = [B * Math.cos(rad), B * Math.sin(rad)];
    console.log(Math.sqrt(Math.pow(pB[0] - pA[0], 2) + Math.pow(pB[1] - pA[1], 2)));
  } else {
    var rad = (radB - radA) * Math.PI / 180;
    var pB = [B, 0];
    var pA = [A * Math.cos(rad), A * Math.sin(rad)];
    console.log(Math.sqrt(Math.pow(pB[0] - pA[0], 2) + Math.pow(pB[1] - pA[1], 2)));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29644
H = list(input())
N = [0]*len(H)

Lflag=0
Rcnt=0
Lcnt=0
cnt=0
for i in range(1,len(H)+1):
    if((H[i-1]=="L") & (Lflag==0)):
        Lflag=1
        Rcnt=i-1
        Lcnt=i
    if((H[i-1]=="R") & (Lflag==1)):
        if((i-1-cnt)%2==0):
            N[Rcnt-1]=int(((i-1)-cnt)/2)
            N[Lcnt-1]=int(((i-1)-cnt)/2)

        else:
            if(Rcnt%2==(i-1)%2):
                N[Rcnt-1]=int(((i-1)-cnt)/2+1)
                N[Lcnt-1]=int(((i-1)-cnt)/2)
            else:
                N[Rcnt-1]=int(((i-1)-cnt)/2)
                N[Lcnt-1]=int(((i-1)-cnt)/2+1)
        cnt=i-1
        Lflag=0

if((len(H)-cnt)%2==0):
    N[Rcnt-1]=int((len(H)-cnt)/2)
    N[Lcnt-1]=int((len(H)-cnt)/2)

else:
    if(Rcnt%2==len(H)%2):
        N[Rcnt-1]=int((len(H)-cnt)/2+1)
        N[Lcnt-1]=int((len(H)-cnt)/2)
    else:
        N[Rcnt-1]=int((len(H)-cnt)/2)
        N[Lcnt-1]=int((len(H)-cnt)/2+1)
    
for para in N:
    print(para, end=" ")


Measured memory_bytes: 5596
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	vi a(n),b(n);
	vii g(n,vi());
	map<pii,int> mp;
	vi c(n,0);
	FOR(i,0,n-1){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		c[a[i]]+++
		c[b[i]]++;
		g[a[i]].PB(b[i]);
		g[b[i]].PB(a[i]);
		mp[MP(a[i],b[i])]=i;
		mp[MP(b[i],a[i])]=i;
	}
	int k=0,idx=0;
	vi ans(n,0);
	FOR(i,0,n){
		if(k<c[i]){
			k=max(k,c[i]);
			idx=i;
		}
	}
	queue<array<int,3>> q;
	q.push({idx,0,idx});
	while (q.size()) {
		auto tpl=q.front();
		q.pop();
		int nw=tpl[0];
		int fob=tpl[1];
		int bf=tpl[2];
		int nxt=1;
		if(nxt==fob)nxt++;
		for (const auto& x:g[nw]){
			int i=mp[MP(nw,x)];
			if(ans[i]!=0){
				continue;
			}else{
				ans[i]=nxt;
				q.push({x,nxt,nw});
				nxt++;
				if(nxt==fob)nxt++;
			}
		}
	}

	cout<<k<<endl;
	FOR(i,0,n-1){
		cout<<ans[i]<<endl;
	}
}


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

class UnionFind {
  vector<int> par, sz;
 public:
  UnionFind(int N) : par(N), sz(N) {
    for (int i = 0; i < N; ++i) par[i] = i;
    for (int i = 0; i < N; ++i) sz[i] = 1;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return  par[x] = root(par[x]);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
  }
};

int main() {
  int n, m, k;
  int a, b, c, d;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> ans(n, -1);
  
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
    --ans[a], --ans[b];
  }
  for (int i = 0; i < n; ++i) ans[i] += uf.size(i);
  for (int i = 0; i < k; ++i) {
    cin >> c >> d;
    --c, --d;
    if (uf.same(c, d) == false) continue;
    --ans[c], --ans[d];
  }
  
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " \n"[i == (n-1)];
  }
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        String[] aryStr = Console.ReadLine().Split(' ');

        int a = int.Parse(aryStr[0]);
        int b = int.Parse(aryStr[1]);
        int c = int.Parse(aryStr[2]);

        int count = 0;

        for (int i = a; i <= b; i++)
        {
            if (c % i == 0)
            {
                count++;
            }
        }

        Console.WriteLine(count);

    }
}

Measured memory_bytes: 9200
def gauss(n):
    ans = int (n * (n + 1) / 2)
    return(ans) 

s = input().replace("><", "> <")
new_s = s.split(" ")

a = [0] * len(new_s)

for i in range(len(new_s)):
    if new_s[i].count("<") >= new_s[i].count(">"):
        a[i] = gauss(new_s[i].count("<"))
        a[i] += gauss(new_s[i].count(">") - 1)
    else:
        a[i] = gauss(new_s[i].count(">"))
        a[i] += gauss(new_s[i].count("<") - 1)

print(sum(a))


Measured memory_bytes: 50800
S = input()
if S == "SSS":
    ans = 0
if S == "RRR":
    ans = 3
if S == "SRR" or S == "RRS":
    ans = 2
if S == "SSR" or S == "SRS" or S == "RSS" or S == "RSR":
    ans = 1
print(ans)


Measured memory_bytes: 9000
n, m = map(int, input().split())
WV = [tuple(map(int, input().split())) for i in range(n)]
W = [w for w, v in WV]
V = [v for w, v in WV]
DP = [[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1, n+1):
    for j in range(W[i-1]):
        DP[i][j] = DP[i-1][j]
    for j in range(W[i-1], m+1):
        DP[i][j] = max(DP[i-1][j], DP[i-1][j-W[i-1]]+V[i-1])
print(DP[n][m])


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

int main(void){
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 T;
	cin >> T;
  REP(_, T) {
	  int64 N, A[3], D;
	  int64 mul[] = {2, 3, 5};
	  cin >> N >> A[0] >> A[1] >> A[2] >> D;
    map<int64, int64> mp;
	  priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
	  pq.emplace(0, N);
	  int64 res = numeric_limits<int64>::max();
	  while (pq.size()) {
	    int64 c, n;
	    tie(c, n) = pq.top(); pq.pop();
	    if (n == 0 && c < res) {
	      res = c;
	    }
	    if (res <= c) {
	      continue;
	    }
      if (res / D >= n) {
        chmin(res, n * D + c);
      }
	    if (mp.count(n) && mp[n] < c) {
	      continue;
	    }
	    REP(i, 3) {
	      if (n % mul[i] == 0) {
	        if (n / mul[i] >= 0 && (!mp.count(n/mul[i]) || mp[n/mul[i]] > A[i] + c)) {
            pq.emplace(A[i] + c, n / mul[i]);
            mp[n / mul[i]] = A[i] + c;
          }
	      } else {
	        int64 cc[2] = {mul[i] - n % mul[i], n%mul[i]};
	        int64 v[2] = {n + cc[0], n - cc[1]};
	        REP(j, 2) {
	          if (v[j] >= 0 && (!mp.count(v[j]) || mp[v[j]] > c + cc[j] * D)) {
	            mp[v[j]] = c + cc[j] * D;
	            pq.emplace(c + cc[j] * D, v[j]);
	          }
	        }
	      }
	    }
	  }
	  cout << res << endl;
	}
}


Measured memory_bytes: 7972
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(A[K-1])


Measured memory_bytes: 38384
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            lst.append(i * j % 2019)
            if i * j % 2019 == 1:
                break
        if i * j % 2019 == 1:
            break
    print(min(lst))
    return


main()


Measured memory_bytes: 3060
N = int(input())
t = [0]
x = [0]
y = [0]

for i in range(N):
    line = input().split()
    t.append(int(line[0]))
    x.append(int(line[1]))
    y.append(int(line[2]))

flag = True
for j in range(1,N+1):
    c = abs(x[j]-x[j-1])+abs(y[j]-y[j-1])
    tm = t[j]-t[j-1]
    if tm-c < 0 or (tm-c) % 2 != 0:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11816
n = int(input())
T_list = list(map(int,input().split()))
summ = sum(T_list)
m = int(input())
drinknum = []
drinktime = []
for x in range(m):
    uketsuke = list(map(int,input().split()))
    drinknum.append(uketsuke[0])
    drinktime.append(uketsuke[1])
for x in range(m):
    print(summ - T_list[drinknum[x]-1] + drinktime[x])

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	int n, m;
	cin >> n >> m;
	vector<string>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i] = "#" + p[i] + "#";
	}
	string x="";
	for (int j = 0; j < m; j++)
		x += "#";
	x = "#" + x + "#";
	p.insert(p.begin(), x);
	p.push_back(x);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (p[i][j] == '.')continue;
			if (p[i + 1][j] == '#')continue;
			if (p[i - 1][j] == '#')continue;
			if (p[i ][j+1] == '#')continue;
			if (p[i ][j-1] == '#')continue;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	vector<int>p;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		p.push_back(a);
	}
	int check = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] == i + 1) {
			check++;
		}
		else {
			ans = ans + (check + 1) / 2;
			check = 0;
		}
	}
	ans = ans + (check + 1) / 2;
	cout << ans;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	string s;
	cin >> s;
	lint a,z,n = s.size();
	rep(i,n) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	rep(i,n) {
		if (s[n-1-i] == 'Z') {
			z = n-1-i;
			break;
		}
	}
	out1(z+1-a);
}

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


Measured memory_bytes: 720
def main():
    n, m = map(int, input().split())
    h = [0]+list(map(int, input().split()))
    to = [0]*(n+1)
    for _ in range(m):
        a, b = map(int, input().split())
        to[a] = max(to[a], h[b])
        to[b] = max(to[b], h[a])
    print(len([1 for hi, t in zip(h[1:], to[1:]) if hi > t]))

if __name__ == "__main__":
    main()

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> x(n);
    x[0] = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) x[0] += a[i];
        else x[0] -= a[i];
    }
    for (int i = 1; i < n; i++) x[i] = 2 * a[i-1] - x[i-1];
    for (int i = 0; i < n; i++) {
        cout << x[i];
        if (i < n - 1) cout << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3992
dev = int(input())
list_x = [float(i) for i in input().split()]
list_y = [float(i) for i in input().split()]

listabs = []
for vector in zip(list_x, list_y):
    x, y = vector
    listabs.append(abs(x -y))

for p in range(1, 4):
    D = 0
    for vector in listabs:
        D += vector**p
    D = D**(1/p)
    print(D)

print(max(listabs))


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }

int main(){
  string s;
  bool flag = false;
  while(cin>>s){
    int N = s.size();
    REP(i,N){
      char c = s[i];
      if(c>='A' && c<='Z'){ s[i] += ('a'-'A');}
      else if(c>='a' && c<='z'){ s[i] += ('A'-'a');}
    }
    if(flag){ cout << " " <<s;}
    else{ cout << s; flag = true;}
  }
  cout <<"\n";
}


Measured memory_bytes: 3148
import sys
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()
B = LI()
C = LI()

res = 0
for i in range(N):
    res += B[A[i] - 1]
    if i < N - 1 and A[i + 1] == A[i] + 1:
        res += C[A[i] - 1]

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  string S,T; cin>>S>>T;
  map<int,char> m;
  int X=N*M/__gcd(N,M);
  rep(i,0,N) m[X/N*i+1]=S[i];
  int ans=X;
  rep(i,0,M){
    int Y=X/M*i+1;
    if(m.count(Y)&&m[Y]!=T[i]){
      ans=-1;
      break;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    Rep (i, N) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= D*D) ans++;
    }

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll calcNumOfCombination(ll n, ll r){
	ll num = 1;
	for(ll i = 1; i <= r; i++){
		num = num * (n - i + 1) / i;
	}
	return num;
}

int main(){
	int n;
	cin >> n;
	map<ll, ll> m;
	m[0]++;
	ll wa = 0;
	rep(i, n){
		ll in;
		cin >> in;
		wa += in;
		m[wa]++;
	}

	ll ans = 0;
	for(auto p : m){
		if(p.second > 1){
			ans += calcNumOfCombination(p.second, 2);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int sum[100010];

int main(void){
    int n,k,q,a;
    cin>>n>>k>>q;
    for(int i=0;i<q;i++){
        cin>>a;
        sum[1]++;
        sum[a]--;
        sum[a+1]++;
        sum[n+1]--;
    }
    for(int i=1;i<n;i++){
        sum[i+1]+=sum[i];
    }
    for(int i=1;i<=n;i++){
        if(sum[i]>=k)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

const string KEYS[] = {"AC", "WA", "TLE", "RE"};

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

  map<string, int> m;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    m[s]++;
  }

  for (const string &key : KEYS) {
    printf("%s x %d\n", key.c_str(), m[key]);
  }
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a%2 == 0 || b%2 == 0){
		cout << "Even\n";
	}
	else{
		cout << "Odd\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int W, H, N;
int maxh[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> W >> H >> N;

    rep(i, 0, N) {
        int x, y; cin >> x >> y;
        chmax(maxh[x], y);
    }
    rrep(x, W - 2, 0) chmax(maxh[x], maxh[x + 1]);

    int ans = inf;
    rep(x, 0, W) chmin(ans, x + maxh[x + 1]);
    cout << ans << endl;
}



Measured memory_bytes: 3544
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N = int(readline())
    W = [(0, 50)]
    for i in range(N):
        b, h = map(int, readline().split())
        W.append((b, h))
    W.append((100, 50))
    M = int(readline())
    S = [0]*(N+1)
    Q = []
    for i in range(M):
        f, a = map(int, readline().split())
        for j in range(N+1):
            if W[j][0] < f < W[j+1][0]:
                S[j] += a
                break
    L = int(readline())
    for i in range(L):
        p, t = map(int, readline().split())
        Q.append((t, i, p))
    Q.sort(reverse=1)
    T = [0]*(N+1)
    C = N+1
    tc = 0
    ans = [50] * L
    EPS = 1e-9
    while 1:
        k = -1; tm = 10**18
        for i in range(C):
            if S[i] == 0:
                continue
            b0, h0 = W[i]; b1, h1 = W[i+1]
            t = (min(h0, h1) * (b1 - b0) * 30 - T[i]) / S[i]
            if t < tm:
                tm = t
                k = i
        assert k != -1
        b0, h0 = W[k]; b1, h1 = W[k+1]
        dt = (min(h0, h1) * (b1 - b0) * 30 - T[k]) / S[k]
        while Q and tc <= Q[-1][0] < tc + dt:
            t, i, p = Q.pop()
            for j in range(C):
                ba, ha = W[j]; bb, hb = W[j+1]
                if ba < p < bb:
                    dt0 = t - tc
                    ans[i] = (S[j] * dt0 + T[j]) / ((bb - ba) * 30)
                    break
        for i in range(C):
            T[i] += S[i] * dt
        if C == 1:
            break
        if h0 < h1:
            if abs(T[k-1] - h0 * (b0 - W[k-1][0]) * 30) < EPS:
                assert S[k-1] == 0
                S[k-1] = S[k]
                T[k-1] += T[k]
                S.pop(k); T.pop(k); W.pop(k)
                C -= 1
            else:
                j = k-1
                while T[j] == W[j][1]:
                    j -= 1
                S[j] += S[k]
                S[k] = 0
        else:
            if abs(T[k+1] - h1 * (W[k+2][0] - b1) * 30) < EPS:
                assert S[k+1] == 0
                S[k+1] = S[k]
                T[k+1] += T[k]
                S.pop(k); T.pop(k); W.pop(k+1)
                C -= 1
            else:
                j = k+1
                while T[j] == W[j+1][1]:
                    j += 1
                S[j] += S[k]
                S[k] = 0
        tc += dt
    for i in range(L):
        write("%.16f\n" % ans[i])
D = int(readline())
for i in range(D):
    solve()


Measured memory_bytes: 5756
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,k:usize,
    }
    let mut ans = 0;
    let mut sms = vec![0; n + 2];
    for i in 1..=(n + 1) {
        sms[i] = sms[i - 1] + i - 1;
    }
    // dbg!(&sms);
    for c in k..=(n + 1) {
        let k = sms[n + 1] - sms[n + 1 - c];
        let l = sms[c];
        // dbg!(c, k, l);
        ans += k - l + 1;
        ans %= MOD;
    }
    println!("{}", ans);
}
const MOD: usize = 1000000007;


Measured memory_bytes: 3584
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n;
ll a[N], b[N], res[N], ans;

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

	cin >> n;
	forn(i, 1, n) {
        cin >> a[i] >> b[i];
	}

	for1(i, n, 1) {
	    a[i] += ans;
        res[i] = b[i] * ((a[i] + b[i] - 1) / b[i]);
        //if (i < n) res[i] = max(res[i], b[i] * ((res[i + 1] + b[i] - 1) / b[i]));
        ans += res[i] - a[i];
        //cerr << res[i] << "\n";
	}

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define ll long long 
#define endl '\n'
#define debug(x)  cout<<x<<" ";
#define for(i,n) for(i=0;i<n;i++)
#define fastInOut   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    fastInOut
    ll x;
    cin>>x;
    int A[x];
    int i;
    for(i,x){
        cin>>A[i];
    }
    int c=0;
    int h=1;
    for(i,x){
        if(A[i]!=h)
           c++;
        else 
          h++;
    }
    if(c==x)
      cout<<-1;
    else
       cout<<c;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> p(4),t(4);
    for(int i=0; i<4; i++){
        cin >> p[i];
    }
    for(int i=0; i<4; i++){
        cin >> t[i];
    }
    int ans = inf;
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            for(int k=0; k<=100; k++){
                int l = max(0,(N - (t[0]*i+t[1]*j+t[2]*k)));
                if(l){
                    l = (l+t[3]-1)/t[3];
                }
                chmin(ans,p[0]*i + p[1]*j + p[2]*k + p[3]*l);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    string s;
    cin >> s;

    int ret = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] != s[i+1]) {
            ret++;
        }
    }

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

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x;
    cin >> x;
    bool dp[100200];
    
    REP(i,6){
        dp[i+100]=true;
    }

    REP(i,100010){
        if(dp[i]){
            dp[i+100]=true;
            dp[i+101]=true;
            dp[i+102]=true;
            dp[i+103]=true;
            dp[i+104]=true;
            dp[i+105]=true;
        }
    }
    if(dp[x]){
        cout <<  1  << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

class SegmentTree {
private:
	int num;
	vector<ll> dat;

	// TODO: Change the operator and the identity element.
	static const ll INI = 0;
	ll op(ll a, ll b) {
		return a + b;
	}

public:
	SegmentTree(int n_) {
		num = 1;
		while (num < n_) num *= 2;
		dat = vector<ll>(2 * num, INI);
	}

	// Update the k-th value (0-indexed) to a.
	void update(int k, ll a) {
		k += num - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}

	// Get the value of the range [a, b).
	// k: The index of the node.
	// [left, right): The range corresponds to the k-th node.
	// Call like getval(a, b).
	ll getval(int a, int b, int k = 0, int left = 0, int right = -1) {
		if (right < 0) right = num;
		if (right <= a || b <= left) return INI;
		if (a <= left && right <= b) return dat[k];
		ll vleft = getval(a, b, 2 * k + 1, left, left + (right - left) / 2);
		ll vright = getval(a, b, 2 * k + 2, left + (right - left) / 2, right);
		return op(vleft, vright);
	}
};


int main() {
	int n; cin >> n;
	vector<ll> a(n), b(n), s(n + 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll lo = 0, hi = 1e9 + 1;
	while (hi - lo > 1) {
		ll mid = lo + (hi - lo) / 2;
		for (int i = 0; i < n; i++) b[i] = a[i] >= mid ? 1 : -1;
		for (int i = 0; i < n; i++) s[i + 1] = s[i] + b[i];
		SegmentTree seg(200005);
		ll cnt = 0;
		for (int i = 0; i <= n; i++) {
			int k = s[i] + 100000;
			cnt += seg.getval(0, k + 1);
			seg.update(k, seg.getval(k, k + 1) + 1);
		}
		if (cnt >= (1LL*n*(n + 1)/2 + 1) / 2) lo = mid;
		else hi = mid;
	}
	cout << lo << endl;
	return 0;
}

Measured memory_bytes: 6780
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), x = sc.nextInt();
        int cnt = n <= x ? 1 : 0, cur = 0, temp;
        for (int i = 0; i < n; ++i) {
            temp = sc.nextInt();
            cur += temp;
            if (cur <= x) ++cnt;
        }
        System.out.printf("%d\n", cnt);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int a,b,i,j,c=0;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) return 0;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				if(c%2==0){
					printf("#");
				}else{
					printf(".");
				}
				c++;
			}
			if(b%2==0){
			if(c%2==0){
				c=1;
			}else{
				c=0;
			}
			}
			printf("\n");
		}
		printf("\n");
		c=0;
	}
	
	return 0;
}


Measured memory_bytes: 2048
import std.stdio, std.string, std.conv;
import std.algorithm;

void main()
{
    for(string s_; (s_=readln().chomp()).length;)
    {
        auto ab = s_.split.map!(to!int)();
        immutable a=ab[0], b=ab[1];
        if(0<a) writeln("Positive");
        else if(a<=0 && 0<=b) writeln("Zero");
        else if(b<0 && (b-a)%2==0) writeln("Negative");
        else if(b<0 && (b-a)%2==1) writeln("Positive");
        else assert(false);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll getmin(ll i,vector<ll> &v,ll n,ll k,vector<ll> &dp)
{
    if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll x=INT_MAX,f=0,j;
    for(j=1;j<=k;j++)
    {
        if(i+j<n)
        {
            x=min(x,abs(v[i]-v[i+j]) + getmin(i+j,v,n,k,dp));
        }
        else
        {
            if(j==1)
                f=1;
            break;
        }
    }
    if(f==0)
    {
        dp[i]=x;
        return x;
    }
    else
    {
        dp[i]=0;
        return 0;
    }
}

int main()
{
  ll k,n,i,tmp;
  cin>>n>>k;
  vector<ll> v;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    v.pb(tmp);
  }
  vector<ll> dp(n,-1);
  cout<<getmin(0,v,n,k,dp)<<"\n";
  return 0;
}

Measured memory_bytes: 14284
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
const unsigned long long INF = 1000000000000000000;

int main()
{
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    int128_t sum = 1;
    for (int i = 0; i < N; i++)
    {
        sum *= A[i];
        if(sum > INF){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << sum << endl;
    return 0;
}


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

struct Rect {
	int h, p;
};
#define MAXH 1400
#define MAXW 1400
int H, W;
int c[MAXH][MAXW];
int T[MAXH][MAXW + 1];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
		}
	}
	for (int j = 0; j < W; j++) {
		T[0][j] = (c[0][j] + 1) % 2;
	}
	T[0][W] = 0;
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (c[i][j] == 0) {
				T[i][j] = T[i - 1][j] + 1;
			} else if (c[i][j] == 1) {
				T[i][j] = 0;
			}
		}
		T[i][W] = 0;
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		stack<Rect> S;
		for (int j = 0; j < W + 1; j++) {
			Rect r = { T[i][j], j };
			if (S.empty()) {
				S.push(r);
			} else if (S.top().h < r.h) {
				S.push(r);
			} else if (S.top().h == r.h) {
				// DO NOTHING
			} else if (S.top().h > r.h) {
				int tgt = j;
				while (!S.empty() && S.top().h >= r.h) {
					Rect pre = S.top();
					S.pop();
					ans = max(ans, (j - pre.p) * pre.h);
					tgt = pre.p;
				}
				r.p = tgt;
				S.push(r);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 18412
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

vector<int> h(200,0);
int n;

void solve(int id){
    int left = id;
    int right = id;
    while(h[left]>0){
        if(left==0) break;
        else left--;
    }
    while(h[right]>0){
        if(right==n-1) break;
        else right++;
    }
    for(int i=left; i<=right;i++){
        h[i]--;
    }
}

int main(){
    cout << fixed << setprecision(10);
    cin >> n;
    rep(i,n) cin >> h[i];
    int ans = 0;
    bool ok = 1;
    while(ok){
        ok = 0;
        rep(i,n){
            if(h[i]>0){
                solve(i);
                ok = 1;
                ans++;
            }
        }
        if(ok==0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int l, i = 0, a[n];
    while (cin >> l) {
        a[i] = l;
        i++;
    }
    int ans = 0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if (a[i]<a[j]+a[k]
                    && a[j]<a[i]+a[k]
                    && a[k]<a[i]+a[j]
                    ){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
n = int(input())
lis = []
cou = 100
for i in range(n):
  num = int(input())
  if num % 10 != 0:
    cou = min(cou,num)
  lis.append(num)
if sum(lis) % 10 == 0 and cou == 100:
  print("0")
elif sum(lis) % 10 == 0:
  print(sum(lis) -cou)
else:
  print(sum(lis))

Measured memory_bytes: 3064
d_pre=input().split()
d=[int(s) for s in d_pre]
A=d[0]
B=d[1]
C=d[2]
D=d[3]
for i in range(210):
    if i%2==0:
        C-=B
        if C<=0:
            print("Yes")
            break
    else:
        A-=D
        if A<=0:
            print("No")
            break

Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

struct Edge {
    int to;
    ll cost;
};

vector<Edge> tree[200000];
ll cost[200000];

int main() {
    int N;
    cin >> N;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        tree[a].push_back((Edge){b, c});
        tree[b].push_back((Edge){a, c});
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    memset(cost, -1, sizeof(cost));

    queue<PLL> que;
    que.push(make_pair(K, 0));  // (頂点, コスト)
    cost[K] = 0;
    while (!que.empty()) {
        auto q = que.front(); que.pop();

        int v = q.first;
        ll c = q.second;

        for (Edge& e : tree[v]) {
            if (cost[e.to] < 0) {
                que.push(make_pair(e.to, c + e.cost));
                cost[e.to] = c + e.cost;
            }
        }
    }

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        cout << cost[x] + cost[y] << endl;
    }

    return 0;
}


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

using namespace std;

int main(){

	int n,a,b,c,d[102];
	cin >> n >> a >> b >> c;
	int ans = c / a;
	for(int i = 0;i < n;i++){
		cin >> d[i];
	}
	sort(d,d+n,greater<int>());
	int sum = 0;
	for(int i = 1;i <= n;i++){
		sum += d[i-1];
		ans = max(ans,(c+sum)/(a+b*i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1176
DBG = !true

# # of patties of k-level burger
def p(k)
  return (2**(k+1) - 1)
end

# # of layers of k-level burger
def s(k)
  return (2**(k+2) - 3)
end

def f(n,x)
  ret = -1 # dmy
  if n==0 || x == 0
    ret = x
  elsif x == 1  # n>0
    ret = 0
  elsif x == 2*s(n-1)+3
    ret = f(n, x-1)
  elsif x > s(n-1)+2
    ret = (p(n-1) + 1 + f(n-1, x-s(n-1)-2))
  elsif x == s(n-1)+2
    ret = (p(n-1) + 1)
  elsif x > 1
    ret = f(n-1, x-1)
  end

  printf("f(%d,%d) returns %d\n", n, x, ret) if DBG
  return ret
end

n,x = gets.split.map{|x| x.to_i}
printf("n:%d x:%d\n", n, x) if DBG
print f(n,x)


Measured memory_bytes: 1788
from sys import stdin
import bisect

N,Q = list(map(int,stdin.readline().strip().split()))
S = input().strip()

P = [0]*N
cnt = 0

for i in range(1,N):
    if S[i-1:i+1] == 'AC':
        cnt+=1
    P[i] = cnt

for i in range(Q):
    l,r = list(map(int,stdin.readline().strip().split()))
    print(P[r-1] - P[l-1])

Measured memory_bytes: 6332
#include<bits/stdc++.h>
#define ll long long
#define ull unsinged long long
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define inf (1LL<<62)
#define sf scanf
#define pf printf
#define repi(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define depi(i,a,b) for(int i=a;i>=b;--i)
#define dep(i,a,b) for(ll i=a;i>=b;--i)
#define mod 1000000007

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    int l=0,r=n/2;
    while(l<=r)
    {
        int mid=(l+r)/2;
        int flag=0;
        map<string,int> mp;
        for(int i=1;i<=n-mid+1;++i)
        {
            string a=s.substr(i-1,mid);
            if(mp[a] && i-mp[a]>=mid)
            {
                flag=1;
                ans=max(ans,mid);
            }
            else if(!mp[a])
                mp[a]=i;
        }
        if(flag)
            l=mid+1;
        else
            r=mid-1;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6668
// AtCoder
// ABC 178  A - Not

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;

int main()
{
	long long x;

	cin >> x;
	
	// 計算
	if (x == 1) {
		cout << '0' << endl;
	} else {
		cout << '1' << endl;
	}
}



Measured memory_bytes: 3164