akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,w=mii()

wei=[0]
val=[0]
for i in range(n):
    x,y=mii()
    wei.append(x)
    val.append(y)

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(1,w+1):
        if wei[i] <=j:
            dp[i][j] = max(dp[i-1][j-wei[i]]+val[i],dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
            

print(dp[-1][-1])

Measured memory_bytes: 125820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,N;
  int S=0;
  cin>>K>>N;
  vector<int>A(N);
  vector<int>B(N);
  for(int X=0;X<N;X++){
    cin>>A[X];
    if(0<X){
      B[X-1]=abs(A[X]-A[X-1]);
    }
  }
  B[N-1]=K-A[N-1]+A[0];
  sort(B.begin(),B.end());
  cout<<K-B[N-1]<<endl;
}


Measured memory_bytes: 4844
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 入出力
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...);}

void solve(std::string S){
    set<char> str;
    REP(i, S.size())
        str.insert(S[i]);

    set<char> alpha;
    for (char i = 'a'; i <= 'z'; i++)
        alpha.insert(i);

    set<char> diff;
    std::set_difference(alpha.begin(), alpha.end(),
            str.begin(), str.end(),
            std::inserter(diff, diff.end()));

    if (diff.size() == 0) print("None");
    else {
        auto itr = diff.begin();
        print(*itr);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if((i+1)%2==1) {
      if(s[i]=='R'||s[i]=='U'||s[i]=='D') {
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if(s[i]=='L'||s[i]=='U'||s[i]=='D') {
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
//x<0の時絶対値をとって処理を共通化する
//場合分け
//(1)原点周りでの往復にたどり着く前に終わる 答え= x-d*k
//条件=x-d*k>=0
//ただしd*kはオーバーフローする->x/d>=kとすればok
//(2)原点周りで終わる
//x/d回は-d,そこから(残り操作回数k-x/d=k')は-d,+d,-d,+dしたがってk'の偶数奇数が知りたい

class Program
{
    static void Main()
    {
        long[] In = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long x = In[0];
        long k = In[1];
        long d = In[2];
        if (x < 0) { x *= -1; }//絶対値とるのはxだけ
        long c = x / d;
        //x-d*k>=0の時
        if (c >= k) Console.WriteLine(x-d*k);
        else
        {
            //繰り返しの前の位置
            //long p = x % d;
            //残数
            k -= c;
            long p = x - d * c;
            if (k % 2 == 0)
            {
                Console.WriteLine(Math.Abs(p));
            }
            else
            {
                Console.WriteLine(Math.Abs(p - d));
            }
        }
    }
}

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

int main() {
	int a,b,c,t;
cin>>a>>b>>c;
if(a>b){t=a;a=b;b=t;}
if(b>c){t=b;b=c;c=t;}
if(a>b){t=a;a=b;b=t;}
cout<<a<< " "<<b<<" "<<c<<endl;

	return 0;
}

Measured memory_bytes: 1164
from collections import*
def s(s):
  f=[1]*-~n
  f[s]=0
  q=deque([(s,0)])
  while q:
    t,c=q.popleft()
    for v in e[t]:
      if f[v]:
        f[v]=0
        q.append((v,c+1))
  return t,c
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  e[a].append(b)
  e[b].append(a)
print('SFeicrosntd'[s(s(1)[0])[1]%3!=1::2])

Measured memory_bytes: 130664
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int N;
    scanf("%d", &N);
    long long A[N + 2], ans = 1000, stonk = 0;
    A[0] = 1000000000;
    A[N + 1] = 0;
    for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    for (int i = 1; i <= N; ++i) {
        if (A[i] >= A[i - 1] && A[i] >= A[i + 1]) ans += stonk * A[i], stonk = 0;
        else if (A[i] <= A[i + 1] && A[i] <= A[i - 1]) stonk += ans / A[i], ans %= A[i];
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
int main(){
FASTIO
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)
    cin>>a[i];
map<int,ll> m;
m[a[0]]=1;
ll ans=0;
for(int i=1;i<n;i++){
  int h=i-a[i];
  if(m.find(h)!=m.end()){
    ans+=m[h];
  }
  m[i+a[i]]++;
}  
map<int,ll> m1;
m1[n-1-a[n-1]]=1;
for(int i=n-2;i>=0;i--){
  int h=i+a[i];
  if(m1.find(h)!=m1.end()){
    ans+=m1[h];
  }
  m1[i-a[i]]++;
}
cout<<((ans)/2);
return 0;
}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  int cnt = 0;
  string b;
  cin >> a >> b;
  for(int i=0;i<a-1;i++){
    if(b.substr(i,3) == "ABC") cnt++;  
  }
  cout << cnt << endl;
}

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

using namespace std;

int main(){
    int a[3];
    while(~scanf("%d%d%d",&a[0],&a[1],&a[2])){
        sort(a,a+3);
        printf("%d\n",a[0]+a[1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define min(p,q)((p)<(q)?(p):(q))
#define in(l,r,k) ((l<r&&(l<=k&&k<r)) || (l>r&&(k<r||l<=k)))

long long L[50],R[50];
int main(){
	long long n,q,k,d;
	scanf("%lld%lld%lld%lld",&n,&q,&k,&d);
	k--,d--;
	int temp=min(q,50);
	long long l=d,r=d+1;
	L[0]=l;
	R[0]=r;
	int flag=0;
	for(int i=0;i<temp;i++){
		l*=2;
		r*=2;
		if((l<r&&r-l>=n)||(l>r&&l-r<=n)){
			flag=1;
			temp=i+1;
			break;
		}
		L[i+1]=l%=n;
		R[i+1]=r%=n;
	}
	if(flag==0){
		if(!in(l,r,k)){
			puts("-1");
			return 0;
		}
	}
	for(int i=0;i<q-temp;i++){
		puts("0");
		k=(k/2)+(n/2)*(k%2);
	}
	while(temp--){
		k=(k/2)+(n/2)*(k%2);
		if(in(L[temp],R[temp],k))puts("0");
		else{
			k=(k+n/2)%n;
			puts("1");
		}
	}
}



Measured memory_bytes: 2104
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main(){
	int t;
	cin >> t;
	for (int i = 0;i < t;++i) {
		int a, b;
		cin >> a >> b;
		a--;
		int ans = 127*a;
		if (a % 2 == 0) {
			ans += b;
		}
		else {
			ans += b ^ 127;
		}
		cout << ans << endl;
	}
}

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

int main(){
    int n, m, i, a;
    cin >> n >> m;
    int ok[n+1] = {}, num[n+1] = {};
    for(i=0; i<m; i++){
        cin >> a;
        ok[a]++;
    }
    num[0] = 1;
    for(i=1; i<=n; i++){
        if(ok[i] == 0){
            if(i>1) num[i] = (num[i-1]+num[i-2])%MOD;
            else num[i] = num[i-1];
        }
    }
    cout << num[n];
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main(){
	int i,a[105]={0},s=0,x,n;
	
	cin>>n;
	
	for(i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=1;
	}
	for(i=1;i<=105;i++){
		if(a[i]==1){
			s++;
		}
	}
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
K = int(input())
s = len(input())

mod = 10 ** 9 + 7
N = 2 * 10**6
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
  fac.append( ( fac[-1] * i ) % mod )
  inv.append( mod - ( inv[mod % i] * (mod // i) % mod ) )
  finv.append( finv[-1] * inv[-1]  % mod )

def cmb(n, r):
  return fac[n] * ( finv[r] * finv[n-r] % mod ) % mod

p25 = [1]
p26 = [1]

for i in range(K):
  p25.append(p25[i]*25%mod)
  p26.append(p26[i]*26%mod)

ans = 0

for i in range(K+1):
  ans += ( cmb(s+K-i-1, s-1) * p25[K-i] % mod ) * p26[i] % mod
  ans %= mod

print(ans)

Measured memory_bytes: 225796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

signed main() {
    vector<int> a;

    rep(i, 3) {
	a.push_back(nextInt());
    }
    sort(all(a));

    if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

void solve() {
    string s; cin >> s;
    string t = "";
    int n = sz(s);
    for (int i = 0; i < n; i++) {
        t += (i & 1 ? 'p' : 'g');
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (t[i] > s[i]) res++;
        else if (t[i] < s[i]) res--;
    }
    cout << res << endl;
} 

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

Measured memory_bytes: 3772
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    var maxL = 0
    var minR = Int.MAX_VALUE
    repeat(m) {
        maxL = Math.max(maxL, sc.nextInt())
        minR = Math.min(minR, sc.nextInt())
    }
    println(Math.max(0, minR - maxL + 1))
}

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

int main() { 
	string st; cin >> st;
	string ast;
	for (auto c : st) {
		if (c == 'A') {

		}
		else {
			ast.push_back(c);
		}
	}
	string ki = "KIHBR";
	if (ast != "KIHBR")cout << "NO" << endl;
	else {
		int num = 0;
		vector<int>nums{ 1,0,0,1,1,1 };
		
		for (auto c : st) {
			if (num == 5) {
				nums[num]--;
			}
			else if (c == ki[num]) {
				num++;
			}
			else {
				nums[num]--;
			}
		}
		if (all_of(nums.begin(), nums.end(), [](const int i) {
			return i >= 0;
		})) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 764
n = int(input())
w = [int(i) for i in input().split()]
m = 10**5
for i in range(1,len(w)):
    a = 0
    b = 0
    a = sum(w[0:i])
    b = sum(w[i:])
    if abs(a-b)<m:
        m = abs(a-b)
print(m)

Measured memory_bytes: 3060
#include <stdio.h>

int n, len, str[100001];

int main(void)
{
    int i, fl = 0;

    scanf("%d %d", &n, &len);

    for (i = 0; i < n; i++) {
        scanf("%d", &str[i]);
    }

    for (i = 0; i < n-1; i++) {
        if (str[i] + str[i+1] >= len) {
            fl = i+1;
            break;
        }
    }

    if (fl) {
        puts("Possible");
        for (i = 1; i < fl; i++) {
            printf("%d\n", i);
        }
        for (i = n-1; i > fl; i--) {
            printf("%d\n", i);
        }
        printf("%d\n", fl);
    } else {
        puts("Impossible");
    }

    return 0;
}
            




Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){

    ll n,m ;
    cin >> n;
    ll c=0 ;
    for(int i=1 ;i<=n ;i++)
    {
        cin >> m;
        if(m != i){c++ ;}
    }

    if(c==2 || c==0){cout << "YES" <<endl ;}
    else {cout << "NO" <<endl ;}
    return 0 ;
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007LL;

ll mfactorials[100000+1];



const ll max_N = 210000;
ll fac[max_N + 1000], facinv[max_N + 1000];

ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % mod, n/2);
    if(n % 2 == 1){
        res = res * x % mod;
    }
    return res;
}

ll nck(ll n, ll k){
    if(k == 0 || n == k){
        return 1;
    }
    return fac[n] * facinv[k] % mod * facinv[n-k] % mod;
}

ll npk(ll n, ll k){
    if(k == 0 || n == k){
        return 1;
    }
    return fac[n] * facinv[n-k] % mod;
}

ll powmod(ll x, ll n) {
    if (n == 0LL) return 1LL;
    x %= mod;
    if (n % 2LL == 0) {
        return powmod((x * x) % mod, n / 2LL);
    }
    else {
        return (x * powmod((x * x) % mod, n / 2LL)) % mod;
    }
}

ll comb(ll n, ll k) {
    return (mfactorials[n] * powmod((mfactorials[k] * mfactorials[n - k]) % mod, mod - 2LL)) % mod;
}

ll patternNum(ll i, ll j) {
    i -= 1LL; j -= 1LL;
    return nck(i + j, i);
}

int main() {
    mfactorials[0] = mfactorials[1] = 1LL;
    for (ll i = 2ll; i <= 100000LL; ++i) {
        mfactorials[i] = (mfactorials[i - 1] * i) % mod;
    }

    fac[0] = 0;
    fac[1] = 1;
    for (int i = 2; i < max_N; ++i){
        fac[i] = (fac[i-1] * i) % mod;
    }
    for (int i = 0; i < max_N; ++i){
        facinv[i] = power(fac[i], mod - 2);
    }
    
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0LL;
    for (ll i = 1LL; i <= H - A; ++i) {
        ans += (patternNum(i, B) * patternNum(H - i + 1LL, W - B)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;
int64_t MAX=1000000000000000000LL;
int keta(int64_t x){
  int count=1;
  while(x/10!=0){
    x/=10;
    count++;
  }
  return count;
}


int main() {
  int N;
  cin>>N;
  bool which =true;
  bool error=false;
  int64_t ans=1;
  vector<int64_t> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
    if(S.at(i)==0) which=false;
  }
  if(which){
    for(int i=0;i<N;i++){
      
      if(S.at(i)>MAX/ans){
        error=true;
        break;
      }
      ans*=S.at(i);
      if(ans>MAX){
        error=true;
        break;
      }
    }
    if(error) cout<<-1;
    else cout<<ans;
  }
  else cout<<0;

}


Measured memory_bytes: 4036
#include<algorithm>

template<class T>
T lis(const T& vec) {
    const int N = vec.size(), INF = 1<<30;
    T dp(N, INF), id(N);
    for (int i = 0; i < N; ++i) {
        id[i] = std::distance(dp.begin(), std::lower_bound(dp.begin(), dp.end(), vec[i]));
        dp[id[i]] = vec[i];
    }
    int length = *max_element(id.begin(), id.end());
    T seq(length + 1);
    for (int i = N - 1; i >= 0; --i)
        if (id[i] == length)seq[length--] = vec[i];
    return seq;
}

#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> vec(N);
    for(int i=0;i<N;++i) cin>>vec[i];
    vector<int> ans=lis(vec);
    cout<<ans.size()<<endl;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t,r;
	cin>>t>>s;
	bool g,f=0;
	for(int i=t.size()-s.size();i>=0;i--){
		r=t;g=1;
		for(int j=0;j<s.size();j++){
			if(!(t[i+j]=='?'||t[i+j]==s[j])){g=0;break;}
			r[i+j]=s[j];
		}
		if(g){
			for(int i=0;i<r.size();i++){if(r[i]=='?')cout<<'a';else cout<<r[i];}
			return 0;
		}
	}
	cout<<"UNRESTORABLE";
	return 0;
}

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

int main() {
    int mod = 1000000007;
  int N;
  cin >> N;
  long long A[N];
  long long sum = 0;
  for(int i = 0; i < N; i++){
      cin >> A[i];
      sum += A[i];
      sum %= mod;
  }
  long ans = 0;

  for(int i = 0; i < N; i++){
      sum -= A[i];
      if(sum < 0) sum += mod;
      ans += A[i]*sum;
      ans %= mod;

  }
  cout << ans << endl;
}

Measured memory_bytes: 5172
N, M = list(map(int, input().split()))

if M==1:
    print(1)
    exit()

C = [1] # (N+K-1, N-1) K=0,1,2,...,30
for k in range(1,31):
    C.append(C[-1]*(k+N-1)//k)

F = {}
f = 2
while f*f<=M and M>1:
    if M%f==0:
        if f in F: F[f] += 1
        else: F[f] = 1
        M//=f
    else:
        f+=1

if M in F: F[M]+=1
else: F[M]=1

d = 1
for f, k in F.items():
    d *= C[k]

print(d%1000000007)

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

int main() {
  int N, K;
  cin >> N >> K;
  char S[N];
  
  for (int i = 0; i < N; i++)
    cin >> S[i];
  
  if (S[K - 1] == 'A')
    S[K - 1] = 'a';
  
  else if (S[K - 1] == 'B')
    S[K - 1] = 'b';
  
  else
    S[K - 1] = 'c';
  
  for (int i = 0; i < N; i++)
    cout << S[i];
  
  return 0;
}

Measured memory_bytes: 256
def Z(S):
    res = [0]*len(S)
    res[0] = len(S)
    i = 1
    j = 0
    while i < len(S):
        while i+j < len(S) and S[j] == S[i+j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < len(S) and k+res[k] < j:
            res[i+k] = res[k]
            k += 1
        i += k
        j -= k
    return res

from collections import defaultdict
N = int(input())
S = input()
ans = 0
for i in range(N):
    s = S[i:]
    z = Z(s)
    for j in range(len(z)):
        z[j] = min(j,z[j])
    ans = max(ans,max(z))

print(ans)

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

struct p{
	long long x,y,idx;
	unsigned long long sqrdist(p b){
		return (x-b.x)*(x-b.x)+(y-b.y)*(y-b.y);
	}
	void read(){
		cin >> x >> y;
	}
	long long operator *(p b){
		return x*b.y - y*b.x;
	}
	bool operator ==(p b){
		return x == b.x && y == b.y;
	}
	void operator -=(p b){
		x -= b.x,y -= b.y;
	}
	bool operator >=(p b){
		return x >= b.x && y >= b.y;
	}
	bool operator <=(p b){
		return x <= b.x && y <= b.y;
	}
	p operator -(p b){
		return {x-b.x,y-b.y};
	}
	long long crossprod(p a , p b){
		a.x -= x , b.x -= x , a.y -= y , b.y -= y;
		return a*b;
	}
};

struct segment{
	p p1,p2;
	void equal(p a , p b){
		p1 = a , p2 = b;
	}
	void readseg(){
		p1.read(),p2.read();
	}
};

bool comp(p a , p b){
	return a.y < b.y;
	//
}

void convexhull(vector<p> v , vector<p> c){
	sort(v.begin(),v.end(),comp);
	for(long long q = 0 ; q < 2 ; q += 1){
		vector<p> g;
		g.push_back(v[0]);
		for(long long i = 1 ; i < v.size() ; i += 1){
			while(g.size() >= 2 && ((v[i] - g[g.size()-2])*(g.back() - g[g.size()-2]) <= 0)){
				g.pop_back();
			}
			g.push_back(v[i]);
		}
		if(q == 0){
			g.pop_back();
		}
		for(p i : g){
			c.push_back(i);
		}
		reverse(v.begin(),v.end());
	}
}

bool intersect(segment a , segment b){
	for(long long i = 0 ; i < 2 ; i += 1){
		p p1 = a.p1;
		long long v1 = (b.p1 - p1)*(a.p2 - p1) , v2 = (b.p2 - p1)*(a.p2 - p1);
		if(v1 * v2 > 0){
			return false;
		}else if(v1 == 0 && v2 == 0){
			if(max(a.p1.x,a.p2.x) < min(b.p1.x,b.p2.x) || max(a.p1.y,a.p2.y) < min(b.p1.y,b.p2.y)){
				return false;
			}
		}
		swap(a,b);
	}
	return true;
}

bool equal(vector<p> a , vector<p> b){
	if(a.size() != b.size()){
		return false;
	}
	for(long long i = 0 ; i < a.size() ; i += 1){
		if(a[i] == b[i]){
			continue;
		}
		return false;
	}
	return true;
}

bool ok[100001];
int cnt[100001];

int main(){
	int n,m,ans=0,pen=0;
	cin >> n >> m;
	for(int i = 0 ; i < m ; i += 1){
		int a;
		string s;
		cin >> a >> s;
		if(s == "AC"){
			if(!ok[a]){
				ok[a] = true;
				ans += 1;
				pen += cnt[a];
			}
		}else{
			if(!ok[a]){
				cnt[a] += 1;
			}
		}
	}
	cout << ans << " " << pen << endl;
}

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

typedef vector <int> vi;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n, k;
    cin >> n >> k;
    vi dp (n, INF), cost (n);
    trav (a, cost)
        cin >> a;
    dp[0] = 0;
    for (i = 1; i < n; ++i)
        for (j = 1; j <= k && i - j >= 0; ++j)
            dp[i] = min (dp[i], dp[i - j] + abs (cost[i - j] - cost[i]));
    cout << dp[n - 1] << '\n';

    return 0;
}


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

#define MAXN 105

int main(){
	int n;
	int arr[MAXN];
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	sort(arr,arr+n);
	if(sum%10==0){
		for(int i=0;i<n;i++){
			if(arr[i]%10!=0){
				cout<<sum-arr[i];
				return 0;
			}
		}
		cout<<0;
		return 0;
	}else{
		cout<<sum;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ar[402];
long long pre[402];
long long dp[402][402];
long long fun(int l,int h)
{
	if(l==h)
	return 0;
	if(l+1==h)
	return dp[l][h]=ar[l]+ar[h];
	if(dp[l][h]!=-1)
	return dp[l][h];
	dp[l][h]=1e18;
	for(int i=l;i<h;i++)
	dp[l][h]=min(dp[l][h],fun(l,i)+fun(i+1,h)+pre[h+1]-pre[l]);
	return dp[l][h];
}
int main() {
	// your code goes here
	int n,i;
	cin>>n;
	pre[0]=0;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++)
	{
		cin>>ar[i];
		pre[i+1]=pre[i]+ar[i];
	}
	cout<<fun(0,n-1);
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  long long X,K,D;
  cin >> X >> K >> D;
  long long ans = (long long)1 << 60;
  if(abs(X)/D >= K)ans = abs(X)-D*K;
  else {
  	if(abs(X)/D % 2 == K % 2)ans = min(ans,abs(X)-abs(X)/D*D);
  	else ans = min(ans,abs(abs(X)-(abs(X)/D+1)*D));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#define M 1000000007
using namespace std;
typedef unsigned long long ull;


ull power(ull x, ull n){
	if(n==0)
		return 1;
	ull temp = power(x*x%M, n/2)%M;
	if(n%2==0){
		return temp;
	}else{
		return x*temp;	
	}
}

int main() {
	ull m,n;
	cin >> m;
	cin >> n;
	cout << power(m,n)%M << endl;
	return 0;
}

Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        //最小のものの右、左の個数
        //k-1だったら1回、(k-1)*2だったr
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int minInd = a.ToList().IndexOf(1);
        Console.WriteLine((nk[0] - 1) / (nk[1] - 1) + ((nk[0] - 1) % (nk[1] - 1) != 0 ? 1 : 0));
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> v = {a,b};
  if(a==1 && b==1) cout << 1000000 << endl;
  else {
    int ans = 0;
    for(int i=0; i<2; i++) {
      if(v[i]==1) ans += 300000;
      if(v[i]==2) ans += 200000;
      if(v[i]==3) ans += 100000;
    }
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s=="ABC")
        cout << "ARC\n";
    else
        cout << "ABC\n";
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll dp[100005][13];

void init()
{
	for (int i = 0; i < 100005; ++i)
	{
		for (int j = 0; j < 13; ++j)
		{
			dp[i][j] = 0;
		}
	}
}

int main()
{
	init();
	string S;
	cin >> S;

	/*
	for (int i = 0; i < S.size(); ++i)
	{
		cout << S[i] << " ";
	}
	cout << endl;
	*/
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] != '?')
		{
			for (int j = 0; j < 13; ++j)
			{
				dp[i+1][(j * 10 + (S[i] - '0')) % 13] = dp[i][j];
			}
		}
		else
		{
			for (int k = 0; k <= 9; ++k)
			{
				for (int j = 0; j < 13; ++j)
				{
					dp[i+1][(j * 10 + k) % 13] += dp[i][j];
					dp[i+1][(j * 10 + k) % 13] %= MOD;
				}
			}
		}

		/*
		for (int j = 0; j < 13; ++j)
		{
			cout << dp[i+1][j] << " ";
		}
		cout << endl;
		*/
	}

	cout << dp[S.size()][5] << endl;
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(n);
	int upper = ceil(sqrt(n));
	int ans[n+1];
	mem(ans);
	
	rep(i, 1, upper+1)
	{
		rep(j, 1, upper+1)
		{
			rep(k, 1, upper+1)
			{
				int tmp = i*i+j*j+k*k+i*j+j*k+k*i;	
				if(tmp > n) break;
				ans[tmp] += 1;
			} 
		}
	}
	rep(i, 1, n+1) cout<<ans[i]<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3672
var
  a,b,i,t:longint;
  s:string;
begin
  readln(a,b);
  readln(s);
  for i:=1 to a+b+1 do
    if (s[i] in ['0'..'9'])and(i<>a+1) then inc(t);
  if (t=a+b)and(s[a+1]='-') then write('Yes')
                            else write('No');
end.

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b || a == c || b == c) {
    if (!(a == b && b == c)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
        #include <stdlib.h>
         
        int main(void)
        {
            int a, b, max = 0;
            int n;
            scanf("%d%d%d", &n, &a, &b);
            long long h[n];
            for (int i = 0; i < n; ++i){
                 scanf("%lld", &h[i]);
                 if (max < h[i])
                    max = h[i];
            }
         
            int del = a - b, l = 0, r = max/b + 1;
            int t;
            while (r - l > 1){
                t = (l+r)/2;
                long long ch = t;
                for (int i = 0; i < n; ++i){
                    if (t*b < h[i]){
                        ch -= (h[i] - t*b)/del + ((h[i] - t*b)%del? 1:0);
                    }
                }
                if (ch < 0)
                    l = t;
                else
                    r = t;
            }
            printf("%d\n", r);
            return 0;
        }

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int neg = 0;
    rep(i, n) {
        ans += abs(a[i]);
        if (a[i] < 0) neg++;
    }

    if (neg % 2 == 1) {
        int minA = INF;
        rep(i, n) minA = min(minA, abs(a[i]));
        ans -= minA * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int N;
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        m[n]++;
    }
    long long int ans = 0;
    for (auto &it : m) {
        if (it.first <= it.second) {
            ans += it.second - it.first;
        } else {
            ans += it.second;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    for (int i = K; i < N; i++) {
        cout << (A[i-K]<A[i] ? "Yes" : "No") << endl;
    }
}


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

int main(){
	int r,g,b;
    int c;
  	cin >> r >> g >> b;
    c = (100*r) + (10*g) + b;
    if( c%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

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

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

signed main() {
    int k, ans=0;
    cin >> k;

    for (int i = k-1; i >= 1; i -= 2) {
        ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

d = {}

for i in range(2, 1000000):
  if i in d:
    continue
  j = i * i
  while j < 1000000:
    d[j]=1
    j+=i

while True:
  n = sys.stdin.readline()
  if not n: break
  n = int(n.rstrip())
  count=0
  for i in range(2, n+1):
    if not i in d:
      count+=1
  print count

Measured memory_bytes: 101592
#include <stdio.h>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

void print(int* A,int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << A[i];
		if (i != n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}
void insert(int* A, int n)
{
	for (int i = 1; i < n; i++)
	{
		print(A, n);
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;

		}
		A[j + 1] = v;

	}
}
void bubble(int* A, int n)
{
	int flag = 1;
	int count=0;
	while (flag)
	{
		
		//print(A, n);
		flag = 0;
		for (int j = n - 1; j > 0; j--)
		{
			if (A[j] < A[j - 1])
			{
				count++;
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = 1;
			}
		}
	}
	print(A, n);
	cout << count << endl;
}
void selection(int* A, int n)
{
	int count=0;
	for (int i = 0; i < n; i++)
	{
		int minj = i;
		for (int j = i; j < n; j++)
		{
			if (A[j] < A[minj])
			{
				minj = j;
			}
		}
		if (i != minj)
		{
			count++;

			int temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
		}
	}

	print(A, n);
	cout << count << endl;
}

int main()
{
	int n;
	cin >> n;
	
	int* A = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	
	selection(A, n);
	return 0;
}


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

int N,L;
int m[6] ;
int x[] = {1,10,100,1000,10000,100000} ;
int table[21] ;

void calc(){
	for( int j=0 ; j<21 ; j++ ){
		table[j] = N ;
		for( int i=0 ; i<L ; i++ ){
			m[i] = N%10 ;
			N /= 10 ;
		}
		sort(m,m+L);
		int a=0 , b=0 ;
		for( int i=0 ; i<L ; i++ ){
			a += m[i] * x[i] ;
			b += m[L-i-1] * x[i] ;
		}
		N = a-b ;
	}
}

int main(){
	
	while( cin >> N >> L , L ){
		calc() ;
		for( int i=1 ; i<21 ; i++ ){
			for( int j=0 ; j<i ; j++ ){
				if( table[i] == table[j] ){
					printf("%d %d %d\n" ,j ,table[i] ,i-j ) ;
					i = 100 ;
					break ;
				}
			}
		}
	}
	
return 0;
}

Measured memory_bytes: 1160
<?php
fscanf(STDIN, '%d %d', $a, $b);
$str = $a. $b;
$ans = 'No';
for($i = 1; $i <= 100100; $i++) {
    if($str == $i * $i) {
        $ans = 'Yes';
        break;
    }
}
echo $ans. "\n";

Measured memory_bytes: 4604
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N;
int main() {
	cin >> N;
	int x = 0;
	while (1LL * x * (x + 1) / 2 < N) x++;
	cout << x << endl;
	return 0;
}

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

typedef long long ll;

using namespace std;

const int mod = 1e9 + 7;

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    map< char, int > used;
    for (int i = 0; i < N; i++) {
        used[S[i]]++;
    }

    ll ans = 1;
    for (auto x : used) {
        if (x.second != 0) {
            ans = (ans * (x.second + 1)) % mod;
        }
    }
    ans -= 1;

    cout << ans % mod << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);

    vector<int> ans(n);
    rep(i, n) ans.at(i) = 1;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(h.at(a) == h.at(b)) {
          ans.at(a) = 0;
          ans.at(b) = 0;
        }
        else if(h.at(a) < h.at(b)) ans.at(a) = 0;
        else if(h.at(b) < h.at(a)) ans.at(b) = 0;
    }

    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ans.at(i) == 1) cnt++;
    }
    cout << cnt << endl;
}




Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i)

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  string s = "ACGT";
  I n;
  cin >> n;
  if (n==3){
    cout << 61 << endl;
    return 0;
  }
  map<vector<char>, I> cur;
  REP(i,s.size()){
    REP(j,s.size()){
      REP(k,s.size()){
        REP(l,s.size()){
          vector<char> tmp(4);
          string s2 = "";
          s2 += s.at(i);
          s2 += s.at(j);
          s2 += s.at(k);
          s2 += s.at(l);
          tmp.at(0) = s.at(i);
          tmp.at(1) = s.at(j);
          tmp.at(2) = s.at(k);
          tmp.at(3) = s.at(l);
          if (s2.find("AGC")==string::npos && s2.find("GAC")==string::npos && s2.find("ACG")==string::npos &&
              s2.find("AGGC")==string::npos && s2.find("ATGC")==string::npos && s2.find("AGTC")==string::npos){
            cur[tmp] = 1;
          }
        }
      }
    }
  }
  I i = 5;
  while (true){
    if (i <= n){
      map<vector<char>, I> tmpV;
      //for(auto [key,value]: cur){
      for(auto itr = cur.begin(); itr != cur.end(); ++itr){
        auto key = itr->first;
        auto value = itr->second;
        REP(i,s.size()){
          vector<char> tmp(4);
          string s2;
          s2 += key.at(1);
          s2 += key.at(2);
          s2 += key.at(3);
          s2 += s.at(i);
          tmp.at(0) = key.at(1);
          tmp.at(1) = key.at(2);
          tmp.at(2) = key.at(3);
          tmp.at(3) = s.at(i);
          if (s2.find("AGC")==string::npos && s2.find("GAC")==string::npos && s2.find("ACG")==string::npos &&
              s2.find("AGGC")==string::npos && s2.find("ATGC")==string::npos && s2.find("AGTC")==string::npos){
            if (cur.find(tmp) == cur.end()){
              tmpV[tmp] = value % MOD;
            }else{
              tmpV[tmp] = (tmpV[tmp] + value) % MOD;
            }
          }
        }
      }
      cur = tmpV;
    }else{
      break;
    }
    i++;
  }
  I t=0;
  //for(auto [key,value]: cur){
  //for(auto itr = cur.begin(); itr != cur.end(); ++itr){
  MREP(itr,cur){
    auto key = itr->first;
    auto value = itr->second;
    t = (t + value) % MOD;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    fastIO;
    ll r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 3600
#[allow(unused_macros, dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros, dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros, dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let mut c: Vec<char> = s.chars().collect();
    let mut s: Vec<char> = "keyence".chars().collect();

    let n = c.len();

    let mut cnt = 0;
    for i in 0..n {
        if c[i] == s[i] {
            cnt += 1;
        } else {
            break;
        }
    }
    for i in 0..n {
        if c[c.len() - 1 - i] == s[s.len() - 1 - i] {
            cnt += 1;
        } else {
            break;
        }
    }

    println!("{}", if cnt >= 7 { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
n, a, b, c = map(int, input().split())
ans_list = []
ans = 'Yes'
s_list = []
for _ in range(n):
    s = input()
    s_list.append(s)
for i in range(n):
    s = s_list[i]
    if s == 'AB':
        if (a < b):
            a += 1
            b -= 1
            ans_list.append('A')
        elif (a > b):
            a -= 1
            b += 1
            ans_list.append('B')
        else:
            if i < n - 1:
                if 'B' in s_list[i + 1]:
                    a -= 1
                    b += 1
                    ans_list.append('B')
                else:
                    a += 1
                    b -= 1
                    ans_list.append('A')
            else:
                a -= 1
                b += 1
                ans_list.append('B')
    elif s == 'BC':
        if (b < c):
            b += 1
            c -= 1
            ans_list.append('B')
        elif (b > c):
            b -= 1
            c += 1
            ans_list.append('C')
        else:
            if i < n - 1:
                if 'B' in s_list[i + 1]:
                    c -= 1
                    b += 1
                    ans_list.append('B')
                else:
                    c += 1
                    b -= 1
                    ans_list.append('C')
            else:
                c -= 1
                b += 1
                ans_list.append('B')
    elif s == 'AC':
        if (c < a):
            c += 1
            a -= 1
            ans_list.append('C')
        elif (c > a):
            c -= 1
            a += 1
            ans_list.append('A')
        else:
            if i < n - 1:
                if 'A' in s_list[i + 1]:
                    c -= 1
                    a += 1
                    ans_list.append('A')
                else:
                    c += 1
                    a -= 1
                    ans_list.append('C')
            else:
                c -= 1
                a += 1
                ans_list.append('A')                
    if (a < 0) | (b < 0) | (c < 0):
        ans = 'No'
print(ans)
if ans == 'Yes':
    for ans in ans_list:
        print(ans)

Measured memory_bytes: 17108
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n, a int
	fmt.Scanf("%d %d\n", &n, &a)

	cnt := 0
	for {
		cnt++
		n -= a
		if n <= 0 {
			break
		}
	}
	fmt.Println(cnt)

	return 0
}

func main() {
	os.Exit(run())
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    map<string, int> map;
    int m = 0;
    REP(i, N) {
        string S;
        std::cin >> S;
        chmax(m, ++map[S]);
    }
    vector<string> ans;
    for(const auto& v : map) {
        if(v.second == m) ans.push_back(v.first);
    }
    REP(i, ans.size()) {
        std::cout << ans[i] << std::endl;
    }

    return 0;
}


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

int search(int n)
{
  vector<int> a(6);
  int i = 0;
  while (n > 0)
  {    
    a.at(i) = n % 10;
    n /= 10;
    ++i;
  }
  if(a.at(0) == a.at(4) && a.at(1) == a.at(3)){
    return 1;
  }else
  {
    return 0;
  }

  
}

int main()
{
  int a, b, count = 0;
  cin >> a >> b;
  
  
  for (int i = a; i <= b; i++)
  {
    if(search(i) == 1){
      ++count;
    }
    
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, m;
int dp[100005];
vector<int> g[100005];

int solve(int u) {
    if((int) g[u].size() == 0)
        return 0;
    int &rt = dp[u];
    if(rt != -1)
        return rt;
    rt = 0;
    for(auto &e : g[u])
        rt = max(rt, 1 + solve(e));
    return rt;
}

int main() {
    IO;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    memset(dp, -1, sizeof dp);
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, solve(i));
    cout << ans;
    return 0;
}


Measured memory_bytes: 7552