akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

public class AtCoderC
{
    static List<string> patterns;

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        patterns = new List<string>();
        Generate(new int[0], n);
        patterns.Sort();

        string p = Console.ReadLine().Replace(" ", "");
        string q = Console.ReadLine().Replace(" ", "");

        int answer = Math.Abs(patterns.IndexOf(p) - patterns.IndexOf(q));
        Console.WriteLine(answer);
    }

    private static void Generate(int[] current, int n)
    {
        int currentLength = current.Length;

        if (currentLength == n)
        {
            string str = "";
            for (int i = 0; i < n; i++)
            {
                str += current[i];
            }
            patterns.Add(str);
            return;
        }

        for (int i = 1; i <= n; i++)
        {
            if (!current.Contains(i))
            {
                int[] newArray = new int[currentLength + 1];
                current.CopyTo(newArray, 0);
                newArray[currentLength] = i;
                Generate(newArray, n);
            }
        }
    }
}

Measured memory_bytes: 20236
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //ハッシュ関数

using namespace std;

//デバッグ時はTESTを定義する。本番時はこの行をコメントアウトする
#define TEST //*******************************************************************************************************************************************

//そうすることで、以下に定義する、デバッグ時にのみ標準出力する、doutコマンドが実現できる。本番時はダミーストリームに出力
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //デバッグ時のdoutコマンドのダミー出力先
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummyを毎回リセットしておかないとメモリ溢れちゃう。
    //どうせ表示しないからgoodbitしなくていいけど、表示する場合はこれしておかないとバグるらしいので、勉強のために。詳しくは http://d.hatena.ne.jp/linden/20060427/p1
#endif


#define disp(A) dout << #A << " = " << (A) << endl
#define disP(A) dout << (A) << " "
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl

const int INF = 1e9;


int main(void) {

    int N;
    cin >> N;

    int left, right;
    int sum = 0;
    
    rep(i,0,N) {
        cin >> left >> right;
        
        sum += right - left + 1;
    }

    cout << sum << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int abroad = 0;
  int rank = 0;

  rep(i, n) {
    if (s.at(i) == 'a') {
      if (rank < a + b) {
        cout << "Yes" << endl;
        rank++;
      } else {
        cout << "No" << endl;
      }
    } else if (s.at(i) == 'b') {
      if (rank < a + b && abroad < b) {
        cout << "Yes" << endl;
        rank++;
        abroad++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b;
    cin >> a >> b;
    if(a + b == 15)
        cout << "+";
    else if(a * b == 15)
        cout << "*";
    else 
        cout << "x";
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Control.Monad (replicateM)
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as VU
import Data.Maybe (fromJust)

solve::VU.Vector Int -> Int
solve an = S.size $ VU.foldl (\acc x -> if S.member x acc then S.delete x acc else S.insert x acc) S.empty an

main = do
  n <- readLn
  an <- VU.replicateM n  (fst . fromJust . B.readInt <$> B.getLine)
  print $ solve an

Measured memory_bytes: 16764
h,w,k = map(int,input().split())

fib = {0:1, 1:1, 2:2} # n 本
for i in range(3,w):
    fib[i] = fib[i-1]+fib[i-2]

f = {} # x ~ x+1 に横線を引く方法が何通りか
for x in range(w-1):
    if(x in [0,w-2]):
        f[x] = fib[w-2]
    else:
        f[x] = fib[x]*fib[w-x-2]

g = {} # xに横線が引かれない方法が何通りあるか
for x in range(w):
    if(x in [0,w-1]):
        g[x] = fib[w-1]
    else:
        g[x] = fib[x]*fib[w-x-1]

# d[m][n] m行目を通った直後にn-1列目にいる
d = [[0 for _ in range(w)] for _ in range(h+1)]
d[0][0] = 1
for m in range(1,h+1):
    for n in range(w):
        d[m][n] = d[m-1][n]*g[n]
        if(n!=0):
            d[m][n] += d[m-1][n-1]*f[n-1]
        if(n!=w-1):
            d[m][n] += d[m-1][n+1]*f[n]
        d[m][n] %= 1000000007
print(d[h][k-1])

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

using namespace std;

#define ll long long

ll n;

bool isPrime(ll n) {
  for (ll i = 2; i <= sqrt(n); i++) {
    if (n%i==0) return false;
  }
  return true;
}

ll lSF(ll n) {
  for (ll i = sqrt(n); i >= 2; i--) {
    if (n%i == 0) {
      return i;
    }
  }
  return -1;
}

void solve() {
  cin >> n;
  if (isPrime(n)) {
    cout << (n-1) << '\n';
    return;
  }
  ll f1 = lSF(n);
  ll f2 = n/f1;
  cout << (f1-1)+(f2-1) << '\n';
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


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

int main(){
    int N;
    long long ans = 0;
    char c;
    long long r = 0, g = 0, b = 0;

    std::cin >> N;
    vector<char> colors(N);

    for(int i = 0; i < N; i++){
        std::cin >> c;
        colors[i] = c;
        if(c == 'R'){
            r++;
        }else if(c == 'G'){
            g++;
        }else if(c == 'B'){
            b++;
        }
    }

    ans = r * g * b;

    for(int i = 0; i < N-2; i++){
        for(int j = i + 1; j < N-1; j++){
            // std::cout << i << " " << j << " " << 2*j -i << "\n";
            if(2*j -i < N){
                if(colors[i]+colors[j]+colors[2*j - i] == 219){
                    ans = ans - 1;
                }
            }
        }
    }

    std::cout << ans;
    // std::cout << 'R' + 'G' + 'B';

}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, a;

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

	// dp[使用枚数][合計]
	int max_sum = 50 * n;
	vector<vector<long long>> dp(n + 1, vector<long long>(max_sum + 100, 0));
	dp[0][0] = 1;

	for (int i = 0; i < n; i++) { // x[i]
		for (int j = n - 1; j >= 0; j--) {
			for (int k = 0; k < max_sum; k++) {
				// if (dp[j][k] > 0) {
				// 	printf("%d %d %d\n", j, k, dp[j][k]);
				// }
				// dp[i+1][k] += dp[i][k];
				dp[j+1][k + x[i]] += dp[j][k];
			}
		}
	}

	// for (int i = 0; i <= n; i++) {
	// 	printf("%d: ", i);
	// 	for (int j = 0; j < 40; j++) {
	// 		printf("%d ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[i][i * a];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
  ull n,i,j,k,l=0;
  string s;
  cin>>s;
  rep(i,s.size()){
    l += s[i]-'0';
  }
  if(l%9==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
int  main() 
{
  auto start=clock();
  fast_io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
  return 0; 
}


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

int main(){
    int N;
    cin >> N;
    
    vector<vector<int>> A(2, vector<int>(N));
    
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < N; j++){
            cin >> A.at(i).at(j);
        }
    }
    
    int max = 0;
    for(int p = 0; p < N; p++){
        int ans = 0;
        for(int j = 0; j < N; j++){
            if(j < p){
                ans += A.at(0).at(j);
            }else if(j == p){
                ans += A.at(0).at(j) + A.at(1).at(j);
            }else{
                ans += A.at(1).at(j);
            }
        }
        if(ans > max){
            max = ans;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+5;
LL n,a,m,b,c,ans;
unordered_map<int,int> ma;
int main()
{
	n=read();
	while(n--){
		a=read();
		ans+=a;
		++ma[a];
	}
	m=read();
	while(m--){
		b=read();
		c=read();
		ans-=ma[b]*b;
		ans+=ma[b]*c;
		ma[c]+=ma[b];
		ma[b]=0;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 7008
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] boss = new int[N];
        
        for(int i= 0 ; i < N-1 ; i++) {
            boss[sc.nextInt()-1]++;
        }
        for(int i = 0 ; i < N ; i++) {
            System.out.println(boss[i]);
        }
    }
}


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

using namespace std;

int main() {
	
	int n, k;
	cin >> n >> k;

	int numm = 1;
	for (int i = 0; i < n; i++) {
		if (numm * 2 < numm + k) { numm *= 2; }
		else { numm += k; }
	}
	cout << numm << endl;
}


Measured memory_bytes: 256
N = input()
last = N[-1]

last = int(last)
if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
    print("hon")
elif last == 0 or last == 1 or last == 6 or last == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61580
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (a > 9 || b > 9)
	{
		println(-1);
	}
	else
	{
		println(a * b);
	}
}

Measured memory_bytes: 256
N=int(input())
a=0
w=0
t=0
r=0
for i in range(N):
  s=input()
  if s=='AC':
    a+=1
  elif s=='WA':
    w+=1
  elif s=='TLE':
    t+=1
  else:
    r+=1

a=str(a)
w=str(w)
t=str(t)
r=str(r)
print('AC','x',a)
print('WA','x',w)
print('TLE','x',t)
print('RE','x',r)
  

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int id;
		int a[7]={1,2,4,8,16,32,64};
		for(int i=1;i<=n;++i)
		{
			for(int j=0;j<7;++j)
				if(i>=a[j])
				{
					id = a[j];
				}
		}
		printf("%d\n",id);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

bool ok=true;
ll n,node[110]={},mi=1e9,ma=-1;  // 最遠距離がindexの点

void init(){
	cin>>n;
	rep(i,n){
		ll a;
		cin>>a;
		node[a]++;
		mi=min(mi,a);
		ma=max(ma,a);
	}
}

int main(void){
	init();
	if(mi != (ma+1)/2)ok=false;
	if(ma%2==0 && node[mi]!=1)ok=false;
	if(ma%2==1 && node[mi]!=2)ok=false;
	reg(i,mi+1,ma)if(node[i]<2)ok=false;
	cout<<(ok?"Possible":"Impossible")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
//using ll = long long;
using namespace std;
int main(){
  long n,ii;
  vector<string> s;
  cin >> n;
  s.resize(n);

  for(ii=0;ii<n;ii++){
	cin >> s[ii];
  }

  int y=0;

  for(ii=0;ii<n;ii++){
	if(s[ii][0] == 'Y'){
	  y = 1;
	}
  }
  
  if(y == 0){
	cout << "Three" << endl;
  }
  else {
	cout << "Four" << endl;
  }
	
  
  return 0;
}


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

int main()
{
	int n,m;
	cin >> n >> m;
	cout << (n-1) * (m-1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b))System.out.println("H");
		else System.out.println("D");
	}
}

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

const int N = 1010, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

int n, m, dp[N][N];
char c[N][N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> c[i][j];
	dp[n][m - 1] = 1;
	for (int i = n - 1; ~i; i--)
		for (int j = m - 1; ~j; j--)
			dp[i][j] = (c[i][j] == '#'? 0: sum(dp[i + 1][j], dp[i][j + 1]));
	cout << dp[0][0];
	return 0;
}

Measured memory_bytes: 5248
N,K = [int(item) for item in input().split()]

ans = 0
for i in range(1,N+1):
  if i < K:
    n = 0
    point = i
    while point < K:
      point *= 2
      n += 1
    ans += 1/N * (1/2)**n
  else:
    ans += 1/N
print (ans)
    

Measured memory_bytes: 2940
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        m: usize,
    }

    if m == 0 {
        println!("1");
    } else {
        let mut ff = vec![false; n];
        let mut f = vec![vec![]; n];
        for _ in 0..m {
            input!{ a: Usize1, b: Usize1 }
            f[a].push(b);
            f[b].push(a);
            ff[a] = true;
            ff[b] = true;
        }
    
        let mut mm = 0;
        for i in 0..n {
            if ff[i] {
                ff[i] = false;
                let mut g = 1;
                let mut q = vec![i];
                while let Some(qi) = q.pop() {
                    for &j in &f[qi] {
                        if ff[j] {
                            ff[j] = false;
                            g += 1;
                            q.push(j);
                        }
                    }
                }
                mm = mm.max(g);
            }
        }
        println!("{}", mm);
    }
}


Measured memory_bytes: 17964
#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;}
//二項係数ここから (1 <= k <= n <10^7 程度なら使える)
//COMinit(); を書くのを忘れない
const int MAX = 2100000;


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;
}
//二項係数ここまで
signed main(){
    COMinit();
    int k;
    cin >> k;
    string s;
    cin >> s;
    int ans = 0;
    int n1 = 1;
    for(int i=0;i<=k;i++){
        int ann = n1 * COM(s.size()+k,i);
        ann %= MOD;
        ans += ann;
        ans %= MOD;
        n1 *= 25;
        n1 %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 54464
n = int(input())
a = [int(input()) for _ in range(n)]
import sys

for i in range(n-1):
    if a[i+1] - a[i] >= 2:
        print(-1)
        sys.exit()
        
if a[0] != 0:
    print(-1)
    sys.exit()
    
a.append(1145141919810)
se = []
pl = [a[0]]
for i in range(n):
    if a[i+1] - a[i] == 1 or a[i+1] - a[i] == 0:
        pl.append(a[i+1])
    else:
        se.append(pl)
        pl = [a[i+1]]
        
from collections import Counter
ans = 0
for l in se:
    b = Counter(l)
    ans += max(l)
    for i in b:
        ans += max(0,b[i]-1) * i
        
print(ans)

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

int main() {
	int n;
	int k;
	cin >> n;
	cin >> k;
	vector<int> arr;
	vector<int> dp(n, 1001001001);
	int num;
	for(int i = 0; i < n; i++) {
		cin >> num;
		arr.push_back(num);
	}
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i < n; i++) {
		for(int j = 1; j <= i && j <= k; j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
		} 
	} cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1276
#!/usr/bin/env python3

def main():
    w, h, n = map(int, input().split())
    left = 0
    right = w
    top = 0
    bottom = h
    for i in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            left = max(left, x)
        elif a == 2:
            right = min(right, x)
        elif a == 3:
            top = max(top, y)
        else:
            bottom = min(bottom, y)
    res = max(0, right - left) * max(0, bottom - top)
    print(res)

if __name__ == "__main__":
    main()


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

using namespace std;

int N;
int number[100004];
int leftGcd[100004] = { 0, }; //left[i]는 첫번째 원소부터 i번째 원소까지의 gcd
int rightGcd[100004] = { 0, }; //right[i]는 i번째 원소부터 N번째 원소까지의 gcd

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

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) cin >> number[i];

	for (int i = 1; i <= N; i++)
	{
		leftGcd[i] = gcd(leftGcd[i - 1], number[i - 1]);
	}

	for (int i = N; i >= 1; i--)
	{
		rightGcd[i] = gcd(rightGcd[i + 1], number[i - 1]);
	}

	int maxGcd = 0;
	for (int i = 1; i <= N; i++)
	{
		maxGcd = max(maxGcd, gcd(leftGcd[i - 1], rightGcd[i + 1]));
	}

	cout << maxGcd;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> S(N);
  for( int i = 0; i < N; i++ ) cin >> S.at(i);
  sort( S.begin(), S.end() );
  for( int i = 0; i < N; i++ ){
    cout << S.at(i);
  }
  cout << " " << endl;
  
}

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

int main()
{
    int A, B, X;
    cin >> A >> B >> X;
    
    cout << (int)((A*B) / pow(__gcd(A,B),2)) * X << endl;
}  



Measured memory_bytes: 3104
import math


class Triangle:
    def __init__(self, x1, y1, x2, y2, x3, y3):
        self.x1 = x1
        self.x2 = x2
        self.x3 = x3
        self.y1 = y1
        self.y2 = y2
        self.y3 = y3
        self.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2)
        self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2)
        self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2)

    def get_acos_a(self):
        val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c)
        return math.acos(val)


while(1):

    try:
        x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
        t1 = Triangle(x1, y1, x2, y2, xp, yp)
        t2 = Triangle(x2, y2, x3, y3, xp, yp)
        t3 = Triangle(x3, y3, x1, y1, xp, yp)

        def is_2pi(x):
            return math.fabs(x - math.pi*2) < 1.0e-10

        if is_2pi(t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a()):
            print("YES")
        else:
            print("NO")

    except:
        break

Measured memory_bytes: 7812
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	string s;
	ll t;
	cin >> s >> t;
	ll memo = 0, ans = 0;
	ll p = 0;
	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1])p++;
	}
	if (p == s.size() - 1)cout << s.size() * t / 2 << endl;
	else {
		string j = s;
		ll nmemo = 0, nans = 0;
		j += '6';
		rep(i, j.size() - 1) {
			if (j[i] == j[i + 1])nmemo++;
			else {
				nans += (nmemo + 1) / 2;
				nmemo = 0;
			}
		}
		string k = s;
		s += k;
		s += '6';
		rep(i, s.size() - 1) {
			if (s[i] == s[i + 1])memo++;
			else {
				ans += (memo + 1) / 2;
				memo = 0;
			}
		}
		cout << nans + (ans - nans) * (t - 1) << endl;
	}
	ggr
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> A(N);
	REP(i, N) cin >> A[i];
	int64 step = 0;
	int64 res = 0;
	FOR(i, 1, N) {
	  step = max((int64)0, A[i-1] + step - A[i]);
	  res += step;
	}
	cout << res << endl;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, M;
  while(cin>>N>>M){
    int a[100], b[100];
    REP(i, M) cin>>a[i]>>b[i];
    int s = 1;
    int ans = INF;
    REP(iter, 10000){
      int next = -1;
      REP(i, M) if(a[i] <= s && b[i] >= s) next = max(b[i] + 1, next);
      s = next;
      if(s > N){
        ans = iter + 1;
        break;
      }else if(s == -1){
        ans = -1;
        break;
      }
    }
    if(ans >= 0) cout<<ans<<endl;
    else cout<<"Impossible"<<endl;
  }
  return 0;
}

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

int
main ()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<double> accum(n+1);

    accum[0] = 0;
    for (int i = 1; i <= n; ++i) {
      int p;
      std::cin >> p;
      auto exp = (p + 1) / 2.0;
      accum[i] = accum[i - 1] + exp;
    }

    auto max = 0.0;
    for (int i = k; i <= n; ++i) {
      auto k_sum = accum[i] - accum[i - k];
      max = std::max(max, k_sum);
    }

    std::printf("%.10f\n", max);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    int tmp = 0;
    vector<int> P(n);
    rep(i, n) cin >> P[i];
    rep(i, k) {
        tmp += P[i] + 1;
        chmax(ans, tmp / 2.0);
    }
    rep(i, n - k) {
        tmp += P[i + k] - P[i];
        chmax(ans, tmp / 2.0);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

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


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

using namespace std;




int main()
{
	int N, ans = 0, check = 0;
	string S;
	map<char, int> m1, m2;

	cin >> N;
	cin >> S;

	for (int i = 0; i < N; i++) {

		for (char c = 'a'; c <= 'z'; c++) {
			m1[c] = m2[c] = 0;
		}

		for (int j = 0; j < i + 1; j++) {
			m1[S[j]] += 1;
		}
		for (int k = i + 1; k < N; k++) {
			m2[S[k]] += 1;
		}

		for (char l = 'a'; l <= 'z'; l++) {
			if (m1[l] != 0&&m2[l] != 0 ) {
				check++;
			}
		}
		ans = max(ans, check);
		check = 0;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N = I()
    S = R(N)
    c = Counter(S)
    [common] = c.most_common(1)
    for k, v in sorted(c.items(), key=lambda x: (-x[1], x[0])):
        if common[1] != v:
            break
        print(k)


if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(N, 0);
    int n;
    for (int i=0; i<M*2; i++) {
        cin >> n;
        a[n-1]++;
    }

    for (int i=0; i<N; i++) {
        if (a[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    X,Y = map(int,input().split())
    if abs(X - Y) <= 1:
        print('Brown')
    else:
        print('Alice')
if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll a, b;
	cin >> a >> b;
	ll ans = a * b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		int x3 = x2-y2+y1;
		int y3 = y2+x2-x1;
		int x4 = x1-y2+y1;
		int y4 = y1+x2-x1;
		System.out.println(x3+" "+y3+" "+x4+" "+y4);

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
int semi[51][51],h,w,r[51][51];
int min(int a,int b){
	if(a<b){
		return a;
	}else{
		return b;
	}
}
int main(){
	cin>>h>>w;
	int i,j,k,n;
	char c[52];
	for(i=0;i<52;i++){
		c[i]='\0';
	}
	for(i=0;i<51;i++){
		for(j=0;j<51;j++){
		semi[i][j]=-1;	
		}
	}
	for(i=0;i<h;i++){
			cin>>c;
		for(j=0;j<w;j++){
			semi[i][j]=(int)(c[j]-'0');
			}
	}
	i=h-1;j=w-1;
	for(i=h-1;i>=0;i--){
		for(j=w-1;j>=0;j--){
			if(i==h-1&&j==w-1){
				r[i][j]=0;
			}else if(j==w-1){
				r[i][j]=r[i+1][j]+semi[i][j];
			}else if(i==h-1){
				r[i][j]=r[i][j+1]+semi[i][j];
			}else{
				r[i][j]=semi[i][j]+min(r[i+1][j],r[i][j+1]);
			}
		}
	}
	cout<<r[0][0]<<endl;
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
gp_hash_table<int, int> table;
typedef tree < int,  null_type,  less<int>,  rb_tree_tag,  tree_order_statistics_node_update > ordered_set;
typedef long long ll;
#define pb push_back
#define pi (acos(-1))
#define ull  unsigned long long
#define ld long double
#define all(v) v.begin(), v.end()
///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);
ll LCM(ll a, ll b)
{
    ll g = __gcd(a,b);
    return (a/g)*b ;
}
string numtostr(ll n)
{
    ostringstream str1 ;
    str1 << n ;
    return str1.str();
}
ll strtonum(string s)
{
    ll x ;
    stringstream str1(s);
    str1 >> x ;
    return x ;
}
ll n,i,a=1000,s;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(i=1; ;++i)
    {
        s=a*i;
        if(s>=n)
            break;
    }
    cout<<s-n<<'\n';
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll prfx[3005][3005],cnt[2][1005][1005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    for(ll i=0;i<n;i++){
        ll x,y;cin>>x>>y;
        char ch;cin>>ch;
        if(ch=='B')y+=k;
        x%=2*k;
        y%=2*k;
        prfx[x][y]++;
        prfx[x+k][y+k]++;
        prfx[x][y+k]--;
        prfx[x+k][y]--;
    }
    for(ll i=0;i<3*k;i++){
        for(ll j=0;j<3*k;j++)prfx[i][j+1]+=prfx[i][j];
    }
    for(ll i=0;i<3*k;i++){
        for(ll j=0;j<3*k;j++)prfx[i+1][j]+=prfx[i][j];
    }
    ll ans = 0;
    for(ll i=0;i<3*k;i++){
        for(ll j=0;j<3*k;j++){
            ll type = (i/k + j/k)%2;
            cnt[type][i%k][j%k]+=prfx[i][j];
        }
    }
    for(ll i=0;i<k;i++)for(ll j=0;j<k;j++)ans=max(ans , max(cnt[0][i][j],cnt[1][i][j]));
    cout<<ans;
}

Measured memory_bytes: 86528
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	std::string str;
	std::cin >> str;
	int a = std::stoi(str.substr(0, 2));
	int b = std::stoi(str.substr(2, 2));
	bool fa = 0 < a && a <= 12;
	bool fb = 0 < b && b <= 12;
	if (fa && fb)
	{
		std::cout << "AMBIGUOUS" << std::endl;
	}
	else if (fa)
	{
		std::cout << "MMYY" << std::endl;
	}
	else if (fb)
	{
		std::cout << "YYMM" << std::endl;
	}
	else
	{
		std::cout << "NA" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

ll dp[200010][5]; //0 lhaji 1 start 2 end 3 rhaji 4 

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++)
    {
        cin>>a[i];
    }

    for(int i = 0; i < 200010; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            dp[i][j]= LLONG_MAX/3;
        }        
    }
    for(int i = 0; i < 5; i++)
    {
        dp[0][0]=0;
    }
    for(int now = 0; now < n; now++)
    {
        ll dpmin = dp[now][0];
        dp[now+1][0] = dp[now][0] + a[now];
        ll haji;
        if(a[now]==0) haji=2;
        else haji = a[now]%2;
        dpmin=min(dpmin, dp[now][1]);
        dp[now+1][1] = dpmin+haji;
        ll mid;
        if(a[now]==0) mid=1;
        else mid = (a[now]+1)%2;
        dpmin=min(dpmin, dp[now][2]);
        dp[now+1][2] = dpmin+mid;
        dpmin=min(dpmin, dp[now][3]);
        dp[now+1][3] = dpmin+haji;
        dpmin=min(dpmin, dp[now][4]);
        dp[now+1][4] = dpmin+a[now];

        
    }

    for(int i = 0; i < n+1; i++)
    {
       
        for(int j = 0; j < 5; j++)
        {
            //cout<<dp[i][j]<<"\t";
        }
        cout<<endl; 
    }
    
    
    ll ans = LLONG_MAX/3;
    for(int i = 0; i < 5; i++)
    {
        ans=min(ans,dp[n][i]);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define X(_) (x[o[_]])
#define Y(_) (y[o[_]])

typedef long long ll;
typedef std::pair <int, int> pr;
const int N = 100054;

int n, Dx, Dy;
int x[N], y[N], o[N];
int p[N], f[N], le[N], lx[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline int max(const int x, const int y) {return x < y ? y : x;}

int ancestor(int x) {return p[x] == x ? x : (p[x] = ancestor(p[x]));}
inline bool dsu(int x, int y, bool un = false) {
	if ((x = ancestor(x)) == (y = ancestor(y))) return true;
	return un && (p[x] = y, false);
}

void scan() {
	int i, j, k, c, u, v, top = 0;
	std::sort(o, o + n, [] (const int A, const int B) {return x[A] < x[B] || (x[A] == x[B] && y[A] < y[B]);});
	for (i = 0; i < n; )
		for (le[top] = i, lx[top++] = X(i++); i < n && X(i - 1) == X(i); ++i);
	le[top] = n;
	for (j = i = 0; i < top; ++i) {
		for (; j < i && lx[j] < lx[i] - Dx; ++j);
		if (lx[j] == lx[i] - Dx)
			for (c = -1, u = v = le[j], k = le[i]; k < le[i + 1]; ++k) {
				for (; u < le[j + 1] && Y(u) < Y(k) - Dy; ++u);
				for (; v < le[j + 1] && Y(v) <= Y(k) + Dy; ++v);
				if (c < v && u < v) {for (up(c, u); c < v; ++c) dsu(o[c], o[k], true); --c;}
				f[o[k]] += v - u;
			}
	}
}

int main() {
	int i, u, v, si, ti; ll ans = 0;
	scanf("%d%d%d", &n, &si, &ti), --si, --ti;
	for (i = 0; i < n; ++i) scanf("%d%d", &u, &v), x[i] = u + v, y[i] = u - v;
	Dx = Dy = max(abs(x[si] - x[ti]), abs(y[si] - y[ti]));
	std::iota(p, p + n, 0), std::iota(o, o + n, 0);
	scan();
	for (--Dy, i = 0; i < n; ++i) std::swap(x[i], y[i]);
	scan(), assert(dsu(si, ti));
	for (i = 0; i < n; ++i) if (dsu(i, si)) ans += f[i];
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    int N,M,C;
    int ans=0;
    scanf("%d %d %d",&N,&M,&C);
    int B[M],A[M];
    int i,j,t,k;
    for(i=0;i<M;i++){
        scanf("%d",&B[i]);
    }
    for(i=0;i<N;i++){
        t=C;
        for(j=0;j<M;j++){
            scanf("%d",&k);
            t += B[j] * k;
        }
        if(t>0) ans += 1;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

int main() {
    int X, N;
    cin >> X >> N;

    set<int> p;
    for (int i = 0; i < N; i++) {
        int pi;
        cin >> pi;

        p.insert(pi);
    }

    int dif = 0;
    while (dif <= X) {
        if (p.find(X - dif) == p.end()) {
            cout << X - dif << endl;
            return 0;
        } else if (p.find(X + dif) == p.end()) {
            cout << X + dif << endl;
            return 0;
        }
        ++dif;
    }

    return 0;
}


Measured memory_bytes: 3144
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll h,w;
    cin>>h>>w;
    f=2;
    //vector<vector<ll>> v(h,vector<ll> (w));
    vector<string> s(h);
    rep(i,h)  cin>>s[i];
    rep(i,h){
        f=1;
        rep(j,w){
            if(s[i][j]!='.') f=0;
        }
        if(f==1){
            for(ll k=i;k<h-1;k++){
            rep(j,w) s[k][j]=s[k+1][j];
            }
            h--;
            i--;
        }
    }
    rep(j,w){
        f=1;
        rep(i,h){
            if(s[i][j]!='.') f=0;
        }
        if(f==1){
            for(ll k=j;k<w-1;k++){
                rep(i,h) {
                    s[i][k]=s[i][k+1];
                    s[i][k+1]=' ';
                }
                
            }
            w--;
            j--;
        }
    }
    //cout<<w<<endl;
        f=1;
        rep(i,h){
            if(s[i][w]!='.') f=0;
        }
        if(f==1){

                rep(i,h) {
                    s[i][w]=' ';
                }
                
            
            w--;
            
        }

    rep(i,h) cout<<s[i]<<endl;
    


    


    return 0;
}


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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;


int main() {
    input;
    ll n, m;
    cin >> n;
    const ll maxx = 1e18;
    ll a[n];
    ll result = 1;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << 0;
            return 0;
        }
    }
    for(int i = 0; i < n; i++) {
        if(maxx / a[i]  >= result) {
            result *= a[i];
        }
        else {
            cout << "-1";
            return 0;
            break;
        }
    }
  cout << result;

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int MAX_K = 5;

set<string> ss;

int main()
{
    string s;
    int K;
    cin >> s >> K;

    REP (i, (int)s.length())
    {
        FOR (j, i + 1, i + MAX_K + 1)
        {
            string tmp = s.substr(i, j - i);
            ss.insert(tmp);
        }
    }

    int cnt = 1;
    for (auto &&x : ss)
    {
        if (cnt == K)
        {
            cout << x << endl;
            break;
        }
        cnt++;
    }

    return 0;
}


Measured memory_bytes: 1664
/*

	TRY_TO_BE8T_ME

*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define FIO ios::sync_with_stdio(0);
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main() 
{
	FIO;
	ll i,j,k,c=0,n,m,d=0,w;
	cin>>n;
	m=n;
	while(n>0)
	{
		w=n%10;
		c+=w;
		n/=10;
	}
	if(m%c==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
 #define LOOP 10000000

int gcd(int a, int b){

    int r;

    if( b > a ) swap(a, b);
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {

    ll A, B;
    ll ans;

    cin >> A >> B;

    ans = gcd(A, B);
    ans = A * B / ans;

    cout << ans << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

void svtr(vector<int> &a){
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
}

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

  cout << max({a*2-1,a+b,b*2-1});
  return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, tmp_min, count;
    cin >> n;

    vector<int> p(n);

    REP(i, n)
    {
        cin >> p[i];

        if (i == 0)
        {
            tmp_min = p[i];
        }
    }

    REP(i, n)
    {
        tmp_min = min(tmp_min, p[i]);

        if (tmp_min >= p[i])
        {
            ++count;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024