akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[][] matrix = new int[n+1][n+1];

		for (int i = 1; i <= n; i++) {
			int nodeF = sc.nextInt();
			int outBountCount = sc.nextInt();
			for (int j = 0; j < outBountCount; j++) {
				int nodeT = sc.nextInt();
				matrix[nodeF][nodeT] = 1;
			}
		}

		int[] v = new int[n+1];
		Arrays.fill(v, -1);
		v[1] = 0;

		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(1);
		v = SearchUtil.bfs(matrix, v, q);

		for (int i = 1; i <= n; i++) {
			System.out.println(i + " " + v[i]);
		}
		sc.close();

	}

	static class SearchUtil {
		/**
		 * @param matrix グラフ
		 * @param v[] 訪問済リスト
		 *
		 * */
		public static int[] bfs(int[][] matrix, int[] v, ArrayDeque<Integer> q) {

			int from = q.poll();
			int count = v[from];
			for (int to = 1; to < matrix[from].length; to++) {
				if (matrix[from][to] == 1) {
					if (v[to] == -1 || count + 1 < v[to]) {
						q.add(to);
						v[to] = count + 1;
					}
				}
			}
			if (!q.isEmpty()) {
				SearchUtil.bfs(matrix, v, q);
			}

			return v;
		}
	}
}




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

#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int main() {
    ll n, k;
    cin >> n >> k;
    cout << ll(log(n) / log(k)) + 1 << endl;
    return 0;
}


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

long long dp[2][2098000];

int main(){
	int n;
	scanf("%d",&n);
	int arr[n][n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&arr[i][j]);
		}
	}
	int N=(1<<n);
	long long MOD=1000000007;
	for(int j=0;j<N;j++){
		dp[0][j]=0;
		dp[1][j]=0;
	}
	dp[0][N-1]=1; dp[1][N-1]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<N;j++){
			int idx=i%2;
			//printf("%d\n",dp[idx][j]);
			if(dp[idx][j]==0)continue;
			int bm=j;
			while(bm&(-bm)){
				int x=(bm&(-bm));
				int y=__builtin_ctz(x);
				if(arr[i][y]==1){
					//printf("%d %d, %d %d, %d %d\n",i,y,idx^1,j-x,idx,j);
					dp[idx^1][j-x]+=dp[idx][j];
					dp[idx^1][j-x]%=MOD;
				}
				bm-=x;
			}
			dp[idx][j]=0;
		}
		//printf("\n");
	}
	printf("%lld",dp[n%2][0]);
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int dp[300000][2];

int main() {
  int n;
  string s;
  while(cin>>n>>s) {
    memset(dp,0,sizeof(dp));
    REP(i, n) {
      dp[i+1][1] = min(dp[i][1] + (s[i] == '.'), dp[i][0] + (s[i] == '.'));
      dp[i+1][0] = dp[i][0] + (s[i] == '#');
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
  }
}


Measured memory_bytes: 2948
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// くじ引き回数
		int N = sc.nextInt();
        List<String> listA = new ArrayList<String>(N);
		for (int i=0; i<N; i++) {
          listA.add(sc.next());
        }

        List<String> listB = new ArrayList<String>(new HashSet<>(listA));

        //System.out.println("ListA = " + listA);
        //System.out.println("ListB = " + listB);
        System.out.println(listB.size());
	}
}

Measured memory_bytes: 75140
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int F = 0;
  cin >> N;
  if (N < 0 or N > 10000){
    F = 3;
  }
  int A = 0;
  vector<int> f(N);
  for(int i = 0;i < N;i++){
    f.at(i) = 0;
  }
  int y = 1;
  int x = 1;
  for(int z = 1;z < N;z++){
    if(F == 3){
      break;
    }
    A = (x + y + z) * (x + y + z) - x * y - y * z - z * x;
    if(A <= N){
      if(x == y and y == z){
        f.at(A - 1) += 1;
        F = 0;
      }
      else if(x == y or y == z){
        f.at(A - 1) += 3;
        F = 0;
      }
      else{
        f.at(A - 1) += 6;
        F = 0;
      }
    }
    else if(y != z){
      y += 1;
      z = y - 1;
    }
    else if(x == y and y == z){
      break;
    }
    else if(F == 0){
      x += 1;
      y = x;
      z = x - 1;
    }
    else{
      break;
    }
  }
  for(int i = 0;i < N;i++){
    if(F == 3){
      break;
    }
    cout << f.at(i) <<endl;
  }
}

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

#define ln '\n'
#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 FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;

    ll ans = 0;
    if(a % 2 == 1 and b % 2 == 1) ans += (b - a + 2) / 2 % 2 == 1 ? 1 : 0;
    else if(a % 2 == 0 and b % 2 == 0) ans += (b - a) / 2 % 2 == 1 ? 1 : 0;
    else ans += (b - a + 1) / 2 % 2 == 1 ? 1 : 0;
    FOR(i, 1, 50) {
        ll a_bit_cnt = (a >> i & 1) == 1 ?
            (1LL << (i + 1)) - a % (1LL << (i + 1)) : 0;
        ll b_bit_cnt = (b >> i & 1) == 1 ? 
            b % (1LL << (i + 1)) - (1LL << i) + 1: 0;
        ll bit_sum = a_bit_cnt + b_bit_cnt;
        
        if(a_bit_cnt < b - a + 1) ans += (bit_sum % 2 == 1 ? 1LL << i : 0);
        else ans += ((b - a + 1) % 2 == 1 ? 1LL << i : 0);
    }

    cout << ans << ln;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> edge(N+1, vector<int>());
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> c(N);
    for (int i = 0; i < N; i++) cin >> c[i];
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    queue<int> q;
    q.push(1);
    vector<int> ans(N+1, 0);
    ans[1] = c[0];
    int pos = 1;
    ll sum = 0;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int nxt : edge[now]) {
            if (ans[nxt] > 0) continue;
            ans[nxt] = c[pos];
            sum += c[pos];
            pos++;
            q.push(nxt);
        }
    }
    cout << sum << endl;
    for (int i = 1; i <= N; i++) {
        if (i < N) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(a + b + c >= 22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int depth[100100];
int par[100100];

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    void init(int n) { par.assign(n,-1);}
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    ll N,M; cin >> N >> M;
    //初期化
    vector<ll> A(M),B(M);
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    UnionFind uf(N);
    ll cur = N*(N-1)/2;
    vector<ll> res;
    for(int i = 0; i < M; i++){
        res.push_back(cur);
        int a = A[M-i-1], b = B[M-i-1];
        if(uf.same(a,b)) continue;
        ll sa = uf.size(a), sb = uf.size(b);
        cur -= sa*sb;
        uf.merge(a,b);
    }
    reverse(res.begin(),res.end());
    for(int i = 0; i < res.size(); i++) cout << res[i] << endl;
}


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

int solve(int a, int b) {
    if (a > 9 || b > 9) {
        return -1;
    } else {
        return a * b;
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << solve(a, b);

    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A[3];
signed main() {
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    if (A[0] == A[1] && A[1] != A[2] || A[0] != A[1] && A[1] == A[2]) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int m,f,r;
        while (true) {
            m = input.nextInt();
            f = input.nextInt();
            r = input.nextInt();
            if (m == -1 && f == -1 && r == -1){
                break;
            }
            String result;
            if (m == -1 || f == -1){
                result = "F";
            } else if (m+f >= 80){
                result = "A";
            } else if (m+f >= 65){
                result = "B";
            } else if (m+f >= 50){
                result = "C";
            } else if (m+f < 30){
                result = "F";
            } else if (r >= 50){
                result = "C";
            } else {
                result = "D";
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26176
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
signed main(){
	
	int x,y;
	cin>>x>>y;
	rep(i,x+1){
		if(2*i+4*(x-i)==y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;

}

Measured memory_bytes: 3580
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		Console.WriteLine(((GetInt() + 1)/ 2 >= GetInt()) ? "YES" : "NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

int main() {
	
	int n, k;
	cin >> n >> k;
	map<int, int> occ;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		occ[x]++;
	}
	vector<int> t;
	for (map<int, int>::iterator x=occ.begin(); x!=occ.end(); x++) {
		t.push_back(x->second);
	}
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	int took = 0;
	for (int i=0; i<min(k, (int) t.size()); i++) {
		took += t[i];
	}	
	
	cout << n - took << endl;
	
}


Measured memory_bytes: 10748
def maxSubarrayXOR(lis, n, INT_BITS = 60):
    idx = 0
    for i in range(INT_BITS-1,-1,-1):
        Mele = -1
        bit_i = 1 << i
        for j in range(idx, n):
            if lis[j] & bit_i and lis[j] > Mele:
                Midx, Mele = j, lis[j]
        if Mele < 0: continue
        lis[Midx], lis[idx] = lis[idx], lis[Midx]
        for j in range(n):
            if j != idx and lis[j] & bit_i:
                lis[j] ^= lis[idx]
        idx += 1
    res = 0
    for x in lis: res ^= x
    return res

n = int(input())
a = list(map(int, input().split()))
t = 0
for x in a: t ^= x
b = [x^(x&t) for x in a]
print(t + maxSubarrayXOR(b, n)*2)

Measured memory_bytes: 16116
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  string s;

  cin >> N;

  //Nの桁数を算出
  int cnt = 1;
  int tmpN = N/10;
  while(tmpN > 0){
    cnt++;
    tmpN = tmpN/10;
  }
  // cout << "cnt = " << cnt << endl;

  if(cnt == 1){
    // cout << "if) cnt == 1" << endl;
    ans = N;
  }else{
    // cout << "else)" << endl;

    int tmpcnt = cnt;
    // cout << "  tmpcnt = " << tmpcnt << endl;

    //上から順に各桁での個数を計算
    while(tmpcnt >= 1){
      // cout << "  while loop )" << endl;
      // cout << "    tmpcnt = " << tmpcnt << endl;
      if(tmpcnt % 2 == 0){
        //偶数桁の場合、答えへの干渉なし

      }else{
        //奇数桁の場合

        if(tmpcnt == cnt){
          //一番上の桁
          ans = N - pow(10.0, cnt - 1) + 1;
          // cout << "      ans = " << ans << endl;
        }else{
          //それ以外
          ans = ans + pow(10.0, tmpcnt - 1) * 9;
          // cout << "      ans = " << ans << endl;
          // cout << "      pow(tmpcnt - 1, 10.0) = " << pow(10.0, tmpcnt - 1) << endl;
        }
      }
      tmpcnt--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力の取得
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

# 求解処理
result = int()
a = 0
while True:
    x_minus = X - a
    if x_minus not in p:
        result = x_minus
        break
    x_plus = X + a
    if x_plus not in p:
        result = x_plus
        break

    a += 1

# 結果出力
print(result)


Measured memory_bytes: 9184
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1:
    if A == B:
        print(1)
    else:
        print(0)
elif N == 2:
    print(1)
else:
    temp = (N - 2) * (B - A) + 1
    print(temp)


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

int main()
{
    int n,m,x,a[201];

    cin>>n>>m>>x;

    for(int i=0;i<m;i++) cin>>a[i];

    int left=0,right=0;

    for(int i=0;i<m;i++)
    {
        if(a[i]<x) right++;
        else left++;
    }
    cout<<min(left,right);

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

class UnionFindTree {
 private:
  int nodeSize;
  vector<int> parent;
  vector<int> rank;
  vector<int> treeSize;

 public:
  UnionFindTree(int ns) {
    nodeSize = ns;
    parent = vector<int>(nodeSize);
    rank = vector<int>(nodeSize, 0);
    treeSize = vector<int>(nodeSize, 1);

    for (int i = 0; i < nodeSize; i++) {
      parent[i] = i;
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) {
      return false;
    }

    if (rank[x] < rank[y]) {
      parent[x] = y;
      treeSize[y] += treeSize[x];
    } else {
      parent[y] = x;
      treeSize[x] += treeSize[y];
      if (rank[x] == rank[y]) {
        rank[x]++;
      }
    }

    return true;
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int getSize(int x) { return treeSize[find(x)]; }
};

int main() {
  int n;
  cin >> n;
  vector<pair<pii, int>> xy, yx;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    xy.eb(mp(mp(x, y), i));
    yx.eb(mp(mp(y, x), i));
  }

  sort(all(xy));
  sort(all(yx));

  vector<pair<int, pii>> cost;
  rep(i, n - 1) {
    cost.eb(mp(xy[i + 1].F.F - xy[i].F.F, mp(xy[i].S, xy[i + 1].S)));
    cost.eb(mp(yx[i + 1].F.F - yx[i].F.F, mp(yx[i].S, yx[i + 1].S)));
  }

  sort(all(cost));

  UnionFindTree uf(n);
  ll ans = 0;
  rep(i, sz(cost)) {
    if (!uf.same(cost[i].S.F, cost[i].S.S)) {
      uf.unite(cost[i].S.F, cost[i].S.S);
      ans += cost[i].F;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7340
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


vector<vector<ll>> bargers(51, vector<ll>());
vector<ll> make_barger(int level){

	if(level == 0){
		vector<ll> vec = {1};
		return vec;
	}
	if(level == 1){
		vector<ll> vec = {1, 3, 1};
		return vec;
	}
	if(bargers[level].size() != 0) return bargers[level];
	
	vector<ll> left = make_barger(level - 1);
	vector<ll> right = left;
	left[0]++;		right.back()++;
		
	vector<ll> barger = left;
	barger.push_back(1);
	barger.insert(end(barger), begin(right), end(right));//barger.push_back(right);

	return bargers[level] = barger;
	
}


ll calc(int level, ll X){

	// an = 2 a_n-1  + 3 を解くと
	// an = 4 2^n  -3  　なので  a_n-1 = 4 2^(n-1) -3	
	ll a_n_1 = 4 * pow((ll)2, level-1) -3; 	
	ll a_n =   4 * pow((ll)2, level)   -3;
	// ll a_n_1 = (ll)4*((ll)1 << (level-1)) - 3; 	
	// ll a_n =  (ll)4 * ((ll)2 << (level)) -3;
	//if(X == 0) return 0;
	if(level == 0 && X <= 0) return 1;
	if(level == 0) return 1;
	
	if(X == 1) return 0;
	if(X <= a_n_1 + 1) return calc(level-1, X - 1);
	// if(X == a_n_1 + 2) return calc(level-1, a_n_1) + 1;
	// if(X == a_n) return 2 * calc(level-1, a_n_1) + 1;
	// return calc(level-1, a_n_1) + 1 + calc(level-1, X-a_n_1-2);// (B  レベルN-1   p) の中のパティの個数  +  レベルN-1の途中のパティの個数
	ll p_n_1 = pow(2, level) - 1; // pn = 2^(n+1) - 1;  // pn = 1 + 2pn_1を解いた
	if(X == a_n_1 + 2) return p_n_1 + 1;
	if(X == a_n) return 2 * p_n_1 + 1;
	return p_n_1 + 1 + calc(level-1, X-a_n_1-2);
}

int main(){
	int N;
	ll X;
	cin >> N >> X;
	// vector<ll> barger = make_barger(N);

	// ll ans = 0;
	// for(ll i=0; i<barger.size(); i++){
	// 	if(i%2 == 1) ans += min(X, barger[i]);
	// 	X -= barger[i];
	// 	if(X <= 0) break;
	// }


	ll ans = calc(N, X);
	cout << ans << endl;

}



Measured memory_bytes: 4072
#include <cstdio>
#include <cstring>
const int maxn = 200005;
char a[maxn];
long long sum;
int main() {
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	for(int i = 1; i <= len; i ++){
		sum += a[i] - '0';
	}
	if(sum % 9 == 0){
		printf("Yes");
	}
	else{
		printf("No");
	}
}

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

int main(){
	int N;cin>>N;
	int i = 1,n = 1000;
	while (i <= 9 && n == 1000){
		if (N <= 111*i){
			n = 111*i;
		}
		i += 1;	
	}
	cout<<n;
	return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# sort
A.sort()
B.sort()
C.sort()

# にぶたんで数えていく
cnt = 0

B_cnt = [0]*N

for i in range(N):
    ok = bisect.bisect_right(C, B[i])
    B_cnt[i] = N-ok

B_cum = [0]*N
B_cum[-1] = B_cnt[-1]

for i in range(N-1, 0, -1):
    B_cum[i-1] = B_cum[i]+B_cnt[i-1]

B_cum.append(0)

for i in range(N):
    cnt += B_cum[bisect.bisect_right(B, A[i])]

print(cnt)

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

int main() {
  int H, N;
  cin >> H >> N;
  
  int A, total = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
  	total += A;
  }
  
  if (H <= total) {
  	cout << "Yes";
  } else {
    cout << "No";
  }
}


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

int main(){
  int N;
  std::string str;
  std::cin>>N;
  std::cin>>str;
  int dotnum=0;
  int sharpnum=0;
  std::vector<int> v;

  for(int i = 0; i < N ; i++){
  	if(str[i]=='.') dotnum++;
  }

  v.push_back(dotnum);

  for(int i = 0 ; i < N ; i++ ){
    if(str[i]=='.'){
      dotnum--;
      v.push_back(dotnum+sharpnum);
    }else{
      sharpnum++;
      v.push_back(dotnum+sharpnum);
    }
  }
  
  int min = *std::min_element(v.begin(),v.end());
  std::cout<<min<<std::endl;
  return 0;
}


Measured memory_bytes: 1784
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

function solve(): number {
	let reader: Reader = new Reader();
	let s = 'X'+reader.readLine()+'X';
	// console.log(s)
	let N = s.length;
	let i = 0, j = s.length-1;
	let answer = 0;
	while (i < j) {
		let left = 0, right = 0;
		while (i+left<N && s.charAt(i+left) == 'x') {
			left++;
		}
		while (j-right>=0 && s.charAt(j-right) == 'x') {
			right++;
		}
		// console.log(i, j, i+left, j-right, s.charAt(i+left), s.charAt(j-right));
		if (i+left > right+j)
			return answer;
		if (s.charAt(i+left) != s.charAt(j-right))
			return -1
		i += left+1;
		j -= right+1;
		answer += Math.abs(left-right);
	}
	return answer;
}

console.log(solve());


Measured memory_bytes: 33256
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 110;
int n[N], a[N],b[N];
int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	long long t, count = 0;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n[i];
	}
	sort(n, n + t);
	int cou = 0;
	for (int i = 1; i < t; i++)
	{
		if (n[i - 1] == n[i])
			b[cou++] = n[i];
	}
	int end = unique(n, n + t) - n;
	for (int i = end; i < t; i++)
	{
		n[i] = b[i - end];
	}
	for (int i = end; i < t; i++)
	{
		for (int j = 0; j < end; j++)
		{
			if (n[j] == n[i])
			{
				a[j]++;
				break;
			}
		}
	}
	for (int i = 0; i < end; i++)
	{
		for (int j = i + 1; j < end; j++)
		{
			for (int k = j + 1; k < end; k++)
			{
				if (n[i] + n[j] > n[k] && n[i] + n[k] > n[j] && n[j] + n[k] > n[i])
				{
					count += (a[i] + 1)*(a[j]+1)*(a[k]+1);
				}
				if (n[i] + n[j] <= n[k])
				{
					break;
				}
			}
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  while(s.size() != 0){
    if(s.substr(0,5) == "esare" || s.substr(0,5) == "maerd")
      s = s.substr(5);
    else if(s.substr(0, 6) == "resare")
      s = s.substr(6);
    else if(s.substr(0, 7) == "remaerd")
      s = s.substr(7);
    else{
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

Measured memory_bytes: 540
#include<stdio.h>
#include<string.h>


int main(void) {
	char S[5];
	int ans=7;
	scanf("%s", &S);
	if (strcmp(S, "SAT") == 0) {
		ans = 1;
	}
	if (strcmp(S, "MON") == 0) {
		ans = 6;
	}
	if (strcmp(S, "TUE") == 0) {
		ans = 5;
	}
	if (strcmp(S, "WED") == 0) {
		ans = 4;
	}
	if (strcmp(S, "THU") == 0) {
		ans = 3;
	}
	if (strcmp(S, "FRI") == 0) {
		ans = 2;
	}
	printf("%d", ans);
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
        String S = scan.next();
        if(S.contains("a")&& S.contains("b") && S.contains("c")) {
        	System.out.println("Yes");
        	
        }
        else {
        System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	string s;

	cin >> n;
	cin >> s;

	int cnt = 0;

	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C') {
			cnt++;
		}
	}

	cout << cnt << endl;


	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;


int main(int argc, char *argv[])
{
	string s;

	cin >> s;

	int ret=0;
	for (int i=0,j=s.length()-1;i<j;i++,j--)
	{
		if (s[i]!=s[j]) ret++;
	}
	cout << ret << endl;
}



Measured memory_bytes: 256
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    ll x;
    cin>>x;
    ll ans;
    if (x >= 400 && x <= 599) {
        ans = 8;
    } else if (x >= 600 && x <= 799) {
        ans = 7;
    } else if (x >= 800 && x <= 999) {
        ans = 6;
    } else if (x >= 1000 && x <= 1199) {
        ans = 5;
    } else if (x >= 1200 && x <= 1399) {
        ans = 4;
    } else if (x >= 1400 && x <= 1599) {
        ans = 3;
    } else if (x >= 1600 && x <= 1799) {
        ans = 2;
    } else if (x >= 1800 && x <= 1999) {
        ans = 1;
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  ll N,C,K;
  cin>>N>>C>>K;
  vector<ll> T(N);
  for(int i(0);i<N;i++){
    cin>>T[i];
  }
  sort(T.begin(),T.end());
  int cnt(0);
  ll syupatsu = T[0];
  int ans(0);
  for(int i(0);i<N;i++){
    ll now = T[i];
    cnt++;
    if(i != 0 && now-syupatsu > K){
      cnt = 1;
      syupatsu = T[i];
      ans++;
    }
    if(cnt == C) {
      cnt = 0;
      syupatsu = T[i+1];
      ans++;
    }
  }
  if(cnt != 0) ans++;
  cout << ans << endl;
  return 0;
}




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

int main(void){
    int N;
    cin >> N;
    
    int counter = 0;
    
    for (int a = 1; a < N; a++) {
        for (int b = 1; b < N/a + 1; b++) {
            if (a*b >= N) {
                break;
            } else {
                counter++;
            }
        }
    }
    
    
    cout << counter;
}


Measured memory_bytes: 3620
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: [i32; 4],
    }
    let mut a = a;
    a.sort();
    puts!("{}\n", if &a == &[1, 4, 7, 9] { "YES" } else { "NO" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int q = Integer.parseInt(str[1]);
		@SuppressWarnings("unchecked")
		PriorityQueue<Integer>[] Q = new PriorityQueue[n];
		for(int i = 0; i < n; i++) Q[i] = new PriorityQueue<Integer>(Collections.reverseOrder());
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			if(op == 0){
				int t = Integer.parseInt(str[1]);
				int x = Integer.parseInt(str[2]);
				Q[t].add(x);
			}else if(op == 1){
				int t = Integer.parseInt(str[1]);
				if(Q[t].isEmpty()) continue;
				System.out.println(Q[t].peek());
			}else{
				int t = Integer.parseInt(str[1]);
				if(Q[t].isEmpty()) continue;
				Q[t].poll();
			}
		}
	}
}



Measured memory_bytes: 71644
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const int INF = 2000000000;
 
vvi g;
vi used, up;

void dfs(int v, int s=0) {
	used[v] = s + up[v];

	for (auto x : g[v]) {
		if (used[x] == -1) {
			dfs(x, used[v]);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	int n, q;
	cin >> n >> q;

	g = vvi(n+1);
	used = vi(n+1, -1);
	up = vi(n+1, 0);
 
    REP(i, 0, n-2) {
    	int a, b;
    	cin >> a >> b;

    	g[a].pb(b);
    	g[b].pb(a);
    }

    REP(i, 1, q) {
    	int p, x;
    	cin >> p >> x;

    	up[p] += x;
    }

    dfs(1);

    REP(i, 1, n) cout << used[i] << " ";
    cout << endl;

	return 0;
}

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

const int N = 100005;

int n, a[N];
bool in(int x, int y) { return x <= n && a[x] >= y; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> a[i];
	std::sort(a + 1, a + n + 1, [] (int x, int y) { return x > y; });
	int p = 0, L = 0, R = 0; while (in(p + 1, p + 1)) ++p;
	for (int i = p + 1; i <= n; ++i) R ^= a[i] >= p;
	L = a[p] - p & 1;
	std::cout << (L || R ? "First" : "Second" ) << '\n';
	return 0;
}

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

int main() {
    long x, a, b;
    cin >> x;
    vector<pair<long, long>> temp;
    rep(i, 200) {
        temp.push_back(make_pair(pow(i, 5), i));
        temp.push_back(make_pair(-pow(i, 5), -i));
    }
    bool flag = false;
    rep(i, temp.size()) {
        rep(j, temp.size()) {
            if(temp.at(i).first - temp.at(j).first == x) {
                a = temp.at(i).second;
                b = temp.at(j).second;
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<pll> C(2 * N);
  REP(i, 2 * N) {
    ll c;
    cin >> c;
    C[i] = make_pair(c, i < N ? 0 : 1);
  }
  sort(ALL(C));
  vl po(2, 0);
  ll ans = 1;
  REP(i, 2 * N) {
    if (C[i].second == 0 && po[1] > 0) {
      ans *= po[1];
      ans %= MOD;
      po[1]--;
    } else if (C[i].second == 1 && po[0] > 0) {
      ans *= po[0];
      ans %= MOD;
      po[0]--;
    } else {
      po[C[i].second]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

long long gdc(long long a, long long b) {
  if(a > b) swap(a, b);
  if(a == 1) return 1;
  if(b % a == 0) return a;
  return gdc(a, b%a);
}

int main() {
  int n;
  cin >> n;
  vector<long long> t(n);
  for(int i = 0; i < n; i++) cin >> t[i];
  long long ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= (t[i] / gdc(ans, t[i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int dp[N][N], r[N], c[N];

main(){
  int n, i, j, k;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d%d", &r[i], &c[i]);
  for(i=0;i<n;i++) for(j=0;j<n;j++) dp[i][j] = 100000000;
  for(i=0;i<n;i++) dp[i][i] = 0;
  for(i=1;i<n;i++){
    for(j=0;j+i<n;j++){
      for(k=0;k<i;k++){
        int cost = dp[j][j+k] + dp[j+k+1][j+i] + r[j] * c[j+k] * c[j+i];
        if(dp[j][j+i] > cost) dp[j][j+i] = cost;
      }
    }
  }
  printf("%d\n", dp[0][n-1]);
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define LL long long

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

int mod(int x, int md) {
	return ((x % md) + md) % md;
}

int n;
string x;

vector<int> f;

int popcount(int x) {
	int c = 0;
	while (x) {
		c += (x % 2);
		x /= 2;
	}
	return c;
}

int main() {
	cin >> n;
	cin >> x;
	f = vector<int>(n + 1);
	f[0] = 0;
	for (int i = 1; i <= n; ++i) {
		f[i] = f[i % popcount(i)] + 1;
		// printf("f[%d] = %d\n", i, f[i]);
	}

	int ct = 0;
	for (int i = 0; i < n; ++i) {
		ct += (x[i] - '0');
	}
	// so we need to deal with ct - 1 & ct + 1
	vector<int> a(0);
	for (int i = n - 1; i >= 0; --i) {
		a.push_back(x[i] - '0');
	}
	vector<int> ans(n);
	// for (int i = 0; i < n; ++i) {
	// 	cout << a[i] << ' ';
	// }
	// cout << endl;

	// deal with flip 0 to 1
	if (ct == n) {

	} else {
		int md = ct + 1;
		int tot = 0;
		vector<int> rm(n);
		int x = 1;
		for (int i = 0; i < n; ++i) {
			rm[i] = x % md;
			x = (x * 2) % md;

			tot += (a[i] * rm[i]);
			tot %= md;
		}
		for (int i = 0; i < n; ++i) {
			if (a[i] == 0) {
				int ntot = mod(tot + rm[i], md);
				// cout << "ntot at " << i << " = " << ntot << endl;
				ans[i] = f[ntot] + 1;
			}
		}
	}

	// deal with flip 1 to 0
	if (ct == 0) {

	} else if (ct == 1) {
		for (int i = 0; i < n; ++i) {
			if (a[i] == 1) {
				ans[i] = 0;
			}
		}
	} else {
		int md = ct - 1;
		int tot = 0;
		vector<int> rm(n);
		int x = 1;
		for (int i = 0; i < n; ++i) {
			rm[i] = x % md;
			x = (x * 2) % md;

			tot += (a[i] * rm[i]);
			tot %= md;
		}
		for (int i = 0; i < n; ++i) {
			if (a[i] == 1) {
				int ntot = mod(tot - rm[i], md);
				// cout << "ntot at " << i << " = " << ntot << endl;
				ans[i] = f[ntot] + 1;
			}
		}
	}

	for (int i = n - 1; i >= 0; --i) {
		printf("%d\n", ans[i]);
	}

	return 0;
}

Measured memory_bytes: 6548
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC070C
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


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

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

void solve(void){
  
  int N;
    
  cin >> N;
  
  vector<ll> T(N);
  
  ll ans=1LL;
  
  REP(i,N){
    cin >> T[i];
    ans = lcm(ans, T[i]);
  }
  
  cout << ans << endl;
 
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            cout<<s[i];
        }
    }
    cout<<endl;
    return(0);
}

Measured memory_bytes: 3700