akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-7

#define INF 1e16

/*
 */

int const MaxSize = 200 + 10;
set<PII> done;

int go(int a, int b, int c) {
	int ns[3] = { a, b, c };
	sort(ns, ns + 3);

	PII step = PII(ns[0], ns[1]);

	if (done.count(step))
		return -1;
	else
		done.insert(step);

	if (a % 2 || b % 2 || c % 2)
		return 0;
	else {
		int nextA = b / 2 + c / 2;
		int nextB = a / 2 + c / 2;
		int nextC = a / 2 + b / 2;

		int nextRes = go(nextA, nextB, nextC);

		if (nextRes < 0)
			return -1;
		else
			return 1 + nextRes;
	}
}

//0 if c, 1 if j
int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);

	int A, B, C;
	cin >> A >> B >> C;

	cout << go(A, B, C) << endl;

	return 0;
}


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

int main(){

  string a,b,c;

  cin >> a >> b >> c;
  
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
d,g = readInts()
P = []
C = []
res = float('inf')
for i in range(d):
    p,c = readInts()
    P.append(p)
    C.append(c)
for bit in range(1 << d):
    SUM = 0
    NUM = 0
    for i in range(d):
        if bit & (1 << i):
            SUM += 100 * (i + 1) * P[i] + C[i]
            NUM += P[i]
    if SUM >= g:
        res = min(res,NUM)
    else:
        for i in range(d-1,-1,-1):
            if bit & (1 << i):
                continue
            else:
                for j in range(P[i]):
                    if SUM >= g:
                        break
                    SUM += 100 * (i+1)
                    NUM += 1
        res = min(res,NUM)
print(res)


Measured memory_bytes: 10480
#include "bits/stdc++.h"
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long

int n;
vector<int> a;
vector<vector<int>> dp;
int sm(int i, int j) {
	int ans = 0;
	for (int k = i; k <= j; k++)
		ans += a[k];
	return ans;
}

int solve(int i, int j) {
	if (i == j)
		return a[i];
	if (i > j)
		return 0;
	if (~dp[i][j])
		return dp[i][j];
	int ans = 4e18;
	for (int k = i; k < j; k++) {
		int l = solve(i, k);

		int r = solve(k + 1, j);
		ans = min(ans, l + r + sm(i, k) + sm(k + 1, j));
	}

	return dp[i][j] = ans;
}

int32_t main() {
	Fast_IO
	cin >> n;
	a = vector<int>(n);
	dp = vector<vector<int>>(n, vector<int>(n, -1));
	for (auto &i : a)
		cin >> i;
	int t = solve(0, n - 1);
	t -= accumulate(a.begin(), a.end(), 0LL);;
	cout << t;
}

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

const int maxn = 1010;
int n, m, A, B;
bool used[1010][1010];
char ans[1010][1010];

int main() {
    scanf("%d %d %d %d", &n, &m, &A, &B);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            ans[i][j] = '.';
        }
    }
    int oldn = n, oldm = m;
    if (n & 1) {
        for (int i = 1; i < m; i++) {
            if (A && !used[n][i] && !used[n][i + 1]) {
                used[n][i] = used[n][i + 1] = 1, A--;
                ans[n][i] = '<', ans[n][i + 1] = '>';
            }
        }
        n--;
    }
    if (m & 1) {
        for (int i = 1; i < n; i++) {
            if (B && !used[i][m] && !used[i + 1][m]) {
                used[i][m] = used[i + 1][m] = 1, B--;
                ans[i][m] = '^', ans[i + 1][m] = 'v';
            }
        }
        m--;
    }
    if (oldn & 1 && oldm & 1 && (A + B) * 2 == n * m && A & 1) {
        A--, B--;
        ans[n - 1][m - 1] = '<', ans[n - 1][m] = '>';
        ans[n + 1][m] = '<', ans[n + 1][m + 1] = '>';
        ans[n - 1][m + 1] = '^', ans[n][m + 1] = 'v';
        ans[n][m - 1] = '^', ans[n + 1][m - 1] = 'v';
    }
    for (int i = 1; i <= n; i += 2) {
        for (int j = 1; j <= m; j += 2) {
            if (A) {
                A--, ans[i][j] = '<', ans[i][j + 1] = '>';
                if (A) A--, ans[i + 1][j] = '<', ans[i + 1][j + 1] = '>';
            } else if (B) {
                B--, ans[i][j] = '^', ans[i + 1][j] = 'v';
                if (B) B--, ans[i][j + 1] = '^', ans[i + 1][j + 1] = 'v';
            }
        }
    }
    if (A || B) {
        printf("NO\n"), exit(0);
    }
    printf("YES\n");
    for (int i = 1; i <= oldn; i++) {
        printf("%s\n", ans[i] + 1);
    }
    return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 3010;

int a[N];
ll dp[N][N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  for (int len = 1; len <= n; ++len)
    for (int i = 1, j = len; j <= n; ++i, ++j) {
      dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
    }
  printf("%lld\n", dp[1][n]);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  ll a ,b, x;
  ll ans;
cin >> a >> b >> x;
if(a == 0) {
ans = b /x + 1;
}else{
ans = b / x - (a - 1) / x;
}
// for (ll i = a % x; i <= b; i++) {
//  if (i % x == 0){
// ans++;
//  }
// }
cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
fn main() {
    input!{
        a: i8,
        b: i8,
        c: i8,
    }
    println!("{}", max(0, c - a + b));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<62;
constexpr auto mod = 1000000007;
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() {
	int n, m;
	cin >> n >> m;
	VI imos(n, 0);
	FOR(i, m) {
		int l, r;
		cin >> l >> r;
		l--;
		imos[l]++;
		if (r < n)imos[r]--;
	}
	FOR1(i, n)imos[i] += imos[i - 1];
	int ans = 0;
	FOR(i, n)if (imos[i] == m)ans++;
	cout << ans << endl;
}


Measured memory_bytes: 640
import sys

def main():
    for line in iter(sys.stdin.readline, ""):
        #print (line)
        a = line.rstrip("\n")
        tmp = a.split(" ")
        a = int(tmp[0])
        b = int(tmp[1])
        n = int(tmp[2])
        cnt = 0
        for i in range(1, n+1):
            if (n % i == 0) and (a <= i and i <= b):
                cnt = cnt + 1
                #print (i)
        print (cnt)    
if __name__ == "__main__":
    main()

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = (x2 - x1);
    int dy = (y2 - y1);
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;
    
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std; 

int main(){
	
	int N,W;
	cin>>N;
	cin>>W;
	
	long long weight[N + 1];
	long long value[N + 1];
	weight[0] = 0;
	value[0] = 0;
	
	for(int i = 1; i <= N; ++i){
		cin >> weight[i];
		cin >> value[i];
	}
	
	long long dp[N + 1][W + 1];
	
	for(int i = 0; i <= N; ++i){
		for(int j = 0; j <= W; ++j){
			dp[i][j] = 0;
		}
	}
	
	for(int i = 1; i <= N; ++i){
		for(int j = 1; j <= W; ++j){
			if(j == weight[i]){
				dp[i][j] = max(dp[i][j],value[i]);
				dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
				if(j - weight[i] >= 0)dp[i][j] = max(dp[i][j],dp[i-1][j-weight[i]] + value[i]);
				}
		}
	}
	
	cout << dp[N][W];

	return 0;
}

Measured memory_bytes: 79104
n,m = map(int,input().split())
pen_list = [0 for i in range(n)]
pen_num = 0
ans_num = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if pen_list[p-1] != -1:
            pen_list[p-1] += 1
    else:
        if pen_list[p - 1] != -1:
            pen_num = pen_num + pen_list[p-1]
            pen_list[p-1] = -1
            ans_num = ans_num + 1
print(ans_num, pen_num)

Measured memory_bytes: 3888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var c = new int[2];
			var t = new List<int>[31];
			for (int i = 0; i < t.Length; i++)
				t[i] = new List<int>();

			while ((c = Console.ReadLine().Split(',').Select(i => int.Parse(i)).ToArray()).Sum() > 0)
				t[c[1]].Add(c[0]);

			var r = 1;
			var v = new Dictionary<int, int>();
			for (int i = t.Length - 1; i >= 0; i--)
			{
				if (t[i].Count > 0)
				{
					for (int j = 0; j < t[i].Count; j++)
					{
						v[t[i][j]] = r;
					}
					r++;
				}
			}
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var n = int.Parse(s);
				Console.WriteLine(v[n]);
			}
		}
	}
}

Measured memory_bytes: 6460
H,W = map(int,input().split())
S = [input() for i in range(H)]

# 4方向の累積和をとって計算する
Rs = [[0]*W for i in range(H)]
Ls = [[0]*W for i in range(H)]
Ds = [[0]*W for i in range(H)]
Us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    # 順方向(左にどれだけ伸びてるか)
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Ls[i][j] = tmp
    tmp = 0
    # 逆方向(右にどれだけ伸びてるか)
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Rs[i][j] = tmp

# 行列転置 順番逆にするだけ
for j in range(W):
    tmp = 0
    # 順方向 上にどれだけ伸びているか
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Us[i][j] = tmp
    tmp = 0
    # 順方向 下にどれだけ伸びているか
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            Ds[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': 
            continue
        # 上下左右に伸びた数を重なっている部分引く
        tmp = Rs[i][j] + Ls[i][j] + Ds[i][j] + Us[i][j] - 3
        ans = max(ans, tmp)
print(ans)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define TIF 1000000000
#define LIF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(2*n);
  int x;
  for(int i=0;i<n;i++){
    cin >> x;
    p[i]={x,1};
  }
  for(int i=0;i<n;i++){
    cin >> x;
    p[i+n]={x,-1};
  }
  sort(all(p));
  LL ans=1;
  LL t=0;
  for(int i=0;i<2*n;i++){
    if(t>0){
      if(p[i].second==1){
        ans=ans*(t+1)%MOD;
      }
    }else{
      if(p[i].second==-1){
        ans=ans*(-t+1)%MOD;
      }
    }
    t+=p[i].second;
  }
  cout << ans << endl;
  return 0;
}

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

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

int n;
int cnt[101];
int cal[5]={5,7,5,7,7,};

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			cnt[i]=str.size();
		}
		int res=-1;
		for(int i=0;i<n;i++){
			if(res!=-1)continue;
			int now=0;
			int len=0;
			for(int j=i;j<n;j++){
				len+=cnt[j];
				if(len==cal[now]){
					now++;
					len=0;
				}else if(len>cal[now]){
					break;
				}
				if(now==5){
					res=i;
					break;
				}
			}
		}
		printf("%d\n",res+1);
	}
	return 0;
}

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

int ls(int S[],int n,int T[],int q){
  int count=0;
  for(int i=0;i<q;++i)
    for(int j=0;j<n;j++)
      if(T[i]==S[j]){
	count++;
	break;
      }
  return count;
}

int main() {
  int n;
  cin >> n;
  int S[n];
  for(int i=0;i<n;++i)
    cin >> S[i];

  int q;
  cin >> q;
  int T[q];
  for(int i=0;i<q;++i)
    cin >> T[i];
  
  cout << ls(S,n,T,q) << endl;
}

Measured memory_bytes: 1196
<?php

fscanf(STDIN, "%d %d", $l, $r);

if ($r - $l >= 2018) {
    echo 0;
} else {
    $min = PHP_INT_MAX;
    for ($i = $l; $i < $r; ++$i) {
        for ($j = $i + 1; $j <= $r; ++$j) {
            $min = min($min, ($i % 2019) * ($j % 2019) % 2019);
        }
    }

    echo $min;
}


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

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  if(B<=A) cout << "delicious" << endl;
  else if(B<=X+A) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] command = br.readLine().split(" ");
		long N = Long.parseLong(command[0]);
		long K = Long.parseLong(command[1]);
		
		long a = N / K ;
		long b = N % K;
		
		long result;
		if(b == 0) result = 0;
		
		
		if(a == 0) {
			if(Math.abs(N) > Math.abs(N - K)) {
				result = Math.abs(N - K);
			}else {
				result = Math.abs(N);
			}
		}else{
			result = (Math.min(b, Math.abs(b - K)));
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define l1 long
#define ld long double
#define lld long long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cout<<"$ "<<x<<" $"<<endl
#define bug(x) cout<<"& "<<x<<" &"<<endl
#define all(v) v.begin(),v.end()
#define lop1(i,j,n) for(int i=j; i<n; ++i)
#define lop2(i,j,n) for(int i=j; i<=n; ++i)
#define lop3(i,n,j) for(int i=n; i>j; --i)
#define lop4(i,n,j) for(int i=n; i>=j; --i)
#define view(v) for(auto i: v) cout<<i<<" "
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
const ll M=1e9+7;
const ld PI=3.1415926536;
//int p[N];
//int find(int k){ return p[k]==k ? k : p[k]=find(p[k]); }
using namespace std;

void solve()
{
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
    return;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    fast
    ll t=1;
	//cin>>t;
    while(t--) solve();
	return 0;
}


Measured memory_bytes: 3572
N = int(input())

a = list(map(int,input().split()))

odd = []
even2 = []
even4 = []

for ai in a:
    if ai%4==0:even4.append(ai)
    elif ai%2==0:even2.append(ai)
    else:odd.append(ai)
if len(even4)>=len(odd):print('Yes')
elif len(even4)+1==len(odd) and len(even2)==0:print('Yes')
else:print('No')

Measured memory_bytes: 14224
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int K, X;
  cin >> K >> X;
  if (K * 500 >= X) {
    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 FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll dp[100010][5];

int main(){
  string S;
  cin >> S;
  ll N = S.size();
  dp[0][0] = 1;
  rep(i,N){
    if(S[i] == 'A'){
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1] + dp[i][0];
      dp[i+1][2] += dp[i][2];
      dp[i+1][3] += dp[i][3];
    }else if(S[i] == 'B'){
      dp[i+1][2] += dp[i][2] + dp[i][1];
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1];
      dp[i+1][3] += dp[i][3];
    }else if(S[i] == 'C'){
      dp[i+1][3] += dp[i][3] + dp[i][2];
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1];
      dp[i+1][2] += dp[i][2];
    }else{
      dp[i+1][0] += dp[i][0] * 3;
      dp[i+1][1] += dp[i][1] * 3 + dp[i][0];
      dp[i+1][2] += dp[i][2] * 3 + dp[i][1];
      dp[i+1][3] += dp[i][3] * 3 + dp[i][2];
    }
    dp[i+1][0] %= MOD;
    dp[i+1][1] %= MOD;
    dp[i+1][2] %= MOD;
    dp[i+1][3] %= MOD;
  }
  cout << dp[N][3] << endl;
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// PfsMap :
func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

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

	N := getInt()
	a := PfsMap(N)

	ans := 0
	for _, v := range a {
		c := 1
		for v >= c {
			ans++
			v -= c
			c++
		}
	}
	out(ans)
}


Measured memory_bytes: 1764
a = [int(input())]

for i in range(1000000):
    if a[i] % 2 == 0:
        a.append(a[i] // 2)
    else:
        a.append(3*a[i] + 1)
    
    if a[i+1] in a[:i]:
        print(i + 2)
        break

Measured memory_bytes: 3060
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#define ll long long
#define str string
#define rtn return
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define db long double
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define pll pair <ll, ll>
#define vi vector<ll>
#define vpll vector<pll>
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define loop1(i, n) for (int i=1;i<=n;++i)
#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

template<class T> void remin(T &a, T b) {a = min(a, b);}
template<class T> void remax(T &a, T b) {a = max(a, b);}
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 1005

int n, m;
char a[N][N];
ll dp[N][N];

void add(ll &a, ll b) {
  a += b;
  a %= MOD;
}

int main() {
  FAST_IO;
  cin >> n >> m;
  rep(i, n) rep(j, m) cin >> a[i][j];
  rep(i, m) {
    if (a[0][i] == '.') dp[0][i] = 1;
    else break;
  }
  rep(i, n) {
    if (a[i][0] == '.') dp[i][0] = 1;
    else break;
  }
  loop(i, 1, n) loop(j, 1, m) {
    if (a[i][j] == '.') {
      if (i - 1 >= 0)
        add(dp[i][j], dp[i - 1][j]);
      if (j - 1 >= 0)
        add(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << dp[n-1][m-1] << endl;
  rtn 0;
}


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

int main(){
    int a[3];
    int tmp;
    int i,j;
    cin>>a[0]>>a[1]>>a[2];
    
    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
            }
        }
    }
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
int main()
{
    int a,b,c,s=0;
    scanf("%d %d %d",&a,&b,&c);
    s=a+b+c;
    if(s>=22)
    {
        printf("bust\n");
    }
    else
       {
            printf("win\n");
       }
}


Measured memory_bytes: 128
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int H, A;
  cin >> H >> A;
  cout << (H - 1) / A + 1 << endl;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let m: usize = scan(tokens);
    let mut a: Vec<usize> = vec(n, |_| scan(tokens));
    a.sort();
    a.reverse();
    let s: usize = a.iter().sum();
    if a[m - 1] * 4 * m >= s {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    bool ans = true;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(A%2 == 0){
            if((A%3 != 0) && (A%5 != 0)) ans = false;
        }
    }
    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

int main()
{
    int64 x, xx, ans;
    cin >> x;
    xx = sqrt(2 * x);
    if (xx * (xx + 1) >= 2 * x)
        ans = xx;
    else
        ans = xx + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    c = a % b
    return gcd(b,c)

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
for i in T:
    ans = ans * i // gcd(ans,i)
print(int(ans))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

long long A[200001];

int main(){
  int i,N;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> A[i];
  }
  long long c,d,r,c2,l;
  d=0;
  c=A[0];
  r=0;
  c2=A[0];
  for (l=0;l<N;++l) {
    while (1) {
      if (c != c2 || r==N) {
        d+=r-l;
        break;
      }
      r+=1;
      if (r<N) {
        c ^= A[r];
        c2 += A[r];
      }
    }
    c^=A[l];
    c2-=A[l];
    //cout << c << " " << c2 << " " << l << " " << r << endl;
  }
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, m;
  cin >> n;
  map<int, int> mp;
  REP(i, n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  cin >> m;

  map<int, int> mp2;
  REP(i, m) {
    int a;
    cin >> a;
    mp2[a]++;
  }
  string ans = "YES";
  REPvec(itr, mp2) {
    if (mp.count(itr->first) == 0 || mp[itr->first] < itr->second) {
      ans = "NO";
    }
  }

  cout << ans << endl;
}

//////////////////////////////////////////////


Measured memory_bytes: 19072
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

int modpow(int a, int b, int m = MOD) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}
 
// 繰り返し二乗法 (modの世界での累乗)
// ※modが素数の場合、この関数で(mod - 2)乗したら、mod割り算ができるよ！
// (参考問題: ABC034 C問題など)
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
 
// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    ll b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

signed main() {
  ll n,a,b;
  cin>>n>>a>>b;
  ll p=modpow(2,n);
  ll ans=p-combination_mod(n,a,MOD)-combination_mod(n,b,MOD)-1;
  if(ans<0){
    ans+=1000000007;
  }
  if(ans<0){
    ans+=1000000007;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    vector<vll> a(3);
    
    f(i,0,2)
        a[i].resize(3);

    f(i,0,2)
        f(j,0,2)
            cin >> a[i][j];
    ll n,t;
    cin >> n;
    bool is=false;

    while(n--)
    {
        cin >> t;
        f(i,0,2)
            f(j,0,2)
                if(a[i][j]==t)
                    a[i][j]=0;
    }

    f(i,0,2)
    {
        bool ist=true;
        f(j,0,2)
            if(a[i][j]!=0)
                ist=false;
        
        if(ist)
            is=true;
    }

    f(i,0,2)
    {
        bool ist=true;
        f(j,0,2)
            if(a[j][i]!=0)
                ist=false;
        
        if(ist)
            is=true;
    }

    if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0)
        is=true;

    if(a[2][0]==0 && a[1][1]==0 && a[0][2]==0)
    is=true;
    
    if(is)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
using namespace std;
ll a,b,c;
int32_t main(){
cin>>a;
cin>>b;
cin>>c;
cout<<min(c,b/a);
return 0;}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String x = sc.next();
      char[] a = new char[3];

      for(int i = 0;i<3;i++){
        a[i] = x.charAt(i);
      }

    if(a[0]==a[2]){
      System.out.println("Yes");
    }else{
        System.out.println("No");
    }

  }
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 3009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
double dp[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
    ll n;
    cin>>n;
    rep(i,0,maxn){
        rep(j,0,maxn){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    double pr[maxn];
    rep(i,0,n)cin>>pr[i];
    rep(i,0,n+1){
        rep(j,0,n+1){
            if(i+j>n)continue;
            if(i>0)dp[i][j]+=dp[i-1][j]*pr[i+j-1];
            if(j>0)dp[i][j]+=dp[i][j-1]*(1-pr[i+j-1]);
        }
    }
    double ans=0;
    rep(i,0,n+1){
        rep(j,0,n+1){
            if(i+j==n && i>j)ans+=dp[i][j];
        }
    }
    cout<<ans<<"\n";
    return 0;   
}

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

int main(){
    int n; cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i]  >> f[i];
    vector<vector<int>> t(n,vector<int>(n,0));
    rep(i,n-1){
        rep(j,n){
            if(i+j >= n-1){
                t[i+1][j] = t[i][j];
                continue;
            }
            int tij = t[i][j];
            int ck = c[i+j]; int sk = s[i+j]; int fk = f[i+j];
            if(tij < sk) tij = sk;
            else if(tij%fk != 0) tij = (tij/fk+1)*fk;
            t[i+1][j] = tij+ck;
        }
    }
    rep(i,n) cout << t[n-1][i] << endl;
    /*rep(i,n){
        rep(j,n){
            cout << t[i][j] << " ";
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 1280
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let n = read_t_in_line::<i32>()[0];
    let d_x = read_t_in_line::<i32>();
    let (d, x) = (d_x[0], d_x[1]);
    let aa : Vec<_> = (0..n).map(|_| read_t_in_line::<i32>()[0]).collect();

    let mut ans = x;
    for a in aa {
        ans += (d - 1) / a + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cmath>
#include <iostream>
#include <utility>
#include <array>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;

int main(){
  int p;
  int n = 0;
  cin >> p;
  for(int i=1;i<=p;i++){
    for(int j=1;j<=p;j++){
      for(int k=1;k<=p;k++){
        int q = gcd(i,j);
        n += gcd(q,k);
      }
    }
  } 
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3676
if __name__ == '__main__':
    [a,b,c,k] = [int(i) for i in input().split()]
    ans = 0
    if k >= a:
        k-=a
        ans += a
    else:
        ans += k
        k = 0
    
    if k>=b :
        k-=b
    else:
        k = 0
    
    if k>=c:
        k-=c
        ans -= c
    else:
        ans -= k
        k = 0
    
    print(ans)

Measured memory_bytes: 9196
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string a;
    cin >> a;
    string ans;

    if(a[2]==a[3] && a[4]==a[5]){
        ans = "Yes";
    }  else{
        ans = "No";
    }
    cout << ans << "\n"; 

    return 0;
}

Measured memory_bytes: 256
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d %d %d %d', $a1, $a2, $a3, $a4);
    fscanf(STDIN, '%d %d %d %d', $b1, $b2, $b3, $b4);
    $arr1 = array($a1, $a2, $a3, $a4);
    $arr2 = array($b1, $b2, $b3, $b4);

    $hit = 0;
    for ($i = 0; $i < 4; $i++) {
        if ($arr1[$i] === $arr2[$i]) {
            $hit++;
            unset($arr1[$i], $arr2[$i]);
        }
    }

    $blow = count(array_intersect($arr1, $arr2));
    printf("%d %d\n", $hit, $blow);
}

Measured memory_bytes: 6608
// Hacheylight
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void add(T &a, T b) { a = (1ll * a + b) % MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }
template <class T> T read() {
    int f = 1 ; T x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}

int T ;
ll a, b, c, d, GCD ;

signed main() {
	scanf("%d", &T) ;
	while (T--) {
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d) ;
		if (a < b) puts("No") ;
		else if (b > d) puts("No") ;
		else if (c >= b - 1) puts("Yes") ;
		else {
			a %= b ;
			d %= b ;
			GCD = __gcd(b, d) ;
			if (a + GCD * ((b - a - 1) / GCD) > c) puts("No") ;
			else puts("Yes") ;
		}
	}


	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    long a = sc.nextLong();
	    long b = sc.nextLong();
	    long k = sc.nextLong();
	    if (k <= (a + b)) {
		    if (a < k) {
		    	k = k - a;
		    	a = 0;
		    } else {
		    	a = a - k;
		    	k = 0;
		    }
		    b = b - k;
			System.out.print(a + " " + b);
	    } else {
	    	System.out.print(0 + " " + 0);
	    } 
	}

}


Measured memory_bytes: 21716
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	ll x;

	while(scanf("%lld", &x)==1)
	{
		ll v=100;
		int ans;

		for(ans=0;;ans++)
		{
			if(v>=x) break;
			v+=v/100;
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  string S;cin>>S;
  int left=-1,right,ans=-1;
  REP(i,0,S.size()){
    if(S.at(i)=='A'){
      left=i;
      break;
    }
  }
  RREP(i,S.size()-1,-1){
    if(S.at(i)=='Z'){
      right=i;
      break;
    }
  }
  print(right-left+1);

}


Measured memory_bytes: 720