akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int elect() {
	int c = gcu();
	switch(c) {
	case '[':
		{
		vector<int> v;
		for (int r; (r = elect());)
			v.push_back(r);
		auto b = v.begin(), m = b + v.size() / 2 + 1;
		nth_element(b, m, v.end());
		return accumulate(b, m, 0);
		}
	case ']':
		return 0;
	default:
		ungetc(c, stdin);
		scanf("%d", &c);
		return c / 2 + 1;
	}
}

int main() {
	for (int n = in(); n--; gcu())
		outl(elect());
}


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

int main() {
  // ここにプログラムを追記
  string s;
  int a = 0;
  cin >>s;
  int s1 = s[0];
  int s2 = s[1];
  int s3 = s[2];
  if(s[0] == '1'){
  	a = a + 1;
  }
  if(s[1] == '1'){
  	a = a + 1;
  }
  if(s[2] == '1'){
  	a = a + 1;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    int N;
    
    cin>>str;
    N = str.size();
    
    ll ans=0, cnt=0;
    rep(i,N){
        if(str[i]=='B'){
            cnt++;
        }else{
            ans+=cnt;
        }
    }
    
    cout1(ans)
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int ans=0;
	string str;
	cin >> str;
	if(str[0]=='1')ans++;
	if(str[1]=='1')ans++;
	if(str[2]=='1')ans++;
	cout << ans << endl;
}

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

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

  int a[n+1];
  for (int i=1; i<=n; i++){
    cin >> a[i];
  }
  int sum = 0, i=1;
  while (sum<100000){
    if (a[i]==2){
      cout << sum+1 << endl;
      return 0;
    }
    else {
      i = a[i];
      sum++;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,hp = 0,minhp = INF;
    cin >> N;
    vector<int> x(N);

    rep(i, N){
        cin >> x.at(i);
    }

    repc(i, 1, 101){
        hp = 0;
        rep(j, N){
            hp += (x.at(j) - i) * (x.at(j) - i);
        }

        if(hp < minhp){
            minhp = hp;
        }
    }

    cout << minhp << endl;
}

Measured memory_bytes: 256
def solve(N):
    A = B = 0
    for i in range(N):
        a, b = map(int, input().split())
        if a > b:
            A += a + b
        elif a < b:
            B += a + b
        else:
            A += a
            B += b
    print(A, B)

while True:
    N = int(input())
    if N == 0:
        break
    solve(N)

Measured memory_bytes: 7672
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int x, a, b;
    string[] s;
    void Solve() {
        //input
        x = io.Int;
        a = io.Int;
        b = io.Int;
        //cal
        Func<int, int> f= (d) => Abs(x - d);
        var ans = f(a) < f(b) ? "A" : "B";
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 11092
#!python3.4
# -*- coding: utf-8 -*-
# abc160/abc160_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    if S[2] == S[3] and S[4] == S[5]:
        print('Yes')
    else:
        print('No')
    return

main()


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

int main(){
    long H;
    long ans = 0;
    int H_log;
    cin >> H;
    H_log = log2(H);
    for(int i = 0; i < 100; i++){
        if(i <= H_log){
            ans += pow(2,i);
        }else{
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll X;
  cin>>X;
  for(ll i=-1000;i<=1000;i++){
    for(ll j=-1000;j<=1000;j++){
      if(X==pow(i,5)-pow(j,5)){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4080
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn
    print $ (n/3)^3



Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  map<char,int> c;
  for(int i=0;i<s.size();i++)
    c[s.at(i)]++;
  cout<<min(c['0'],c['1'])*2<<endl;
  
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  long i,n,min;
  min=1000000000000000;
  long arroy[6];
  arroy[0]=0;
  scanf("%ld",&n);
  for(int j=1;j<6;j++){
    scanf("%ld",&arroy[j]);
    if(min>arroy[j]){
      min=arroy[j];}
  }
  if(n<=min)
    printf("5\n");
  else if(n%min==0) {
    long time;
    time = 4+n/min;
    printf("%ld\n",time);
  }
  else if(n%min != 0) {
    long time2;
    time2=5+n/min;
    printf("%ld\n",time2);
  }
  return 0;
}

    


Measured memory_bytes: 128
import sys
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapify(A)
    for _ in range(m):
        a = (heappop(A) * (-1)) // 2
        heappush(A, a * (-1))

    print(sum(A) * (-1))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14180
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int N; cin>>N;
  vi A;
  vi revA;
  REP(i,N){
    int n;
    cin>>n;
    A.push_back(n);
    revA.push_back(n);
  }
  reverse(ALL(revA)); // for making dpr[]

  // making left_GCD and right_GCD
  vi dpl(N,0); dpl[0]=-1, dpl[1]=A[0];
  vi dpr(N,0); dpr[0]=-1, dpr[1]=revA[0];
  REP(i,N){
    if(i>1){
      dpl[i] = gcd(dpl[i-1], A[i-1]);
      dpr[i] = gcd(dpr[i-1], revA[i-1]);
    }
  }
  reverse(ALL(dpr));

  int ans = 0;
  REP(i,N){
    if(i==0) ans = max(ans, dpr[i]);
    else if(i==N-1) ans = max(ans, dpl[i]);
    else ans = max(ans, gcd(dpl[i], dpr[i]));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2036
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
typedef vector<string> Graph;
int used[1123],v;
int dfs(Graph &g,int p){
  if(used[p])return 0;
  used[p]=1;
  int re=1;
  rep(i,v)
    if(g[p][i]=='Y')
      re+=dfs(g,i);
  return re;
}

int memo[1124][2][2][2][2];

int solve(int n,int edge,int even,int rem,int to){
  //  cout<<"("<<n<<","<<edge<<","<<even<<","<<rem<<","<<to<<")"<<endl;
  int re=0;
  if(n==2 && even==0)
    return to==1;
  if(n==0 && even==2)
    return to==0;
  if(memo[n][edge][even][rem][to])
    return memo[n][edge][even][rem][to]-1;
  if(even==1 && to ==0){
    re=1;
  }else if(!rem){
    re=1-solve(n-2+2*even,edge+even,1-even,1,1-to);
  }else{
    if(even){
      re|=1-solve(n,1-edge,0,1,1-to);
      if(rem%2)
	re|=1-solve(n,1-edge,1,0,1-to);
    }else{
      re|=1-solve(n-2,edge,1,1,1-to);
      if(rem%2)
	re|=1-solve(n-2,edge,1,0,1-to);
    }
  }
  memo[n][edge][even][rem][to]=re+1;
  //  cout<<"("<<n<<","<<edge<<","<<even<<","<<rem<<","<<to<<"):"<<re<<endl;
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k,e=0;
  cin>>v;
  Graph strs(v);
  vector<int> ccs;
  rep(i,v){
    cin>>strs[i];
    e+=count(all(strs[i]),'Y');
  }
  e/=2;
  //  cout<<e<<endl;
  rep(i,v)
    if(!used[i])
      ccs.pb(dfs(strs,i));
  int rem=0;
  for(int cc:ccs)
    rem+=(cc-1)*cc/2;
  rem-=e;
  //    cout<<ccs<<endl;
  if(v%2){
    cout<<(e%2==v%4/2?"Hanako":"Taro")<<endl;
  }else{
    int oc=0,ec=ccs.size();
    rep(i,ccs.size())
      oc+=ccs[i]%2;
    ec-=oc;
    //    cout<<ec<<","<<oc<<endl;
    if(ec==0){
      /*if(ccs.size()==2){
	cout<<"Hanako"<<endl;
	return 0;
	}*/
      //     cout<<"odd:"<<solve(oc,rem%2,0,rem>0,1)<<endl;
      //      cout<<"even:"<<solve(oc,rem%2,0,rem>0,0)<<endl;
      cout<<(e%2==v/2%2 && solve(oc,rem%2,0,rem>0,1) ||
	     e%2!=v/2%2 && solve(oc,rem%2,0,rem>0,0)?"Taro":"Hanako")<<endl;
    }else if(ec==1){
      int odd=0;
      cout<<(solve(oc,rem%2,1,rem>0,1)||e%2!=v/2%2?
	     "Taro":"Hanako")<<endl;
    }else{
      cout<<(e%2!=v/2%2?"Taro":"Hanako")<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
ll p=1000000007;
long long int pow_mod(long long int a, long long int k, long long int c)
{
    long long int ans = 1;
    while(k)
    {
        if(k % 2) ans *= a;
        a = (a * a) % c;
        k /= 2;
        ans %= c;
    }
    return ans;
}
ll quick_mod(ll a, ll b)
{
    ll ans = 1;
    a %= p;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * a % p;
            b--;
        }
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}

ll C(ll n, ll m)
{
    if(m > n) return 0;
    ll ans = 1;
    for(int i=1; i<=m; i++)
    {
       ll a = (n + i - m) % p;
      ll b = i % p;
        ans = ans * (a * quick_mod(b, p-2) % p) % p;
    }
    return ans;
}

ll Lucas(ll n, ll m)
{
    if(m == 0) return 1;
    return C(n % p, m % p) * Lucas(n / p, m / p) % p;
}

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    // 计算2的n次方对（10e+7)求余
    ll cow=pow_mod(2,a,1000000007);
    cow-=1;
    ll ca,cb;
    ca=Lucas(a,b);
    cb=Lucas(a,c);
    ll ans=cow-ca-cb;
    while(ans<0)
        ans+=1000000007;
    cout<<ans<<endl;
}


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

#define Khaled ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lli long long int
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define FOR(i, n) for (i = 0; i < n; i++)
#define FO(i,k,n) for(i = k; i <= n; i++)
#define in(v) for(auto &it : v) cin >> it;
#define out(v) for(auto it : v) cout << it << ' '; cout << endl;
#define all(arr) arr.begin(), arr.end()
#define PI acos(-1)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define MAX 100005
 
using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;

string let = "abcdefghijklmnopqrstuvwxyz";

void solve()
{
    lli i, j, n, m, a, b, c, d, x, y, z, k, l;
    string s;
    cin >> s;
    l = s.size();
    if(s[l-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;

    return;
}

int main()
{
    Khaled
    // freopen("input", "r", stdin);
    // freopen("output" , "w" , stdout);
    int t = 1,i;
    // cin >> t;
    FO(i,1,t) {
        solve();
    }

    return 0;
}

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

using namespace std;

string s, sol;

int main () {
    cin >> s;
    int len = s.size();
    for (int i=0; i<len; i++) {
        if (s[i] != 'B') sol += s[i]; else if (!sol.empty()) sol.pop_back();
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AAntiAdjacency {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, k;
	    in >> n >> k;
	    ans2(k <= ceill(n, 2), out);
	}
};


int main() {
	AAntiAdjacency solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)
#define ll LL
#define st f
#define nd s
#define pb PB
#define mp MP
#define eb emplace_back
#define siz(c) SIZ(c)
const int inf = 1e9+7;
const ll INF = 1e18L+7;

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

LL pionta(LL x)
  {
  return x * x * x * x * x;
  }

int main()
{
  LL X;
  cin >> X;

  int zakres = 5000;
  FOR(A, -zakres, zakres)
    {
    FOR(B, -zakres, zakres)
      {
      if(pionta(A) - pionta(B) == X)
        {
        cout << A << " " << B << endl;
        return 0;
        }
      }
    }
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    q[p[i]-1]=i;
  }
  int m=1;
  int cnt=1;
  for(int i=0;i<n-1;i++){
    if(q[i]<q[i+1]){
      cnt++;
    }
    m=max(m,cnt);
    if(q[i]>=q[i+1]){
      cnt=1;
    }
  }
  cout << n-m << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string a,b,c;cin>>a>>b>>c;
    cout<<"A"<<b[0]<<"C"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  ll x, y; cin >> x >> y;
  ll z = 2e9 + 1;
  ll a =   y - x;
  ll b = - y - x + 1;
  ll c =   x - y + 2;
  ll d =   x + y + 1;
  if(a < 0)a = z;
  if(b < 0)b = z;
  if(c < 0)c = z;
  if(d < 0)d = z;
  ll e = min(a,b);
  ll f = min(c,d);
  cout << min(e,f) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define  mod 1000000007

int main(void){
   int N,X,T;
   int ans=0;
 
   scanf("%d %d %d",&N,&X,&T);
   
   if(N%X==0)
  printf("%d\n",N/X*T);
   else
  printf("%d\n",(N/X+1)*T);
   return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int main() {
    cin >> s;
    bool ok = false;
    if (s[0] == s[1] && s[1] == s[2])
        ok = true;
    if (s[2] == s[3] && s[1] == s[2])
        ok = true;
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    a[i] = a[i - 1] + x;
  }
  ll ans1 = 0, cnt1 = 0;
  for (int i = 1; i <= n; i++) {
    ll tmp = llabs(a[i] + cnt1) + 1;
    if (i%2 == 1) {
      if (a[i] + cnt1 <= 0) {
        ans1 += tmp;
        cnt1 += tmp;
      }
    }
    else {
      if (a[i] + cnt1 >= 0) {
        ans1 += tmp;
        cnt1 -= tmp;
      }
    }
  }
  ll ans2 = 0, cnt2 = 0;
  for (int i = 1; i <= n; i++) {
    ll tmp = llabs(a[i] + cnt2) + 1;
    if (i%2 == 1) {
      if (a[i] + cnt2 >= 0) {
        ans2 += tmp;
        cnt2 -= tmp;
      }
    }
    else {
      if (a[i] + cnt2 <= 0) {
        ans2 += tmp;
        cnt2 += tmp;
      }
    }
  }
  ll ans = min(ans1, ans2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
sx, sy, tx, ty = map(int, input().split())

ans = 'R' * (tx - sx)
ans += 'U' * (ty - sy)
ans += 'L' * (tx - sx)
ans += 'D' * (ty - sy + 1)
ans += 'R' * (tx - sx + 1)
ans += 'U' * (ty - sy + 1)
ans += 'LU'
ans += 'L' * (tx - sx + 1)
ans += 'D' * (ty - sy + 1)
ans += 'R'

print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int l, r;
	cin >> l >> r;
	if (r - l + 1 >= 2019) {
	  cout << 0 << endl;
	} else {
	  int res = 2020;
	  FOR (i, l, r + 1) {
		FOR (j, i + 1, r + 1) {
		  res = min(res, ((i % 2019) * (j % 2019) % 2019));
		}
	  }
	  cout << res << endl;
	}
	
    return 0;
}



Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

#define N	200000

int *oj[N], oo[N];

void link(int i, int j) {
	int o = oo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		oj[i] = (int *) realloc(oj[i], o * 2 * sizeof *oj[i]);
	oj[i][o] = j;
}

int aa[N];

void dfs(int i) {
	static char used[N];
	int o;

	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		dfs(j);
	}
	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		used[aa[j]] = 1;
	}
	while (used[aa[i]])
		aa[i]++;
	for (o = 0; o < oo[i]; o++) {
		int j = oj[i][o];

		used[aa[j]] = 0;
	}
}

int main() {
	static int pp[N];
	static char visited[N];
	int n, i, k, a;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &pp[i]), pp[i]--;
	i = 0;
	while (!visited[i])
		visited[i] = 1, i = pp[i];
	k = 0;
	while (visited[i] == 1)
		visited[i] = 2, i = pp[i], k++;
	if (k % 2 == 0) {
		printf("POSSIBLE\n");
		return 0;
	}
	for (i = 0; i < n; i++)
		oj[i] = (int *) malloc(2 * sizeof *oj[i]);
	for (i = 0; i < n; i++)
		if (visited[i] != 2)
			link(pp[i], i);
	a = -1;
	for (i = 0; i < n; i++)
		if (visited[i] == 2) {
			dfs(i);
			if (a != -1 && a != aa[i]) {
				printf("POSSIBLE\n");
				return 0;
			}
			a = aa[i];
		}
	printf("IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 11536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    int a[n];
    int am=0;
    rep(i,n) {
        cin>>a[i];
        am=max(am,a[i]);
    }
    double x=am/2;
    double dis=INF;
    int ans;
    rep(i,n){
        if(abs(a[i]-x)<dis){
            if(a[i]==am) continue;
            dis=abs(a[i]-x);
            ans=i;
        }
    }
    cout << am << " " << a[ans] << endl;





}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;
    if(S[S.size()-1] == 's')
    {
        cout << S<< "es";
    }
    else
    {
        cout << S << 's';
    }
    
    return 0;
}

Measured memory_bytes: 3620
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Disjoint Set of Common Divisors
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

/* main */

int main() {
  ll a, b;
  scanf("%lld%lld", &a, &b);

  ll g = gcd<ll>(a, b);
  //printf("g=%lld\n", g);

  int cnt = 1;
  for (ll p = 2; p * p <= g; p++)
    if (g % p == 0) {
      cnt++;
      while (g % p == 0) g /= p;
    }
  if (g > 1) cnt++;

  printf("%d\n", cnt);
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    if((s.substr(5,2)).compare("04")<=0){
        cout <<"Heisei" <<endl;
    }else{
        cout <<"TBD"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	char a[7], b[4];

	scanf("%s %s", a, b);
	strcat(a, b);

	const size_t val = (size_t)atoi(a);

	bool isSquareNum = false;

	for (size_t candidate = 1; candidate*candidate <= val; candidate++) {
		if (candidate*candidate == val) {
			isSquareNum = true;
			break;
		}
	}

	puts((isSquareNum ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
import math

# NとKの入力、Nはサイコロの面の数,Kは得点
strings = input().split()

n = int(strings[0])
k = int(strings[1])
prob = 0
'''
x = int(math.log(k / n, 2)) + 1
print(x)
prob = (1 / 3) * pow(1 / 2, x)
'''
# 1~Nまでのサイコロによるそれぞれの確率を算出
for num in range(1, n+1):
    if num < k:
        x = math.ceil(math.log2(k / num))
        prob += pow(1 / 2, x)
    else:
        prob += 1
print(prob / n)


Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		int[] v=new int[m+1];
		for(int i=1;i<=m;i++) v[i]=scanner.nextInt();
		int[] dp=new int[n+1];
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0]=0;
		for(int i=0;i<=n;i++){
			if(dp[i]!=Integer.MAX_VALUE/2){
				for(int j=1;j<=m;j++){
					if(i+v[j]<=n)
						dp[i+v[j]]=Math.min(dp[i+v[j]], dp[i]+1);
				}
			}
		}
		System.out.println(dp[n]);
	}

}



Measured memory_bytes: 27204
N=int(input())
p=[(int(a),i+1) for i,a in enumerate(input().split())]
p.sort()
a=[0]*N
b=[0]*N
a[0]=p[0][1]
b[0]=10**9
for i in range(1,N):
  if p[i][1]>p[i-1][1]:
    a[i]=a[i-1]+p[i][1]-p[i-1][1]+1
    b[i]=b[i-1]-1
  if p[i][1]<p[i-1][1]:
    a[i]=a[i-1]+1
    b[i]=b[i-1]+p[i][1]-p[i-1][1]-1
    
print(" ".join(list(map(str,a))))
print(" ".join(list(map(str,b))))

Measured memory_bytes: 45944
//by xiqiao
#include<bits/stdc++.h>
#define maxn 132072
using namespace std;
typedef long long ll;
int n,flag;
vector <pair<int,int> > v[maxn];
vector <pair<ll,ll> > can[maxn],tmp;
int lc[maxn],rc[maxn];
ll dep[maxn],inf,MID;
void pre(int x){
	if(v[x].size()==0)return;
	lc[x]=v[x][0].first;dep[lc[x]]=dep[x]+v[x][0].second;
	rc[x]=v[x][1].first;dep[rc[x]]=dep[x]+v[x][1].second;
	pre(lc[x]);pre(rc[x]);
}
void update(int x){
	sort(tmp.begin(),tmp.end());
	ll p=inf;
	for(int i=0;i<(int)tmp.size();i++){
		if(tmp[i].second<p){
			can[x].push_back(tmp[i]);
			p=tmp[i].second;
		}
	}
}
void dfs(int x){
	can[x].clear();
	if(!flag)return;
	if(!lc[x]){
		can[x].push_back(make_pair(dep[x],dep[x]));return;
	}
	dfs(lc[x]);dfs(rc[x]);
	int l=lc[x],r=rc[x];
	if(can[lc[x]].size()>can[rc[x]].size())swap(lc[x],rc[x]);
	tmp.clear();
	int wh=-1;
//	cout<<"----------"<<x<<"--------------"<<endl;
//	for(int i=0;i<(int)can[l].size();i++)cout<<"<"<<can[l][i].first<<" "<<can[l][i].second<<">"<<" ";cout<<endl;
//	for(int i=0;i<(int)can[r].size();i++)cout<<"<"<<can[r][i].first<<" "<<can[r][i].second<<">"<<" ";cout<<endl;
	for(int i=0;i<(int)can[l].size();i++){
		while(wh<(int)can[r].size()-1 && (can[l][i].second+can[r][wh+1].first-2*dep[x])<=MID)wh++;
		if(wh>=0)tmp.push_back(make_pair(can[l][i].first,can[r][wh].second)),tmp.push_back(make_pair(can[r][wh].second,can[l][i].first));
	}
	wh=0;
	for(int i=0;i<(int)can[l].size();i++){
		while(wh<(int)can[r].size() && (can[l][i].first+can[r][wh].second-2*dep[x])>MID)wh++;
		if(wh<(int)can[r].size())tmp.push_back(make_pair(can[r][wh].first,can[l][i].second)),tmp.push_back(make_pair(can[l][i].second,can[r][wh].first));
	}
	update(x);
	if((int)can[x].size()==0){flag=0;return;}
	//judge
//	for(int i=0;i<(int)tmp.size();i++)cout<<"<"<<tmp[i].first<<" "<<tmp[i].second<<">"<<" ";cout<<endl;
}
bool check(ll mid){
	MID=mid;flag=1;
	for(int i=1;i<=n;i++)can[i].clear();
	dfs(1);
	if(flag)return 1;
	return 0;
}
int main(){
//	freopen("travel.in","r",stdin);
	//freopen("travel.out",'w",stdout); 
	scanf("%d",&n);
	ll L=0,R=0;
	for(int i=2;i<=n;i++){
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(make_pair(i,y));
		R+=y;
	}
	inf=R+5;
	pre(1);
//	cout<<check(6);return 0;
	
	while(L<R){
		ll mid=(L+R)/2;
		//cout<<mid<<" "<<check(mid)<<endl;
		if(check(mid))R=mid;
		else L=mid+1;
	}
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 34672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char s[1000005];
int dp[1000005][2]={0};
int main()
{
    //int n;
    //cin >>n;
    cin >> s+1;
    int len = strlen(s+1);
    //cout<<len<<endl;
    dp[0][1]=1;
    for(int i=1;i<=len;i++){
        dp[i][0]=min(dp[i-1][0]+s[i]-'0',dp[i-1][1]+10-s[i]+'0');
        dp[i][1]=min(dp[i-1][0]+s[i]-'0'+1,dp[i-1][1]+9-s[i]+'0');
    }
    cout << dp[len][0]<<endl;
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	string s,t;
	for(ll i=0;i<n;i++){
		s+='0'+m;
	}
	for(ll i=0;i<m;i++){
		t+='0'+n;
	}
	if(s<t){
		cout <<s;
	}
	else{
		cout << t;
	}
	// your code goes here
	return 0;
}

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


int main() {
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s.at(i)==','){
      s.at(i)=' ';
    }
  }
  cout<<s<<endl;
 
}



Measured memory_bytes: 256
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)

vector<int> makeFactor(int x) {
	vector<int> factors;
	factors.push_back(2);
	for (size_t i = 3; i <= sqrt(x); i+=2)
	{
		bool flag = false;
		Foreach(item, factors) if (i%item == 0) { flag = true; break; }
		if (!flag) factors.push_back(i);
	}
	return factors;
}

int main(){
	int N;
	string s, t;
	cin >> N >> s >> t;
	int ans = N * 2;
	if (s == t) { out(N); return 0; }
	Rep(i, N) {
		bool f = true;
		For(n, i, N) {
			if (s[n] != t[n - i]) {
				f = false;
				break;
			}
		}
		if (f) {
			ans = i + N;
			break;
		}
	}
	out(ans);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

//UnionFind 木
// T (typename) : グラフの頂点を表す型, (int)parent, (int)size を持つ必要あり
template <typename T>
struct UnionFind {
    vector<T> &u;
    UnionFind(vector<T> &u) : u(u) {
        for (int i = 0; i < u.size(); i++) {
            u[i].parent = i;
        }
    }
    int root(int x) {
        if (x < 0 || u.size() <= x)
            return -1;
        else if (x == u[x].parent)
            return x;
        else
            return u[x].parent = root(u[x].parent);
    }
    bool connect(int a, int b) {
        a = root(a), b = root(b);
        if (a == b || a < 0 || b < 0) return false;
        { /* do something */
        }
        u[b].parent = a;
        return true;
    }
    // O(u.size())
    void count(map<int, int> &ret) {
        for (int i = 0; i < u.size(); i++) {
            int tmp = u[i].parent;
            if (!ret.count(tmp)) {
                ret[tmp] = 0;
            }
            ret[tmp]++;
        }
    }
};

template <typename Edge>
void Kruskal(vector<Edge> &edge, int N, vector<Edge> &ans) {
    struct Node {
        int parent;
    };
    rev_priority_queue<Edge> q;
    vector<Node> node(N);
    UnionFind<Node> uf(node);
    for (auto e : edge) q.push(e);
    while (!q.empty()) {
        Edge e = q.top();
        q.pop();
        if (uf.root(e.v1) != uf.root(e.v2)) {
            uf.connect(e.v1, e.v2);
            ans.push_back(e);
        }
    }
}

struct Edge {
    int v1, v2;
    i64 cost;
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<i64, int>> X(N), Y(N);
    for(int i = 0; i < N; i++) {
        i64 x, y;
        cin >> x >> y;
        X[i] = {x, i}, Y[i] = {y, i};
    }
    sort(WHOLE(X)), sort(WHOLE(Y));
    vector<Edge> e;
    for(int b = 0; b < 2; b++) {
        for(int i = 0; i < N - 1; i++) {
            auto s = X[i], t = X[i + 1];
            e.push_back({s.second, t.second, t.first - s.first});
        }
        swap(X, Y);
    }
    vector<Edge> span;
    i64 ans = 0;
    Kruskal(e, N, span);
    for(auto x : span) ans += x.cost;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16108
import itertools as ito
import copy
[H, W, K]=list(map(int, input().split()))
xlist=[]
for i in range(H):
    xlist.append(input().split())
clist=[]
for x in xlist:
    y=[]
    for l in x[0]:
        y.append(l)
        #print(l)
    clist.append(y)
#print(clist)
gyochange=[]
retuchange=[]
for j in range(W+1):#列数
    ls2=ito.combinations(range(W),j)
    for retu in ls2:
        retuchange.append(retu)
for i in range(H+1):#行数
    ls1=ito.combinations([k for k in range(H)],i)
    for gyo in ls1:
        gyochange.append(gyo)
#print(gyochange)
#print(retuchange)
ans=0
cc=copy.deepcopy(clist)
for gch in gyochange:
    for rch in retuchange:
        clist=copy.deepcopy(cc)
        #print(gch,rch)
        for g in gch:
            for j in range(W):
                clist[g][j]='r'
        for r in rch:
            for i in range(H):
                clist[i][r]='r'
        clist=list(ito.chain.from_iterable(clist))
        #print(clist,clist.count('#'))
        if clist.count('#')==K:
            ans+=1
            #print('good')
print(ans)


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

int top,S[1000];
void push(int);
int pop();

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;

  return S[top+1];
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){
    // Your code here!
    long long n, k, count = 0;
    
    cin >> n;
    for(long long i = 6; i < 55555; i++)
        if(i % 5 == 1 && IsPrime(i)){
            cout << i << ' ';
            count++;
            if(count == n)
                break;
        }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<utility>
#include<queue>
#include<cmath>
#include<functional>
#include<vector>
#define int long long
using namespace std;
int w[105],v[105],f[105][100005];
signed main()
{
	int N,W;
    scanf("%lld %lld",&N,&W);
    for(int i=1;i<=N;i++)scanf("%lld %lld",&w[i],&v[i]);
    for(int i=1;i<=N;i++)f[i][0]=0;
    for(int i=1;i<=N;i++)for(int j=1;j<=W;j++){if(j>=w[i])f[i][j]=max(f[i-1][j-w[i]]+v[i],f[i-1][j]);else f[i][j]=f[i-1][j];}
    printf("%lld",f[N][W]);
    return 0;
}

Measured memory_bytes: 79360
import java.util.Scanner;

public class Main {

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

		String s = sc.next();

		System.out.println("" + s.charAt(0) + s.substring(1, s.length() - 1).length() + s.charAt(s.length() - 1));

		sc.close();
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(s==u) a--;
    if(t==u) b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N, K;
	cin >> N >> K;
	int KK = K * 2;
	// int income = 0;
	vector<vint> accW(2020, vint(2020));
	vector<vint> accB(2020, vint(2020));
	rep(i, N) {
		int x, y;
		string c;
		cin >> x >> y >> c;
		x %= KK;
		y %= KK;
		// int sc = c == "B" ? income++, -1 : 1;
		if (c == "W") accW[y + 1][x + 1]++;
		else accB[y + 1][x + 1]++;
		// 1 <= y + 1, x + 1 <= K
		// acc[y + 1][x + 1] += sc;
	}
	rep(y, 2005) repr(x, 1, 2005) accW[y][x] += accW[y][x - 1], accB[y][x] += accB[y][x - 1];
	rep(x, 2005) repr(y, 1, 2005) accW[y][x] += accW[y - 1][x], accB[y][x] += accB[y - 1][x];
	int ans = 0;
	rep(y, K + 1) rep(x, K + 1) {
		int yy = y + K;
		int xx = x + K;
		int migiue = accW[KK][KK] - accW[yy][KK] - accW[KK][xx] + accW[yy][xx];
		int hidariue = accW[KK][x] - accW[yy][x];
		int migishita = accW[y][KK] - accW[y][xx];
		int hidarishita = accW[y][x];
		int migi = accB[yy][KK] - accB[yy][xx] - accB[y][KK] + accB[y][xx];
		int ue = accB[KK][xx] - accB[KK][x] - accB[yy][xx] + accB[yy][x];
		int hidari = accB[yy][x] - accB[y][x];
		int shita = accB[y][xx] - accB[y][x];
		int mannaka = accW[yy][xx] - accW[yy][x] - accW[y][xx] + accW[y][x];
		int hoge = migiue + hidariue + migishita + hidarishita + migi + ue + hidari + shita + mannaka;
		// int hoge = acc[K][K] - acc[y][K] - acc[K][x] + 2 * acc[y][x];
		ans = max(ans, hoge);
	}
	rep(y, K + 1) rep(x, K + 1) {
		int yy = y + K;
		int xx = x + K;
		int migiue = accB[KK][KK] - accB[yy][KK] - accB[KK][xx] + accB[yy][xx];
		int hidariue = accB[KK][x] - accB[yy][x];
		int migishita = accB[y][KK] - accB[y][xx];
		int hidarishita = accB[y][x];
		int migi = accW[yy][KK] - accW[yy][xx] - accW[y][KK] + accW[y][xx];
		int ue = accW[KK][xx] - accW[KK][x] - accW[yy][xx] + accW[yy][x];
		int hidari = accW[yy][x] - accW[y][x];
		int shita = accW[y][xx] - accW[y][x];
		int mannaka = accB[yy][xx] - accB[yy][x] - accB[y][xx] + accB[y][x];
		int hoge = migiue + hidariue + migishita + hidarishita + migi + ue + hidari + shita + mannaka;
		// int hoge = acc[K][K] - acc[y][K] - acc[K][x] + 2 * acc[y][x];
		ans = max(ans, hoge);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 34304
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
int h, w;
string s[50];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>h>>w;
    for(int i=0;i<w;i++) {
        cin>>s[i];
    }
    for(int i=0;i<w;i++){
        s[i].c_str();
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(s[i][j]=='#'){
                bool c=false;
                for(int k=0;k<4;k++){
                    if(i+dy[k]<0||j+dx[k]<0||i+dy[k]>=w||j+dx[k]>=h)continue;
                    if(s[i+dy[k]][j+dx[k]]=='#'){
                        c=true;
                    }
                }
                if(!c){
                    cout<<"No"<<"\n";
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << "\n";
}

Measured memory_bytes: 256
n, k = map(int, input().split())

plst = []
xlst = []
ylst = []
dlst = []

for i in range(n):
  x1,y1,d1,x2,y2,d2 = map(int, input().split())
  plst.append((x1,y1,d1,x2,y2,d2))
  xlst.append(x1)
  xlst.append(x2)
  ylst.append(y1)
  ylst.append(y2)
  dlst.append(d1)
  dlst.append(d2)

xlst = list(set(xlst))
ylst = list(set(ylst))
dlst = list(set(dlst))

xlst.sort()
ylst.sort()
dlst.sort()

xdic = {}
ydic = {}
ddic = {}

for i, v in enumerate(xlst):
  xdic[v] = i
for i, v in enumerate(ylst):
  ydic[v] = i
for i, v in enumerate(dlst):
  ddic[v] = i

new_map = [[[0] * len(dlst) for _ in ylst] for _ in xlst]

for p in plst:
  x1, y1, d1, x2, y2, d2 = p
  x1, y1, d1, x2, y2, d2 = xdic[x1], ydic[y1], ddic[d1], xdic[x2], ydic[y2], ddic[d2]
  for x in range(x1, x2):
    for y in range(y1, y2):
      for d in range(d1, d2):
        new_map[x][y][d] += 1

ans = 0
for i in range(len(xlst) - 1):
  for j in range(len(ylst) - 1):
    for z in range(len(dlst) - 1):
      x, y, d = xdic[xlst[i]], ydic[ylst[j]], ddic[dlst[z]]
      if new_map[x][y][d] >= k:
        ans += (xlst[i + 1] - xlst[i]) *(ylst[j + 1] - ylst[j]) * (dlst[z + 1] - dlst[z])
print(ans)


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

int main() {
  int N, sum = 0;

  cin >> N;
  int i = N;
  while (0 < i) {
    sum += i % 10;
    i = i / 10;
  }
  if (N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256