akhauriyash/Code-Regression huggingface dataset:
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back
#define inf (1<<29)

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        string S;
        cin >> S;
        int mx = 0;
        int f = 0;
        int s = 0;
        rep(i,sz(S)){
            if(S[i]=='A'){
                f = i;
                break;
            }
        }
        irep(i,sz(S)-1,0){
            if(S[i]=='Z'){
                s = i;
                break;
            }
        }

        cout<<abs(s-f)+1<<endl;



return 0;
}



Measured memory_bytes: 720
s1 = input()
s2 = input()

ret = ""
l1 = len(s1)
l2 = len(s2)

for i, j in zip(s1, s2):
    ret += i+j

if l1 < l2:
    ret += s2[-1]
elif l1 > l2:
    ret += s1[-1]

print(ret)



Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum;
		String str[];
		while(true){
			sum=0;
			try{
				str=br.readLine().split("");
				if(str[0].equals("0")){
					break;
				}
				for(int i = 0 ; i < str.length ; i++){
					sum += Integer.parseInt(str[i]);
				}
				System.out.println(sum);

			}catch (Exception e) {
				System.err.println(e);
			}
		}
	}

}

Measured memory_bytes: 25500
N, M = map(int, input().split())
edges_used = {}

from heapq import heappush, heappop
def dijkstra(n, graph, s):
    dist = [float('inf')] * n
    hq = [(0, s)]
    dist[s] = 0
    while hq:
        c, v = heappop(hq)
        if dist[v] < c:
            continue
        for t, cost in graph[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(hq, (dist[t], t))
    return dist

graph = [[] for _ in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((b, c))
    graph[b].append((a, c))
    edges_used[(a, b, c)] = False
dist = [dijkstra(N, graph, i) for i in range(N)]

for edge in edges_used.keys():
    a, b, c = edge
    for i in range(N):
        if dist[i][a] == dist[i][b] + c or dist[i][b] == dist[i][a] + c:
            edges_used[edge] = True

ans = 0
for used in edges_used.values():
    if not used:
        ans += 1
print(ans)

Measured memory_bytes: 76400
import std.stdio;
import std.string;
import std.conv;

immutable MIN = 0;
immutable MAX = 1000000;
immutable DATA_SET = 200;

int main(string[] argv)
{
	string[] ans;

	char[] buf;
	while(stdin.readln(buf)){
		int temp1 = buf.split(" ")[0].chomp().to!int();
		int temp2 = buf.split(" ")[1].chomp().to!int();
		ans ~= (temp1 + temp2).to!string();
	}

	foreach(string str;ans){
		writeln(str.length);
	}

    return 0;
}

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

typedef struct{
  int to,cost;
}Edge;

const int N = 100;
vector<Edge> edge[N];
int f[N];
int findMax(int n,int src,int maxhp){
  for(int i=0;i<n;i++){
    f[i] = 0;
  }
  for(int i=0;i<edge[src].size();i++){
    int next = edge[src][i].to;
    f[next] = max(f[next],maxhp+edge[src][i].cost);
    f[next] = min(f[next],maxhp-1);
  }
  //O(VE)
  for(int loop=0;loop<n-1;loop++){
    for(int i=0;i<n;i++){
      int now = i;
      if (f[now] == 0)continue;
      for(int j=0;j<edge[i].size();j++){
	int next = edge[now][j].to;
	f[next] = max(f[next],f[now]+edge[now][j].cost);
	f[next] = min(f[next],maxhp);
      }
    }
  }
  return f[src];
}

int cost[N];
int prevCost[N];
bool haveInfLoop[N];
int solve(int n,int src,int dst,int maxhp){
  edge[dst].clear();
  for(int i=0;i<n;i++){
    int tmp = findMax(n,i,maxhp);
    haveInfLoop[i] = tmp == maxhp;
  }


  for(int i=0;i<n;i++){
    cost[i] = 0;
    prevCost[i] = 0;
  }
  cost[src] = maxhp;
  prevCost[src] = maxhp;
  for(int loop=0;loop<n;loop++){
    for(int now=0;now<n;now++){
      if (cost[now] == 0)continue;
      for(int j=0;j<edge[now].size();j++){
	int next = edge[now][j].to;
	cost[next] = max(cost[next],cost[now]+edge[now][j].cost);
	cost[next] = min(cost[next],maxhp);
      }
    }

    for(int now=0;now<n;now++){
      if (cost[now] == 0)continue;
      for(int j=0;j<edge[now].size();j++){
	int next = edge[now][j].to;
	if (min(maxhp,cost[now] + edge[now][j].to)  != cost[next]){
	  //if (findMax(n,next,maxhp) == maxhp){
	  if (haveInfLoop[next]){
	    cost[next] = maxhp;
	  }
	}
      }
    }
  end:;
  }
  return cost[dst];
}

main(){
  int n,m;
  int tc = 1;
  while(cin>>n>>m && n){
    for(int i=0;i<n;i++){
      edge[i].clear();
    }
    for(int i=0;i<m;i++){
      int f,t,w;
      cin>>f>>t>>w;
      edge[f].push_back((Edge){t,w});
    }
    int s,t,hp;
    cin>>s>>t>>hp;
    int ans = solve(n,s,t,hp);
    cout <<"Case " << tc++ << ": ";
    if (ans == 0)cout <<"GAME OVER" << endl;
    else cout << ans << endl;
  }
  return false;
}

Measured memory_bytes: 972
import sys
import heapq
from collections import deque
from functools import cmp_to_key
from itertools import combinations
from itertools import permutations
si = sys.stdin.readline
so = sys.stdout.write
sys.setrecursionlimit(10000)


def main():
    s = si()[:-1]
    t = si()[:-1]
    cnt = 1000+1
    for i in range(len(s)-len(t)+1):
        curr = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                curr += 1
        cnt = min(cnt, curr)
    print(cnt)


if __name__ == '__main__':
    main()


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

int main (){
        long long N;
        long long Ans;
        long long max=1,min=1000000000;
        long long arr[100000] = {};
        cin >> N ;
        
        for(long long i = 1; i<=N;i++){
            cin >> arr[i];
            if(arr[i] >= max){
                max = arr[i];
            }
            
            if(arr[i] <= min){
                min = arr[i];
            }
            
        }
        
        cout <<abs (max - min)<< endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

//座圧2
//前準備：
//圧縮したい配列aに-INFとINFを追加する
//uniquell(a,comp,n)でcompに昇順の配列を作る
ll compf(ll n,ll*comp,ll compcnt){
	//comp[i]<=n<comp[i+1]なるiを返す
	ll l=0,r=compcnt;
	while(r-l>1){
		ll m=(l+r)/2;
		if(comp[m]<=n)l=m;
		else r=m;
	}
	return l;
}
int uniquell(ll*t,ll*ans,int cnt){
	ll*a=calloc(cnt,sizeof(ll));
	memcpy(a,t,cnt*sizeof(ll));
	sortup(a,cnt);
	int c=0;
	ans[0]=a[0];
	rep(i,1,cnt)if(a[i]!=ans[c])ans[++c]=a[i];
	free(a);
	return c+1;
}

ll xx[4010],yy[4010];
ll xcnt,ycnt;
ll xx1[2010],yy1[2010],xx2[2010],yy2[2010];
ll cumsum[4010][4010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld%lld%lld",xx1+i,yy1+i,xx2+i,yy2+i);
		xx[2*i]=xx1[i];xx[2*i+1]=xx2[i];
		yy[2*i]=yy1[i];yy[2*i+1]=yy2[i];
	}
	xcnt=uniquell(xx,xx,2*n);
	ycnt=uniquell(yy,yy,2*n);
	for(int i=0;i<n;i++){
		int xxx1=compf(xx1[i],xx,xcnt);
		int xxx2=compf(xx2[i],xx,xcnt);
		int yyy1=compf(yy1[i],yy,ycnt);
		int yyy2=compf(yy2[i],yy,ycnt);
		cumsum[xxx1][yyy1]++;
		cumsum[xxx1][yyy2]--;
		cumsum[xxx2][yyy1]--;
		cumsum[xxx2][yyy2]++;
	}
	for(int i=0;i<xcnt;i++)for(int j=0;j<ycnt;j++)cumsum[i][j+1]+=cumsum[i][j];
	for(int j=0;j<ycnt;j++)for(int i=0;i<xcnt;i++)cumsum[i+1][j]+=cumsum[i][j];
	ll ans=0;
	for(int i=0;i<xcnt;i++)for(int j=0;j<ycnt;j++){
		if(cumsum[i][j])ans+=(xx[i+1]-xx[i])*(yy[j+1]-yy[j]);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 127376
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var out = os.Stdout
var in = os.Stdin

func readInput(in io.Reader) string {
	s, err := bufio.NewReader(in).ReadString('\n')
	if err != nil {
		panic(err)
	}
	return s
}

func toInts(s string) []int {
	var nums []int
	for _, f := range strings.Fields(s) {
		n, err := strconv.Atoi(f)
		if err != nil {
			panic(err)
		}
		nums = append(nums, n)
	}
	return nums
}

func calcCost(i, j int) int {
	return int(math.Abs(float64(i - j)))
}

func minCost(nums []int) (cost int) {
	n := len(nums)
	for i := 1; i < n; i++ {
		cost = cost + calcCost(nums[i], nums[i-1])
	}
	return cost
}

func main() {
	input := readInput(in)
	nums := toInts(input)
	sort.Ints(nums)
	fmt.Fprintln(out, minCost(nums))
}

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

using namespace std;

int main () {
	int N,T; cin >> N >> T;
	vector<int> A(N),mia(N,1e9),maa(N);
	for(auto&a:A) cin >> a;
	mia[0]=A[0]; maa[N-1]=A[N-1];
	for(int i=1;i<N;++i) mia[i]=min(mia[i-1],A[i]);
	for(int i=N-2;i>=0;--i) maa[i]=max(maa[i+1],A[i]);
	int maxi=0,ans=0;
	for(int i=0;i<N;++i) maxi=max(maxi,maa[i]-mia[i]);
	pair<int,int> prev;
	for(int i=0;i<N;++i) {
		auto tmp=make_pair(maa[i],mia[i]);
		if(prev!=tmp&&maxi==maa[i]-mia[i]) ++ans,prev=tmp;
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

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

ll N;
vector<ll> H;

void input() {
    cin >> N;
    H.resize(N);
    for (auto& h : H)
        cin >> h;
}

ll solve() {
    ll height = H[0];
    ll count = 1;
    for (int i = 1; i < N; i++) {
        if (H[i] >= height) {
            height = H[i];
            count++;
        }
    }
    return count;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<vector>
#include<list>
#include<algorithm>
#define MAX 100000
using namespace std;

vector<int> G[MAX];
list<int> ans;
bool color[MAX];
int v, e;

void dfs(int u){
    color[u] = true;
    for(int i = 0; i < G[u].size(); i++){
        int x = G[u][i];
        if(!color[x]) dfs(x);
    }
    ans.push_front(u);
}

void tSort(){
    for(int i = 0; i < v; i++){
        if(!color[i]) dfs(i);
    }
}

int main(){
    int s, t;
    scanf("%d %d", &v, &e);
    for( int i = 0; i < v; i++) color[i] = false;
    for(int i = 0; i < e; i++){
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
    }
    
    tSort();
    std::list<int>::iterator itr;
    for( itr = ans.begin(); itr != ans.end(); itr++){
        cout << *itr << endl;
    }
    return 0;
}


Measured memory_bytes: 6312
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define EPS 1e-9

struct ufo {
	double x, y;
	double r, v;

	ufo() {}
	ufo(double x_, double y_, double r_, double v_) {
		x = x_; y = y_; r = r_; v = v_;
	}

	bool operator<(const ufo & obj) const {
		return x*x + y*y < obj.x*obj.x + obj.y*obj.y;
	}

	bool operator==(const ufo & obj) const {
		return x==obj.x && y==obj.y && r==obj.r && v==obj.v;
	}
};

int main() {
	int N, R;

	while(cin >> R >> N, R || N) {
		vector<ufo> u;
		for(int i = 0; i < N; i++) {
			double x, y, r, v;
			cin >> x >> y >> r >> v;
			u.push_back(ufo(x,y,r,v));
		}

		int ret = 0;
		int count = 0;
		while(!u.empty()) {
			for(int i = 0; i < u.size(); i++) {
				double x, y;
				x = u[i].x; y = u[i].y;
				x -= u[i].v * cos(atan2(u[i].y, u[i].x));
				y -= u[i].v * sin(atan2(u[i].y, u[i].x));
				if(u[i].x * x < 0) x = 0;
				if(u[i].y * y < 0) y = 0;
				u[i].x = x; u[i].y = y;
			}

			sort(u.begin(), u.end());
			ufo aim(0,0,0,0);
			for(int i = 0; i < u.size(); i++) {
				if(u[i].x*u[i].x + u[i].y*u[i].y < R*R + EPS) {
					u.erase(u.begin() + i);
					i--;
					ret++;
				}
				else {
					if(aim == ufo(0,0,0,0)) {
						aim = u[i];
						u.erase(u.begin() + i);
						i--;
					}
					else {
						double theta = (atan2(aim.y, aim.x)- atan2(u[i].y, u[i].x));
						double d0, d1, d2;
						d0 = sqrt(u[i].x*u[i].x + u[i].y*u[i].y);
						d1 = d0 * cos(theta);
						d2 = d0 * sin(theta);

						if(abs(d2) < u[i].r + EPS /*&& d1 > 0*/) {
							double d3;
							d3 = sqrt(u[i].r*u[i].r - d2*d2);

							if(d1 + d3 > R) {
								u.erase(u.begin() + i);
								i--;
							}
						}
					}
				}
			}
//			cout << "sz:" << u.size() << endl;
		}

		cout << ret << endl;
	}
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  ll n;
  cin>>n;
  vec t(n);
  vec x(n);
  vec y(n);
  loop(i,n){
    cin>>t[i]>>x[i]>>y[i];
  }
  ll T=0,X=0,Y=0;
  bool check=true;
  loop(i,n){
    if(abs(X-x[i])+abs(Y-y[i])>t[i]-T||abs(abs(X-x[i])+abs(Y-y[i])-(t[i]-T))%2==1)check=false;
      
    T=t[i];
    X=x[i];
    Y=y[i];
  }
  if(check)putout("Yes");
  else putout("No");
  
  
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

int n/*, sz*/;
//vector<int> spf;

// void sieve(int mx){
//     sz = mx+5;
//     spf = vector<int>(sz);
//     spf[1] = 1;
//     for(int i = 2; i < sz; i++) spf[i] = i;
//     for(int i = 4; i < sz; i+=2) spf[i] = 2;

//     for(int i = 3; i*i < sz; i++){
//         if(spf[i] == i){
//             for(int j = i*i; j < sz; j+=i){
//                 if(spf[j]==j) spf[j] = i;
//             }
//         }
//     }
// }

// vector<int> factor(int x){
//     vector<int> ans;
//     while(x != 1){
//         ans.push_back(spf[x]);
//         x /= spf[x];
//     }
//     return ans;
// }

void solve(){
    cin >> n;
    unordered_map<int, int> cnt;
    //vector<int> a(n);
    //int mx = 0;
    for(int i = 0; i < n; i++){
        //cin >> a[i];
        int in; cin >> in;
        cnt[in]++;
        //mx = max(mx, in);
    }

    //sieve(mx);

    vector<pair<int, int>> a;
    for(auto p : cnt) a.push_back(p);

    int ans = 0;
    unordered_set<int> nums;
    sort(a.begin(), a.end());
    for(int i = 0; i < (int)a.size(); i++){
        // vector<int> f = factor(a[i].first);
        // bool ok = true;
        // for(int j : f){
        //     if(nums.find(j) != nums.end()) ok = false;
        // }
        bool ok = true;
        //cout << a[i].first << ": ";
        for(int j = 1; j*j <= a[i].first; j++){
            if(a[i].first%j==0){
                //cout << j << " " << a[i].first/j << " ";
                if(nums.find(j) != nums.end() || nums.find(a[i].first/j) != nums.end()) ok = false;
            }
        }//cout << '\n';
        if(ok && a[i].second <= 1){
            ans++;
            //cout << a[i].first << '\n';
        }
        nums.insert(a[i].first);
    }

    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 21284
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

constexpr int MOD = 1e9 + 7;

ll pow_mod(ll a , ll p, ll MOD){
    if( p < 2){
        ll ans = 1;
        while(p--){
            ans =  (ans * a) % MOD;
        }
        return ans;
    }else{
        if( p % 2){
            ll ans = pow_mod(a, p / 2, MOD);
            ans = (ans * ans) % MOD;
            ans = (a * ans) % MOD;
            return ans;
        }else{
            ll ans = pow_mod(a , p /2, MOD);
            ans = (ans * ans) % MOD;
            return ans;
        }
    }
}

constexpr int mxN = 2000;
ll dp[mxN];
void solve(){
    int n;
    read(n);
    if( n < 3){
        cout << 0 << endl;
        return;
    }else{
        dp[3] = 1;
        dp[4] = 1;
        dp[5] = 1;
        dp[6] = 2;
        for(int i = 7 ; i <= n ; i++){
            dp[i] = 1;
            for(int j = 3 ; j < i; j++){
                dp[i] += dp[i - j];
                if( dp[i] >= MOD){
                    dp[i] = dp[i] % MOD;
                }
            } 
        }
        cout << dp[n] << endl;
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def resolve():
    ofs = 3200
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [[0]*w for _ in range(h)]
    x = abs(A[0][0]-B[0][0])
    dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = 0
            if(i-1 >= 0):
                t |= dp[i-1][j]
            if(j-1 >= 0):
                t |= dp[i][j-1]
            dp[i][j] |= ((t << x) | (t >> x))

    for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s == '1'):
            print(i)
            return


if __name__ == "__main__":
    INF = float("inf")
    MOD = 10**9+7
    resolve()


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

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int n,bool visited[nmax]){
	bool all=true;
	for(int i=0;i<n;i++){
		if(visited[i]==false) all=false;
	}
	if(all) return 1;
	int ret=0;
	for(int i=0;i<n;i++){
		if(graph[v][i]==false) continue;
		if(visited[i]) continue;
		visited[i]=true;
		ret+=dfs(i,n,visited);
		visited[i]=false;
	}
	return ret;
}

int main() {
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		graph[a-1][b-1]=true;
		graph[b-1][a-1]=true;
	}
	bool visited[nmax];
	for(int i=0;i<n;i++){
		visited[i]=false;
	}
	visited[0]=true;
	cout << dfs(0,n,visited) << endl;
	return 0;
}


Measured memory_bytes: 256
def shred(num, bit):
    num = list(str(num))
    i = 0
    while bit:
        if bit & 1:
            num[i] += num.pop(i+1)
        else:
            i += 1

        bit >>= 1

    return num

def testcase_ends():
    t, num = map(int, raw_input().split())
    if t == 0 and num == 0:
        return 1

    cutcand = []
    curmax = -1
    for i in range(1<<(len(str(num))-1)):
        cut = shred(num, i)
        sumcut = sum(map(int, cut))

        if sumcut > t:
            continue
        elif sumcut == curmax:
            cutcand.append(cut)
        elif sumcut > curmax:
            cutcand = [cut]
            curmax = sumcut
    
    if len(cutcand) > 1:
        print 'rejected'
    elif len(cutcand) == 1:
        print curmax, ' '.join(cutcand[0])
    else:
        print 'error'

    return 0

def main():
    while True:
        if testcase_ends():
            return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 6296
#include<iostream>
#include<map>
using namespace std;
int N;
string S;
map<string,int>m;
int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>S;
        m[S]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int dp[1000010][2];

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

    dp[0][0] = 0;
    dp[0][1] = 1;
    for (int i = 0; i < n.size(); ++i) {
        dp[i+1][0] = min(dp[i][0] + (n[i] - '0'), dp[i][1] + 10 - (n[i] - '0'));
        dp[i+1][1] = min(dp[i][0] + (n[i] - '0') + 1, dp[i][1] + 9 - (n[i] - '0'));
    }
    cout << dp[n.size()][0] << endl;
}


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

const long long MOD = 1000000007;

template <long long MOD_ = (long long)1e9 + 7>
class ModMath {
public:
    ModMath(int N = 0)
        : N_(N)
    {
    }

    template <class... Ts>
    constexpr long long mul(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res * tail) % MOD_), 0)... };
        return res;
    }

    template <class... Ts>
    constexpr long long add(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res + tail) % MOD_), 0)... };
        return res;
    }

    constexpr long long pow(long long x, long long y)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = mul(ans, x);
            }
            x = mul(x, x);
            y >>= 1;
        }
        return ans;
    }

    long long combination(long long n, long long k)
    {
        if (k < 0 || k > n) {
            return 0;
        }
        if (fact_.empty()) {
            build_fact();
        }
        return mul(fact_[n], fact_inv_[k], fact_inv_[n - k]);
    }

private:
    void build_fact()
    {
        if (!fact_.empty()) {
            return;
        }
        fact_.resize(N_ + 1);
        fact_[0] = 1;
        for (ll i = 1; i <= N_; i++) {
            fact_[i] = mul(fact_[i - 1], i);
        }
        fact_inv_.resize(N_ + 1);
        fact_inv_[N_] = pow(fact_[N_], MOD_ - 2);
        for (ll i = N_ - 1; i >= 0; i--) {
            fact_inv_[i] = mul(fact_inv_[i + 1], (i + 1));
        }
    }

    int N_;
    vector<long long> fact_;
    vector<long long> fact_inv_;
};

void solve(long long N, long long K)
{
    ModMath<MOD> m;
    vector<ll> gcd_sums(K + 1);
    for (ll i = K; i >= 1; i--) {
        gcd_sums[i] = m.pow(K / i, N);
        for (ll j = 2; j * i <= K; j++) {
            gcd_sums[i] -= gcd_sums[i * j];
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= K; i++) {
        ans = m.add(ans, m.mul(i, gcd_sums[i]));
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,c,d=1,e=1;
  cin>>a;
  vector<int> b(a);
  fo(i,a)
    cin>>b[i];
  Sort(b);
  c=b.size();
  if(c%2==1){
    fo(i,a){
    if((i+1)/2*2!=b[i])
      d=0;
    }
  }
  else{
    fo(i,a){
      if(i/2*2+1!=b[i])
        d=0;
    }
  }
  if(d){
    fo(i,a/2){
      e*=2;
      e%=1000000007;
    }
  }
  else
    e=0;
  cout<<e<<endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int[] A;
    static int[] B;

    static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);
        B = sc.nextIntArray(N);
        System.out.println( solve() );
    }

    static long solve() {
        Arrays.sort(A);
        Arrays.sort(B);

        long ans = 1;
        int ai = 0;
        int bi = 0;
        int ab = 0;
        while(ai < N || bi < N) {
            if( bi == N ) {
                ans = ans * -ab % MOD;
                ai++;
                ab++;

            } else if( ai == N ) {
                ans = ans * ab % MOD;
                bi++;
                ab--;

            } else if( A[ai] < B[bi] ) {
                if( ab < 0 ) {
                    ans = ans * -ab % MOD;
                }
                ai++;
                ab++;

            } else {
                if( ab > 0 ) {
                    ans = ans * ab % MOD;
                }
                bi++;
                ab--;
            }
        }

        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Measured memory_bytes: 43548
def main():
    n = input()
    s = input()
    raw_list = list(map(int, s.split()))

    max = raw_list[0]
    count = 1

    for i in range(1,len(raw_list)):
        if raw_list[i] >= max:
            count += 1
            max = raw_list[i]
    print (count)

if __name__ == "__main__":
    main()

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int amin = 100005;
  int bmin = 100005;
  rep(i,A) {
    cin >> a[i];
    amin = min(amin, a[i]);
  }
  rep(i,B) {
    cin >> b[i];
    bmin = min(bmin, b[i]);
  }
  int ans = amin + bmin;
  rep(i, M){
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ans = min(ans, a[x]+b[y]-c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for i in range(m):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[u].append(v)
        E[v].append(u)

    # bipartite check
    col=[-1]*n
    col[0]=0
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv in E[v]:
            if(col[v]==col[nv]): # 二部グラフではない -> 全部繋げられる
                print(n*(n-1)//2-m)
                return
            elif(col[nv]!=-1 and col[nv]^col[v]): continue
            col[nv]=1-col[v]
            Q.append(nv)

    # 二部グラフ -> 偶数と奇数とが繋げられる
    even=col.count(0)
    odd=col.count(1)
    print(even*odd-m)
resolve()

Measured memory_bytes: 59244
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;
int main(){
  int N; cin >> N; string S; cin >> S; int max_cnt = 0;
  for(int i = 1; i < N; i++){
    string X,Y; X = S.substr(0,i); Y = S.substr(i,N - i); int cnt = 0;
    bool alphabet[26] = {false};
    for(int j = 0; j < X.size(); j++){
      alphabet[X[j] - 'a'] = true;}
    for(int k = 0; k < Y.size(); k++){
      if(alphabet[Y[k] - 'a'] == true){alphabet[Y[k] - 'a'] = false; cnt++;}}
    max_cnt = max(max_cnt,cnt);}
  
  cout <<max_cnt << endl;
  
  return 0;}

Measured memory_bytes: 384
#include<iostream>
#include<string>

void solve_A() {
	int S, W;
	std::cin >> S >> W;
	//std::string result = (S <= W ? "unsafe" : "safe");
	std::cout << (S <= W ? "unsafe" : "safe") << std::endl;
}

int main()
{
	solve_A();
    return 0;
}


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

int main() {
	string akb = "KIHBR";
	int index = 0;
	string buff;
	bool success = false;
	bool beforeA = false;
	getline(cin, buff);
	for (int i = 0; i < buff.length(); ++i) {
		if (buff[i] == akb[index]) {
			beforeA = false;
			++index;
			if (index >= akb.length()) {
				if (buff.length() - 1 - i > 1) {
					break;
				}
				else if (buff.length() - 1 - i == 1) {
					if (buff[i + 1] != 'A') {
						break;
					}
				}
				success = true;
				goto endLoop;
			}
		}
		else if (buff[i] == 'A') {
			if (beforeA) {
				beforeA = false;
				break;
			}
			else {
				switch (index) {
				case 0:
				case 3:
				case 4:
				case 5:
					beforeA = true;
					break;
				default:
					beforeA = false;
					goto endLoop;
					break;
				}
			}
		}
		else {
			beforeA = false;
			break;
		}
	}
endLoop:
	cout << (success ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int N; cin>>N;
  cout<<"Christmas";
  rep(i,25-N) cout<<" Eve";
}












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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

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

int main() {
	int N, a, b, ans=0;
	int tmp=0;
	cin >> N >> a >> b;
	REP(i, 1, N+1){
		if(i % 10 == 0) tmp = sum(i);
		else ++tmp;
		if(tmp >= a && tmp <=b) ans+=i; 
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int val, size_, heap[2097168]; char c[9];
inline void insert(int x) {
	int ptr = size_++; heap[ptr] = x;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
}
inline int extract() {
	int ret = heap[1], ptr = 1;
	while ((ptr << 1) + 1 < size_) {
		ptr <<= 1;
		if (heap[ptr] > heap[ptr + 1]) swap(heap[ptr >> 1], heap[ptr]);
		else swap(heap[ptr + 1], heap[ptr >> 1]), ptr++;
	}
	heap[ptr] = heap[--size_], heap[size_] = 0;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
	return ret;
}
int main() {
	size_ = 1;
	while (scanf("%s", c), c[2] != 'd') {
		if (c[0] == 'i') scanf("%d", &val), insert(val);
		else printf("%d\n", extract());
	}
	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int n=3;
  vector<int> v(n); rep(i, 0, n){ cin >> v[i]; }
  sort(all(v));
  Yes(v[0]+v[1]==v[2]);

    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use whiteread::parse_line;

fn main() {
    let (_n, k): (usize, usize) = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();
    let mut map: HashMap<usize, usize> = HashMap::new();

    for &ai in &a {
        map.entry(ai).and_modify(|x| *x += 1).or_insert(1);
    }
    let mut val: Vec<_> = map.values().collect();
    let len = val.len();
    println!(
        "{}",
        if len > k {
            val.sort();
            val.iter().take(len - k).fold(0, |x, &y| x + y)
        } else {
            0
        }
    );
}


Measured memory_bytes: 12180
open Batteries
let n = read_int ()
let h_list = read_line () |> String.split_on_char ' ' |> List.map int_of_string

let rec pp lst last =
  match lst with
  | [] -> []
  | first :: rest when last = -1 -> (first-1) :: pp rest (first-1)
  | first :: rest -> if first > last then (first-1) :: pp rest (first-1) else first :: pp rest first


let rec check lst last =
  match lst with
  | [] -> true
  | first :: rest when last = -1 -> check rest first
  | first :: rest -> if first < last then false else check rest first

let _ = if check (pp h_list (-1)) (-1) then print_endline "Yes" else print_endline "No"



Measured memory_bytes: 13952
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, k;
	cin >> n >> k;
	vector<int> v(n), up(n + 1);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	while (k--) {
		for (int i = 0; i < n; i++) {
			up[max(i - v[i], 0)]++;
			up[min(i + v[i] + 1, n)]--;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			v[i] = (sum += up[i]);
			up[i] = 0;
		}
		if (*min_element(all(v)) == n)
			break;
	}
	for (int i = 0; i < n; i++)
		cout << v[i] << ' ';
}


Measured memory_bytes: 4748
def answer(o: str, e: str) -> str:
    result = ''
    e += ' '
    for i in range(len(o)):
        result += o[i] + e[i]

    return result.strip()


def main():
    o = input()
    e = input()
    print(answer(o, e))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl
#define sz(a) (ll)(a.size())
#define endl "\n"

ll h[200005],a[200005],dp[200005],tree[800005];

void build(ll node, ll s,ll e){
  if(s==e){
    tree[node]=dp[s];
  }else{
    ll mid=(s+e)/2;
    build(2*node,s,mid);
    build(2*node+1,mid+1,e);
    tree[node]=max(tree[2*node],tree[2*node+1]);
  }
}

void update(ll node,ll index,ll s,ll e,ll val){
  if(s==e){
    tree[node]=val;
    dp[index]=val;
  }else{
    ll mid=(s+e)/2;
     if(index<=mid) update(2*node,index,s,mid,val);
     else update(2*node+1,index,mid+1,e,val);
     tree[node]=max(tree[2*node],tree[2*node+1]);
  }
}

ll query(ll node,ll l,ll r,ll s,ll e){
  if(r<s || l>e) return 0;
  else if(l<=s && e<=r) return tree[node];
  else {
    ll mid=(s+e)/2;
    return max(query(2*node,l,r,s,mid),query(2*node+1,l,r,mid+1,e));
  }
}


int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,1,n+1) cin>>h[i];
  forn(i,1,n+1) cin>>a[i];
  build(1,1,n);
  // dp[i] - max total beauty with last flower having height i
  for(ll i=1;i<n+1;i++){
    if(h[i]==1) {dp[h[i]]=a[i];update(1,h[i],1,n,dp[h[i]]);}
    else{
      dp[h[i]]=a[i]+query(1,1,h[i]-1,1,n);
      update(1,h[i],1,n,dp[h[i]]);
    }
  }
  ll ans=1;
  forn(i,1,n+1) ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11264
# coding: utf-8

def main():
    S = input()
    dic = {'N':0, 'S':0, 'E':0, 'W':0}
    ans = 'No'

    for s in S:
        dic[s] += 1

    if (dic['N'] == 0 and dic['S'] == 0) or (dic['N'] > 0 and dic['S'] > 0):
        if (dic['E'] == 0 and dic['W'] == 0) or (dic['E'] > 0 and dic['W'] > 0):
            ans = 'Yes'

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    vector<int> A(N, 0);
    vector<int> cnt(N, 1);
    A[0] = 1;
    rep(i, M){
        int x, y;
        cin >> x >> y;
        x--, y--;
        if(A[x] == 1){
            if(cnt[x] == 1){
                A[x] = 0;
            }
            A[y] = 1;
        }
        cnt[x]--;
        cnt[y]++;
    }
    
    int ret = 0;
    rep(i, N){
        if(A[i] > 0){
            ret++;
        }
    }
    output(ret, 0);
    
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 2e5 + 5;

ll ans[maxn];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	ll n = s.size();
	vector<ll>xd;
	for (ll i = 0; i < n - 1; i++) {
		if (s[i] == 'L' && s[i + 1] == 'R') {
			xd.push_back(i);
		}
	}
	xd.push_back(n - 1);
	for (ll i = 0; i < (ll)xd.size(); i++) {
		ll l = (i ? xd[i - 1] + 1 : 0);
		ll r = xd[i];
		ll pos = -1;
		for (ll j = l; j <= r; j++) {
			if (s[j] == 'L') {
				pos = j; break;
			}
		}
		for (ll j = l; j <= r; j++) {
			ll kek = 0;
			if (j <= pos) {
				kek = pos - j;
			}
			else {
				kek = j - pos;
			}
			if (kek % 2 == 0) {
				ans[pos] ++;
			}
			else {
				ans[pos - 1]++;
			}
		}
	}
	for (ll i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}

	return 0;

}
/*

*/

Measured memory_bytes: 1864
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(ll i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

ll N;
ll A[200010];
ll ans;

int main(){
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
    }
    if(A[0]!=0){
        p(-1);
        return 0;
    }

    RREP(i,1,N){
        if(A[i]>A[i-1]+1){
            p(-1);
            return 0;
        }
        if(A[i]==A[i-1]+1){
            ans++;
        }else{
            ans+=A[i];
        }

    }

    p(ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll res = max({a,b,c}) * 10;
  res += a + b + c - max({a,b,c});
  cout << res << endl;
}

Measured memory_bytes: 3624