akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;
const int MAX = 5100000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    ll x,y;cin >>x>>y;
    ll sum=x+y;
    if(sum%3!=0){
        cout <<0<<endl;
        return 0;
    }
    sum/=3;
    x-=sum;
    y-=sum;
//    cout <<sum<<" "<<x<<endl;
    ll ans=COM(sum,x);
    cout<<ans <<endl;
    return 0;
}

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

char maze[51][51];
int vis[51][51];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            cin >> maze[i][j];
        }
    }


    int dx[] = {0, 0, -1, 1};
    int dy[] = {-1, 1, 0, 0};


    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            //4近傍サーチ
            if(maze[i][j] == '#'){
                for(int idx=0; idx < 4; idx++){
                    int nx = i + dx[idx];
                    int ny = j + dy[idx];
                    if(maze[nx][ny] == '#'){
                        vis[i][j] = 1;
                        vis[nx][ny] = 1;
                    }
                }
            }
        }
    }

    //照合
    int flag = 1;
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            if(maze[i][j] == '#' and vis[i][j] != 1){
                flag = 0;
                break;
            }
        }
    }

    /*
    //debug
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++) cout << vis[i][j] << " ";
        cout << endl;
    }
    */

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scanf("%d %d\n", &n, &x)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	sort.Ints(m)
	for i := range m {
		x -= m[i]
	}
	rem := x / m[0]
	fmt.Println(n + rem)
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<time.h>
#include<random>
#include<string>
#include<cmath>
#include <ctime>
#include<bitset>
#include <cctype>
#define low_bit(x) ((x)&(-(x)))
#define debug cout<<"*********degug**********";
#define index index_
#define int long long
#define RE register
#define yn yn_
using namespace std;
mt19937 rnd(233);
const long long max_ = 1e7 + 7;
const double alpha = 0.75;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
struct {
	int value, weight;
}node[max_];
int h, n,f[max_];
signed main() {
	h = read(), n = read();
	int maxx = -1;
	for (int i = 1; i <= n; i++) {
		node[i].weight = read(), node[i].value = read();
		maxx = max(maxx, node[i].weight);
	}
	for (int i = 1; i <= h + maxx; i++)f[i] = INF;
	for (int i = 1; i <= n; i++) {
		for (int j = node[i].weight; j <= h + maxx; j++) {
			f[j] = min(f[j], f[j - node[i].weight] + node[i].value);
		}
	}
	int ans = INF;
	for (int i = h; i <= h + maxx; i++) {
		ans = min(ans, f[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2432
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}

ll dp[mx],b[mx],a,k;
ll solve(ll i)
{
    if(i==a)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll x=INT_MAX;
    for(ll j=1;j<=k;j++)
    {
        if(i+j<=a)
            x = min(x,abs(b[i]-b[i+j])+solve(i+j));
    }
    return dp[i] = x;
}

int main()
{
    speed();
    ll i;
    cin>>a>>k;
    rep1 (i,1,a)
        cin>>b[i];
    mem(dp,-1);
    cout<<solve(1)<<endl;

}



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

string s,ans;

int main(){
  int i,w;
  cin >> s >> w;
  for(i=0;i<s.size();++i){
    if(i%w==0)ans+=s[i];
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
n, k =map(int, input().split())

ans = 0

for i in range(1, n+1):
  cnt = 0
  x = i
  while x <= k-1:
    x = x * 2
    cnt += 1
  ans += 1 / (2**cnt)
  
print("{0:.12f}".format(ans/n))

Measured memory_bytes: 3060
#include <iostream>
#define llint long long

using namespace std;

llint n, k, m;
llint dp[305][305], dp2[305][305];

int main(void)
{
	cin >> n >> k >> m;
	
	dp2[0][0] = 1;
	for(int i = 0; i < 305; i++){
		for(int j = 0; j < 305; j++){
			if(j > i) continue;
			dp2[i+1][j+1] += dp2[i][j] * (i-j+1) % m, dp2[i+1][j+1] %= m;
			dp2[i+1][j] += dp2[i][j], dp2[i+1][j] %= m;
		}
	}

	for(int i = 0; i <= k; i++) dp[0][i] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= k; j++){
			for(int l = 0; l <= i; l++){
				dp[i][j] += dp[i-l][j-1] * dp2[i][l] % m, dp[i][j] %= m;
			}
		}
	}
	cout << dp[n][k] << endl;
	
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string S;cin>>S;
    string n="2018";
    REP(i,S.size()){
        if(i<=3){
            printf("%c",n[i]);
        } else {
            printf("%c",S[i]);
        }
    }
    printf("\n");
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2 && a>=1 && a<=3 &&b>=1 &&b<=3)
    {
        int c;
        for(c=1;c<=3;c++)
            if((a*b*c)%2 !=0)
            {printf("Yes");
            break;}
        else {printf("No");break;}
        return 0; 
    } 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

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

    cout << c << " " << a << " " << b << endl;   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int last=h[0];
    int maxcnt=0;
    int cnt=0;
    for(int i=1;i<n;i++){
        if(last<h[i]){
            cnt=0;
        }else{
            cnt++;
        }
        maxcnt=max(maxcnt,cnt);
        last=h[i];
    }
    cout<<maxcnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n;
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>

int main(){
   char s[11];
   int i,j,d;
    
   scanf("%s",s);
   d=999;
   for (i=0;i<strlen(s)-2;i++) {
      j=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
      if (abs(753-j)<d) d=abs(753-j);
   }
   printf("%d\n",d);
   return 0;
}


Measured memory_bytes: 128
def main():
    n = int(input())
    s = input().rstrip()
    k = int(input())
    c = s[k-1]
    for i in range(n):
        if s[i] != c:
            print("*", end="")
        else:
            print(s[i], end="")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
long long f(long long x){
    if(x==-1) return 0;
    switch(x%4){
        case 0:
            return x;
            break;
        case 1:
            return 1;
            break;
        case 2:
            return x+1;
            break;
        case 3:
            return 0;
            break;
        default:
            return 114514;
            break;
    }
}
int main(){
    long long a,b,ans;
    int i;
    cin >> a >> b;
    if(a==b){
        cout << a << endl;
        return 0;
    }
    ans = f(a-1)^f(b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = ' ' + input()
t = ' ' + input()
dp = [[0 for _ in range(len(t))] for _ in range(len(s))]
for i in range(1, len(s)):
    for j in range(1, len(t)):
        if s[i] == t[j]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = len(s)-1, len(t)-1
ret = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ret += s[i]; i -= 1; j -= 1
print(ret[::-1])

Measured memory_bytes: 121052
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       char s[7];

       scanf("%s", s);

       if(s[2] == s[3] && s[4] == s[5])
              puts("Yes");
       else  
              puts("No");
       return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	string W,str;
	cin >> W;
	int cnt=0;
	while(cin >> str){
		if(str=="END_OF_TEXT") break;

		transform(str.begin(),str.end(),str.begin(),::tolower);
		if(str==W){
			cnt++;
		}
	}

	println(cnt);

	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

constexpr int N = 32;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> x(n), y(n); for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n; i++) if ((x[0] + y[0]) - (x[i] + y[i]) & 1) return cout << -1 << '\n', 0;
  lint s, t;
  if (x[0] + y[0] & 1) {
    VV<> ds, dt; assign(ds, n, N); assign(dt, n, N);
    for (int i = 0; i < n; i++) {
      s = y[i] + x[i];
      t = y[i] - x[i];
      for (int j = 0; j < N; j++) {
        if (s > 0) {
          ds[i][j] = 1;
          s -= 1LL << N - 1 - j;
        } else {
          ds[i][j] = -1;
          s += 1LL << N - 1 - j;
        }
        if (t > 0) {
          dt[i][j] = 1;
          t -= 1LL << N - 1 - j;
        } else {
          dt[i][j] = -1;
          t += 1LL << N - 1 - j;
        }
      }
    }
    cout << N << '\n';
    for (int i = N - 1; i >= 0; i--) cout << (1LL << i) << (i ? ' ' : '\n');
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < N; j++) {
        if (ds[i][j] == 1 and dt[i][j] == 1) cout << 'U';
        if (ds[i][j] == 1 and dt[i][j] == -1) cout << 'R';
        if (ds[i][j] == -1 and dt[i][j] == 1) cout << 'L';
        if (ds[i][j] == -1 and dt[i][j] == -1) cout << 'D';
      }
      cout << '\n';
    }
  } else {
    VV<> ds, dt; assign(ds, n, N); assign(dt, n, N);
    for (int i = 0; i < n; i++) {
      s = y[i] + x[i] - 1;
      t = y[i] - x[i] + 1;
      for (int j = 0; j < N; j++) {
        if (s > 0) {
          ds[i][j] = 1;
          s -= 1LL << N - 1 - j;
        } else {
          ds[i][j] = -1;
          s += 1LL << N - 1 - j;
        }
        if (t > 0) {
          dt[i][j] = 1;
          t -= 1LL << N - 1 - j;
        } else {
          dt[i][j] = -1;
          t += 1LL << N - 1 - j;
        }
      }
    }
    cout << N + 1 << '\n';
    cout << 1 << ' ';
    for (int i = N - 1; i >= 0; i--) cout << (1LL << i) << (i ? ' ' : '\n');
    for (int i = 0; i < n; i++) {
      cout << 'R';
      for (int j = 0; j < N; j++) {
        if (ds[i][j] == 1 and dt[i][j] == 1) cout << 'U';
        if (ds[i][j] == 1 and dt[i][j] == -1) cout << 'R';
        if (ds[i][j] == -1 and dt[i][j] == 1) cout << 'L';
        if (ds[i][j] == -1 and dt[i][j] == -1) cout << 'D';
      }
      cout << '\n';
    }
  }
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    p = LI()
    a = inf
    ans = 0
    for i in range(n):
        ans += a >= p[i]
        a= min(a, p[i])
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 70736
#include<stdio.h>
int main(void){
    int a,b,c,i;
    while(1){
        int A[2]={0},B[2]={0},C[2]={0};
        scanf("%d %d %d",&a,&b,&c);
        if(a==-1&&b==-1&&c==-1)break;
        b=b+a*60;
        C[0]=7200-(c+b*60);
        C[1]=C[0]*3;
        for(i=0;i<2;i++){
            B[i]=C[i]/60;
            C[i]=C[i]%60;
            A[i]=B[i]/60;
            B[i]=B[i]%60;
            printf("%02d:%02d:%02d\n",A[i],B[i],C[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 612
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(input().split()) for i in range(M)) #改行行列
    l=[0]*N
    was=[0]*N
    for p,s in S:
        p=int(p)-1
        if s=="AC":
            l[p]=1
        else:
            if not l[p]:
                was[p]+=1
    wa=0
    for i in range(N):
        if l[i]:
            wa+=was[i]
            
    print(sum(l),wa)




if __name__ == "__main__":
    main()

Measured memory_bytes: 101636
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.length();
	int a,b;
	for(int i=0;i<len;i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=len-1;i>=0;i--){
		if(s[i]=='Z'){
			b=i;
			break;
		}
	}
	cout<<b-a+1<<endl;	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<char> arr[k];
    memset(arr, 0, sizeof(arr));
    ll r, s, p;
    cin >> r >> s >> p;
    map<char, ll> mp;
    mp['r'] = p;
    mp['s'] = r;
    mp['p'] = s;
    string m;
    cin >> m;
    for (ll i = 0; i < n; i++)
    {
        arr[i % k].push_back(m[i]);
    }
    ll sum = 0;
    for (ll i = 0; i < k; i++)
    {
        for (ll j = 0; j < arr[i].size(); j++)
        {
            sum += mp[arr[i][j]];
            if (j != (ll)arr[i].size() - 1ll)
            {
                if (arr[i][j] == arr[i][j + 1])
                {
                    j++;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 5200
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])


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


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

int main() {
	ll n, x, a;
	cin >> n >> x;
	vector <ll> vec;
	vec.push_back(x);
	for(ll i = 1; i < n+1; i++)
	{
	cin >> a;
	vec.push_back(a);
	}
	
	sort(vec.begin(), vec.end());
	ll ans = vec[1]-vec[0];
	
	for(ll i = 2; i < vec.size(); i++)
	{
		ans = gcd(vec[i]-vec[i-1], ans);
	}
	
	cout << ans;
	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1400
import collections
N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
MAX = c.most_common()[0][1]

values, counts = zip(*c.most_common())
ans = []
for i in range(len(counts)):
    if counts[i] == MAX:
        ans.append(values[i])
ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 59496
s = gets.to_i
t = Math.sqrt(s).ceil
t += 1 if t*t <= s
a = [0,0]
if s == 10**18
    a[2] = 0
    a[3] = 10**9
    a[4] = 10**9
    a[5] = 0
elsif t*t-t < s
    a[2] = t
    a[3] = 1
    a[4] = t*t-s
    a[5] = t
else
    a[2] = t-1
    a[3] = 1
    a[4] = t*t-t-s
    a[5] = t
end
puts a.join(" ")

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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   
  long long int first,second,third,fourth;
   cin>>first>>second>>third>>fourth;
   long long int ans=0;
   if(fourth>0){
    ans+=min(first,fourth);
    fourth-=min(first,fourth);
    }
    if(fourth>0)
    {

        
        fourth-=min(second,fourth);
    }    
    if(fourth>0)
    {
        ans-=min(third,fourth);
        fourth-=min(third,fourth);
    }

    cout<<ans<<endl;

  return 0;

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[100001][2];
vector <int> v[100001];
ll count(int root, int parent, int col)
{
	if(dp[root][col]!=-1)
		return dp[root][col];
	ll ans = 1, fl = 0;
	if(col==1)
	{
		for(auto j: v[root]){
			if(j!=parent)
			{
				ans *= count(j,root,0);
				ans %= mod;
			}
		}
		return dp[root][col] = ans;
	}
	if(col==0)
	{
		for(auto j: v[root])
		{
			if(j!=parent)
			{
				ll ans1 = 0;
				ans1 += count(j,root,0);
				ans1 %= mod;
				ans1 += count(j,root,1);
				ans1 %= mod;
				ans *= ans1;
				ans %= mod;
			}
		}
		return dp[root][col] = ans;
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	for(int i=0;i<n-1;i++)
    	{
    		cin>>a>>b;
    		v[a].pb(b);
    		v[b].pb(a);
    	}
    	memset(dp,-1,sizeof(dp));
    	ll ans = count(2,-1,0);
    	ans += count(2,-1,1);
    	ans %= mod;
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 11776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 10500
#define MAXD 105
#define MOD (int)(1e9 + 7)

int f[MAXN][MAXD][2];
int p[MAXN];
char s[MAXN];
int n, d, z;

int main() {
    scanf("%s%i", s + 1, &d);
    n = strlen(s + 1);
    reverse(s + 1, s + 1 + n);
    p[1] = 1 % d;
    for(int i = 2; i <= n; ++i) p[i] = p[i - 1]*10 % d;

    s[n + 1] = '0';
    f[n + 1][0][1] = 1;

    for(int i = n + 1; i >= 1; --i) 
        for(int r = 0; r < d; ++r) {
            if (f[i][r][0]) {
                // not match
                for(int j = 0; j <= 9; ++j) {
                    z = (r + j) % d;

                    f[i - 1][z][0] = (f[i - 1][z][0] + f[i][r][0]) % MOD;
                }

            }

            if (f[i][r][1]) {

                // match
                for(int j = 0; j < s[i] - '0'; ++j) {
                    z = (r + j) % d;
                    f[i - 1][z][0] = (f[i - 1][z][0] + f[i][r][1]) % MOD;
                }

                z = (r + (s[i] - '0')) % d;

                f[i - 1][z][1] = f[i][r][1] % MOD;
            }
        }

    z = (f[0][0][0] + (ll)f[0][0][1] + (MOD - 1)) % MOD;
    printf("%i\n", z);

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



int main(void)
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n;
    SI(n);
    int arr[n];
    F(i, 0, n)
    {
        SI(arr[i]);
    }
    int dp[n];
    dp[0] = 0;
    F(i, 1, n)
    {
        if(arr[i] > arr[i - 1])
            dp[i] = 0;
        else
            dp[i] = dp[i - 1] + 1;
    }
    SO(*max_element(dp, dp + n));
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
int a,b,c,k,z=0;

scanf("%d %d %d",&a,&b,&c);
while(z==0){	
if(a>b){k=a; a=b;b=k;}
if(b>c){k=b; b=c;c=k;}
if(a>c){k=a; a=c;c=k;}
if((a<b&&b<c) ||(a==b&&b==c)||(a==b&&a<c)||(a<b&&b==c)){
z+=1 ;}}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
def rep(n):
    n=str(n)
    l=len(n)
    for i in range (0,l//2+1):
        if n[i]!=n[l-i-1]:
            return False
    return True

A,B=map(int,input().split(' '))
count = 0
for i in range(A,B+1):
    if rep(i):
        count += 1
print(count)

Measured memory_bytes: 42348
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,a[200005],b[200005];
int dp[4005][4005],ans;
int fac[8005],inv[8005];

int C(int x,int y){
	return 1ll*(1ll*fac[x]*inv[y]%mod)*inv[x-y]%mod;
}

int main(){
	scanf("%d",&n);
	fac[0]=1;
	for(int i=1;i<=8000;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	for(int i=2;i<=8000;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=8000;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
	for(int i=1;i<=n;i++) scanf("%d %d",&a[i],&b[i]);
	for(int i=1;i<=n;i++) dp[2000-a[i]][2000-b[i]]++;
	for(int i=0;i<=4000;i++){
		for(int j=0;j<=4000;j++){
			if(i>0) dp[i][j]+=dp[i-1][j],dp[i][j]%=mod; 
			if(j>0) dp[i][j]+=dp[i][j-1],dp[i][j]%=mod;
		}
	}
	for(int i=1;i<=n;i++) ans+=dp[a[i]+2000][b[i]+2000],ans%=mod;
	for(int i=1;i<=n;i++) ans=(ans-C(2*a[i]+2*b[i],2*a[i])+mod)%mod;
	ans=1ll*ans*inv[2]%mod;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 64512
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 3 1
3 2
)");
#define cin input
#endif

int main()
{
	int h, w, n;
	cin >> h >> w >> n;

	vector<set<int>> s(h);

	REP (i, n)
	{
		int x, y;
		cin >> x >> y;
		s[x - 1].insert(y - 1);
	}

	int x, y = 0;

	for (x = 0; x < h; ++x)
	{
		auto it = s[x].upper_bound(y);
		if (it != s[x].begin())
			break;
		if (x && (it == s[x].end() || *it != y + 1))
			++y;
	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#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 forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int n,fa[maxn],k,deep[maxn];
bool novis[maxn];
set<int> son[maxn];
set<pin> bg;
inline void dfs(int x){
	for(int v:son[x]){
		deep[v]=deep[x]+1;
		if(deep[v]>k)bg.insert(mk(deep[v],v));
		dfs(v);
	}
}
inline void redfs(int x){
	novis[x]=1;
	if(bg.count(mk(deep[x],x)))bg.erase(mk(deep[x],x));
	for(int v:son[x]){
		if(novis[v])return;
		redfs(v);
	}
}
inline int getfa(int x,int k){
	while(k--)x=fa[x];return x;
}
typedef set<pin>::iterator It;
int main(){
	read(n);read(k);
	rep(i,1,n)read(fa[i]);
	int ans=0;
	if(fa[1]!=1){
		ans++;
		fa[1]=1;
	}
	rep(i,2,n)son[fa[i]].insert(i);
	dfs(1);
	while(bg.size()){
		It it=bg.end();
		it--;ans++;
		int x=getfa(it->w2,k-1);
		redfs(x);
		son[1].insert(x);
		son[fa[x]].erase(x);
		fa[x]=1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 18688
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	ll N;
	vector<ll> arr;

	cin>>N;

	REP(i,N){
		ll a;
		cin>>a;
		arr.push_back(a);
	}
	
	
	sort(arr.begin(),arr.end(),greater<ll>() );
	
	ll max[2] = {0,0};
	int index = 0;
	for(int i = 0; i < N - 1; i++){
		if(arr[i] == arr[i+1]){
			max[index++] = arr[i];
			if(index > 1)break;
			i++;
		}
	}

	if(index < 2){
		cout<<0<<endl;
	}
	else{
		cout<< max[0] * max[1] <<endl;
	}

	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

bool f[3][3];

int main(){
  int A[3][3];
  rep(i,3)rep(j,3){
    cin >> A[i][j];
  }
  int N;
  cin >> N;
  int b;
  rep(i,N){
    cin >> b;
    rep(j,3)rep(l,3){
      if(A[j][l] == b) f[j][l] = true;
    }
  }
  string ans = "No";
    
  rep(i,3){
    if(f[i][0] and f[i][1] and f[i][2]) ans = "Yes";
  }
  rep(i,3){
    if(f[0][i] and f[1][i] and f[2][i]) ans = "Yes";
  }
  
  if(f[0][0] and f[1][1] and f[2][2]) ans = "Yes";
  if(f[0][2] and f[1][1] and f[2][0]) ans = "Yes";
  if(f[0][2] and f[1][1] and f[2][0]) ans = "Yes";
  cout << ans << endl;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "SUN") cout << 7;
    else if (s == "SAT") cout << 1;
    else if (s == "FRI") cout << 2;
    else if (s == "THU") cout << 3;
    else if (s == "WED") cout << 4;
    else if (s == "TUE") cout << 5;
    else cout << 6;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
double ar[3001];
double dp[3001][30001];
ll vis[3001][3001];

double pb(ll ind,ll cnt){
    if(vis[ind][cnt]!=-1) return dp[ind][cnt];
    if(ind>=n){
        if(cnt>=(n/2)+1) return 1;
        else return 0;
    }
    double x=ar[ind]*pb(ind+1,cnt+1);
    double y=(1-ar[ind])*pb(ind+1,cnt);
    vis[ind][cnt]=1;
    return dp[ind][cnt]=x+y;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n;
    for(ll i=0;i<n;i++) cin>>ar[i];
    memset(vis,-1,sizeof(vis));
    double ans=pb(0,0);
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 772736
import numpy as np
def f(nums, a):
  return 0  if nums.size<=1 else (np.searchsorted(nums, a//nums, side='right').sum()-np.searchsorted(nums, int(pow(a, 1/2)), side='right'))//2

N, K=map(int, input().split())
A=np.sort(list(map(int, input().split())))

p=np.sum(A>0)
q=np.sum(A<0)
Z=N-p-q
AP=A[-p:] if p>0 else np.array([])
AN=A[:q] if q>0 else np.array([])

b=(N-Z)*Z+Z*(Z-1)//2
a=p*q

if K<=a:
  x=AP[-1]*AN[0]-1
  y=AP[0]*AN[-1]
  while y-x>1:
    tmp=(y+x)//2
    counter=np.searchsorted(AN, tmp//AP, side='right').sum()
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
elif K<=a+b:
  print(0)
else:
  x=0
  y=10**18
  K=K-a-b
  if q<=1:
    while y-x>1:
      tmp=(y+x)//2
      if f(AP, tmp)<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  AN=AN[::-1]
  AN=-AN
  
  if p<=1:
    while y-x>1:
      tmp=(y+x)//2
      counter=f(AN, tmp)
      if counter<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  while y-x>1:
    tmp=(y+x)//2
    if f(AP, tmp)+f(AN, tmp)<K:
      x=tmp
    else:
      y=tmp
  print(y)

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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<double> temp(N);
  for(int i=0;i<N;i++){
    cin >> temp.at(i);
    temp.at(i) = T-temp.at(i)*0.006;
    temp.at(i) = fabs(temp.at(i)-A);
  }
  double div = temp.at(0);
  int num = 1;
  for (int i=0;i<N;i++){
    if(temp.at(i) < div){
      div = temp.at(i);
      num = i+1;
    }
  }
  cout << num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main() {
    LL a,b,c,d;
    cin >> a >> b >> c >> d;
    LL ans = a*c;

    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;

}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    string s, t;
    cin >> s >> t;
    vvi dp(s.size() + 1, vi(t.size() + 1, 0));
    auto lcs = dp;
    REP(i, 0, s.size()) {
        REP(j, 0, t.size()) {
            if (dp[i][j+1] >= dp[i+1][j]) {
                dp[i+1][j+1] = dp[i][j+1];
                lcs[i+1][j+1] = 2;
            }
            else {
                dp[i+1][j+1] = dp[i+1][j];
                lcs[i+1][j+1] = 3;
            }
            if (s[i] == t[j] && dp[i][j] >= dp[i+1][j+1]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                lcs[i+1][j+1] = 1;
            }
        }
    }
    string ans;
    ll i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (lcs[i][j] == 1) {
            ans.pb(s[i-1]);
            i--;
            j--;
        }
        else if (lcs[i][j] == 2)
            i--;
        else
            j--;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 141184
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

vector<string> split(const string &str, char sep) {
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

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

    string input;
    getline(cin, input);
    vector<string> s = split(input, ' ');

    int a = atoi(s[0].c_str());
    int b = atoi(s[1].c_str());

    if ( a == b ){
        cout << "a == b\n";
    } else if (a > b) {
        cout << "a > b\n";
    } else {
        cout << "a < b\n";
    }

    return 0;
}

Measured memory_bytes: 3160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}
#[warn(dead_code)]
fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n + 1];
    let mut is_prime = vec![true; n + 1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n + 1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {
            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

#[warn(unused_mut)]
#[warn(unused_imports)]
use std::collections::BTreeSet;
fn main() {
    input! {
        S: String,
    };
    let week = vec!["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    for i in 0..week.len() {
        if S == week[i] {
            println!("{}", 7 - i);
        } else {
        }
    }
}


Measured memory_bytes: 4352
#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 500009 /// Still trying to be one thing
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int 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) (int)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int vet[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<vet[n-1]<<endl;
    return 0;   
}           



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static int solve(int A, int B) {
        if (A >= 13) {
            return B;
        } else if (A >= 6) {
            return B / 2;
        } else {
            return 0;
        }
    }
}

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

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

    int n;
    cin >> n;
    vector<pair<ll, ll>> c(n);
    rep(i, n) cin >> c[i].second >> c[i].first;

    sort(c.begin(), c.end());
    ll s = 0;
    string ans = "Yes";
    rep(i, n)
    {
        s += c[i].second;
        if (c[i].first < s)
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i = 1; i < n; i++){
        ans += n/i;
        if(n%i == 0)
            --ans;
        // --ans;
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=450;
//templete
//↓Union-Find Tree
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
//↑Union-Find Tree
//↓座標圧縮：vectorを入れると対応関係をmap[旧座標]=新座標で返す
map<int,int> comp(vector<int> v){
	map<int,int> pam;
	int sz=v.size();
	for(int i=0;i<sz;i++){
		pam[v[i]]=0;
	}
	//新座標が1からほしいときはnc=1にする
	int nc=0;
	for(pair<int,int> i:pam){
		pam[i.first]=nc;
		nc++;
	}
	return pam;
}
//↑座標圧縮
int main() {
	int H,W;
	cin>>H>>W;
	string S[SIZE];
	for(int i=0;i<H;i++)
		cin>>S[i];
	UnionFind U(400*H*W+1);
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int k=0;k<4;k++){
				int x=i+dx[k],y=j+dy[k];
				if(x<0 || H<=x || y<0 || W<=y)
					continue;
				if(S[i][j]==S[x][y])
					continue;
				U.unionSet(i*W+j,x*W+y);
			}
		}
	}
	pint R[200000];
	set<int> tes;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int r=U.root(i*W+j);
			tes.insert(r);
			if(S[i][j]=='.')
				R[r].first++;
			else
				R[r].second++;
		}
	}

	ll ans=0;
	for(int i:tes){
		ans+=1LL*R[i].first*R[i].second;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 255104