akhauriyash/Code-Regression huggingface dataset:
while True:
    a, op, b = input().split()

    a = int(a)
    b = int(b)

    if op == "?":   
        break

    elif op == "-":
        print(a - b)

    elif op == "*":
        print(a * b)

    elif op == "/":
        print(a // b)

    elif op == "+":
        print(a + b)



Measured memory_bytes: 5592
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

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

    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<int64_t> valueA(A), valueB(B), valueC(C);
    REP(i, A) cin >> valueA[i];
    REP(i, B) cin >> valueB[i];
    REP(i, C) cin >> valueC[i];
    sort(ALL(valueA), greater());
    sort(ALL(valueB), greater());
    sort(ALL(valueC), greater());

    vector<int64_t> v;
    v.insert(v.end(), valueA.begin(), valueA.begin() + X);
    v.insert(v.end(), valueB.begin(), valueB.begin() + Y);
    v.insert(v.end(), valueC.begin(), valueC.end());
    sort(ALL(v), greater());

    int64_t ans = 0;
    REP(i, X+Y) ans += v[i];
    cout << ans << '\n';
}


Measured memory_bytes: 9176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scaner sc = new Scaner();
        write wr = new write();

        int N=sc.Int1;
        var H=sc.IntArr;
        bool ans=true;
        for(int i=0;i<N;++i){
            if(i==0){
                H[0]--;
            }
            else {
                if(H[i]-H[i-1]==0){
                    continue;
                }
                else if(H[i]-H[i-1]>0){
                    H[i]--;
                    continue;
                }
                else {
                    ans=false;
                    break;
                }
            }
        }
    if(ans)wr.wri("Yes");
    else wr.wri("No");
    }
}





class Scaner
{
    public string Str => Console.ReadLine();

    public string[] StrArr => Str.Split(' ');

    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public char[] CharArr => Str.ToArray();
    public long Long1 => LongArr[0];
    public int Int1 => IntArr[0];
    
}



class write
{
    public  void wri<T>(T x)
    {
        Console.WriteLine(x);
    }
}



Measured memory_bytes: 30044
while 1:
    m,nn,nx= map(int,input().split())
    if m==0: break
    s=[int(input()) for _ in range(m)]
    v=k=0
    for i in range(nn-1,nx):
        t=s[i]-s[i+1]
        if v<=t:
            k,v=i+1,t
    print(k)

Measured memory_bytes: 7572
//by xiqiao
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
int n,Q;
const ll inf=1ll<<60;
int abss(int x){if(x>0)return x;return -x;}
struct node{
	ll mx,mn1,mn2;
	ll flag;
}a[maxn*4];
void update(int x){
	a[x].mx=min(a[x*2].mx,a[x*2+1].mx);
	a[x].mn1=min(a[x*2].mn1,a[x*2+1].mn1);
	a[x].mn2=min(a[x*2].mn2,a[x*2+1].mn2);
}
void build(int x,int l,int r){
	if(l==r){
		a[x].mx=a[x].mn1=a[x].mn2=inf;
		return;
	}
	int mid=(l+r)/2;
	build(x*2,l,mid);build(x*2+1,mid+1,r);
	update(x);
}
void down(int x){
	if(a[x].flag){
		ll t=a[x].flag;a[x].flag=0;
		a[x*2].flag+=t;a[x*2].mx+=t;a[x*2].mn1+=t;a[x*2].mn2+=t;
		a[x*2+1].flag+=t;a[x*2+1].mx+=t;a[x*2+1].mn1+=t;a[x*2+1].mn2+=t;
	}
}

void modify(int x,int l,int r,int wh,ll val){
	if(l==r){
		if(a[x].mx<=val)return;
		a[x].mx=val;a[x].mn1=val-wh;a[x].mn2=val+wh;return;
	}
	down(x);
	int mid=(l+r)/2;
	if(mid>=wh)modify(x*2,l,mid,wh,val);
	else modify(x*2+1,mid+1,r,wh,val);
	update(x);
}
ll find1(int x,int l,int r,int tx,int ty){
	if(l>=tx && r<=ty){
		return a[x].mn1;
	}
	down(x);
	int mid=(l+r)/2;
	ll ret=inf;
	if(mid>=tx)ret=min(ret,find1(x*2,l,mid,tx,ty));
	if(mid<ty)ret=min(ret,find1(x*2+1,mid+1,r,tx,ty));
	return ret;
}
ll find2(int x,int l,int r,int tx,int ty){
	if(l>=tx && r<=ty)return a[x].mn2;
	down(x);
	int mid=(l+r)/2;ll ret=inf;
	if(mid>=tx)ret=min(ret,find2(x*2,l,mid,tx,ty));
	if(mid<ty)ret=min(ret,find2(x*2+1,mid+1,r,tx,ty));
	return ret;
}
ll query(int x,int l,int r,int wh){
	if(l==r)return a[x].mx;
	int mid=(l+r)/2;
	down(x);
	if(mid>=wh)return query(x*2,l,mid,wh);
	else return query(x*2+1,mid+1,r,wh);
}
void print(){
	puts("");
	for(int i=1;i<=n;i++){
		printf("%lld ",query(1,1,n,i));
	}
	puts("");
}
int main(){
	scanf("%d%d",&n,&Q);int last,B;
	scanf("%d%d",&last,&B);
	build(1,1,n);
	modify(1,1,n,B,0);
	while(Q--){
		int x;scanf("%d",&x);
		ll u=find1(1,1,n,1,x)+x;//cout<<find1(1,1,n,1,x)<<endl;
		ll v=find2(1,1,n,x+1,n)-x;//cout<<find1(1,1,n,1,x)<<" "<<find1(1,1,n,1,x)+x<<" "<<u<<" "<<v<<endl;
		a[1].flag+=abss(x-last);a[1].mx+=abss(x-last);
		a[1].mn1+=abss(x-last);a[1].mn2+=abss(x-last);
		modify(1,1,n,last,min(u,v));last=x;
	//	print();
	}
	printf("%lld\n",a[1].mx);
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    if (X < 600) puts("8");
    else if (X < 800) puts("7");
    else if (X < 1000) puts("6");
    else if (X < 1200) puts("5");
    else if (X < 1400) puts("4");
    else if (X < 1600) puts("3");
    else if (X < 1800) puts("2");
    else if (X < 2000) puts("1");
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> alp(30, 0);
    rep(i, n){
        int t = s[i] - 'a';
        //cout << t << endl;
        alp[t]++;
    }
    
    rep(i, 30){
        //cout << alp[i] << endl;
        if(alp[i] % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){

    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        p[i]--;
    }
    long long cnt = 0;
    for (int i = 0; i < N ; i++)
    {
        if(p[i]==i) {
            int tmp = p[i+1];
            p[i + 1] = p[i];
            p[i] = tmp;
            cnt++;
        }
        if(i==N-1){
            if(p[i]==N-1)
                cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string a;
int lena,flag;
int main(){
	cin>>a;
	lena=a.size();
	for(int i=0;i<lena;i++){
		if(a[i]=='C'){
			for(int j=i+1;j<lena;j++){
				if(a[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
			}
		}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    if a == b == c:
        print(-1)
        quit()
ans = 0
a_n = 0
b_n = 0
c_n = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a_n = (b+c)//2
    b_n = (a+c)//2
    c_n = (a+c)//2
    a = a_n
    b = b_n
    c = c_n
    ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#include<ctime>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
	ll h, n;
	cin >> h >> n;
	vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, int_INF));
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	dp[0][0] = 0;

	rep(i, n) {
		rep(j, h + 1) {
			int nj = min(j + a[i], h);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][nj] = min(dp[i + 1][j] + b[i], dp[i + 1][nj]);
		}
	}

	cout << dp[n][h] << endl;
}

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

using namespace std;
const int N = 22;

int n, a[N], b[N];
int go(int i, int x, int y) {
	if (i == n)
		return x - y;
	return max(go(i + 1, x, y), go(i+ 1, x + a[i], y + b[i]));
}
int main() {
//	freopen("input.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	for (int i = 0; i < n; ++i)
		scanf("%d", b + i);
	printf("%d\n", go(0, 0, 0));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc062.contest.atcoder.jp/tasks/arc074_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		sc.close();
		
		long ans = Math.min((H%3==0 ? 0:1)*W,(W%3==0 ? 0:1)*H);
		ans = Math.min(ans, getAreaDiff(W,H));
		ans = Math.min(ans, getAreaDiff(H,W));
		
		System.out.println(ans);
		
	}
	
	static long getAreaDiff(long w, long h){
		long diff = h*w;
		for(int i=1; i<h; i++){
			long h1 = i;
			long h2 = h-i;
			long a1 = h1*w;
			long a2 = h2*(w/2);
			long a3 = h2*(w-w/2);
			long area = Math.max(Math.max(a1,a2),a3) - Math.min(Math.min(a1,a2),a3);
			diff = Math.min(diff, area);
		}
		return diff;
	}

}


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

int main(){
  int N,M;
  
  cin >> N;
  cin >> M;
  
  int A[M];
  int T = 0;
  
  for(int i = 0; i < M; i++){
    cin >> A[i];
    T += A[i];
  }
  
  if(N >= T){
    cout << N - T << endl;
  }else{
    cout << -1 <<endl;
  }
}
  
  


Measured memory_bytes: 3636
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B;

int main() {
	scanf("%lld %lld", &A, &B);
	if((A + B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
	}
	else {
		ll ans = (A + B) / 2;	
		printf("%lld\n", ans);
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;
const int maxn = 100;
char s[maxn];
int num[30];

int main ()
{
    string v = "KIHBR";
    int flag = 1;
    cin >> s;
    int len = strlen(s);
    memset(num,0,sizeof(num));
    for (int i = 0;i < len;++i) {
        num[s[i]-'A']++;
    }
    string r = "";
    for (int i = 0;i < len;++i) {
        if (s[i] != 'A')
            r += s[i];
    }
    for(int i = 0; i < len - 1; i++){
    	if (s[i] == s[i+1] && s[i] == 'A') {
    		flag = 0;
    	}
    }
    int ans = 0;
    for (int i = 1;i < 30;++i) {
        if (num[i] == 1)
            ans++;
    }
    if (r != v) flag = 0;
    int ik,ii,ih;
    for (int i = 0;i < len;++i) {
        if (s[i] == 'K')
            ik = i;
        if (s[i] == 'I')
            ii = i;
        if (s[i] == 'H')
            ih = i;
    }
    if (!(ik+1 == ii && ii+1 == ih)) flag = 0;
    if (!flag)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

}


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

using namespace std;

int main(){
	int n;

	cin >> n;

	vector<double> x(n);

	vector<string> u(n);

	for (int i = 0; i < n; i++){
		cin >> x[i] >> u[i];
	}

	double sum = 0;

	for (int i = 0; i < n; i++){
		if (u[i] == "JPY")sum += x[i];
		else sum += 380000 * x[i];
	}

	cout << sum << endl;

	system("pause");

	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAXSIZE 10



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

    vector<string> t3(3); //2
    t3[0] = "aa.";
    t3[1] = "..b";
    t3[2] = "..b";

    vector<string> t4(4); //3
    t4[0] = "abcc";
    t4[1] = "abdd";
    t4[2] = "eefg";
    t4[3] = "hhfg";
    vector<string> t5(5); //3
    t5[0] = ".abcc";
    t5[1] = "eab..";
    t5[2] = "e.fgg";
    t5[3] = "hhf.i";
    t5[4] = "kkjji";
    vector<string> t7(7); //3
    t7[0] = "aa.bb.c";
    t7[1] = ".dd..fc";
    t7[2] = "e.a..f.";
    t7[3] = "e.aee..";
    t7[4] = "..ghhii";
    t7[5] = "..g..mn";
    t7[6] = "kk...mn";
    vector<string> ans(n,"");
    if(n==2){
        cout << -1 << endl;
        return 0;
    }
    if(n%3==0){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n/3; j++){
                ans[i] += t3[i%3];
            }
        }

    }else if(n%4==0){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n/4; j++){
                ans[i] += t4[i%4];
            }
        }

    }else if(n%5==0){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n/5; j++){
                ans[i] += t5[i%5];
            }
        }
    }else if(n%7==0){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n/7; j++){
                ans[i] += t7[i%7];
            }
        }
    }else if(n%4==1){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans[i] += '.';
            }
        }
        for(int i = 0; i < n-5; i++){
            ans[i].replace(4*(i/4),4, t4[i%4]);
        }
        for(int i = 0; i < 5; i++){
            ans[n-5+i].replace(n-5,5,t5[i]);
        }
    }else if(n%4==3){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans[i] += '.';
            }
        }
        for(int i = 0; i < n-7; i++){
            ans[i].replace(4*(i/4),4, t4[i%4]);
        }
        for(int i = 0; i < 7; i++){
            ans[n-7+i].replace(n-7,7,t7[i]);
        }
    }else if(n%4==2){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                ans[i] += '.';
            }
        }
        for(int i = 0; i < n-10; i++){
            ans[i].replace(4*(i/4),4, t4[i%4]);
        }
        for(int i = 0; i < 5; i++){
            ans[n-5+i].replace(n-5,5,t5[i]);
        }
        for(int i = 0; i < 5; i++){
            ans[n-10+i].replace(n-10,5,t5[i]);
        }
    }

    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }


    return 0;
}


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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,k,n,sum=0;
    cin>>n>>k>>x>>y;
    if(k>n){
            k=n;
            n=0;
    }
    else n-=k;
    while(k--)sum+=x;
    while(n--)sum+=y;
    cout<<sum<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t n; cin >> n;
	int64_t m; cin >> m;
	int64_t sum = 0;
	int64_t a[n];
	rep(i,n) {
		cin >> a[i];
		sum += a[i];
	}
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(4 * m * a[i] >= sum) {
			++ans;
		}
	}
	cout << (ans >= m ? "Yes" : "No") << '\n';
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    int mini = sum;
    int prefix = 0;
    for (int i = 0; i < N; i++)
    {
        prefix += a[i];
        mini = min(mini, abs(prefix - (sum - prefix)));
    }
    cout << mini << endl;
    return 0;
}

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


/*

#の周りを+1していく解き方。めんどい。
あと，いきなりs[i][j]てやっていいみたい。

int main (){

int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i=0; i<H; i++) cin >> S.at(i);
int field[H][W];
for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if(S.at(i).at(j)=='#') field[i][j]=-1;
        else field[i][j]=0;
    }
}

for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]==-1){
            for(int dx=-1; dx<=1; dx++){
                for(int dy=-1; dy<=1; dy++){
                    int nx=x+dx, ny=y+dy;
                    if(0<=nx && nx<H && 0<=ny && ny<W && field[nx][ny]!=-1){
                        field[nx][ny]++;
                    }
                }
            }
        }
    }
}
for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]>=0) cout << field[x][y];
        else cout << "#";
    }
    cout << endl;
}


}
*/
#define rep(i,n) for(int i=0; i<n; i++)
int main (){

int H, W;
cin >> H >> W;
string s[H+10];
rep(i,H) cin >> s[i];

rep(i,H){
    rep(j,W){
        if(s[i][j]=='#'){
        cout << "#";
        }
        else{
        int cnt=0;
        for(int dx=-1; dx<=1; dx++){
            for(int dy=-1; dy<=1; dy++){
                int nx=i+dx, ny=j+dy;
                if(0<=nx && nx<=H && 0<=ny && ny<=W && s[nx][ny]=='#')
                cnt++;
            }
        }
        cout << cnt;
        }
    }
    cout << endl;
}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int x, y;
	cin >> n >> x >> y;
  int k,l;
	vector<int>a(n,0);
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
          	k = i+1;
          	l = j+1;
			int g = abs(k - x);
			int p = abs(y - l);
			a[min(j - i,g+p+1)]++;
		}
	}
	for (int i = 1; i <= n - 1; i++) {
		cout << a[i] << endl;
	}
}


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

int main() {
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	string foo, bar;
  	cin >> foo >> bar;
  	int N = (int) foo.length();
  	int M = (int) bar.length();
  	int dp[N + 1][M + 1];
  	for(int i = 0; i <= N; ++i) {
  		for(int j = 0; j <= M; ++j) {
  			if(i == 0 || j == 0) {
  				dp[i][j] = 0;
  			} else {
  				if(foo[i - 1] == bar[j - 1]) {
  					dp[i][j] = 1 + dp[i - 1][j - 1];
  				} else {
  					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
  				}
  			}
  		}
  	}
  	string res = "";
  	int len = dp[N][M];
  	int i = N, j = M;
  	while(len) {
  		if(foo[i - 1] != bar[j - 1]) {
  			if(dp[i - 1][j] >= dp[i][j - 1]) i--;
  			else j--;
  		} else {
  			res += foo[i - 1];
  			i--,j--;
  			len--;
  		}
  	}
  	reverse(res.begin(), res.end());
  	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 35456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC148C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            long A = long.Parse(AB[0]);
            long B = long.Parse(AB[1]);
            if (A < B)
            {
                long temp = A;
                A = B;
                B = temp;
            }
            long ans = A;
            while (ans % B != 0)
            {
                ans += A;
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main(void)
{
  int a, b;
  int sum, length;
  char s[1000000 + 1000000];

  while (scanf("%d", &a) != EOF) {
    scanf("%d", &b);
    sum = a + b;
    //printf("%d\n", sum);
    sprintf(s, "%d", sum);
    length = strlen(s);
    printf("%d\n", length);
  }

  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x << endl)
#define mid (l + r) / 2
#define pii pair <int, int>
#define fi first
#define sc second

using namespace std;

#define int long long

const int N = 1e5 + 5;

int dp[N];

signed main(){
	ios::sync_with_stdio(0);
	for(int i=0; i<N; i++) dp[i] = LLONG_MAX;
	int h, n;
	cin >> h >> n;
	vector <pii> ar(n);
	for(int i=0; i<n; i++){
		cin >> ar[i].fi >> ar[i].sc;
		dp[ar[i].fi] = min(dp[ar[i].fi], ar[i].sc);
	}

	// [spell][cost]

	for(int i=0; i<N; i++){
		for(int j=0; j<n; j++){
			if(i < ar[j].fi) continue;
			if(dp[i-ar[j].fi] != LLONG_MAX){
				dp[i] = min(dp[i], dp[i-ar[j].fi] + ar[j].sc);
			}
		}
	}

	int res = LLONG_MAX;
	for(int i=h; i<N; i++){
		if(dp[i] != LLONG_MAX)
			res = min(res, dp[i]);
	}

	cout << res;

	return 0;
}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(string S){
    ll mx = 0;
    rep(i, sz(S)) {
        FOR(j, i, sz(S)) {
            string s = S.substr(i, j-i+1);
            // cout << s << endl;
            bool flag = true;
            rep(i, sz(s)) {
                if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') {
                    flag = false;
                    break;
                }
            }
            if (flag) mx = max(mx, sz(s));
        }
    }
    cout << mx << endl;
}

int main() {
  string S;
    cin >> S;
  solve(S);
  return 0;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	ll a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ll lcm = (c * d) / __gcd(c, d);
	ll repeat;
	a%lcm ==0? repeat = b/lcm - a/lcm + 1: repeat = b/lcm - (a/lcm);
	ll afirst; a%c == 0?afirst = b/c - a/c + 1: afirst = b/c - (a/c);
	ll bfirst; a%d == 0?bfirst = b/d - a/d + 1: bfirst = b/d - (a/d);
	ll result =(b - a + 1) -( afirst + bfirst - repeat);
	printf("%lld", result);
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

void main()
{
    int[] input = readln().split.to!(int[]);
    int N = input[0];
    int M = input[1];
    int C = input[2];
    auto blist = readln().split.to!(int[]);
    int count;
    foreach(int i; 0..N)
    {
        auto sList = readln().split.to!(int[]);
        long sum = 0;
        foreach(int k; 0..M)
        {
            sum += blist[k]*sList[k];
        }
        sum += C;
        count += sum > 0 ? 1 : 0;
    }
    writeln(count);
}

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

int main(){
	string s,t;
    int k=0;
    
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
    	if(s.at(i)!=t.at(i)) k++;
    }
    
    if(k!=0) {
    	cout << "No" << endl;
    } else{
      	cout << "Yes" << endl;
    }
  
  	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int n = s.length();
		boolean[] a = new boolean[100000];
		long MOD = 1000000007;
		
		for(int i = 0; i < n; i++)
			a[i] = s.charAt(i) == '1';
		
		long an = 0;
		
		long[] pow2 = new long[100005];
		long[] pow3 = new long[100005];
		
		long cp2 = 1;
		long cp3 = 1;
		for(int i = 0; i < 100005; i++)
		{
			pow2[i] = cp2;
			pow3[i] = cp3;
			cp2=(cp2*2)%MOD;
			cp3=(cp3*3)%MOD;
		}
		
		int ones = 0;
		for(int i = 0; i < n; i++)
		{
			if(a[i])
			{
				int digle = n-i-1;
				//this one is 0 and the rest is wildcard
				long cur = (pow3[digle] * pow2[ones])%MOD;
				an = (an+cur)%MOD;
				ones++;
				//rest it not all 0
			}
			else
			{
				//this one is 0 and the rest depends
				
			}
		}
		long cur = (pow2[ones])%MOD;
		an = (an+cur)%MOD;

		System.out.println(an);
	}

}


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

int main() {
	string b;
	cin >> b;
	if (b == "A"){
		cout << "T";
	}
	else if(b == "T"){
	 	cout << "A";
	}
	else if(b == "C"){
		cout << "G";
	}
	else{
		cout << "C";
	}
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int w; cin >> w;
    for(int i = 0; i < (int)s.size(); i += w){
        cout << s[i];
    }
    cout << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
char board[500][500];
int main() {
	int m, n; cin >> m >> n;
	vector<int> v;
	vector<P> alfloc[26];
	int out = 0;
	rep(i, m) {
		string s; cin >> s;
		rep(j, n) {
			board[i][j] = s[j];
			if (s[j] != '.') {
				int x = s[j] - 'A';
				if (alfloc[x].size()) {
					alfloc[x].push_back({ i,j });
				}
				else {
					v.push_back(x);
					alfloc[x].push_back({ i,j });
				}
			}
		}
	}
	int len = v.size();
	vector<int> inter[26][2];
	int used[26];
	fill(used, used + 26, 1);
	rep(i, len) {
		used[v[i]] = 0;
		int alf = v[i];
		int sx = alfloc[alf][0].first;
		int gx = alfloc[alf][1].first;
		int sy = alfloc[alf][0].second;
		int gy = alfloc[alf][1].second;
		if (abs(sx - gx) + abs(sy - gy) == 1) {
			inter[v[i]][0].push_back(v[i]);
			inter[v[i]][1].push_back(v[i]);
			continue;
		}
		int cnt = 0;
		if (sx > gx) {
			swap(sx, gx); cnt++;
		}
		if (sy > gy) {
			swap(sy, gy); cnt++;
		}
		Rep1(j, sx, gx) {
			char x1 = board[j][sy];
			char x2 = board[j][gy];
			if (x1 != '.'&&x1 - 'A' != v[i]) {
				inter[v[i]][0].push_back(x1 - 'A');
			}
			if (x2 != '.'&&x2 - 'A' != v[i]) {
				inter[v[i]][1].push_back(x2 - 'A');
			}
		}
		Rep1(j, sy, gy) {
			char x1 = board[sx][j];
			char x2 = board[gx][j];
			if (cnt % 2 == 0) {
				if (x1 != '.'&&x1 - 'A' != v[i]) {
					inter[v[i]][1].push_back(x1 - 'A');
				}
				if (x2 != '.'&&x2 - 'A' != v[i]) {
					inter[v[i]][0].push_back(x2 - 'A');
				}
			}
			else {
				if (x1 != '.'&&x1 - 'A' != v[i]) {
					inter[v[i]][0].push_back(x1 - 'A');
				}
				if (x2 != '.'&&x2 - 'A' != v[i]) {
					inter[v[i]][1].push_back(x2 - 'A');
				}
			}
		}
	}
	while (true) {
		bool f = true;
		rep(i, 26) {
			if (used[i])continue;
			rep(j, 2) {
			    bool g = true;
				rep(k, (int)inter[i][j].size()) {
					if (!used[inter[i][j][k]])g = false;
				}
				if (g) {
					f = false;
					used[i] = 1;
					out += 2;
					break;
				}
			}
		}
		if (f)break;
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3428
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 5223372036854775807
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=1000105;
const int NN=200005;
const ll md=1e9+7;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll m;
    cin >> m;
    ll n;
    cin >> n;
    ll a[N]={0};
    for (int i=1;i<=n;i++){
        cin >> a[i];
        m-=a[i];
    }
    if (m<0){
        cout << -1 << E;
    }else cout << m << E;
    r0;
}
/*











*/





Measured memory_bytes: 11420
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

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

int main()
{
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long ac,ad,acd,bc,bd,bcd;
	ac=(a-1)/c;
	ad=(a-1)/d;
	acd=(a-1)/(c*d/gcd(c,d));
	bc=b/c;
	bd=b/d;
	bcd=b/(c*d/gcd(c,d));

	cout << b-a+1-((bc+bd-bcd)-(ac+ad-acd)) << endl;




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second<b.second);
}

int main(){
    map<int,pair<int,int> >m;
    int a;
    vector<pair<int,int> >row,col,dia,v;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
        {
            cin>>a;
            m[a]={i+1,j+1};
        }
    }
    int n;
    cin>>n;
    int r[3]={0},c[3]={0},d[2]={0},d1=0,d2=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(m[a].first==0 && m[a].second==0)
            continue;
        else{
//            row.push_back(m[a]);
//            col.push_back(m[a]);
            //if(m[a].first==1)
            r[m[a].first-1]++;
            c[m[a].second-1]++;
            v.push_back(m[a]);
        }
    }
    sort(r,r+3,greater<int>());
    sort(c,c+3,greater<int>());
    bool f=0;
    if(r[0]==3 || c[0]==3){
        f=1;
    }
    else{
        sort(v.begin(),v.end());
        for(int i=0,j=1,k=3;i<v.size();i++){
                if(d1==3 || d2==3){
                    f=1;break;
                }
            if(v[i].first==v[i].second)
                d1++;
            if(v[i].first==j && v[i].second==k){
                d2++;
                j++;k--;
            }
        }
        if(d1==3 || d2==3)
            f=1;
    }
    if(f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
ans=[100*a,0]
for i in range(f//(100*a)+1):
  for j in range((f-100*a*i)//(100*b)+1):
    for k in range(f//c+1):
      if i==0 and j==0:
        break
      for l in range((f-c*k)//d+1):
        if 100*a*i+100*b*j+c*k+d*l>f:
          break
        elif c*k+d*l>(a*i+b*j)*e:
          break
        else:
          if (c*k+d*l)/(100*a*i+100*b*j+c*k+d*l)>ans[1]/ans[0]:
            ans=[100*a*i+100*b*j+c*k+d*l,c*k+d*l]
print(ans[0],ans[1])

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);

		String strt = input.readLine( );
		String[] tlist = strt.split(" ");
		int[] t = new int[n];
		int sum = 0;
		for(int i=0; i<n; i++){
			t[i] = Integer.parseInt(tlist[i]);
			sum = sum + t[i];
		}

		String strm = input.readLine( );
		int m = Integer.parseInt(strm);
		String[][] xlist = new String[m][];
		int answer = sum;

		for(int i=0; i<m; i++){
			String str = input.readLine( );
			xlist[i] = str.split(" ");
			answer = sum + Integer.parseInt(xlist[i][1]) - t[Integer.parseInt(xlist[i][0])-1];
			System.out.println(answer);
		}


	}

}


Measured memory_bytes: 8660
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n;

inline void work() {
    cin >> n;
    queue<LL> q;
    for (int i = 1; i < 10; ++i) {
        q.push(i);
    }
    for (int i = 1; i < n; ++i) {
        LL u = q.front();
        q.pop();
        int digit = u % 10;
        if (digit != 0) {
            q.push(u * 10 + digit - 1);
        }
        q.push(u * 10 + digit);
        if (digit != 9) {
            q.push(u * 10 + digit + 1);
        }
    }
    cout << q.front() << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  map<int,int>k;
  for(int i=0;i<N;i++){
    k[a[i]]++;
  }

  vector<int>p;//要素の種類を格納する配列
  int q=0;
  for(auto c:k){
    p.push_back(c.first);
    q^=c.first;
  }
  int s=k.size();
  if(k[0]==N){cout<<"Yes"<<endl;}
  else if(N%3!=0){
    if(k[0]==N){cout<<"Yes"<<endl;}
     else{cout<<"No"<<endl;}
  }
  else { 
    bool ok=false;
    if(s==3&&k[p[0]]==N/3&&k[p[1]]==N/3&&k[p[2]]==N/3){ok=true;}
    else if(k.size()==2){
      if(k[p[0]]==2*N/3){ok=true;q^=p[0];}
      if(k[p[1]]==2*N/3){ok=true;q^=p[1];}
    }
    if(q!=0){ok=false;}
    if(ok){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
  return 0;  
}

Measured memory_bytes: 7612
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean has1 = false;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] == 1) {
                has1= true;
            }
        }
        if (!has1) {
            System.out.println(-1);
            return;
        }

        int count = 0;
        int tmp = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] != tmp) {
                count++;
            } else {
                tmp++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 84532
#include <iostream>
#include <vector>

using namespace std;

vector <int> a (102);
vector <int> dp (100005, 0);

int main()
{
    int n, k;

    cin >> n >> k;

    for(int i = 0; i < n; i++)
        cin >> a[i];

    for(int i = 1; i <= k; i++)
        for(int j = 0; j < n; j++)
        {
            int last = i - a[j];

            if(last >= 0 && dp[last] == 0)
            {
                dp[i] = 1;
            }
        }


    if(dp[k] == 0)
    {
        cout << "Second";
        return 0;
    }

     cout << "First" ;


    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    if(k < a){
      System.out.println(k);
    }else if(k <= a + b){
      System.out.println(a);
    }else{
      System.out.println(2 * a + b - k);
    }
  }
}


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

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

  vector<ll> a(n), b(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll sign;
  ll tmp = 0;
  for (ll i = 0; i < n; i++) {
    sign = (i % 2) ? -1 : +1;
    tmp += sign * a[i];
  }
  b[0] = tmp;

  for (ll i = 1; i < n; i++) {
    b[i] = a[i - 1] * 2 - b[i - 1];
  }

  for (ll i = 0; i < n; i++) {
    cout << b[i] << " " << endl;
  }
}


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

int main()
{
    int n;
    cin>>n;
    string str1,str2,ans="";
    cin>>str1>>str2;
    for (int i = 0; i < n; ++i)
    {
        ans += str1[i];
        ans += str2[i];
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define size(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >>c;
  if(a == b){
    cout << c;
  }else if(a == c){
    cout << b;
  }else{
    cout << a;
  }
}

Measured memory_bytes: 256
////////////////////////////////////////////    _LeMur_
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;

string s , t;

int ind[27];
int go[N][27];

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
	cin >> s >> t;
	int n = (int)s.size();
	s += s;
	for(int i=0;i<26;i++){
        ind[i] = -1;
	}
	for(int i=(int)s.size()-1;i>=0;i--){
        for(int j=0;j<26;j++){
            if(ind[j] == -1)
                go[i][j] = ind[j];
            else
                go[i][j] = ind[j] - i + 1;
        }
        go[i][ s[i] - 'a' ] = 1;
        ind[ s[i] - 'a' ] = i;
	}
	int it = 0;
	long long len = 0;
	for(int i=0;i<(int)t.size();i++){
        int c = t[i] - 'a';
        if(go[it][c] == -1){
            cout << -1 << endl;
            return 0;
        }
        len += go[it][c];
        it = (it + go[it][c]) % n;
	}
	cout << len << endl;
    return 0;
}


Measured memory_bytes: 21788
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n,x;
	cin>>n>>x;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	int cnt=0;
	rep(i,n){
		if(x-a[i]>=0){
			x-=a[i];
			cnt++;
		}
	}
	if(cnt==n&&x>0){
		cnt--;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e9;
const int MAX_N = 500;

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    cout << (n-1+k-2)/(k-1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/range/adaptor/indexed.hpp>
#include <boost/range/adaptor/filtered.hpp>
#include <boost/algorithm/cxx11/all_of.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace boost::algorithm;
using chars_with_index = boost::range::index_value<char&, long int>;
int main()
{
    string s;
    cin >> s;

    auto is_odd = [](chars_with_index v) { return v.index() % 2 == 1; };
    auto is_even = [](chars_with_index v) { return v.index() % 2 == 0; };

    bool easy =
        all_of(s | indexed(1) | filtered(is_odd),
            [](chars_with_index v) { return v.value() == 'R' || v.value() == 'U' || v.value() == 'D'; })
        &&
        all_of(s | indexed(1) | filtered(is_even),
            [](chars_with_index v) { return v.value() == 'L' || v.value() == 'U' || v.value() == 'D'; });

    cout << (easy ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    L=[list(map(int,input().split())) for _ in range(m)]
    S=[]
    G=[]
    for l in L:
        if l[0]==1: S.append(l[1])
        if l[1]==n: G.append(l[0])
    print("POSSIBLE"if len(set(S)&set(G))>0 else "IMPOSSIBLE")
main()

Measured memory_bytes: 61100
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int b[N];
int main(){
	int n,k,Q;
	scanf("%d %d %d",&n,&k,&Q);
	for(int i=1;i<=Q;i++){
		int temp;
		scanf("%d",&temp);
		b[temp]++;
	}
	for(int i=1;i<=n;i++){
		a[i]=k-(Q-b[i]);
		if(a[i]<=0)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i, s, t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i, t, s) for(int i = (int)(t); i >= (int)(s); i--)
#define lson rt << 1
#define rson rt << 1 | 1
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double lb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> VI;
typedef std::vector<ll> VL;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> rbtree;
ll gcd(ll x, ll y){ return y % x == 0 ? x : gcd(y % x, x); }
template<class T>T my_abs(T a){ if(a < 0) a = -a; return a; }
inline ll read(){
    ll ret = 0, sign = 1;
    char c = getchar();
    while(c < '0' || c > '9'){ if(c == '-') sign = -1; c = getchar();}
    while(c >= '0' && c <= '9'){ ret = ret * 10 + c - '0'; c = getchar(); }
    return ret * sign;
}
inline void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

//void expand_stack_space(){
//    int size = 256 << 20; // 256MB
//    char *p = (char*)malloc(size) + size;
//    __asm__("movl %0, %%esp\n" :: "r"(p));
//}
const int maxn = 1e6 + 7;
char s[maxn];
int n;
pii a[maxn];
int main(){
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%s", s + 1);
        int len = strlen(s + 1);
        a[i].fi = a[i].se = 0;
        for(int j = 1; j <= len; ++j) {
            if(s[j] == ')' && a[i].se > 0) --a[i].se;
            if(s[j] == '(') ++a[i].se;
        }
        for(int j = len; j >= 1; --j) {
            if(s[j] == '(' && a[i].fi > 0) --a[i].fi;
            if(s[j] == ')') ++a[i].fi;
        }

        //printf("l r --- %d %d\n", a[i].fi, a[i].se);
    }
    sort(a + 1, a + n + 1, [](pii &x, pii &y) {
            if(x.se >= x.fi && y.se < y.fi) return true;
            if(x.se < x.fi && y.se >= y.fi) return false;
            if(x.se >= x.fi && y.se >= y.fi) return x.fi < y.fi;
            if(x.fi >= x.se && y.fi >= y.se) return x.se > y.se;
         });
    if(a[1].fi != 0) return !printf("No");
    int st = a[1].se;
    for(int i = 2; i <= n; ++i) {
        st -= a[i].fi;
        if(st < 0) return !printf("No");
        st += a[i].se;
    }
    if(st > 0) return !printf("No");
    puts("Yes");
    return 0;
}


Measured memory_bytes: 11524
#include <stdio.h>
 
#define REP(i,n) for(unsigned long long i=0;i<(n);i++)
#define FOR(i,a,b) for(unsigned long long i=(a);i<(b);i++)
 
template<class T>
T maxs(T &a, const T &b){
	if(a < b) a = b;
	return a;
}
 
unsigned long long n, table[110000], max, ans;
 
int main(void){
	scanf("%llu", &n);
	REP(i, n){
		unsigned long long a;
		scanf("%llu", &a);
		table[a]++;
		table[a + 1]++;
		table[a + 2]++;
		maxs(max, a);
	}
	REP(i, max + 1) maxs(ans, table[i]);
	printf("%llu\n", ans);
}

Measured memory_bytes: 896