akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n%1000==0){
    cout<<0<<'\n';
    return(0);
  }
  cout<<1000-n%1000<<'\n';
  return(0);
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    char S[15];
    scanf("%s", S);
    if(S[5]=='0' && S[6]<='4' &&S[6] >='1'){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }
    return 0;
}

Measured memory_bytes: 128
/* *Your Love Makes me STRONG,
   You'r Hate Makes Me UNSTOPABBLE.*
 
  *HOPE is a good thing,Maybe The BEST of Things.
   And No Good Things Ever Dies.*
  
  *Keep calm,Be patient And Chase Your DREAM*
 12-09-2020-Remember The Date(Div=2)
*/


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MN7 ios::sync_with_stdio(0);cin.tie(nullptr);
using namespace std;
ll t,n,i,j,k,a,b,c,d,p,q,r,x,y,z,m,cnt,flag;
string s;
void nahid()
{
 cin>>a>>b>>c>>d;
 x=a*c;y=a*d;
 p=b*c;q=b*d;
 m=max(x,y);n=max(p,q);
 cnt=max(m,n);
 cout<<cnt<<endl;

 

}
int main()
{ MN7 //cin>>t;while(t--)
  nahid();
}


Measured memory_bytes: 3680
def main():
    n = int(input())
    Mtx = list(map(int, input().split()))
    
    showMtx(Mtx)
    for i in range(1,n):
        for j in range(i,0,-1):
            if Mtx[j] < Mtx[j-1]:
                Mtx[j-1], Mtx[j] = Mtx[j], Mtx[j-1]
            # print(i, j, sep=', ')
        showMtx(Mtx)
                

def showMtx(Mtx):    
    q = len(Mtx)
    for i in range(q):
        if i != q - 1:
            print(Mtx[i], sep=' ', end=' ')
        else:
            print(Mtx[i])



if __name__ == '__main__':
    main()



Measured memory_bytes: 5980
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
long long a[N];
long long dp[N];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i + 1 < n) dp[i + 1] =  min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		if (i + 2 < n) dp[i + 2] =  min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
int main()
{
    int k, n;
    vector<int> houselist;
    
    cin >> k >> n;
    houselist.resize( n );
    for (auto i = 0; i < n; i++) {
        cin >> houselist[i];
    }
  
    int min = k;
    int kyori;
    for (auto i = 0; i < n; i++) {
        int base = houselist[i];
        int tail = (i - 1 + n) % n;
        kyori = houselist[tail] < base  ?
                houselist[tail] + k - base :
                houselist[tail] - base;
        if (kyori < min) {
            min = kyori;
        }
    }
    cout << min << endl;
    return 0;
}

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

int n;
char grid[255][255];
int dx[] = {1,0,1,-1};
int dy[] = {0,1,1,1};

int solv(int sx, int sy) {
	int res = 0;
	for (int i=0; i<4; ++i) {
		int cnt = 0, x = sx, y = sy;
		while (0 <= x && x < n && 0 <= y && y < n) {
			cnt = (grid[y][x] == '1' ? cnt+1 : 0);
			res = max(res, cnt);
			x += dx[i];
			y += dy[i];
		}
	}
	return res;
}

int main() {
	while (cin >> n, n) {
		char c;
		for (int i=0; i<n*n; ++i) {
			cin >> grid[i/n][i%n];
		}
		int res = 0;
		for (int i=0; i<n; ++i) {
			res = max(max(res, solv(0, i)), max(solv(n-1, i), solv(i, 0)));
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	cin >> n;
	FOR(i,1,n+1){
		if(i%3==0) {
			cout << " " << i;
			continue;
		}
		int k = i;
		while(1){
			if(k%10==3){
				cout << " " << i;
				break;
			}
			if(k==0) break;
			k/=10;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
const int N=400010;
struct A{
	int x,y;
}a[N],b[N];
int e[N],nex[N],head[N],ed=0;
int del[N],c[N],fa[N],d[N];
void adde(int x,int y){e[++ed]=y;nex[ed]=head[x];head[x]=ed;}
int flag;
void dfs(int x,int f){
	if(flag) return;
	fa[x]=f;
	for(int i=head[x];i;i=nex[i]){
		if(flag) return;
		if(e[i]==f) continue;
		if(!fa[e[i]]){
			if(flag) return;
			c[e[i]]=(i+1)/2;
			dfs(e[i],x);
		}
		else{
			if(flag) return;
			del[(i+1)/2]=1;
			for(int j=x;j!=e[i];j=fa[j]){
				del[c[j]]=1;
			}
			flag=1;
			return;
		}
	}
}
int n,m;
void solve(int id){
	int i,m0=0;
	memset(head,0,sizeof(head));ed=0;
	memset(d,0,sizeof(d));flag=0;
	memset(fa,0,sizeof(fa));
	memset(del,0,sizeof(del));
	memset(e,0,sizeof(e));
	memset(c,0,sizeof(c));
	memset(nex,0,sizeof(nex));
	if(id) random_shuffle(a+1,a+m+1);
	for(i=1;i<=m;i++){
		adde(a[i].x,a[i].y);
		adde(a[i].y,a[i].x);
		d[a[i].x]++;d[a[i].y]++;
	}
	int mn=n+1,imn;
	for(i=1;i<=n;i++)
		if(d[i]&&d[i]<mn) mn=d[i],imn=i;
	dfs(imn,-1);
	for(i=1;i<=m;i++)
		if(!del[i]) a[++m0]=a[i];
	m=m0;
}
int main(){
	int i,km;
	srand(19260817);
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d",&a[i].x,&a[i].y);
		d[a[i].x]++;d[a[i].y]++;
	}
	for(i=1;i<=n;i++)
		if(d[i]%2==1) break;
	if(i<=n){printf("No\n");return 0;}
	for(i=1;i<=m;i++) b[i]=a[i];
	km=m;
	for(i=1;i<=3;i++){
		if(m==0) break;
		solve(0);
	}
	if(i>=4){printf("Yes\n");return 0;}
	m=km;
	for(i=1;i<=m;i++) a[i]=b[i];
	for(i=1;i<=3;i++){
		if(m==0) break;
		solve(1);
	}
	if(i>=4){printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 19840
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    S = in_s()
    K = in_n()
    N = len(S)

    subs = set()
    for i in range(N):
        for j in range(1, K + 1):
            if i + j <= N:
                subs |= {S[i:i + j]}

    subs = sorted(subs)
    print(subs[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10588
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int N,K;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    vector<int> array;
    vector<int> len;
    int num;
    int temp = -1,lenm,lenp;
    REP(i,N){
        cin >> num;
        if(i != 0) {
            if(array[i-1] < 0 && num >= 0){
                temp = i;
            }
        }else{
            if(num >= 0){
                temp = i;
            }
        }
        array.push_back(num);
    }
    if(temp == -1) temp = array.size();
    for(int i=temp-K;i != temp;i++){
        if(i >= 0 && i+K-1 < array.size()) {
            lenm = array[i];
            lenp = array[i+K-1];
            len.push_back(2*abs(lenm) + abs(lenp));
            len.push_back(abs(lenm) + 2*abs(lenp));
            // cout << lenm << "   " << lenp << endl;
        }
    }
    if(temp >= K){len.push_back(abs(array[temp-K]));}
    if(array.size() > temp+K-1){len.push_back(abs(array[temp+K-1]));}
    // REP(i,len.size()) cout << len[i] << endl;
    VSORT(len);
    cout << len[0] << endl;
    

    return 0;
}

Measured memory_bytes: 1400
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(A)

for _ in range(M):
    discount = (-1) * heapq.heappop(A)
    discount //= 2
    heapq.heappush(A, -discount)

print(-sum(A))

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

using namespace std;

typedef long long ll;

struct tv {
    int s, t, c;
};

bool cmp(const tv t1, const tv t2) {
    return t1.t < t2.t;
}

int main() {
    int n, c; cin >> n >> c;
    vector<tv> infos(n);
    for (int i = 0; i < n; ++i) {
        int s, t, ci; cin >> s >> t >> ci;
        infos[i] = tv { s, t, ci };
    }
    sort(infos.begin(), infos.end(), cmp);
    vector<pair<int, int>> t_c;
    for (auto t : infos) {
        sort(t_c.begin(), t_c.end(), greater<>());
        int ts = t.s;
        int tt = t.t;
        int tc = t.c;
        bool possible = false;
        for (auto &ti : t_c) {
            if (ti.second == tc) {
                if (ti.first <= ts) {
                    possible = true;
                    ti.first = tt;
                    break;
                }
            } else {
                if (ti.first < ts) {
                    possible = true;
                    ti.first = tt;
                    ti.second = tc;
                    break;
                }
            }
        }
        if (!possible) {
            t_c.push_back({tt, tc});
        }
    }
    cout << t_c.size();
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long m = 0;
	for (int i = 0; i < n; i++) {
		m += a[i] / 2;
		a[i] %= 2;
		if (a[i] && a[i + 1]) {
			m++;
			a[i]--;
			a[i + 1]--;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 640
#!python3.4.3

def chmin(x, y):
    if x < y:
        return x
    else:
        return y
    
def main():
    n = int(input())
    h = list(map(int, input().split(' ')))
    dp = [0]

    for i in range(1, len(h)):
        dp.append(0)
        
        if i == 1:
            dp[i] = abs(h[i] - h[i-1])
        else:
            dp[i] = chmin(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
    print(dp[-1])

if __name__ == "__main__":
    main()



Measured memory_bytes: 13924
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int t=0;
  for(int i=1;i<n;i++){
    if(s[i-1]!=s[i])t++;
  }
  t++;int y=1;//cerr<<t<<endl;
  cout<<n-max(y,t-2*k);
 


    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define INF 1e9
#define N 200010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{int nu,ne,qu;}a[N*6];
struct Onfo{int be,en;}f[N];
struct Unfo{int nu,we;}d[N];
int n,p,num=1,b[N],s,t,di[N],li[N],ansn,nu,cur[N],no[N],an[N];
bool vi[N];
bool comp(const Unfo &a,const Unfo &b){return a.nu<b.nu;}
void jb(int x,int y,int z){a[++num].nu=y;a[num].ne=b[x];b[x]=num;a[num].qu=z;a[++num].nu=x;a[num].ne=b[y];b[y]=num;a[num].qu=0;}
bool bfs(){
	for (int i=1;i<=t;i++) di[i]=INF;
	int l=1,r=1;li[l]=s;di[s]=0;
	while (l<=r){
		for (int y=b[li[l]];y;y=a[y].ne)if (di[a[y].nu]==INF&&a[y].qu!=0){di[a[y].nu]=di[li[l]]+1;li[++r]=a[y].nu;}
		l++;
	}
	return (di[t]!=INF);
}
int dinic(int x,int xi){
	if (x==t){ansn+=xi;return xi;}
	int sh=0,nu;
	for (int y=cur[x];y;y=a[y].ne){
		cur[x]=y;
		if (a[y].qu!=0&&di[a[y].nu]==di[x]+1){
			nu=dinic(a[y].nu,min(a[y].qu,xi-sh));
			sh+=nu;a[y].qu-=nu;a[y^1].qu+=nu;
			if (sh==xi) return sh;
		}
	}
	return sh;
}
int main(){
	read(n);
	for (int i=1;i<n;i++){
		read(p);
		while(p--){read(d[++nu].nu);d[nu].we=i;if(d[nu].nu!=1){jb(i,d[nu].nu+n,1);}}
	}
	sort(d+1,d+nu+1,comp);
	s=n*2+1,t=n*2+2;
	for (int i=1;i<=n;i++)jb(s,i,1);
	for (int i=n+1;i<=n+n;i++)jb(i,t,1);
	for (int i=1,j=0;i<=n;i++){f[i].be=j+1;while (d[j+1].nu==i)j++;f[i].en=j;}
	while (bfs()){
		for(int i=1;i<=t;i++)cur[i]=b[i];
		dinic(s,INF);
	}
	if (ansn==n-1){
		for (int i=1;i<n;i++)
			for (int j=b[i];j;j=a[j].ne)
				if (a[j].nu!=s&&a[j].qu==0)no[i]=a[j].nu-n;
		for (int i=1;i<n;i++) vi[i]=true;
		int l=1,r=1;li[l]=1;
		while (l<=r){
			for (int i=f[li[l]].be;i<=f[li[l]].en;i++){
				if (vi[d[i].we]){
					vi[d[i].we]=false;li[++r]=no[d[i].we];
					an[d[i].we]=li[l];
				}
			}
			l++;
		}
		if (r!=n)cout<<"-1"<<endl;
		else{
			for (int i=1;i<n;i++)printf("%d %d\n",an[i],no[i]);
		}
	}else{
		puts("-1");
	}
	return 0;
}

Measured memory_bytes: 19968
N,H=map(int,input().split())
sl=[]
th=[]
for i in range(N):
  s,t=map(int,input().split())
  sl.append(s)
  th.append(t)
th.sort()
gsl=max(sl)
ans=0
while th:
  if gsl<th[-1]:
    at=th.pop(-1)
    H-=at
    ans+=1
    if H<=0:
      break
  else:
    ans+=H//gsl
    if H%gsl!=0:
      ans+=1
    break
else:
  ans+=H//gsl
  if H%gsl!=0:
    ans+=1
print(ans)

Measured memory_bytes: 11300
import numpy as np

N, M = [int(i) for i in input().split()]
X = []
Y = []
Z = []
for i in range(N):
    x,y,z = [int(i) for i in input().split()]
    X.append(x)
    Y.append(y)
    Z.append(z)

# Evaluation
patterns = [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],
           [-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]

# evaluation
candidates = []
for pattern in patterns:
    score = []
    # print(pattern)
    for x, y, z in zip(X,Y,Z):
        score.append(sum(np.asarray([x,y,z]) * np.asarray(pattern)))
        score.sort() # 昇順で並び替え
    # 大きい方からM個取り出して和を取る
    candidates.append(sum(score[-1:-M-1:-1]))
print(max(candidates))


Measured memory_bytes: 21692
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll n,x,y,z;
	cin>>n;
	map<ll,ll>mp;
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>x;
		mp[x]++;
		sum+=x;
		
	}
	ll q;
	cin>>q;
	while(q--)
	{
		cin>>y>>z;
		sum-=(mp[y]*y);
		sum+=(mp[y])*z;
		mp[z]+=mp[y];
		mp[y]=0;
		cout<<sum<<endl;
		
	}
	
	
	
	
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll a[N];
  rep(i, N) cin >> a[i];

  ll ans = 0;
  for(ll e: a){
    while(e % 2 == 0){
      e /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll N,A[100000],req[100000];
vi al[100000];

bool dfs(int i,int p) {
	//bool succ=1;
	ll s=0,M=0,a,b;

	if (al[i].size()==1 && p!=-1) {
		req[i]=A[i];
		return 1;
	}

	for (int j:al[i]) if (j!=p) {
		if (!dfs(j,i)) return 0;
		s+=req[j];
		smax(M,req[j]);
	}

	a=2*(s-A[i]);
	b=s-a;

	if (a<0 || b<0) return 0;

	if (2*(M-b)>a) return 0;
	
	req[i]=b;
	return 1;
}

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

	cin >> N;
	for (int i=0;i<N;i++) cin >> A[i];
	for (int i=1;i<N;i++) {
		int u,v;cin >> u >> v;u--;v--;
		al[u].push_back(v);
		al[v].push_back(u);
	}

	for (int i=0;i<N;i++) if (al[i].size()==1) {
		if (dfs(i,-1) && req[i]==A[i]) cout << "YES\n";
		else cout << "NO\n";
		return 0;
	}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    ll k, a, b;
    cin >> k >> a >> b;

    if(b - a <= 2){
        cout << k + 1 << endl;
    }else{
        ll ans = (k - (a - 1)) / 2 * (b - a) + a;
        if((k - (a - 1)) % 2 == 1){
            ans++;
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
map<char,string>m;
int main(){
m['A']="100101";
m['B']="10011010";
m['C']="0101";
m['D']="0001";
m['E']="110";
m['F']="01001";
m['G']="10011011";
m['H']="010000";
m['I']="0111";
m['J']="10011000";
m['K']="0110";
m['L']="00100";
m['M']="10011001";
m['N']="10011110";
m['O']="00101";
m['P']="111";
m['Q']="10011111";
m['R']="1000";
m['S']="00110";
m['T']="00111";
m['U']="10011100";
m['V']="10011101";
m['W']="000010";
m['X']="10010010";
m['Y']="10010011";
m['Z']="10010000";
m['\'']="000000";
m[' ']="101";
m[',']="000011";
m['-']="10010001";
m['.']="010001";
m['?']="000001";
  string s;
  while(getline(cin,s)){
    string t;
    r(i,s.size())t+=m[s[i]];
    while((t.size()%5))t+='0';
    for(int i=0;i<t.size();i+=5){
      int p=(t[i]-'0')*16+(t[i+1]-'0')*8+(t[i+2]-'0')*4+(t[i+3]-'0')*2+(t[i+4]-'0')*1;
      if(p<=25)cout<<(char)(p+'A');
      else if(p==26)cout<<' ';
      else if(p==27)cout<<'.';
      else if(p==28)cout<<',';
      else if(p==29)cout<<'-';
      else if(p==30)cout<<'\'';
      else if(p==31)cout<<'?';
    }
      cout<<endl;
  }
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	bool vis[105]={0};
	bool ok=1;
	while(ok)
	{
		ok=0;
		for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(!vis[i] && !vis[j] && s[i]=='(' && s[j]==')')
			{
				ok=1;
				vis[i]=vis[j]=1;
			}
	}
	int l=0,r=0;
	for(int i=0;i<n;i++)
		if(!vis[i] && s[i]=='(') l++;
		else if(!vis[i] && s[i]==')') r++;
	for(int i=0;i<r;i++)
		cout<<'(';
	cout<<s;
	for(int i=0;i<l;i++)
		cout<<')';
	
	return 0;
}

Measured memory_bytes: 256
//abc106_a.cpp
//Sat Aug 18 19:55:58 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b;
	cin >> a >> b;

	cout << a*b-a-b+1<< endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        int[] A = new int[N], map = new int[100001];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = ScanInt();
            sum += A[i];
            map[A[i]]++;
        }
        var Q = ScanInt();
        for (int i = 0; i < Q; i++) {
            int B = ScanInt(), C = ScanInt();
            sum += (C - B) * map[B];
            map[C] += map[B];
            map[B] = 0;
            Console.WriteLine(sum);
        }
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 29188
//BUGSBUNNY
//IIT ROORKEE
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[200010], factinv[200010] , first = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,200010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!first) first = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    //-------------------------------------------------------------------------------   
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();
    //-------------------------------------------------------------------------------   
    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;    
        rep(i,t)
            solve();
    //-------------------------------------------------------------------------------
        clk = clock() - clk;
        cerr << fixed << setprecision(12) << "Time: " << ((double)clk)/CLOCKS_PER_SEC;
    //-------------------------------------------------------------------------------
}

void solve()
{
    int n;
    set<string> s;
    cin >> n;
    rep(i,n)
    {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
} 

Measured memory_bytes: 19372
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    a.sort!"a > b";
    auto g = a.group.array;
    long s = 1;
    long cnt;
    foreach (x; g)
    {
        if (cnt == 0 && x[1] >= 4)
        {
            writeln(x[0] * x[0]);
            return;
        }
        if (x[1] >= 2)
        {
            s *= x[0];
            ++cnt;
        }
        if (cnt == 2)
        {
            s.writeln;
            return;
        }
    }

    0.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4532
N, M = map(int, input().split())
As = list(map(int, input().split()))
for i in range(len(As)):
    As[i] = -As[i]
import heapq

heapq.heapify(As)
for i in range(M):
    ma = heapq.heappop(As)
    heapq.heappush(As, -(-ma // 2))
s = sum(As)
print(-s)


Measured memory_bytes: 72300
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=A+B;
		int D=A-B;
		int E=A*B;
		int ans=0;
		ans=Math.max(E, (Math.max(C, D)));	
	System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
    ll N;
    ll n;
    cin >> N;
    map<ll, ll>res;
    vector<ll>val;
    n = N;
    for (ll i = 2; i*i <= N; i++) {
        if (N % i == 0) {
            val.push_back(i);
        }
        while (N % i == 0) {
            res[i]++;
            N /= i;
        } 
    }
    if (N != 1) {
        val.push_back(N);
        res[N] = 1;
    }
 
    ll ans = 0;
    ll cnt = 0;
    for (int i = 0; i < val.size(); i++) {
        ll a = 1;
        cnt = 1;
        while (res[val[i]] >= a) {
            cnt++;
            a += cnt;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String In1[] = new String[n];
		int In2[] = new int[n];
		String N1b[] = new String[n];
		int N2b[] = new int[n];
		String N1s[] = new String[n];
		int N2s[] = new int[n];
		int count = 0;
		int minj = 0;
		int l, i, j = 0;
		
		for (int k = 0; k <= n - 1; k++) {
			String x = scanner.next();
			String y = x.substring(0, 1);
			String z1 = x.substring(1, 2);
			int z = Integer.parseInt(z1);
			In1[k] = y;
			In2[k] = z;			
			N1b[k] = y;
			N2b[k] = z;
			N1s[k] = y;
			N2s[k] = z;
			
		} //ここまでで配列に要素を入れる

		//bubble sort
        for (i = 0; i < n - 1; i++) {
            for (j = n - 1; j > i; j--) {
                if (N2b[j] < N2b[j-1]) {
                    int a = N2b[j - 1];
                    N2b[j - 1] = N2b[j];
                    N2b[j] = a;
                    
                    String b = N1b[j - 1];
                    N1b[j - 1] = N1b[j];
                    N1b[j] = b;
                }
            }
        }
        for (int k = 0; k < n - 1; k++) {
            System.out.print (N1b[k] + N2b[k] + " ");
            }
        System.out.println (N1b[n - 1] + N2b[n - 1]);
        System.out.println("Stable");
 
    //selection sort
    for (i = 0; i <= n - 1; i++) {
        minj = i;
        for (j = i; j <= n - 1; j++) {
            if (N2s[j] < N2s[minj]) {
                minj = j;
            }
        }
        int a = N2s[i];
        N2s[i] = N2s[minj];
        N2s[minj] = a;
        
        String b = N1s[i];
        N1s[i] = N1s[minj];
        N1s[minj] = b;
    }
    for (int k = 0; k < n - 1; k++) {
        System.out.print (N1s[k] + N2s[k] + " ");
        }
    System.out.println (N1s[n - 1] + N2s[n - 1]);  
    for (l = 0;l <= n - 1;l++) {
    	if (N1b[l] != N1s[l]) {
    		System.out.println("Not stable");
    		break;
    	} 
    	if (l == n - 1) {
    		System.out.println("Stable");
    	}
    }
}
}


Measured memory_bytes: 26380
def main():
    from collections import Counter as ct
    n = int(input())
    a = list(map(int, input().split()))

    npa = ct([i+1+j for i, j in enumerate(a)])
    nma = ct([i+1-j for i, j in enumerate(a)])

    cnt = 0

    for i, j in npa.items():
        cnt += j*nma[i]
    print(cnt)


main()


Measured memory_bytes: 61612
#include<stdio.h>
#define MAX 100

int main(){
    int r, c, i, j, k;
    int a[MAX][MAX];
    int x = 0;
    int y = 0;
    int z = 0;

    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i = 0; i < r + 1; i++){
        for(j = 0; j < c + 1; j++){
            if(j < c && i < r){
                x += a[i][j];
                
                
                printf("%d", a[i][j]);
                printf(" ");
            }
            else if(j == c && i < r){
                printf("%d\n", x);
                z += x;
                x = 0;
            }
            else if(i == r && j < c){
                for(k = 0; k < r; k++){
                    y += a[k][j];
                }
                printf("%d", y);
                printf(" ");
                y = 0;
            }
            else if(i == r && j == c){
                printf("%d\n", z);
            }

        }
    }
    return 0;
}


Measured memory_bytes: 2000
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main() {
    double a, b;
    cin >> a >> b;
    printf("%.10lf\n", a / b);
}

Measured memory_bytes: 764
#include <stdio.h>

int main()
{
    int a, b;
    if ( scanf("%d %d", &a, &b) != 2) {
        printf("InputError!\n");
        return -1;
    }

    if (a == 1) a = 14;
    if (b == 1) b = 14;

    if      (a == b) puts("Draw");
    else if (a >  b) puts("Alice");
    else             puts("Bob");

    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
    val bList = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
    val cList = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    // 初回
    var ans = bList[aList[0]-1]

    // 2回目以降
    for (i in 1 until n) {

        ans += bList[aList[i] - 1]

        if (aList[i] == aList[i - 1] + 1) {
            ans += cList[aList[i] - 2]
        }
    }

    println(ans)
}

Measured memory_bytes: 37864
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		if(n>9){
			result += 9;
		}else{
			result += n;
		}

		if(n<=99){

		}else if (n>999){
			result +=900;
		}else{
			result += n-99;
		}

		if(n<=9999){
			
		}else if(n==100000){
			result +=90000;
		}else{
			result += n-9999;
		}
		System.out.println(result);


	}



}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_167
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            string t = Read();

            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i])
                {
                    WriteLine("No");
                    return;
                }
            }

            WriteLine("Yes");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int cur = 100;
	int x; cin >> x;
	int yr = 0;
	while (cur < x)
	{
		cur = cur + cur / 100;
		yr++;
	}

	cout << yr << '\n';
	return 0;
}

Measured memory_bytes: 3640
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }



int main()
{
	while (true)
	{
		int w, h;
		pii start, goal;
		int n;
		int a[200][200] = {};
		bool flag[200][200] = {};
		bool ok = false;
		cin >> w >> h;if (!w)break;
		cin >> start.first >> start.second;
		cin >> goal.first >> goal.second;
		cin >> n;

		FOR(i, n)
		{
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			for (int X = x; X <= x+1+(d?0:2); X++)
			{
				for (int Y = y; Y <= y + 1 + (d ? 2 : 0); Y++)
				{
					a[X][Y] = c;
				}
			}
		}

		flag[start.first][start.second] = true;
		queue<pii> que; 
		if(a[start.first][start.second]!=0)que.push(start);

		while (!que.empty())
		{
			pii now = que.front(); que.pop();
			if (now == goal)
			{
				cout << "OK" << endl;
				ok = true;
			}

			FOR(i, 4)
			{
				pii next=now;
				next.first += dx[i]; next.second += dy[i];

				if (a[next.first][next.second] == a[now.first][now.second] && !flag[next.first][next.second])
				{
					flag[next.first][next.second] = true;
					que.push(next);
				}
			}
		}

		if (!ok)cout << "NG" << endl;
	}
}

Measured memory_bytes: 3304
N,K = map(int, input().split())
mod = 10 ** 9 + 7
n = N * 2
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod

if N <= K+1:
  print(comb(n-1,N))
else:
  ans = (1 + (N * (N-1))) % mod
  for i in range(2,K+1):
    mini_ans = (comb(N,i) * comb(N-1,N-i-1)) % mod
    ans = (ans + mini_ans) % mod
  print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    FOR(i, 0, n){
        cin >> s[i];
    }
    
    int q;
    cin >> q;
    vector<int> t(q);
    int cnt=0;
    FOR(i, 0, q){
        cin >> t[i];
        int left=0,right=n;
        int mid;
        while(left<right){
            mid = (left+right)/2;
            if(t[i]==s[mid]){
                cnt++;
                break;
            }
            if(t[i] > s[mid]){
                left = mid+1;
            }
            if(t[i] < s[mid]){
                right = mid;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>

using namespace std;
using namespace std::chrono;

vector<string> a, b;
int n, m;

bool check(int s_i, int s_j) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j)
      if (a[s_i + i][s_j +j] != b[i][j])
        return false;
  return true;
}

int main() {
  auto start = high_resolution_clock::now();

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

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

  for (int i = 0; i + m <= n; ++i)
    for (int j = 0; j + m <= n; ++j)
      if (check(i, j)) {
        cout << "Yes\n";
        return 0;
      }

  cout << "No\n";

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &&i : A) {
        cin >> i;
    }
    vector<int> memo(N);
    memo[0] = A[0];
    int ans = -INF32;
    FOR(i, 1, N) {
        ans     = max(ans, A[i] - memo[i - 1]);
        memo[i] = min(memo[i - 1], A[i]);
    }
    std::cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4376
import java.util.Scanner;

public class Main {

	private static final String STR_YES = "Yes";
	private static final String STR_NO = "No";

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

		String str = sc.next();

		sc.close();

		char s3 = str.charAt(2);
		char s4 = str.charAt(3);
		char s5 = str.charAt(4);
		char s6 = str.charAt(5);

		if (s3 == s4 && s5 == s6) {
			System.out.print(STR_YES);
		} else {
			System.out.print(STR_NO);
		}

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, M;
    cin >> N >> M;
    vector<int> S(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            --s;
            S[i] |= (1 << s);
        }
    }
    // cout << "S" << endl;
    // dump(S);
    vector<int> P(M);
    rep(i, M) {
        cin >> P[i];
        P[i] = P[i] % 2;
    }
    // cout << "P" << endl;
    // dump(P);

    int ans = 0;
    for (int i = 0; i < (1 << N); ++i) {
        bool ok = true;
        for (int j = 0; ok && j < M; ++j) {
            int test = (i & S[j]);
            int bits = __builtin_popcount(test);
            // cout << "i, S[j], test, bits = " << i << ' ' << S[j] << ' ' << test << ' ' << bits << endl;
            ok = (bits % 2 == P[j]);
        }
        if (ok) ++ans;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  int ans=0;
  sort(p.begin(),p.end());
  for(int i=0;i<N-1;i++){
    ans += p.at(i);
  }
  ans += p.at(N-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int A[25], n;

int solve(int p, int t){
	
	if (p == n){
		if (t == 0){
			return (1);
		}
		else {
			return (0);
		}
	}
	
	if (solve(p + 1, t - A[p]) == 1){
		return (1);
	}
	if (solve(p + 1, t) == 1){
		return (1);
	}
	return (0);
}

int main(void)
{
	
	int M, q, i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	
	for (i = 0; i < q; i++){
		scanf("%d", &M);
		
		
		
		if (solve(0, M) == 1){
			puts("yes");
		}
		else {
			puts("no");
		}
	}
	return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x - k + 1; i <= x + k - 1; ++i){
        cout << i;
        if(i != x + k - 1)
            cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<string>s(n); VE t(n); rep(i, n)cin >> s[i] >> t[i];
	string x; cin >> x;
	bool ok = false;
	int ans = 0;
	rep(i, n) {
		if (ok) {
			ans += t[i];
		}
		if (s[i] == x)ok = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256