akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

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

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

int main()
{
	ll n, x;
	cin >> n >> x;
	vector<ll> subl;
	rep(i, n) {
		ll xx;
		cin >> xx;
		subl.push_back(abs(x - xx));
	}
	ll g = subl[0];
	rep(i, n) {
		g = gcd(subl[i], g);
	}
	cout << g << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 4144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<b){
			System.out.println("a < b");
		}
		else if(a>b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26324
#include<iostream>
#include<vector>
int main() {
	std::vector<int> seki;
	int n;
	int k = 0;
	std::cin >> n;
	for (int i=0; i < 10; i++) {
		for (int j=0; j < 10; j++) {
			seki.emplace_back(i * j);
		}
	}
	for (int i=0; i < seki.size(); i++) {
		if (seki[i] == n) {
			k = 1;
			break;
		}
	}
	if (k == 1) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin >> s;
    int ans = 1 << 29;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (int(s[i] - '0') == i % 2)
        {
            cnt++;
        }
    }
    ans = min(cnt, ans);
    cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (int(s[i] - '0') == (i + 1) % 2)
        {
            cnt++;
        }
    }
    ans = min(cnt, ans);
    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

num = [0]*(10**6+1)

for x in a:
    num[x] += 1

pairwise = True
for i in range(2, 10**6+1):
    cnt = sum(num[i::i])
    if cnt == n:
        print('not coprime')
        exit()
    if cnt > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    print('setwise coprime')
    


Measured memory_bytes: 127452
use itertools::Itertools;

fn main() {
    let a: u32 = text_io::read!();
    let mut sum= 0;
    let b = a.to_string().chars().map(|a|a.to_digit(10).unwrap()).collect_vec();
    for i in 0..b.len() {
        sum+=b[i];
    }
    println!("{}",if a%sum==0 {"Yes"}else{"No"})
}

Measured memory_bytes: 2156
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
H = [0]+list(map(int, input().split()))
dp = [[[10**18]*(N+1) for _ in range(K+1)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for j in range(K+1):
        for k in range(N+1):
            if j+1<=K:
                dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k])
            
            dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][k]+max(0, H[i+1]-H[k]))

ans = 10**18

for i in range(K+1):
    for j in range(N+1):
        ans = min(ans, dp[N][i][j])
    
print(ans)

Measured memory_bytes: 256008
# D - I hate Factorization
M = 1000
N = [0]
for i in range(1,M+1):
    N.append(i)
    N.append(-i)

def main(X):
    global N
    for i in N:
        for j in N:
            if i**5-j**5==X:
                return i,j

X = int(input())
A,B = main(X)
print(A,B)

Measured memory_bytes: 9128
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>

#define PII pair<int,int>
#define LLI long long int

using namespace std;
#define WMAX 1000000010
int main(){
	int N,W;cin>>N>>W;
	vector<int>w(N+1);
	vector<int>v(N+1);
	for(int i=1;i<=N;i++)cin>>w[i]>>v[i];
	vector<vector<int> >dp(N+1,vector<int>(200010,WMAX));
	for(int i=0;i<=N;i++)dp[i][0]=0;
	for(int i=1;i<=N;i++){
		for(int j=0;j<100010;j++){
			if(dp[i-1][j]<WMAX){
				dp[i][j]=min(dp[i][j],dp[i-1][j]);
				dp[i][j+v[i]]=min(dp[i-1][j]+w[i],dp[i][j+v[i]]);
				//cout<<i<<" "<<j<<endl;
			}
		}
	}
	//for(int i=0;i<=N;i++){
	//	for(int j=0;j<40;j++)cout<<dp[i][j];
	//	cout<<endl;
	//}
	int ans=0;
	for(int j=0;j<100010;j++)if(dp[N][j]<=W)ans=j;
	cout<<ans<<endl;


	return 0;
}



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

using namespace std;

int N, K;
char sir[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s\n", sir + 1), N = strlen (sir + 1);
scanf ("%d", &K);
for (int i=1; i<=N; i++)
if (sir[i] != 'a')
{
    int need = 'z' - sir[i] + 1;
    if (need <= K) K -= need, sir[i] = 'a';
}
K %= 26;
while (K --) if (++sir[N] == 'z' + 1) sir[N] = 'a';
printf ("%s\n", sir + 1);
return 0;
}


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

#define QQ_LIMIT 9


int main(void){

  for(int i = 1 ;i <= QQ_LIMIT ;i++){
    for(int j = 1 ;j <= QQ_LIMIT ;j++ ){
      cout << i << "x" << j << "=" << i*j << endl;
    }
  }

  return 0;
}

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

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  char s[2][n+5];
  cin >> s[0] >> s[1];
  long ans;
  int i;
  bool one;
  if (s[0][0] == s[1][0]) {
    ans = 3;
    one = true;
    i = 1;
  }
  else {
    ans = 6;
    one = false;
    i = 2;
  }
  for (; i<n; i++) {
    if (one) {
      if (s[0][i] == s[1][i]) {
        ans *= 2;
        ans %= MOD;
        one = true;
      } else {
        ans *= 2;
        ans %= MOD;
        one = false;
        i++;
      }
    } else {
      if (s[0][i] == s[1][i])
        one = true;
      else {
        ans *= 3;
        ans %= MOD;
        one = false;
        i++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int a,b;
  cin >> a >> b;
  vi tower(1005,0);
  for(int i=1;i<1000;i++)
    {
      int tmp=1;
      for(int j=0;j<i;j++)
	{
	  tower[i]+=tmp;
	  tmp++;
	}
    }
  int c=b-a;
  cout << tower[c]-b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    rep(i,n-1)a[i+1] += a[i];
    int ans = INF;
    rep(i,n-1){
        int x = a[i];
        int y = a[n-1]-a[i];
        ans = min(ans, abs(x-y));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m;
    cin >> n >> m;
    vll ac(n), wa(n);
    ll p;
    string s;
    REP(i, m) {
        cin >> p >> s;
        p--;
        if (ac[p]) continue;
        if (s == "AC") {
            ac[p] = 1;
        }
        else wa[p]++;
    }
    ll acs = 0, was = 0;
    REP(i, n) {
        if (ac[i]) {
            acs++;
            was += wa[i];
        }
    }
    cout << acs << " " << was << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;n>i;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	cout<<a.at(n-1)-a.at(0)<<endl;
}

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

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

  
  
   if(b<=a+2*k-1){
    for (int i=a;i<b+1;i++){
      cout<<i<<endl;
    }
  }
    
   else {
     for (int i=a;i<a+k;i++){
       cout<<i<<endl;
     }
     for (int i=b-k+1;i<b+1;i++){
       cout<<i<<endl;
     }
   }
    
    
  
}

  













Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	char maze[H][W];
	rep(h, 0, H) rep(w, 0, W) cin >> maze[h][w];

	int cost[H][W];
	int wall_num = 0;
	rep(h, 0, H) rep(w, 0, W) {
		if(maze[h][w] == '#') wall_num++;
		cost[h][w] = 1e9;
	}

	cost[0][0] = 0;
	queue<pair<int, int> > q;
	q.push(make_pair(0, 0));

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

	while(!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();
		int x = p.first, y = p.second;
		rep(i, 0, 4) {
			int nx = x + dx[i], ny = y + dy[i];
			if(0 <= nx and nx < W and 0 <= ny and ny < H) {
				if(cost[ny][nx] != 1e9) continue;
				if(maze[ny][nx] == '#') continue;
				cost[ny][nx] = cost[y][x] + 1;
				q.push(make_pair(nx, ny));
			}
		}
	}

	if(cost[H - 1][W - 1] == 1e9) {
		cout << -1 << endl;
		return 0;
	}

	int rsl = H * W - (cost[H - 1][W - 1] + 1) - wall_num;
	cout << rsl << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,N;
  cin>>N;
  vec a(50000,1);
  a[1]=0;
  For(i,2,50001){
    if(a[i]){
      for(j=2;i*j<=50000;j++)a[i*j]=0;
    }
  }
  j=11;
  rep(i,N){
    while(a[j]==0)j+=5;
    cout<<j<<" ";
    j+=5;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 640
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $k);
$factors = [];
if ($b-$a >= 2*$k){
    for ($tmp = $a; $tmp < $a+$k; $tmp++){
        array_push($factors, $tmp);
    }
    for ($tmp = $b-$k+1; $tmp <= $b; $tmp++){
        array_push($factors, $tmp);
    }
} else {
    for ($tmp = $a; $tmp <= $b; $tmp++){
        array_push($factors, $tmp);
    }
}
sort($factors);
for ($tmp = 0; $tmp < count($factors); $tmp++){
    print("{$factors[$tmp]}\n");
}
?>

Measured memory_bytes: 4728
N=int(input())
A,B= map(int, input().split())
P = [int(_) for _ in input().split()]
A_c=B_c=A_B=0
for i in range(N):
    if P[i]<=A: 
        A_c = A_c+1
    elif P[i]>B: 
        B_c = B_c+1
    else:
        A_B = A_B+1
print(min(A_B,A_c,B_c))

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int[][] dist, enemy;
	int n, m, l;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			m = sc.nextInt();
			l = sc.nextInt();
			if( (n|m|l) == 0 ) break;
			
			dist = new int[n][n]; enemy = new int[n][n];
			for(int[] a: dist) fill(a, INF);
			for(int[] a: enemy) fill(a, INF);
			
			for(int i=0;i<m;i++) {
				int a = sc.nextInt()-1, b = sc.nextInt()-1, d = sc.nextInt(), e = sc.nextInt();
				dist[a][b] = dist[b][a] = d;
				enemy[a][b] = enemy[b][a] = e;
			}
			
			System.out.println(dijkstra());
		}
	}
	
	int dijkstra() {
		int[][] cost = new int[n][l+1];
		for(int[] a: cost) fill(a, INF);
		
		PriorityQueue<E> que = new PriorityQueue<E>();
		que.add(new E(0, l, 0));
		cost[0][l] = 0;
		for(;!que.isEmpty();) {
			E cur = que.remove();
			if(cost[cur.p][cur.l] != cur.c) continue;
			if(cur.p == n-1) return cur.c;
			
			for(int i=0;i<n;i++) {
				if(cost[i][cur.l] > cur.c + enemy[cur.p][i]) {
					cost[i][cur.l] = cur.c + enemy[cur.p][i];
					que.add(new E(i, cur.l, cur.c + enemy[cur.p][i]));
				}
				if(cur.l-dist[cur.p][i]>=0 && cost[i][cur.l-dist[cur.p][i]] > cur.c) {
					cost[i][cur.l - dist[cur.p][i]] = cur.c;
					que.add(new E(i, cur.l-dist[cur.p][i], cur.c));
				}
			}
		}
		return -1;
	}
	
	class E implements Comparable<E> {
		int p, l, c;
		
		E(int p, int l, int c) {
			this.p = p;
			this.l = l;
			this.c = c;
		}
		
		public int compareTo(E o) {
			// TODO Auto-generated method stub
			return c-o.c;
		}
		
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 60764
// C++ program of a space optimized DP solution for 
// 0-1 knapsack problem. 
#include<bits/stdc++.h> 
using namespace std; 
#define int long long
// val[] is for storing maximum profit for each weight 
// wt[] is for storing weights 
// n number of item 
// W maximum capacity of bag 
// dp[W+1] to store final result 
int KnapSack(int val[], int wt[], int n, int W) 
{ 
    // array to store final result 
    //dp[i] stores the profit with KnapSack capacity "i" 
    int dp[W+1]; 
      
    //initially profit with 0 to W KnapSack capacity is 0 
    memset(dp, 0, sizeof(dp)); 
  
    // iterate through all items 
    for(int i=0; i < n; i++)  
        //traverse dp array from right to left 
        for(int j=W; j>=wt[i]; j--) 
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
    /*above line finds out maximum of  dp[j](excluding ith element value) 
      and val[i] + dp[j-wt[i]] (including ith element value and the 
      profit with "KnapSack capacity - ith element weight") */    
    return dp[W]; 
} 
  
// Driver program to test the cases 
int32_t main() 
{ 
	int val[102], wt[102];
	int n, W; cin>>n>>W;
	for(int i = 0; i < n; i++){
		cin>>wt[i]>>val[i];
	}
    //int val[] = {7, 8, 4}, wt[] = {3, 8, 6}, W = 10, n = 3; 
    cout << KnapSack(val, wt, n, W) << endl; 
    return 0; 
} 
  
// This code is contributed by Gaurav Mamgain 


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	long long cnt[200];
	vector<int> p;
	for(int i=2;i<999;i++){
		bool ok=true;
		for(int j=0;j<p.size();j++)if(i%p[j]==0)ok=false;
		if(ok)p.push_back(i);
	}
	for(int i=0;i<200;i++)cnt[i]=1;
	int n;cin>>n;
	for(int i=2;i<=n;i++){
		int k=i;
		for(int j=0;j<p.size();j++){
			while(k%p[j]==0)cnt[j]++,k/=p[j];
		}
	}
	long long ans=1;
	for(int i=0;i<200;i++){
		ans*=cnt[i];
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    string A, B;
    cin >> A >> B;
    FOR(i, 0, N)
        cout << A[i] << B[i];
    cout << endl;
    return 0;
};

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

int main() {
	int h, w;
	cin >> h >> w;
	char grid[h][w];
	int dp[h][w];
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i == 0 && j ==0){
				continue;
			}
			else if(i == 0){
				if(grid[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = dp[i][j - 1];
				}
			}
			else if(j == 0){
				if(grid[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = dp[i - 1][j];
				}
			}
			else{
				if(grid[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = (dp[i - 1][j]%1000000007 + dp[i][j - 1]%1000000007)%1000000007;
				}
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<int> R,C;

int row[100010];
int col[100010];

int main(){
  cin>>N;
  R.resize(N);
  C.resize(N);
  rep(i,N) cin>>R[i]>>C[i];

  for(int i=0;i<N;i++){
    if(row[R[i]]>0||col[C[i]]>0){
      cout<<-1<<endl;
      return 0;
    }
    row[R[i]]=C[i];
    col[C[i]]=R[i];
  }

  ll ans=0;
  for(int i=1;i<=N;i++){
    if(row[i]==i) continue;
    swap(row[i],row[row[i]]);
    ans++;
    i--;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
int s,i,a[5],sum;
int main()
{
	cin>>s;
	a[1]=s%10;
	a[2]=(s%100-a[1])/10;
	a[3]=(s/100)%10;
	a[4]=s/1000;
	for(i=1;i<=4;i++)
	if(a[i]==2)
	sum++;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, n;
    scanf("%d", &n);
    if(n==1){
        printf("Hello World\n");
    }
    else{
        scanf("%d%d", &a, &b);
        printf("%d\n", a+b);
    }
    return 0;
}
    


Measured memory_bytes: 128
n,a,b,c,d = (int(i)-1 for i in input().split())
s = input()
if c<d:
    if ("##" in s[a+1:c]) or ("##" in s[b+1:d]): x = "No"
    else: x = "Yes"
else:
    if "..." in s[b-1:d+2]: x = "Yes"
    else: x = "No"
print(x)

Measured memory_bytes: 3572
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  sum <$> replicateM 10 (getl toInt) >>= print

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 3704
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll n;
cin>>n;
ll cnt=0;
for(ll i=1;i<=n;i++)
{
    if(i&1)
    {
        cnt++;
    }
}
double prob=(cnt*1.0)/(n*1.0);
cout<<prob<<endl;
return 0;
}


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

int main() {
    cin >> S;
    int len = S.length();
    for(int i = 0; i < len-1; ++i) {
        if(S.at(i) == S.at(i+1)) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var x = myRead.readInt();
            int ans = 8 - (x - 400) / 200;
            WriteLine(ans);
            Out.Flush();
        }




    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }


}

Measured memory_bytes: 27484
use std::cmp::{min,max};
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main(){
    let n = read::<i32>();
    let mut v = Vec::new();
    let mut maxv:i32 = -10000000000000000;
    
    for _ in 0..n{ v.push(read::<i32>()) }
    let mut minv:i32 = v[0];
    for j in 1..n as usize{
        maxv = max(maxv,v[j] - minv);
        minv = min(minv,v[j])
    }
    println!("{}",maxv);
}


Measured memory_bytes: 5040
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define mod 1000000007
#define MOD mod
#define sec setprecision
#define RAND_MAX 0x7fffffff
using namespace std;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a)%mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rip(i, n)cin >> a[i], a[i]--;
	int count = 0;
	for (int i= 0; i < n; i++) {
		if (a[i] == count)count++;
	}
	if (count == 0)cout << -1 << endl;
	else cout << n - count << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int MOD = 1000000007;

map<long long, int> mp;
void prime_factorization(long long num) {
  for (long long i = 2; i * i <= num; ++i) {
    if (num % i != 0) continue;
    int exponent = 0;
    while (num % i == 0) {
      ++exponent;
      num /= i;
    }
    mp[i] += exponent;
  }
  if (num != 1) ++mp[num];
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  FOR(i, 2, n + 1) prime_factorization(i);
  long long ans = 1;
  FOR(i, 2, n + 1) if (mp[i] > 0) (ans *= (mp[i] + 1)) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  set<int> l;
  for(int i=1; i<10; i++)for(int j=1; j<10; j++){
    l.insert(i*j);
  }
  cout<<(l.count(n) ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) {
    cout << (m == 1 ? 1 : max(m - 2, 0)) << '\n';
  } else if (n == 2) {
    cout << 0 << '\n';
  } else {
    cout << 1LL * n * m - n * 2 - m * 2 + 4 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3620
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var arr=(Arr[1]).split(" ").map(Number);
var min=arr.reduce(function(a,b){return Math.min(a,b);});
var max=arr.reduce(function(a,b){return Math.max(a,b);});
var sum=arr.reduce(function(a,b){return a+b;});
console.log(min+" "+max+" "+sum);

Measured memory_bytes: 17812
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import time
from sys import stdin
from Queue import Queue
start = time.clock()
i = 0
num=int(stdin.readline())
L=[]
for _ in range(num):
    L.append([int(s) for s in stdin.readline().split()[2:]])

d=[-1]*num
d[0]=0
q=Queue(100)
q.put(0)
while not q.empty():
    u=q.get()
    for v in L[u]:
        if d[v-1]<0:
            d[v-1]=d[u]+1
            q.put(v-1)
for i,v in enumerate(d):
    print (i+1,v)

Measured memory_bytes: 4840
n,m=map(int,input().split())
a=list()
c=list()
for i in range(n):
    a.append(list(map(int,input().split())))
    a[i].append(sum(a[i]))
    print(" ".join(list(map(str,a[i]))))
for i in range(m+1):
    z=0
    for j in range(n):
        z+=a[j][i]
    c.append(z)
print(" ".join(list(map(str,c))))


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

void F(int x,map<int,int>&mp){
  if(x <= 1)return;
  if(x == 2){
    mp[x]++;
    return;
  }
  if((x&1)==0){
    F(2,mp);F(x>>1,mp);
    return;
  }
  for(int i = 3; i*i <= x; i+=2){
    if(x % i == 0){
      F(i,mp);F(x/i,mp);
      return;
    }
  }
  mp[x]++;
}

int Cnt(int x){
  int cnt = 0;
  while(x%2 == 0){
    x /= 2;
    cnt++;
  }
  return cnt;
}

void M(map<int,int>&a,map<int,int>&b){
  for(auto&e:b){
    ChangeMax(a[e.first],e.second);
  }
}

int Pow(int a,int b){
  if(b == 0) return 1;
  if(b == 1) return a;
  if((b&1) == 1) return Pow(Pow(a,b>>1),2)*a;
  if(b == 2) return a*a;
  return Pow(Pow(a,b>>1),2);
}

int main(){
  int n;ll m; cin >> n >> m;
  vector<int> v(n); cin >> v;
  {
    int pre = 0;
    for(int i = 0; i < n; ++i){
      if(i == 0)pre = Cnt(v[i]);
      else if(pre != Cnt(v[i])){
	cout << 0 << endl;
	return 0;
      }
    }
  }  
  map<int,int> mp;
  for(auto e:v){
    map<int,int> nw;
    F(e,nw);
    M(mp,nw);
  }
  ll base = 1;
  for(auto e:mp){
    base *= Pow(e.first,e.second);
  }
  int ans = 2*m/base;
  ans = (ans+1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double PI =acos(-1);

int main()
{
	double a, b, rad, h, s, l;
	cin >> a >> b >> rad;
	rad = rad * PI/180;
	h = b * sin(rad);
	s = a * h * 0.5;
	l = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(rad));

	cout << fixed << setprecision(10) << s << '\n'
		 << l << '\n'
		 << h << '\n';
	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
int n,flag=1;

char ss[200];
cin>>n;
for(int i=0;i<n;i++){
cin>>ss[i];
}
if(n%2!=0) {
        flag=0;
}

else if(n%2==0)
{
  for(int i=0;i<(n/2);i++){
    if(ss[i]!=ss[n/2+i]){
        flag=0;
        break;
    }

  }

}
if(flag) cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
return 0;
}

Measured memory_bytes: 3628
import math
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]

OK = max(H)//B+1
NG = 0

ans = OK
while OK-NG > 1:
    mid = (OK+NG)//2  # 試行する値
    cnt = 0

    for h in H:
        if h > mid*B:
            cnt += math.ceil((h-mid*B)/(A-B))

    if cnt <= mid:
        OK = mid
    else:
        NG = mid

print(OK)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}
int dpx[5000][10000];
int dpy[5000][10000];


int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;s.push_back('T');
    int x, y;cin >> x >> y;
    int n = s.size();
    vector<int> xx;
    vector<int> yy;
    int b = 0;
    int count = 0;
    for(int i=0;i<n;i++){
        if(s[i] == 'T'){
            if(count%2 == 0){
                xx.push_back(i-b);
            }else{
                yy.push_back(i-b);
            }
            count++;
            b = i+1;
        }
    }
    int nx = xx.size();
    memset(dpx, 0, sizeof(dpx));
    dpx[0][5000] = 1;
    for(int i=0;i<nx;i++){
        for(int j=0;j<10000;j++){
            if(dpx[i][j] == 1){
                dpx[i+1][j+xx[i]] = 1;
                if(i != 0){
                    dpx[i+1][j-xx[i]] = 1;
                }
            }
        }
    }
    int ny = yy.size();
    memset(dpy, 0, sizeof(dpy));
    dpy[0][5000] = 1;
    for(int i=0;i<ny;i++){
        for(int j=0;j<10000;j++){
            if(dpy[i][j] == 1){
                dpy[i+1][j+yy[i]] = 1;
                dpy[i+1][j-yy[i]] = 1;
            }
        }
    }
    //cout << dpx[nx][5000+x] << " " << dpy[ny][5000+y] << endl;
    if(dpx[nx][5000+x] == 1 && dpy[ny][5000+y] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 391040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
// #define PI 3.14159265358979323846264338327950L

int main() {
  while(1) {
    string s;
    cin >> s;
    if(s == "0") break;

    int sum = 0;
    rep(i, s.size()) {
      sum += s[i] - '0';
    }

    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	k <- readInt
	as <- map ( \a -> [a] ) <$> readInts
	print . ( * 2 ) . sum . map minimum . map ( [ id, ( k - ) ] <*> ) $ as


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

int main() {
  long long int a, b, k;
  cin >> a >> b >> k;
  //cout << a << " " << b << " " << k << endl;
  
  if(a >= k){
    a -= k;
  }else if(a < k && k <= (a + b)){
    b -= k - a;
    a = 0;
  }else{
    a = 0;
    b = 0;
  }
  cout << a << " " << b <<endl;
}

Measured memory_bytes: 384
local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.update = function(self, idx)
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    self:update(idx)
  end
end
SegTree.opValue = function(self, idx, value)
  self.stage[self.stagenum][idx] = self.func(self.stage[self.stagenum][idx], value)
  self:update(idx)
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local function axiscomp(ary)
  local z = {}
  for i = 1, #ary do
    z[i] = ary[i]
  end
  table.sort(z)
  local ac, acinv = {}, {}
  local cur = 0
  for i = 1, #z do
    if not acinv[z[i]] then
      cur = cur + 1
      ac[cur] = z[i]
      acinv[z[i]] = cur
    end
  end
  return ac, acinv
end

local n = io.read("*n")
local xs, ys = {}, {}
local idx = {}
for i = 1, n do
  xs[i], ys[i] = io.read("*n", "*n")
  idx[i] = i
end
table.sort(idx, function(a, b) return xs[a] < xs[b] end)
local ycomp, yinv = axiscomp(ys)
local st_xpy = SegTree.new(n, mmi, 10 * 1000000007)
local st_xmy = SegTree.new(n, mmi, 10 * 1000000007)
local ret = 0
for i = 1, n do
  local x, y = xs[idx[i]], ys[idx[i]]
  local ypos = yinv[y]
  ret = mma(ret, x + y - st_xpy:getRange(1, ypos))
  ret = mma(ret, x - y - st_xmy:getRange(ypos, n))
  st_xpy:opValue(ypos, x + y)
  st_xmy:opValue(ypos, x - y)
end
print(ret)


Measured memory_bytes: 33460
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Reverse Game
public class Main{
	Scanner sc=new Scanner(System.in);

	int m, n;
	int[][] a;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		a=new int[n][m];
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				a[j][i]=sc.nextInt();
			}
		}
		solve();
	}

	void solve(){
		int N=n*m, M=N/64+1;
		long[][] A=new long[N][M];
		for(int y=0; y<n; y++){
			for(int x=0; x<m; x++){
				int q=y*m+x;
				for(int j=0; j<n; j++){
					for(int i=0; i<m; i++){
						if(i==x||j==y||abs(x-i)==abs(y-j)){
							int p=j*m+i;
							A[q][p>>>6]|=1L<<(p&63);
						}
					}
				}
				if(a[y][x]==1){
					int p=m*n;
					A[q][p>>>6]|=1L<<(p&63);
				}
			}
		}
		int rank=0;
		boolean NG=false;
		for(int j=0; j<N; j++){
			int at=-1;
			for(int i=j; i<N; i++){
				if((A[i][j>>>6]>>>(j&63)&1)==1){
					at=i;
					break;
				}
			}
			if(at==-1){
				continue;
			}
			long[] t=A[j];
			A[j]=A[at];
			A[at]=t;
			for(int k=j+1; k<N; k++){
				if((A[k][j>>>6]>>>(j&63)&1)==1){
					for(int i=0; i<M; i++){
						A[k][i]^=A[j][i];
					}
				}
			}
			rank++;
		}
		for(int j=N-1; j>=0; j--){
			int at=-1;
			for(int i=N-1; i>=0; i--){
				if((A[j][i>>>6]>>>(i&63)&1)==1){
					at=i;
					break;
				}
			}
			if(at==-1){
				NG|=(A[j][m*n/64]>>>(m*n%64)&1)==1;
				continue;
			}
			for(int k=j-1; k>=0; k--){
				if((A[k][at>>>6]>>>(at&63)&1)==1){
					for(int i=0; i<M; i++){
						A[k][i]^=A[j][i];
					}
				}
			}
		}
		println(NG?"0":powMod(2, N-rank, (long)1e9+9)+"");
	}

	long powMod(long x, long k, long mod){
		if(k==0){
			return 1%mod;
		}else if(k%2==0){
			return powMod(x*x%mod, k/2, mod);
		}else{
			return x*powMod(x, k-1, mod)%mod;
		}
	}

	void println(String s){
		System.out.println(s);
	}

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

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

struct Node{
  struct Node *prev;
  struct Node *next;
  long key;
};

typedef struct Node * np;
np MN(long);
void IN(np);
void DN(np);
void FI(long);
np dummy;

int main(){
  long int val,i,n;
  char op[12];
  np roop;
  
  scanf("%ld",&n);
  dummy = MN(0);
  
  for(i=0;i<n;i++){
    scanf("%s",op);
    
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      DN(dummy->next);
    }
    else if(strcmp(op,"deleteLast") == 0){
      DN(dummy->prev);
    }
  }

  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");

  return 0;
}

void FI(long value){
  np n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
    
}

void DN(np th){
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}

void IN(np newn){
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}

np MN(long key){
  np not = (np)malloc(sizeof(struct Node));
  //n = new struct node();
  not->prev = not;
  not->next = not;
  not->key = key;
  return not;
} 



Measured memory_bytes: 33000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    string s, t;    cin >> s >> t;
    string ans="No";
    if(s.size()+1==t.size() && s.substr(0, s.size()) == t.substr(0, s.size())){
        ans = "Yes";
    }
    cout << ans << endl;
}



Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    s1, s2 = 0, 0
    c1, c2 = 0, 0
    for i in range(N):
        if i % 2 == 0:
            if s1 + A[i] > 0:
                s1 += A[i]
            else:
                c1 += abs(s1 + A[i]) + 1
                s1 = 1
            if s2 + A[i] < 0:
                s2 += A[i]
            else:
                c2 += abs(s2 + A[i])+1
                s2 = -1
        else:
            if s1 + A[i] < 0:
                s1 += A[i]
            else:
                c1 += abs(s1 + A[i]) + 1
                s1 = -1
            if s2 + A[i] > 0:
                s2 += A[i]
            else:
                c2 += abs(s2 + A[i]) + 1
                s2 = 1
    print(min(c1, c2))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 63724
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int sum = 0;
	bool t = 0;
	string s;
	cin >> s;
	for (int i = 0;i < s.size() - 1;i++) {
		if (t) {
			if (s[i + 1] != '9')s[i + 1] = '9';
		}
		else {
			if (s[i + 1] != '9') {
				s[i] = (s[i] - '0' - 1) + '0';
				s[i + 1] = '9';
				t = 1;
			}
		}
	}
	for (int i = 0;i < s.size();i++)sum += (int)(s[i] - '0');

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256