akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <random>
#include <functional>
#include <ctime>

using std::cout;
using std::endl;
using std::cin;

constexpr char dir[] = {'N','E','W','S'};

class dice{
public:
	explicit dice(int in[6]){
		for(int i=0;i<6;i++){
			v[i]=in[i];
		}
	}
	void mov(const char c){
		int buf;
		switch(c){
			case dir[0]:{
				buf = v[0];
				v[0] = v[1];
				v[1] = v[5];
				v[5] = v[4];
				v[4] = buf;
				break;
			}
			case dir[1]:{
				buf = v[0];
				v[0] = v[3];
				v[3] = v[5];
				v[5] = v[2];
				v[2] = buf;
				break;
			}
			case dir[2]:{
				buf = v[0];
				v[0] = v[2];
				v[2] = v[5];
				v[5] = v[3];
				v[3] = buf;
				break;
			}
			case dir[3]:{
				buf = v[0];
				v[0] = v[4];
				v[4] = v[5];
				v[5] = v[1];
				v[1] = buf;
				break;
			}
		}
	}
	int operator[](size_t i){return v[i];}
	bool operator==(dice d){
		for(int i=0;i<6;i++){
			if(v[i]!=d[i])return false;
		}
		return true;
	}
	bool operator!=(dice d){
		return !operator==(d);
	}
private:
	int v[6];
};

bool issame(dice d1,dice d2){
	int i=0;
	auto rgen = std::bind(std::uniform_int_distribution<>(0,3),std::mt19937(time(nullptr)));
	while(i<100){
		d1.mov(dir[rgen()]);
		if(d1==d2)return true;
		i++;
	}
	return false;
}

int main(){
	int in1[6],in2[6];
	for(int i=0;i<6;i++){
		cin >> in1[i];
	}
	for(int i=0;i<6;i++){
		cin >> in2[i];
	}
	cout << (issame(dice(in1),dice(in2))?"Yes":"No") << endl;
}

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

using namespace std;

const int N = 1e5 + 100, C = 29;

int a[N], cnt[N];
int n, ans, tmp;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j <= C; j++)
			if ((a[i] >> j) & 1) {
				cnt[j]++;
				break;
			}
		tmp ^= a[i];
	}
	for (int i = C; i >= 0; i--) {
		if ((tmp >> i) & 1) {
			if (!cnt[i])
				return cout << -1, 0;
			ans++;
			tmp ^= (1 << (i + 1)) - 1;
		}
	}
	return cout << ans, 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
	    Scanner sc=new Scanner(System.in);
	    long mod=1000000007;
	    int n=sc.nextInt();
	    long ans=pow(10,n,mod)-pow(9,n,mod)-pow(9,n,mod)+pow(8,n,mod);
	    while(ans<0) {
	    	ans+=mod;
	    }
		System.out.println(ans%mod);
	}
	static long pow(long val,int n,long mod) {
		if(n==0) return 1;
		if(n==1) return val;
		long root=pow(val,n/2,mod);
		root=(root*root)%mod;
		if(n%2!=0) {
			root=root*val;
			root%=mod;
		}
		return root%mod;
	}
}
class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}



Measured memory_bytes: 35492
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
 
#define INF 1000000021
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll MOD =  1000000007ll; 
 ll a[N], b[N], d[N];
ll bn(ll x, ll y)
{
	ll r = 1;
	for(;y>0;y>>=1ll)
	{
		if(y & 1)
			r = (r * x) % MOD;
		x = (x * x) % MOD;
	}
	return r;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i]; 
	ll ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		ll x = 0, y = 0;
		for(int j = 1; j <= n; j ++)
			x += (a[j] < a[i]);
		b[i] = x;
		for(int j = i + 1; j <= n; j ++)
			y += (a[j] < a[i]);
		d[i] = y;
		ll s = ((((d[i] + d[i] + (k-1)*b[i])%MOD)*k)%MOD)*(bn(2,MOD-2));
		ans = (ans + s) % MOD;
	}
	cout << ans;
 
 
 
 
 
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 2304
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll a,b,x;
    std::cin >> a>>b>>x;
    if(a==0){
        std::cout << b/x+1 << std::endl;
    }else{
        std::cout << b/x-(a-1)/x << std::endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#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 MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, K;
    cin >> N >> K;

    // N+1
    vector<ll> A;
    A.push_back(0);
    REP(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }

    vector<ll> S(N+1);
    REP(i,N+1){
        S[i] = A[i];
        if(i > 0)
            S[i] += S[i-1];
        S[i] %= K;
    }

    vector<ll> X(N+1);
    REP(i,N+1){
        ll x = S[i] - i%K;
        X[i] = (K + x) % K;
    }

    //for(auto&& x : X)
    //    cout << x << endl;

    map<ll, ll> ma;
    REP(i,min(K,N+1)){
        ma[X[i]]++;
    }

    ll ans = 0;
    REP(i,N+1){
        ll x = X[i];
        ma[x]--;

        ll num = ma[x];
        ans += num;

        if(i + K < N+1){
            ll add = X[i+K];
            ma[add]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17392
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, m, s[2222], t[2222];
int dp[2222][2222];
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> s[i];
	rep(i, m)cin >> t[i];
	rep(i, n + 1)dp[i][0] = 1;
	rep(i, m + 1)dp[0][i] = 1;
	rep(i, n)rep(j, m) {
		if (s[i] == t[j]) {
			dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
		}
		else {
			dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
		}
		dp[i + 1][j + 1] += mod;
		dp[i + 1][j + 1] %= mod;
	}
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 35072
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    string s;
    cin >> n >> s >> k;
    REP(i, n){
        if(s[i] != s[k-1]){
            s[i] = '*';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

template<typename T>
T gcd(T a,T b){
    if(b==0)return a;
    return gcd(b,a%b);
}

template<typename T>
T lcm(T a,T b){
    T d=gcd(a,b);
    return (a/d)*b;
}

int main(){
    int n;
    std::cin>>n;
    int ans=1;
    for(int i=0;i<n;++i){
        int a;
        std::cin>>a;
        ans=lcm(ans,a);
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 3108
// 解き直し.
// https://img.atcoder.jp/agc009/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
#define pb push_back
int d[101010];    // 頂点 1 からの 距離 を 保存.
int dp[101010];   // 人 v に対応する頂点を根とした部分木だけに限定した場合のトーナメントの深さの最小値.
int memo[101010]; // 訪問済みフラグ.

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param G: グラフ.
// @param s: グラフの探索開始頂点.
// @param d: 探索開始地点からの距離.
// @return: 特に無し.
void bfs(vvi &G, int s, int* d){
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    d[s] = 0; // スタート地点は, 距離ゼロを指定.
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : G[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            if(d[e] > 0)            continue;
            if(d[e] == 0 && e != s) d[e] = d[u] + 1, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, a;
    scanf("%d", &N);
    vvi G(N);
    rep(i, N - 1){
        scanf("%d", &a);
        a--;
        G[i + 1].pb(a);
        G[a].pb(i + 1);
    }
    
    // 2. 頂点 1 から 各頂点までの距離を計算.
    bfs(G, 0, d);
    
    // 3. 頂点 1 から 遠い順に並び替え.
    priority_queue<P> pq;
    rep(i, N) pq.push({d[i], i});
    // while(!pq.empty()){
    //     P p = pq.top();
    //     pq.pop();
    //     printf("dist=%d v=%d\n", p.a, p.b);
    // }
    
    // 4. dp更新.
    while(!pq.empty()){
        // 頂点を一つ取得.
        P v = pq.top();
        pq.pop();
        
        int p = v.b; // 親頂点.
        
        // 訪問済みならば, Skip.
        if(memo[p]) continue;
        memo[p] = 1;
        
        // 子頂点について, 並び替え.
        priority_queue<P> subPQ;
        for(auto &c : G[p]) subPQ.push({dp[c], c});
        
        // 親頂点 p が, 子頂点 c と 試合を行う.
        int idx = 0;
        while(!subPQ.empty()){
            P c = subPQ.top();
            subPQ.pop();
            if(d[p] < d[c.b]) dp[p] = max(dp[p], dp[c.b] + (++idx));
        }
    }
    // rep(i, N) printf("%d ", dp[i]);
    // puts("");
    
    // 5. 出力.
    printf("%d\n", dp[0]);
    return 0;
    
}

Measured memory_bytes: 12044
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

map<int,int> mp1;
map<int,int> mp2;

signed main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        int a1;
        cin >> a1;
        mp1[i+a1] ++;
        mp2[i-a1] ++;
    }
    int ans = 0;
    for ( auto i = mp1.begin(); i != mp1.end() ; ++i){
        ans +=  i->second * mp2[i->first]; 
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 37916
import java.util.*;
class Main{
  public static void main(String[]z){
    int t=0,u=0,i=0,j=0;
    Scanner x=new Scanner(System.in);
    for(;x.hasNext();t=u=i=j=0){
      String s=x.nextLine();
      for(;(t=s.indexOf("IOI",t))!=-1;t+=2)i++;
      for(;(u=s.indexOf("JOI",u))!=-1;u+=3)j++;
      System.out.println(j+"\n"+i);
    }
  }
}

Measured memory_bytes: 12000
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

struct ModComb {
    int Size;
    ll Mod;
    vl fact;
    vl inv_fact;

    ll pow(ll a, ll n) {
        ll res = 1;
        while (n > 0) {
            if (n & 0b01) { 
                res *= a;
                res %= Mod;
            }
            a = a*a;
            a %= Mod;
            n >>= 1;
        }
        return res;
    }

    ll inv(ll num) {
        return pow(num, Mod - 2);
    }

    void init(const int SIZE, const ll MOD){
        Size = SIZE;
        Mod = MOD;

        fact = vl(Size);
        fact[0] = 1;
        FOR (i,1,Size) {
            fact[i] = fact[i - 1] * i % Mod;
        }

        inv_fact = vl(Size);
        inv_fact[0] = 1;
        inv_fact[Size-1] = inv(fact[Size-1]);
        for (int i = Size - 1; i > 0; i--) {
            inv_fact[i - 1] = inv_fact[i] * i % Mod;
        }
    }

    ModComb(){}

    ModComb(const int SIZE, const ll MOD) {
        init(SIZE, MOD);
    }

    ll C(ll n, ll r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * inv_fact[r] % Mod * inv_fact[n - r] % Mod;
    }

    ll P(ll n, ll r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * inv_fact[n - r] % Mod;
    }
};

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

  const ll MOD = 1e9+7;
  int N,K; cin>>N>>K;
  vi A(N); REP(i,N) cin>>A[i];

  if (K==1) {
    cout << 0 << endl;
    return 0;
  }

  sort(A.begin(), A.end());

  ModComb comb(N, MOD);

  ll hi = 0;
  FOR(i, K-1, N) {
    ll cb = comb.C(i, K-1);
    hi += cb * A[i] %MOD;
  }
  hi %= MOD;
  
  ll lo = 0;
  REP(i, N-K+1) {
    ll cb = comb.C(N-1-i, K-1);
    lo += cb * A[i] %MOD;
  }
  lo %= MOD;

  ll ans = (hi-lo)%MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include<math.h>
#include <iostream>
using namespace std;

void Factorization(int v){
	int k = 2;
	while (v != 1 && k <= (int)sqrt((double) v)){
		if (v % k == 0){
			v = v / k;
			cout<<" "<<k;
			k = 2;
		}
		else
			k++;
	}
	cout<<" "<<v;
}

int main(){
	int n;
	cin>>n;
	cout<<n<<":";
	Factorization(n);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClarss
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		string[] io = Input();
		int a = int.Parse(io[0]);
		int b = int.Parse(io[1]);
		
		if((a+b)%2==0)
			{
				Console.WriteLine((a+b)/2);
			}
			else
			{
			Console.WriteLine("IMPOSSIBLE");
			}
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;

	static int MAX = 10000000;
	static	ArrayList<TreeNode> tree;
	static HashSet<Integer> set;
	static long ans;

	static HashSet<Integer> memo;
	static HashMap<Integer, TreeNode> map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a + b + c >= 22){
			System.out.println("bust");
		}else{
			System.out.println("win");

		}



	}
















static long fac[] = new long[MAX];
static long finv[] = new long[MAX];
static long inv[] = new long[MAX];



//テーブルの作成
static void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
static	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;
}








static int upperbond(int k,ArrayList<Integer> data){		//k以下で最大の値をdataの中から探し、返す二分探索
	if(data == null){
		return -1;
	}
	int max = data.size();
	int min = -1;
	while(max-min > 1){
		int mid = (max+min)/2;
		if(data.get(mid) <= k){
			min = mid;
		}else{
			max = mid;
		}
	}


	//		if(min != -1){
	//			min = data.get(min);
	//		}

	//		System.out.println(max);
	return min;					//indexを返している
}

static int lowerbond(int k,ArrayList<Integer> data){		//k以上で最小の値をdataの中から探し、返す二分探索
	if(data == null){
		return -1;
	}
	//		System.out.println("lo");
	//		System.out.println("lo");
	int max = data.size();
	int min = -1;

	while(max-min > 1){
		int mid = (max+min)/2;
		if(data.get(mid) >= k){
			max = mid;
		}else{
			min = mid;
		}
	}

	return max;			//indexを返している
}



static int gcd(int a,int b){				//最大公約数を返す
	if(b == 0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}
static long gcd(long a,long b){
	if(b == 0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}



static long lcm (long a, long b) {
	long g = gcd(a,b);
	return a/g*b;
}
}



class TreeNode{
	int value;
	ArrayList<TreeNode> children;
	boolean root;
	boolean fchild;

	public TreeNode(int value,ArrayList<TreeNode> children,boolean root) {
		this.value = value;
		this.children = children;
		this.root = root;
	}


}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}






Measured memory_bytes: 258260
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        sc.close();
        for(int i = 0 ; i < a.length() + b.length() ; i++){
            if(i % 2 == 0) System.out.print(a.charAt(i / 2));
            if(i % 2 == 1) System.out.print(b.charAt(i / 2));
        }
        System.out.println();
    }
}

Measured memory_bytes: 35580
import java.util.Scanner;

class Main {
    static final int hMin = 60;
    static final int hSec = 3600;
    public static void main(String[] args) throws Exception{
        Scanner input = new Scanner(System.in);
        int hs = input.nextInt();
        int ms = hs%hSec;
        int cs = ms%60;
        System.out.println(hs/hSec+":"+ms/hMin+":"+cs);
    }
}

Measured memory_bytes: 26320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
int main(void)
{
	int n,i;
	ll sum=0,s1=0,s2=0;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",&a[i]);
	FOR(i,0,n){
		sum+=a[i];
		if(i%2==0&&sum<=0){
			s1+=(1-sum);
			sum=1;
		}
		if(i%2&&sum>=0){
			s1+=(sum+1);
			sum=-1;
		}
	}
	sum=0;
	FOR(i,0,n){
		sum+=a[i];
		if(i%2==0&&sum>=0){
			s2+=(sum+1);
			sum=-1;
		}
		if(i%2&&sum<=0){
			s2+=(1-sum);
			sum=1;
		}
	}
	printf("%lld\n",MIN(s1,s2));
	return 0;
}

Measured memory_bytes: 512
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([]int) int
var FindMax func([]int) int
var StrReverse func(string) string
var NthB func(int, int) int
 
func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
	GetIntAbs = getIntAbs
	NthB = nthB
}
 
func main() {
	n := ReadInt()
  a := ReadIntSlice(n)
  for _, n := range a {
    if (n % 2 != 0) {
      continue
    }
    if (n % 3 != 0 && n % 5 != 0) {
      fmt.Println("DENIED")
      return
    }
  }
  fmt.Println("APPROVED")
}
 
func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}
 
func newReadString() func() string {
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}
 
func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}
 
func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}
 
func readInt() int {
	i := ReadInt64()
	return int(i)
}
 
func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
 
func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}
 
/*------ number util ------*/
 
func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
 
func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}
 
func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}
 
func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}
 
// nのnthビット目
func nthB(n, nth int) int {
	return n >> uint(nth) & 1
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
int main(){
  using namespace std;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    int a,b,c;
    cin >> a >> b >> c;
    int l,m,s;
    s = min(a,min(b,c));
    m = max(max(min(a,b),min(b,c)),min(c,a));
    l = max(a,max(b,c));
    if(l*l == m*m + s*s){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3000 * 100 + 10, inf = 1e9;

long long a[N];
 
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 3 * n; i++)
		cin >> a[i];
	sort(a, a + 3 * n);
	int k = n;
	long long ans = 0, cnt = 3 * n - 2;
	while(k)
	{
		ans += a[cnt];
		cnt -= 2;
		k--;
	}
	cout << ans << endl;
}

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

N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]

ac = [0] * N
cnt = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        cnt += 1
    ac[i] = cnt
    
for l, r in lr:
    print(ac[r-1] - ac[l-1])

Measured memory_bytes: 30692
#include <bits/stdc++.h>
using namespace std; 
#define priority_queue pq
#define pu push
#define loop for(int i=0;i<n;i++)	
int32_t main(){
int n,m;
cin>>n>>m;
float ar[n];
loop
cin>>ar[i];
float sum=0;
loop
sum+=ar[i];
float l=(sum)/(4*m);
int flag=0;
for(int i=0;i<n;i++)
if(ar[i]>=l)
flag++;
//cout<<l<< " "<<sum;
if(flag<m)
cout<<"No";
else
cout<<"Yes";	

}


Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }  // answer stored in matrix A
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }
ll ainv, binv;
void extgcd(ll a, ll b){ if(b==0){/* hcf = a; */ ainv = 1; binv = 0; } else{ extgcd(b, a%b); ll temp = ainv; ainv = binv; binv = temp - (a/b)*binv; } }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a[3];
    for(int i=0; i<3; i++) cin >> a[i];
    sort(a, a+3);
    int ans = 0;
    ans += a[1]-a[0] + a[2]-a[1];
    cout << ans;
    return 0;
}

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

int gcd(int a, int b) {
  int x = max(a, b);
  int y = min(a, b);
  if(x % y == 0) {
    return y;
  }
  return gcd(y, x % y);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  // 0からiの最大公約数
  vector<int> dp1(N, 1);
  //iからN - 1の最大公約数
  vector<int> dp2(N, 1);
  dp1.at(0) = A.at(0);
  for(int i = 1; i < N; i++) {
    dp1.at(i) = gcd(dp1.at(i - 1), A.at(i));
  }
  dp2.at(N - 1) = A.at(N - 1);
  for(int i = N - 2; i >= 0; i--) {
    dp2.at(i) = gcd(dp2.at(i + 1), A.at(i));
  }
  int ans = 1;
  for(int i = 0; i < N; i++) {
    if(i == 0) {
      ans = max(ans, dp2.at(1));
    }
    else if(i == N - 1) {
      ans = max(ans, dp1.at(N - 2));
    }
    else {
      ans = max(ans, gcd(dp1.at(i - 1), dp2.at(i + 1)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4504
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  FOR(i,N){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  bool f=true;
  FOR(i,N-1){
    if(A[i]==A[i+1]){
      f=false;
      break;
    }
  }
  if(f){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  cin >> n;
  long long int ans = 0;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n,0) cin >> a[i];
  rep(i,n,0){
    cin >> b[i];
    ans += b[i];
  }
  rep(i,n-1,0) cin >> c[i];
  rep(i,n-1,0){
    if(a[i+1] - a[i] == 1){
      ans += c[a[i]-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  int h, w, k;
  cin>>h>>w>>k;
  vector<string> s(h);
  REP(i, h){
    cin>>s[i];
  }
  
  long long ans = INF;
  REP(div, 1<<h){
    if(div>>(h-1)&1)continue;
    int gid[h];
    int g = 0;
    REP(i, h){
      gid[i] = g;
      if(div>>i&1) g++;
    }
    g++;
    
    //int c[g][w] = {};
    vector<vector<int>> c(g, vector<int>(w, 0));
    REP(i, h) REP(j, w) c[gid[i]][j] += s[i][j] - '0';
    vector<int> cnt(g, 0);
    
    long long temp = g - 1;
    auto add = [&](int j){
      REP(i, g) cnt[i] += c[i][j];
      bool ok = true;
      REP(i, g) if(cnt[i] > k) ok = false;
      return ok;
    };
    REP(j, w){
      if(!add(j)){
        temp++;
        cnt = vector<int>(g, 0);
        if(!add(j)){
          temp = INF;
          break;
        }
      }
    }
    ans = min(ans, temp);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi a(n);
    for (int &x : a) cin >> x;
    vi f(n, INF);
    f[0] = 0;
    fore(i, 0, n) {
        for (int j : {i + 1, i + 2}) {
            if (j < n) f[j] = min(f[j], f[i] + abs(a[i] - a[j]));
        }
    }
    cout << f[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int N,a[200005];
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
		scanf("%d",&a[i]);
	int ans=0,now=0,v[2]{};
	for (int i=1;i<=N+1;i++){
		int p[2]{0,a[i]-now};
		if (p[0]<p[1]) swap(p[0],p[1]);
		int nex[3]{1000000000,1000000000,0};
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				nex[j+k]=min(max(0,v[j]+p[k]),nex[j+k]);
		int d=nex[0]>a[i];
		for (int j=0;j<2;j++)
			v[j]=nex[j+d];
		ans+=d;
		now=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a*b==2)cout<<3<<endl;
	else if(a*b==3)cout<<2<<endl;
	else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdlib>



void swap(int &a, int &b){
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(){
  //const int STACK_SIZE 200;
  std::string s;
  std::stack<int> stack;
  while(std::cin >> s){
    if (s == "+" || s == "*" || s == "-"){
      const int var2 = stack.top(); stack.pop();
      const int var1 = stack.top(); stack.pop();
      int res;
      
      if (s == "+"){
	res = var1 + var2;
      }
      else if (s == "*"){
	res = var1 * var2;
      }
      else if (s == "-"){
	res = var1 - var2;
      }
      stack.push(res);
    }
    else{
      stack.push(atoi(s.c_str()));
    }
  }
  
  std::cout << (stack.top()) << std::endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
int n,k;
string s;
cin>>n>>s>>k;
char ch=s[k-1];
for(int i=0;i<s.size();i++){
    if(s[i]!=ch){
        s[i]='*';
    }
}
cout<<s<<endl;
   return 0;    
}

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

template<typename T>
auto print(std::vector<T> array,bool reverse = false) 
 -> void{
 	if(reverse){
		auto iterator = array.rbegin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.rend();++iterator){
			std::cout<<" "<< *iterator;
		}

	}else{
		auto iterator = array.begin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.end();++iterator){
			std::cout<<" "<< *iterator;
		}
	}
	std::cout<<"\n";
}

template<typename T>
auto println(std::vector<T> array) 
 -> void{
	for(auto v : array){
		std::cout<< v <<"\n";
	}
}

int cnt = 0;

template<typename T>
auto insertionSort(std::vector<T> *A,int n,int g)
 -> void{
 	for(int i = g;i < n;i++){
 		auto v = (*A)[i];
 		auto j = i - g;
 		while(j >= 0 && (*A)[j] > v){
 			(*A)[j+g] = (*A)[j];
 			j = j - g;
 			cnt++;
 		}
 		(*A)[j+g] = v;
 	}
 }

template<typename T>
auto shellSort(std::vector<T> *A,int n)
 -> void{
 	cnt = 0;

 	int h = 0;
 	std::vector<int> G;
    for(int k = 1;;k++){
    	h = static_cast<int>((pow(3,k)-1)/2);
    	if(h > n)
    		break;
    	G.push_back(h);
    }

 	std::cout<< G.size() <<std::endl;
 	print(G, true);

 	for(auto it = G.rbegin();it != G.rend();++it){
 		insertionSort<T>( A, n, (*it));
 	}

 }

auto main()
 -> int{

	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);

	int n;
	std::cin>>n;

	std::vector<int> array(n);
	for(int i=0;i < n;i++)
		std::cin>>array[i];

	shellSort( &array, n);

 	std::cout<< cnt <<"\n";
	println(array);

	return 0;
}

Measured memory_bytes: 9044
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define N 10010
int a[N],b[N],c[N];
int main()
{
    long long s1,s2;
    int i,j,k,n;
    s1=0;
    s2=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
        scanf("%d",&b[i]);
    for(i=1;i<=n;i++)
        c[i]=a[i]-b[i];
    sort(c+1,c+n+1);
    for(i=1;i<=n;i++)
    {
        if(c[i]>0)
            break;
        s1=s1+c[i]/2;
    }
    for(;i<=n;i++)
        s2=s2+c[i];
    s1=fabs(s1);
    if(s1<s2)
        printf("No\n");
    else
        printf("Yes\n");
    //printf("%lld %lld\n",s1,s2);
    return 0;
}


Measured memory_bytes: 256
import sys
class Tree():
    def __init__(self):
        self.root = None
    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    def find(self, key):
        x = self.root
        while x and x.key != key:
            if x.key < key:
                x = x.right
            else:
                x = x.left
        return x
    def delete(self, key):
        z = self.find(key)
        y = self.successor(z) if z.left and z.right else z
        x = y.left if y.left else y.right

        if x:
            x.parent = y.parent
        if y.parent == None:
            self.root = x 
        elif y == y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x
        if y != z:
            z.key = y.key
    def successor(self, x):
        if x.right:
            return self.minimum(x.right)
        y = x.parent
        while y and x == y.right:
            x = y
            y = y.parent
        return y

    def minimum(self, x):
        while x.left:
            x = x.left
        return x
    
    def print(self):
        print('',' '.join(map(str, self.root.inwalk())))
        print('',' '.join(map(str, self.root.prewalk())))
    
class Node():
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None
    def prewalk(self):
        ret = [self.key]
        if self.left:
            ret += self.left.prewalk()
        if self.right:
            ret += self.right.prewalk()
        return ret
    def inwalk(self):
        ret = []
        if self.left:
            ret += self.left.inwalk()
        ret += [self.key]
        if self.right:
            ret += self.right.inwalk()
        return ret
tree = Tree()
n = sys.stdin.readline()
for line in sys.stdin:
    if line[0] == 'i':
        tree.insert(int(line.split()[1]))
    elif line[0] == 'f':
        print('yes' if tree.find(int(line.split()[1])) else 'no')
    elif line[0] == 'd':
        tree.delete(int(line.split()[1]))            
    else:
        tree.print()

Measured memory_bytes: 218676
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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 dx[] = {0,0,-1,1};
const int dy[] = {1,-1,0,0};
const int INF = 1001001001;
int main() {
    //入力
    int h,w;
    cin >> h >> w;
    int sh,sw;
    cin >> sh >> sw;
    sh--;sw--;
    int gh,gw;
    cin >> gh >> gw;
    gh--;gw--;
    vector<string>field(h);
    rep(i,h) cin >> field[i];

    vector<vector<int>>dist(h,vector<int>(w,INF));
    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<>> que;//(仮の最短距離、座標)を入れて照準に並べる
    dist[sh][sw] = 0;
    que.push({0,{sh,sw}});
    
    //近いところから最短距離を決めていく
    while(!que.empty()) {
        auto v = que.top();que.pop();
        int x = v.second.first;
        int y = v.second.second;
        if(v.first > dist[x][y]) continue;
        //魔法を使わない場合
        rep(i,4) {
            int nx = x+dx[i];
            int ny = y+dy[i];
            if(nx<0 || ny<0 || nx>=h || ny>=w) continue;
            if(field[nx][ny] == '#') continue;
            if(dist[nx][ny] > dist[x][y]) {
                dist[nx][ny] = dist[x][y]; //移動するのにかかるコストは０
                que.push({dist[nx][ny],{nx,ny}});
            }
        }
        //魔法を使う場合
        for(int i = -2;i<=2;i++) {
            for(int j = -2;j <= 2;j++) {
                int nx = x+i;
                int ny = y+j;
                if(nx<0 || ny<0 || nx>=h || ny>=w) continue;
                if(field[nx][ny] == '#') continue;
                if(dist[nx][ny] > dist[x][y]+1) {
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push({dist[nx][ny],{nx,ny}});
                }
            }
        }
        
    }
    //出力
    if(dist[gh][gw] == INF) cout << -1 << endl;
    else cout << dist[gh][gw] << endl;
}   

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int l,r,d; cin >> l >> r >> d;

  int cnt = 0;
  for(int i = l;i<=r;i++){
    if(i%d==0) cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define INT_MAX 2147483647

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

    cout << 3*r*r << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int cnt = 0;
		for (int i = 0; i < 3; i++) {
			if (s[i] == t[i]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

namespace ConsoleApp1AtCoder_Beginner_Contest_132
{
    class Program
    {
        //解説参照(https://www.youtube.com/watch?v=mso8tE1yMl8)
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var grp = new Graph(N);
            for(var i=0;i<M;++i)
            {
                var uv = Sarray();
                grp.Add(uv[0] - 1, uv[1] - 1);
            }
            var ST = Sarray();
            var S = ST[0] - 1;
            var T = ST[1] - 1;
            grp.bfs(S, T);
            var ans = grp.GetDist(T);
            if (ans == long.MaxValue) { ans = -1; }
            else { ans /= 3; } 
            WriteLine(ans);
        }
        public class Graph
        {
            List<long>[] graph;
            long[] visited;
            long[,] dist;
            public Graph(long n)
            {
                graph = new List<long>[n];
                for(var i=0;i<n;++i)
                {
                    graph[i] = new List<long>();
                }
                visited = new long[n];
                dist = new long[n, 3];
                for (var i = 0; i < n; ++i)
                {
                    for (var j = 0; j < 3; ++j)
                    { dist[i, j] = long.MaxValue; }
                }
            }
            public void Add(long u, long v)
            {
                graph[u].Add(v);
            }
            public long GetDist(long u)
            { return dist[u, 0]; }
            struct pair
            {
                public long first;
                public long second;
                public pair(long f,long s)
                {
                    first = f;
                    second = s;
                }
            }
            Queue<pair> q = new Queue<pair>();
            public void bfs(long s, long t)
            {
                q.Enqueue(new pair(s, 0));
                dist[s, 0] = 0;
                while(0!=q.Count)
                {
                    var pr = q.Dequeue();
                    long v = pr.first;
                    long l = pr.second;
                    foreach (var u in graph[v])
                    {
                        var nl = (l + 1) % 3;
                        if (dist[u, nl] != long.MaxValue) continue;
                        dist[u, nl] = dist[v, l] + 1;
                        q.Enqueue(new pair(u, nl));
                    }
                }
            }
        }

    }
}


Measured memory_bytes: 31484
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
using namespace std;

int main() {
        string s;
        cin >> s;
        int n = s.size();
        vector<int> cnt(3);
        for (int i = 0; i < n; i ++) cnt[s[i] - 'a'] ++;
        if (abs(cnt[0] - cnt[1]) <= 1 && abs(cnt[1] - cnt[2]) <= 1 && abs(cnt[2] - cnt[0]) <= 1) puts("YES");
        else puts("NO");
        return 0;
}



Measured memory_bytes: 512
h,w,d=map(int,input().split())
dict={}

for i in range(1,h+1):
  lst=list(map(int,input().split()))
  for j in range(w):
    dict.setdefault(lst[j],(i,j+1))

cost=[0]*(h*w)

for i in range(d,h*w):
  cost[i]=cost[i-d]+abs(dict[i-d+1][0]-dict[i+1][0])+abs(dict[i-d+1][1]-dict[i+1][1])


ans=0

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(cost[r-1]-cost[l-1])


Measured memory_bytes: 83272
#include <stdio.h>
int main(void){
    int a, b, c, count;
    
    count = 0;
    
    scanf("%d %d %d" ,&a, &b, &c);
    
    for(int x = a; x <= b; x++){
        if(c % x == 0){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2124
# 怪文書 / Dubious Document
n = int(input())
s=[]
for i in range(n):
    s.append(input())
ls = sorted(list(set(s[0])))
ans = ""
for l in ls:
    cnt = min ([s[i].count(l) for i in range(n)] )
    ans += l*cnt
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

const Int MOD = 1000000007;
const Int MAX = 200010;

Int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

Int 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;
}

int main(){ 

    COMinit();

    Int n, k, k2;
    cin >> n >> k;

    k2 = min(k, n-1);

    Int ans = 1;

    rep1(i,k2) {
        ans = (ans + COM(n,i) * COM(n-1,n-i-1) % MOD) % MOD;
    }

    cout << ans << endl;


    
}


Measured memory_bytes: 4992