akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	
	void solve() {
		int N = sc.nextInt();
		int[] A = sc.nextIntArray(3 * N);
		
		long[] B = new long[3 * N + 1];
		long[] C = new long[3 * N + 1];
		
		{
			PriorityQueue<Integer> q= new PriorityQueue<>();
			long sum = 0;
			for (int i = 0; i < N; i++) {
				sum += A[i];
				q.add(A[i]);
			}
			for (int i = N; i <= 3 * N; i++) {
				B[i] = sum;
				if (i < 3 * N) {
					sum += A[i];
					q.add(A[i]);
					sum -= q.poll();
				}
			}
//			tr(B);
		}
		{
			PriorityQueue<Integer> q = new PriorityQueue<>();
			long sum = 0;
			for (int i = 3*N-1; i >= 2*N; i--) {
				sum += A[i];
				q.add(-A[i]);
			}
			for (int i = 2*N-1; i >= 0; i--) {
				C[i+1] = sum;
				sum += A[i];
				q.add(-A[i]);
				sum += q.poll();
			}
			C[0] = sum;
//			tr(C);
		}
		long ans = -(1L << 58);
		for (int i = N; i <= 2*N; i++) {
			ans = max(B[i] - C[i], ans);
		}
		out.println(ans);
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

int main(){

    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> a[i][j];
        }
    }

    vector<vector<int>> b(m, vector<int>(l));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < l; ++j){
            cin >> b[i][j];
        }
    }

    vector<vector<long long>> matrix(n, vector<long long>(l));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            for(int k = 0; k < m; ++k){
                matrix[i][j] += (long long) a[i][k] * (long long) b[k][j];
            }
        }
    }
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            cout << matrix[i][j];
            if(j == l-1){
                cout << endl;
            }
            else{
                cout << ' ';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define INF 2e9
#define N 3000
using namespace std;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f; 
}
int n,m;
bool a[N];
struct Edge{
	int v,nxt;
}e[N<<1];
int head[N],size;
void add(int u,int v)
{
	e[++size].v=v;
	e[size].nxt=head[u];
	head[u]=size;
}
int dep[N],f[N],sum[N],pct[N];
void dfs(int u,int fa)
{
	dep[u]=dep[fa]+1;
	int pos=0;
	sum[u]=0;
	pct[u]=a[u];
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(v==fa)continue;
		dfs(v,u);
		sum[v]+=pct[v];
		sum[u]=sum[u]+sum[v];
		pct[u]+=pct[v];
		if(sum[v]+pct[v]>sum[pos]+pct[pos])pos=v;
	}
	if(2*sum[pos]<=sum[u])f[u]=sum[u]/2;
	else f[u]=sum[u]-sum[pos]+min(f[pos],(2*sum[pos]-sum[u])/2);
}
int main()
{
	n=read();	
	for(int i=1;i<=n;++i)scanf("%1d",&a[i]);
	for(int i=1;i<n;++i)
	{
		int x=read(),y=read();
		add(x,y);
		add(y,x);
	}
	dep[0]=-1;
	int ans=INF;
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(2*f[i]==sum[i])ans=min(ans,f[i]); 
	}
	if(ans==INF)ans=-1;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
#include <assert.h>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    string S;
    cin >> S;
    if(S[S.size()-1]=='s'){
        S = S+"es";
        cout << S <<endl;
    }else{
        S = S+"s";
        cout << S <<endl;

    }

}

int main(){
    Main();
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef long long ll ;
using namespace std;

int main()
{
    FAST;
    int a[3];
    cin>>a[1]>>a[2]>>a[0];
    cout<<a[0]<<" "<<a[1]<<" "<<a[2];
    return 0;
}


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

int main() {
    int N; cin>>N;
    double ans=0;
    for (int i = 0; i < N; i++){
        int A;cin>>A;
        ans+=1.0/A;
    }
    printf("%.6f\n",1.0/ans);
}

Measured memory_bytes: 3764
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Dec 19 22:13:45 2018
//
package main

import "fmt"

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	if isPrime(M) {
		fmt.Println(1)
		return
	}

	for i := N; i <= M; i++ {
		if M%i == 0 {
			fmt.Println(M / i)
			return
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MN 700
using namespace std;
inline int read()
{
	int x=0,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();}
	return x*f;
}
bitset<705> b;
int s[MN+5][MN+5],n,m,vis[MN+5],c[MN+5],flag,num[2];
void dfs(int x,int v)
{
	vis[x]=1;c[x]=v;++num[v];
	for(int j=1;j<=n;++j) if(j!=x&&!s[x][j])
	{
		if(!vis[j]) dfs(j,v^1);
		else if(c[j]!=v^1) flag=1;	
	}
}
int main()
{
	n=read();m=read();b[0]=1;
	for(int i=1;i<=m;++i) 
	{
		int x=read(),y=read();
		s[x][y]=s[y][x]=1;	
	}
	for(int i=1;i<=n;++i) 
		if(!vis[i]) num[0]=num[1]=0,dfs(i,0),b=(b<<num[0])|(b<<num[1]);
	if(flag) return 0*puts("-1");int ans=1e9;
	for(int j=0;j<=n;++j) if(b[j]) ans=min(ans,j*(j-1)/2+(n-j)*(n-j-1)/2);
	cout<<ans; 
	return 0;
}
 

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n; cin>>n;
	int ans=0;
	if(n==10 or n==100 or n==1000 or n==10000 or n==100000) ans=10;
	else{
		ans+=n/100000;
		n%=100000;
		ans+=n/10000;
		n%=10000;
		ans+=n/1000;
		n%=1000;
		ans+=n/100;
		n%=100;
		ans+=n/10+n%10;
	}
	cout<<ans<<endl;
	return 0;
}


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

using ll = long long int;
const ll INF = 1e18;

int main() {
  int a, b, q;
  std::cin >> a >> b >> q;
  std::vector<ll> s;
  std::vector<ll> t;
  s.push_back(-INF);
  t.push_back(-INF);
  for (int i = 0; i < a; i++) {
    ll x;
    std::cin >> x;
    s.push_back(x);
  }
  for (int i = 0; i < b; i++) {
    ll x;
    std::cin >> x;
    t.push_back(x);
  }
  s.push_back(INF);
  t.push_back(INF);

  for (int i = 0; i < q; i++) {
    long long int x;
    std::cin >> x;
    ll ns = std::upper_bound(s.begin(), s.end(), x) - s.begin() - 1;
    ll nsp = std::lower_bound(s.begin(), s.end(), x) - s.begin();
    ll nt = std::upper_bound(t.begin(), t.end(), x) - t.begin() - 1;
    ll ntp = std::lower_bound(t.begin(), t.end(), x) - t.begin();
    std::vector<ll> ss = {s[ns], s[nsp]};
    std::vector<ll> tt = {t[nt], t[ntp]};
    ll ans = INF;
    for (auto s : ss) {
      for (auto t : tt) {
        ll d1 = std::abs(s - x) + std::abs(t - s);
        ll d2 = std::abs(t - x) + std::abs(s - t);
        ans = std::min(ans, std::min(d1, d2));
      }
    }
    std::cout << ans << std::endl;
  }
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long long> points(n);

  for(int i = 0; i < n; i++) {
    cin >> points.at(i);
  }

  for(int i = k; i < n; i++) {
    if(points.at(i - k) < points.at(i)) {
      cout << "Yes" << endl; 
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int N;string A,B,C;cin>>N>>A>>B>>C;
	int ans=0;int a=0;
	rep(i,N){
		if(A.at(i)==B.at(i)){
			a++;
		}
		if(B.at(i)==C.at(i)){
			a++;
		}
		if(C.at(i)==A.at(i)){
			a++;
		}
		if(a==0){
			ans++;
			ans++;
		}else if(a==1){
			ans++;
		}else if(a==3){

		}
		a=0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll n;
  cin>>n; n;
	vv<int> g(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b; --a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}
	vector<int> d(n,MOD);
	{
		d[0]=0;
		queue<int> que; que.emplace(0);
		while(que.size()){
			int v=que.front(); que.pop();
			for(int w:g[v])if(MN(d[w],d[v]+1)) que.emplace(w);
		}
	}
	out(d,1);
	vector<int> os,es;
	rep(i,n) (d[i]%2?es:os).pb(i);
	vector<int> re(n);
	reps(o,1,3){
		if(os.size()>es.size()) swap(os,es);
		for(int v=o;v<=n;v+=3){
			re[es.back()]=v;
			es.pop_back();
		}
	}
	os.insert(os.end(),all(es));
	for(int v=3;v<=n;v+=3){
		re[os.back()]=v;
		os.pop_back();
	}
	rep(i,n) cout<<re[i]<<" \n"[i+1==n];
	return 0;
}


Measured memory_bytes: 15728
#include <iostream>
#include <string>
using namespace std;
int main(){

    int n;
    string s;

    cin >> n >> s;
    for (int i = 0; i < s.length();i++){
        int x = (int)s[i] + n;

        if (x > 90)
            x = x - 26;

        s[i] = (char)x;
        cout << s[i];
    }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
string s;
int a=0,b=0,c=0,d=0;
signed main(){
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='N'){
			a++;
		}elif(s[i]=='W'){
			b++;
		}elif(s[i]=='S'){
			c++;
		}else{
			d++;
		}
	}
	if(((a>0&&c>0)||(a==0&&c==0))&&((b>0&&d>0)||(b==0&&d==0))){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;



int32_t main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif



	long long int  i, j, n, d, sum = 0;

	cin >> n;

	int v[n];

	int mx = 0;

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




	for (int i = 0; i < n; ++i)
	{
		mx = max(mx, v[i]);

		sum = sum + (mx - v[i]);

	}

	cout << sum << endl;


}

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

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        int n = 3;
        
        if(a==b&&a==c) n -= 2;
        else if(a == b) n--;
        else if(a == c) n--;
        else if(b == c) n--;

        System.out.print( n );
        System.out.println();
	}
}

Measured memory_bytes: 9684
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
long long sweep=min(k,x/d);
x-=sweep*d;
  k-=sweep;
  
  if(k%2==0)
    cout<<x<<endl;
  else
    cout<<d-x<<endl;
  
}

Measured memory_bytes: 3636
n,m = map(int,input().split())
mod = int(1e9+7)
f = [True for i in range(n+1)]
for i in range(m):
	f[int(input())] = False
dp=[1]+[0 for i in range(n+1)]
for i in range(n):
	if f[i+1]:
		dp[i+1] = (dp[i]+dp[i-1])%mod
print(dp[n])

Measured memory_bytes: 7808
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  unsigned long long H, W;

  cin >> H >> W;
  if (H == 1 or W == 1) {
    cout << 1;
  } else {
    if (H % 2 == 0 or W % 2 == 0) {
      cout << W * H / 2;
    } else {
      cout << W * (H / 2) + W / 2 + 1;
    }
  }
}

Measured memory_bytes: 3528
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200001)

typedef struct _range {
    int upper, lower;
    struct _range *ubound, *lbound;
} Range;

Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    return range;
}

int idx[N_MAX];
long long sum;
Range range;

void calc(int value, int index) {
    Range *tmp = &range;
    long long len1, len2, len3;
    for (;;) {
        if (tmp->lower <= index && index <= tmp->upper) {
            len1 = (long long)(tmp->upper - tmp->lower + 1);
            len2 = (long long)(tmp->upper - index);
            len3 = (long long)(index - tmp->lower);
            sum += ((len1 * (len1 + 1LL) - (len2 * (len2 + 1LL)) - (len3 * (len3 + 1LL))) )  * (long long)value;
            if (tmp->lower == index) {
                tmp->lower++;
            } else if (tmp->upper == index) {
                tmp->upper--;
            } else {
                tmp->lbound = newRange(tmp->lower, index - 1);
                tmp->ubound = newRange(index + 1, tmp->upper);
                tmp->lower = tmp->upper = index;
            }
            break;
        } else if (index < tmp->lower) {
            tmp = tmp->lbound;
        } else {
            tmp = tmp->ubound;
        }
    }
}

char buf[N_MAX * 10];
char *p = buf;

int getInt(void) {
    int v = 0;
    while (*p < '0' || '9' < *p) p++;
    while ('0' <= *p && *p <= '9') {
        v = v * 10 + (int)(*p - '0');
        p++;
    }
    return v;
}

int main(void){
    int i, n;
    int a;
    
    a = fread(buf, sizeof(char), sizeof(buf), stdin);
    
    n = getInt();

    for (i = 0; i < n; i++) {
        a = getInt();
        idx[a] = i;
    }
    
    range.upper = n - 1;
    
    for (i = 1; i <= n; i++) {
        calc(i, idx[i]);
    }
    
    printf("%lld\n", sum / 2LL);

    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
int main(void){
int N,X[101],i,a;
  double ave=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&X[i]);
    ave+=X[i];
  }
  ave=(int)(ave/N+0.5);
  for(i=0;i<N;i++){
	a+=(X[i]-ave)*(X[i]-ave);
  }
  printf("%d",a);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;
int main(){

	int a,b;
	int d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	cout<<d<<" "<<r<<" "<< fixed <<  setprecision(6)<<  f<<endl;
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#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)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
        ll n;
        cin>>n;
        ll x;
        cin>>x;
        vll v(n);
        forn(i,n)cin>>v[i];
        if(n%2==0){
            v.pb(0);
            ++n;
        }
        vll o=v;
        ll ans=0;
        //for(ll i=1; i<n; i+=2)v[i]-=min(max(0LL,max(v[i]+v[i+1]-x,(v[i]+v[i-1])-x)),v[i]);
        //for(ll i=0; i<n; i+=2)if(v[i]>x)v[i]+=x-v[i];
        for(ll i=1;i<n;i++){
            if(v[i]+v[i-1]>x){
                v[i]-=min(v[i],v[i]+v[i-1]-x);
            }
        }
        if(v[0]>x)v[0]-=(v[0]-x);
        //forn(i,n)cout<<v[i]<<' ';cout<<endl;
        forn(i,n)ans+=o[i]-v[i];
        cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int A, B; std::cin >> A >> B;
	int all = 1;
	int ans = 0;
	while (all < B) {
		--all;
		all += A;
		++ans;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N;
    cin>>N;
    vector<int> Vec(N);
    for (int i=0;i<N; i++){
        cin>>Vec.at(i);
    }
    vector<int> Neo(N);
    for (int i=0; i<N; i++){
        Neo.at(Vec.at(i)-1)=i+1;
    }
   for (int i=0; i<N;i++){
       cout<<Neo.at(i);
       if(i<N-1){
           cout<<" ";
       }
   }
    
}

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

using namespace std;

int main(void)
{
  string s, t;
  cin >> s >> t;
  bool res = false;
  for (int i = 0; i < s.size(); ++i) {
    rotate(s.begin(), s.begin() + 1, s.end());
    if (s == t) res = true;
  }
  cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long k=sc.nextLong();
		long[] h = new long[(int) n];
		
		for(int i=0;i<n;i++) {
			h[i]=sc.nextLong();
		}

		Arrays.sort(h);
		long sum=0;
		
		for(int i=0;i<n-k;i++) {
			sum+=h[i];
		}
		
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 60768
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (b); i >= (a); i--)
#define trav(a, x) for (auto& a : x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define dbg(x) cerr<<#x" = "<<x<<endl
ll powmod(ll a, ll b, ll m) {ll res = 1; a %= m; for (; b; b >>= 1) {if (b & 1) res = res * a % m; a = a * a % m;} return res;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template<typename T>
inline void read(T &t) {register int c = getchar(); t = 0; while (!isdigit(c))c = getchar();while (isdigit(c)) t = t * 10 + c - 48, c = getchar();}
template<typename T>
inline void write(T x) {static int sta[70]; int top = 0; do {sta[top++] = x % 10, x /= 10;} while (x); while (top) putchar(sta[--top] + 48); putchar('\n');}

//POJ
//#include <iostream>
//#include <vector>
//#include <algorithm>
//#include <cstring>
//#include <queue>
//#include <map>
//#include <iomanip>
//
//using namespace std;
//typedef long long ll;
const int MOD = 1e9 + 7;  // 998244353
const int INF = 0x3f3f3f3f;  //1e20
const int MAXN = 1 << 11;
const int MAXM = 60;

int T;
string s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    string cur = s.substr(0, 1);
    int ans = 1;
    for(int i = 1; i < sz(s); i++){
        if(sz(cur) == 2){
            cur = s.substr(i, 1);
            ans++;
            continue;
        }
        if(s.substr(i, 1) == cur){
            if(i == sz(s) - 1){
                break;
            }
            else{
                cur = s.substr(i, 2);
                i++;
                ans++;
            }
        }
        else{
            cur = s.substr(i, 1);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);

int main() {

    fastio;


    ll n;
    vector<ll> height(100005);
    vector<ll> dp(100005);

    cin >> n;
    for(ll i = 0; i < n; i++) cin >> height[i];

    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);

    for(ll i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1] + abs(height[i] - height[i-1]) , dp[i-2] + abs(height[i] - height[i-2]));
    }
    cout << dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int h, w;
	char ch[] = "#.";
	register int i, j;
	while (1) {
		scanf("%d %d", &h, &w);
		if ((h == 0) && (w == 0)) {
			break;
		}
		for (j = 0; j++ < h; ) {
			for (i = 0; i++ < w; ) {
				putchar(ch[(i + j) & 1]);
			}
			putchar('\n');
		}
		putchar('\n');
	}
	
	return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	int n;
	cin >> n;
	set<int> s;
	int a;
	while(n--) {
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3612
n, k = map(int, input().split())
count = 0

if k % 2 != 0:
    print((n // k) ** 3)
else:
    for i in range(1, n + 1):
        if i % k == (k // 2):
            count += 1
    print(count ** 3 + (n // k) ** 3)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main(){
    int a,b,c,buf;
    cin >> a >> b >> c;
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    if(b>c){
        buf=b;
        b=c;
        c=buf;
    }
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    cout << a << " "<< b << " " << c << endl;
     
    return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  while (b <= a) {
    b *= 2;
    k--;
  }
  while (c <= b) {
    c *= 2;
    k--;
  }
  if (k >= 0) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0))
    cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>

using namespace std;

int main(){
    int p[4][4];
    int a,b;

    FOR(i,0,4){
        FOR(j,0,4){
            p[i][j]=0;
        }
    }

    FOR(i,0,3){
        cin >> a >> b;
        p[a-1][b-1]=1;
        p[b-1][a-1]=1;  
    }

    int point=0;
    int tmp=0;
    FOR(i,0,4){
        tmp = 0;
        FOR(j,0,4){
            if(p[i][j]==1)
                tmp++;
        }
        if(tmp%2==1){
            point++;
        }
    }

    cout << ( (point==2 || point==0) ? "YES" : "NO") << endl;
    return 0;
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> city(N);

    for(int i=0; i < M; i++){
        int from, to;
        cin >> from >> to;
        city.at(from-1)++;
        city.at(to-1)++;
    }
    
    for(int i=0; i < N; i++){
        cout << city.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c; cin >> a >> b >> c;
  if(c > a+b) {
    cout << a+b+b+1 << endk;
  } else {
    cout << c+b << endk;
  }
  return 0;
}


Measured memory_bytes: 3624
s = list(input())
t = ["A", "K", "I", "H", "A", "B", "A", "R", "A"]


if s[-1] != "A":
    s = s + ["A"]
for i in range(len(t)):
    if len(s) <= i: break
    if t[i] != s[i] and t[i] != "A":
        break
    if t[i] != s[i] and t[i] == "A":
        s.insert(i, "A")

if s == t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;

int h, w, k, m, j, m1;
string s[10];
int a[10], b[10];

int main()
{
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
		cin >> s[i];

	m = h + w;

	for (int t = 0; t < (1 << (h - 1)); t++) {
		int c = 0;

		for (int d = 0; d < h - 1; d++)
			if ((1 << d) & t)
				c++;

		j = 0;
		m1 = c;
		memset(b, 0, sizeof(b));

		bool g = 1;

		while (g && j < w) {
			memset(a, 0, sizeof(a));
			int d = 0;

			for (int i = 0; i < h; i++) {
				if (s[i][j] == '1')
					a[d]++;

				if ((1 << i) & t)
					d++;
			}

			for (int i = 0; i < c + 1; i++) {
				if (a[i] > k) {
					g = 0;
					break;
				}
			}

			if (g) {
				bool f = 1;

				for (int i = 0; i < c + 1; i++) {
					if (b[i] + a[i] > k) {
						f = 0;
						break;
					}
				}

				if (f) {
					for (int i = 0; i < c + 1; i++)
						b[i] += a[i];
				}
				else {
					memcpy(b, a, sizeof(a));
					m1++;
				}

				j++;
			}
		}

		if(g)
			m = min(m, m1);
	}

	cout << m << endl;
}


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

typedef struct city_s{
    int Y;
    int P;
    int num;
    int rank;
    
    bool operator < (const city_s& t) const{
        if(P < t.P)return true;
        if(P == t.P && Y<t.Y )return true;
        return false;
    }
    bool operator > (const city_s& t) const{
        if(num < t.num)return true;
        return false;
    }

    
}city;

city C[100000];
int N,M;

int main(void){
    cin >> N>>M;
    rep(i,M){
        cin >> C[i].P >> C[i].Y;
        C[i].num = i;
    }
    sort(C,C+M);
    C[0].rank=1;
    rep(i,M-1){
        if(C[i].P == C[i+1].P)C[i+1].rank=C[i].rank+1;
        else C[i+1].rank=1;
    }
    sort(C,C+M,greater<city>());
    //rep(i,M)cout << C[i].num <<" " << C[i].P << " " << C[i].Y << " " << C[i].rank << endl;
    rep(i,M){
            cout << setfill('0') << right << setw(6);
        cout<<C[i].P;
            cout << setfill('0') << right << setw(6);
        cout << C[i].rank;
        cout << endl;
    }
}


Measured memory_bytes: 3072
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

bool _check(ll a[],ll b[], ll n){
    for(ll i=0;i<n;i++){
        if(a[i]!=b[i]){
            return false;
        }
    }
    return true;
}

int main(){


    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;
    bool flag=s[2]==s[3] && s[4]==s[5];
    cout<<(flag?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define vii vector<int,int>
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;
const int INF = 1e18L + 7 ;

int main(){fast ;
	ll n,w ;
	cin >> n >> w ;
	vector<ll>wt(n),val(n) ;
	
	for(int i=0;i<n;i++)
		cin >> wt[i] >> val[i] ;
		
	ll sm_val = 0 ;
	for(auto i:val)
		sm_val += i ;
	
	vector<ll>dp(sm_val+1,INF) ;
	dp[0] = 0 ;
    for(int item = 0; item < n; ++item) {
        for(int j = sm_val - val[item]; j >= 0; --j) {
            dp[j+val[item]] = min(dp[j+val[item]], dp[j] + wt[item]);
        }
    }
	ll res = 0 ;
	for(ll i=0;i<=sm_val;i++){
		if(dp[i]<= w)
			res = max(res,i) ;
	}
	
	cout << res << endl ;
}




Measured memory_bytes: 1024
from collections import defaultdict
n = int(input())
lis = []
dd = defaultdict(int)
for i in range(n):
  s = input() 
  
  lis.append(s)
  if i==0:
    for j in range(len(s)):
      dd[s[j]]+=1
  else:
    tmp = defaultdict(int)
    for j in range(len(s)):
      tmp[s[j]]+=1 
    for key in dd.keys():
      if dd[key]!=0 and tmp[key]!=0:
        dd[key] = min(dd[key], tmp[key])
      else:
        dd[key]=0
        

res = []
for key in dd.keys():
  if dd[key]!=0:
    res.append(key*dd[key])
res.sort()
print(''.join(res))



Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<vector<ll>> a(n, vector<ll>(3));
  for(int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    a[i][2] = a[i][0] + a[i][1];
  }
  sort(a.begin(), a.end(),
      [](const vector<ll> &l, const vector<ll> &r) { return l[2] > r[2]; });
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      ans += a[i][0];
    } else {
      ans -= a[i][1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8744
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, a, b;

int main() {
	cin >> n >> a >> b;
	if (b % 2 == a % 2) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
	  long amount = 100;
		long count = 0;
      	while(amount <X){
          amount = (long)(amount*1.01);
            count++;
        } 
      System.out.println(count);
}
}

Measured memory_bytes: 35708
total = 0
temp = 0
S = input()

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'G' or S[i] == 'C' or S[i] == 'T':
        temp += 1
    else:
        if temp > total:
            total = temp
        temp = 0

if temp > total:
    total = temp

print(total)


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();

        int min = Integer.MAX_VALUE;
        for (int i = 1; i <= n / 2; i++) {
            int j = n - i;
            min = Math.min(min, calc(i) + calc(j));
        }
        out.println(min);
    }

    int calc(int a) {
        int x = 0;
        while (a > 0) {
            x += a % 10;
            a /= 10;
        }
        return x;
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 100000; i++) {
    if (i  * 8 / 100 == a && i * 10 / 100 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 0x7fffffff
#define MAXN 100010
#define MOD 1000000007
#define int long long
using namespace std;
inline int read(){
	int ret=0,pos=1;char c=getchar();
	while(!isdigit(c) && c!='-' ) c=getchar();
	if(c=='-')	pos=-1,c=getchar();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
	return pos*ret;
}
inline int fst_pow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=(a*a)%MOD)	if(b&1)	ret=a*ret%MOD;
	return ret;
}

int n,k,inv[200010],fac[200010],sum=1;

int F(int x,int y){
	if(y>x)	return 0 ;
	return ((fac[x]*inv[y])%MOD)*inv[x-y]%MOD;
}


signed main(){
	cin>>n>>k;
	inv[0]=1;fac[0]=1;
	for(int i=1;i<=n;++i)	fac[i]=(int)(fac[i-1]*i)%MOD,inv[i]=fst_pow(fac[i],MOD-2);
	for(int i=1;i<=min(n-1,k);++i){
		int ssum=F(n,i);
		int t=n-i,u=F(n-1,n-t);
		sum=(sum+ssum*u%MOD)%MOD;
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main(void){
   
   string s,d="keyence";
   int a=0,c=0;

   cin>>s;
   a=s.size();
   int b=s.find("keyence");
    if(b!=-1) cout<<"YES"<<endl;
    else if(b==-1){
        for(int i=0;i<7;i++){
            if(s[i]!=d[i]){
            c=i;
            break;
            } 
        }
       //cout<<c;
       //cout<<s.substr(a-c-1)<<" "<<d.substr(c)<<endl;
        if(d.substr(c)==s.substr(a-7+c)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
   
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	int ans=x/(y+z);
	if(x%(y+z)<z)
	{
		ans--;
		printf("%d\n",ans);
	}
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

int h,w,a[11][11];
void input()
{
    cin>> h>> w;
    up(i,0,9)
     up(j,0,9)
      cin>> a[i][j];

}
void solve()
{
	up(k,0,9)
     up(i,0,9)
      up(j,0,9)
       a[i][j]= min(a[i][j], a[i][k]+ a[k][j]);
    long res= 0;
    up(i,1,h)
     up(j,1,w)
     {
     	int b; cin>> b;
     	if (b>=0) res+= a[b][1];
     }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		double[] con = new double[6];
		while (sc.hasNext()) {
			for (int i = 0; i < 6; i++) {
				con[i] = sc.nextInt();
			}
			double x = 0;
			double y = 0;
			x = (con[2] * con[4] - con[1] * con[5]) / (con[0] * con[4] - con[1] * con[3]);
			y = (con[2] * con[3] - con[0] * con[5]) / (con[1] * con[3] - con[0] * con[4]);
			BigDecimal xx = new BigDecimal(x);
			BigDecimal yy = new BigDecimal(y);
			xx = xx.setScale(3, BigDecimal.ROUND_HALF_UP);
			yy = yy.setScale(3, BigDecimal.ROUND_HALF_UP);

			System.out.println(xx + " " + yy);
		}

	}

}

Measured memory_bytes: 26472
N = int(input())
AAA = [int(i) for i in input().split()]
BBB = [0]
for a in AAA:
    BBB.append(a+BBB[-1])
ans=[]
#print(BBB)
BBB=sorted(BBB)
#print(BBB)
prev = float("inf")
buff=BBB[0]
ans=[]
for i,b in enumerate(BBB):
    #print(b,prev,buff)
    if b==prev:
        buff+=1
    else:
        if buff>=2:
            #print("append!")
            ans.append(buff)
        buff=1
        prev=b
if buff!=1:
    ans.append(buff)
#print(ans)
print(sum([(i-1)*i//2 for i in ans]))

Measured memory_bytes: 26136
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s ;
   cin>>s;
   int k ;
   cin>>k;
   int le = s.size() ;
   set<string> st;
   vector<int>g[26];
    
    for(int i = 0 ; i < le ; i++ )
    {
        g[s[i]-'a'].push_back(i);
    }
    
    for( int i=0 ; i<26  && st.size() < k ; i++ )
    {
        int len = g[i].size () ;
         if(len) 
         st.insert(s.substr(g[i][0] , 1 ));
              for ( int j = 0 ; j < len ; j++ )
              {
                  for( int  xx = g[i][j] + 1 ; xx < min( g[i][j] + 5,le ) ; xx++ )
                  {
                      st.insert ( s.substr( g[i][j] , xx- g[i][j] + 1 ));
                  }
              }
        
    }
        
    
    int cnt=1;
    for( auto it = st.begin() ; it!= st.end() ; ++it )
    {
        if(cnt == k)
        {
            
            cout<<*it<<endl;
            break;
        }
        cnt++;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 200100;
int a[120];
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    int n;scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    int ma=1,mi=1;
    for(int i=2;i<=n;++i){
        if(a[i]>a[ma])ma=i;
        if(a[i]<a[mi])mi=i;
    }
    printf("%d\n",2*(n-1));
    if(a[ma]>=0&&abs(a[ma])>=abs(a[mi])){
        for(int i=1;i<=n;++i)if(i!=ma)printf("%d %d\n",ma,i);
        for(int i=1;i<n;++i)printf("%d %d\n",i,i+1);
    }else{
        for(int i=1;i<=n;++i)if(i!=mi)printf("%d %d\n",mi,i);
        for(int i=n;i>1;--i)printf("%d %d\n",i,i-1);
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
q = int(input())
h,t = [],[]
p = 0

for i in range(q):
    c = input().split()
    if c[0] =='1':
        h,t = t,h
        p = 1-p
    else:
        if c[1] =='1':
            h.append(c[2])
        else:
            t.append(c[2])
if p ==1:
    s = s[::-1]
print("".join(h[::-1])+s+"".join(t))

Measured memory_bytes: 12144
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] O = sc.next().toCharArray();
		char[] E = sc.next().toCharArray();
		StringBuffer sb = new StringBuffer();
		int cnt = 0;
		while (true) {
			if (cnt == O.length) break;
			sb.append(O[cnt]);
			if (cnt < E.length) sb.append(E[cnt]);
			cnt++;
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    long int a,b;
    cin >> a;
    cin >> b;


    long int h_l, h_h, t_l, t_h;

    h_l = ceil(double(a)*100.0/8.0);
    if (floor(double(a+1)*100.0/8.0)==double(a+1)*100.0/8.0)
    {
        h_h = int(double(a+1)*100.0/8.0) - 1;
    } else
    {
        h_h = int(double(a+1)*100.0/8.0);
    }
    
    
    

    t_l = ceil(double(b)*100.0/10.0);
    t_h = int(double(b+1)*100.0/10.0) - 1;

    if (h_h < t_l || t_h < h_l)
    {
        cout << -1 << endl;
    }else
    {
        cout << max(h_l,t_l) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*input
3
1 1 1
13 5 7
*/
#include "bits/stdc++.h"
using namespace std;
long long a[200005],b[200005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n;
	priority_queue<pair<long long,int>> pq;
	for(int i=0;i<n;++i) cin >> a[i];
	for(int i=0;i<n;++i) {
		cin >> b[i];
		if(b[i]>a[i]) pq.push({b[i],i});
		else if(b[i]<a[i]) return cout<<-1,0;
	}

	long long ans = 0;
	int iter = 0;
	while(pq.size()){
		auto i = pq.top().second; pq.pop();
		long long left = b[i?i-1:n-1], right = b[i<n-1?i+1:0];
		long long mn = min(left,right);
		long long sum = left+right;

		long long moves = (b[i]-max({left,right,a[i]})+sum-1)/sum;
		ans += moves;
		b[i] -= sum*moves;
		if(b[i]>a[i]) pq.push({b[i],i});
		else if(b[i]<a[i])
			return cout<<-1,0;
		// if(iter++==25) break;
		// for(int i=0;i<n;cout<<b[i++]<<' '); cout << '\n';
	}
	cout << ans;
}

Measured memory_bytes: 9200
#include <stdio.h>
int main (){
	int uang;
	int kembalian;
	int harga;
	scanf("%d",&harga);
	for (uang=0 ; uang<harga ; uang+=1000){
		uang;
	}
	printf("%d",uang-harga);	
	
	
return 0;	
	
}

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

#define ll long long int

const int H=1e4+2,N=1e3+4;
ll dp[H][N],n,h;
vector<ll> a,b;

void pre(){
    for(int i=0;i<H;i++){
        for(int j=0;j<N;j++){
            dp[i][j] = -1;
        }
    }
}

ll recur(ll h, ll ind){
    // cout << "recuring on " << h << " and " << ind << " with " << a[ind] << " " << b[ind] << "\n";
    if(h > 0 && ind < 0)
        return 1e10;
    else if(h<=0)
        return 0;
    else if(dp[h][ind] != -1)
        return dp[h][ind];
    
    return dp[h][ind] = min(b[ind]+recur(h-a[ind],ind), recur(h,ind-1));

}
// 9 3
// 8 3
// 4 2
// 2 1

void solve(){
    pre();
    // cin >> n >> h;
    cin >> h >> n;
    a.resize(n);    b.resize(n);
    for(int i=0;i<n;i++)
        cin >> a[i] >> b[i];

    cout << recur(h,n-1) << '\n';
}

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

    int test=1;
    // cin >> test;
    while(test--)
        solve();
    
    return 0;
}

Measured memory_bytes: 79232