akhauriyash/Code-Regression huggingface dataset:
/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"Yes"<<endl
#define NO                      cout<<"No"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second
#define print(a)                for(auto it: a) cout<<it<<" "
#define all(a)                  a.begin(),a.end()
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    AHNAF;
    int n;cin>>n;vii v(n);int cnt=0;
    for(int i=0; i<n; i++) cin>>v[i];
    SORT(v);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<i; j++)
        {
            for(int k=0; k<j; k++)
            {
                if(v[i]!=v[j] && v[j]!=v[k] && v[k]+v[j]>v[i] && v[i]+v[j]>v[k]) cnt++;
            }
        }
    }
    cout<<cnt;
}



Measured memory_bytes: 3624
N = int(input())
import math


def f(a, b):
    return max(len(str(a)), len(str(b)))


ans = 1e12
a = math.ceil(math.sqrt(N))
for i in range(1, a+1):
    if N % i == 0:
        ans = min(ans, f(i, N // i))
print(ans)

Measured memory_bytes: 3060
import heapq

# d = [8, 2, 2, 7, 4, 6, 5, 3, 8]

N = int(input())
d = list(map(int, input().split()))
d_rev = d[::-1]

d1 = d[:N]
heapq.heapify(d1)
d2 = [-i for i in d_rev[:N]]
heapq.heapify(d2)
sum_d1 = sum(d1)
sum_d2 = sum(d2)

sum_d1_arr = [sum_d1]
sum_d2_arr = [sum_d2]

for k in range(N, 2 * N):
    c = sum_d1_arr[-1]
    c += d[k]
    n = heapq.heappushpop(d1, d[k])
    c -= n
    sum_d1_arr.append(c)

    e = sum_d2_arr[-1]
    e += -d_rev[k]
    n = heapq.heappushpop(d2, -1 * d_rev[k])
    e -= n
    sum_d2_arr.append(e)

print(max(v+w for v, w in zip(sum_d1_arr, sum_d2_arr[::-1])))

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

pair<int, int> bfs(const vector<vector<int>> &G, int s) {
    pair<int, int> res;
    queue<int> que;
    vector<int> dist((int)G.size(), -1);
    que.push(s);
    dist[s] = 0;
    while(!que.empty()) {
        int cur = que.front(); que.pop();
        for(auto &to : G[cur]) {
            if(dist[to] == -1) {
                que.push(to);
                dist[to] = dist[cur] + 1;
                res = make_pair(to, dist[to]);
            }
        }
    }
    return res;
}

int Diameter(const vector<vector<int>> &G) {
    auto tmp = bfs(G, 0);
    auto res = bfs(G, tmp.first);
    return res.second;
}

void solve() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << (Diameter(G) % 3 != 1 ? "First" : "Second") << '\n';
}

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


Measured memory_bytes: 13556
#include <iostream>

using namespace std;

int main(){
    string str;
    cin >> str;
    int l = str.length();
    int n,w,s,e;
    n = false;
    w = false;
    s = false;
    e = false;
    for(int i = 0; i<l;i++){
        if(str[i]=='N'){
           n = true;
        }
        if(str[i]=='W'){
           w = true;
        }
        if(str[i]=='S'){
           s = true;
        }
        if(str[i]=='E'){
           e = true;
        }
    }
    if(n == s && w == e){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector <ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < Y; ++i)
	{
		cin >> b[i];
	}
	for (int i = 0; i < Z; ++i)
	{
		cin >> c[i];
	}

	vector <ll> bc;

	for (int i = 0; i < Y; ++i)
	{
		for (int k = 0; k < Z; ++k)
		{
			bc.push_back(b[i]+c[k]);
		}
	}
	sort(bc.rbegin(), bc.rend());
	sort(a.begin(), a.end());

	vector <int> bcidx(X);

	for (int turn = 0; turn < K; ++turn)
	{
		ll bestval = NG;
		ll besti = NG;

		for (int i=0;i<X;i++)
		{
			if (bcidx[i] < SZ(bc))
			{
				const ll val = a[i] + bc[bcidx[i]];
				if (val > bestval)
				{
					bestval = val;
					besti = i;
				}
			}
		}

		cout << bestval << endl;
		bcidx[besti]++;
	}

	return 0;
}


Measured memory_bytes: 10480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

const int MAX=60;

int main() {
  int N;
  cin >> N;
  vvi cnt(MAX,vi(MAX,0));
  rep(i,N) {
    long double d;
    cin >> d;
    ll x = d*10e8+0.5;
    int a=0,b=0;
    while(x>0&&x%2==0) {
      x /= 2;
      a++;
    }
    while(x>0&&x%5==0) {
      x /= 5;
      b++;
    }
    cnt[a][b]++;
  }
  ll ans1 = 0;
  ll ans2 = 0;
  rep(a,MAX) {
    rep(b,MAX) {
      rep(c,MAX) {
        rep(d,MAX) {
          if(a+c<18) continue;
          if(b+d<18) continue;
          if(a==c&&b==d) {
            ans1 += ll(cnt[a][b])*(cnt[a][b]-1)/2;
            continue;
          }
          ans2 += ll(cnt[a][b]) * cnt[c][d];
        }
      }
    }
  }
  ans2 /= 2;
  cout << ans1+ans2 << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
     
    int main(void) {
       int N;
       int i,j;
       int min, max, maxsub;
     
       scanf("%d", &N);
       int A[N];
       if(N >= 2 && N <= 100) {
          for(int i = 0; i < N; i++) {
             scanf("%d", &A[i]);
             if(A[i] < 1 && A[i] > 1000000000) {
                printf("error\n");
                return -1;
             }
          }
       } else {
          printf("error\n");
          return -1;
       }
     
       min = A[0];
       max = A[0];
       for (i = 0; i < N; i++) {
          if (A[i] > max) {
             max = A[i];
          } else if(A[i] < min) {
             min = A[i];
          }
       }
       maxsub = max -min;
       printf("%d\n", maxsub);
     
       return (0);
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	
	int s1 = 0, s2 = 0;
	REP(i, M) {
		int a;
		scanf("%d", &a);
		if (a < X) s1++;
		if (a > X) s2++;
	}
	
	cout << min(s1, s2) << endl;
	
	return 0;
}


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

int mod = 1000000007;

int main()
{
    string S;
    cin >> S;

    for (int i = 0; i < 19; i++)
    {
        if (i == 5 || i == 13)
            cout << " ";
        else
            cout << S[i];
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
#define INF (1<<30)

int T[20][20];
int dp[1<<16];
int N;
main(){
	int i,j,k;
	while(cin >> N, N){
		for(i=0;i<N;i++)
			for(j=0;j<=N;j++) cin >> T[i][j];
		fill(dp, dp+(1<<16), INF);
		dp[0]=0;
		for(i=0;i<(1<<N);i++){
			for(j=0;j<N;j++){
				if(i&(1<<j)) continue;
				int min = T[j][0];
				for(k=0;k<N;k++){
					if(i&(1<<k) && T[j][k+1] < min) min = T[j][k+1];
				}
				if(dp[i] + min < dp[i|(1<<j)]) dp[i|(1<<j)] = dp[i] + min;
			}
		}
		cout << dp[(1<<N)-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1416
#include <stdio.h>

int main() {
  int a, b, tmp;
  scanf("%d", &a);
  scanf("%d", &b);
  if (a > b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  if (a == 1 && b == 2) {
    printf("3\n");
  } else if(a == 1 && b == 3) {
    printf("2\n");
  } else {
    printf("1\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main {


    public static int longestPathInADAG(int N, Map<Integer, List<Integer> > graph, int[] indegree) {

        Queue<Integer> q = new LinkedList<>();
        int[] topoOrder = new int[N];
        int topIdx = 0;
        for(int i=1; i<=N; i++) {
            if(indegree[i] == 0)
                q.add(i);
        }

        while(!q.isEmpty()) {
            Integer node = q.poll();
            topoOrder[topIdx++] = node;

            for(Integer nei: graph.getOrDefault(node, new ArrayList<>())) {
                if(--indegree[nei] == 0) {
                    q.add(nei);
                }
            }
        }

        int[] longestPath = new int[N + 1];

        for(int i=0; i<N; i++) {
            int currNode = topoOrder[i];

            for(Integer nei: graph.getOrDefault(currNode, new ArrayList<>())) {
                longestPath[nei] = Math.max(longestPath[nei], longestPath[currNode] + 1);
            }
        }

        int answer = Integer.MIN_VALUE;

        for(int i=1; i<=N; i++) {
            answer = Math.max(answer, longestPath[i]);
        }
        return answer;
    }

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

        Map<Integer, List<Integer> > graph = new HashMap<>();

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] indegree = new int[N + 1];

        for(int i=0; i<M; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            List<Integer> edges = graph.getOrDefault(from, new ArrayList<>());
            edges.add(to);
            indegree[to]++;
            graph.put(from, edges);
        }

        System.out.println(longestPathInADAG(N, graph, indegree));
    }
}


Measured memory_bytes: 104920
#include <iostream>

using namespace std;

int main(){
  int n, m, q, cnt=0;
  int s[10000] = {};

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> q;
    for(int j = 0; j < n; j++){
      if(s[j] == q){
	cnt++;
	break;
      }
    }
  }

  cout << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  double sum = 0;
  int n,m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a,a+n,greater<int>());
  for (int i = 0; i < m; i++){
    if (sum / (4 * m) > a[i]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

void solve() {
	int a, b;
	cin >> a >> b;
	cout << (6 - a - b) << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if ((h | w) == 0)
				break;
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 'A') {
						ay = i;
						ax = j;
					} else if (map[i][j] == 'B') {
						by = i;
						bx = j;
					}
				}
			}
			int[][] dp = new int[h][w];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 30);
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.push(new Point(ay, ax, 0));
			dp[ay][ax] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				int y = p.y;
				int x = p.x;
				int step = p.step;

				for (int[] m : move) {
					int ny = y + m[0];
					int nx = x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] == '#')
						continue;
					if (dp[ny][nx] <= step + 1)
						continue;
					dp[ny][nx] = step + 1;
					deque.offer(new Point(ny, nx, step + 1));
				}

			}
			char[] p = scanner.next().toCharArray();
			int e;
			for (e = 0; e < 9000; e++) {
				if (dp[by][bx] <= e)
					break;
				char o = p[e % p.length];
				int ny = by + (o == '2' ? 1 : 0) - (o == '8' ? 1 : 0);
				int nx = bx + (o == '6' ? 1 : 0) - (o == '4' ? 1 : 0);
				if (!isOK(ny, nx))
					continue;
				by = ny;
				bx = nx;
			}
			System.out.println(e < 9000 ? e + " " + by + " " + bx
					: "impossible");
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int ay, ax, by, bx, h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

	}
}

Measured memory_bytes: 24172
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;

    ll d = abs(a - b);
    if (d == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        if (v <= w)
        {
            cout << "NO" << endl;
        }
        else
        {
            ll s = v - w;
            if (s * t >= d)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=5005;
const int MOD=1e9+7;

int n, k;
string s;
int cache[N][N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

int dp(int idx, int rem)
{
	if(idx<0)
		idx=0;
	if(rem==0)
		return (idx==n);
	int &ans=cache[idx][rem];
	if(ans!=-1)
		return ans;
	ans=dp(idx+1, rem-1)*2;
	ans+=dp(idx-1, rem-1);
	ans%=MOD;
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>k>>s;
	n=s.size();
	int ans=dp(0, k);
	ans*=pow(modinv(2), n, MOD);
	ans%=MOD;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;

vll divisor(ll n){
  vll res;
  for (ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i!=n/i) res.push_back(n/i);
    }
  }
  return res;
}

int main(){
  ll N;cin>>N;
  vll res=divisor(N);
  ll ans=0;
  int M=res.size();
  for (int i=0;i<M;++i){
    if(N/res[i]<(res[i]-1)) ans+=(res[i]-1);
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
long long a[50005]={0};
long long res=1,n,k;
int main(){
	bool p=0;
	cin>>n;
	if(n%2==0){
		for(int i=0;i<n;i++){
			cin>>k;
			if(k%2==0){
				p=1;
			}
			a[(k-1)/2]++;
		}
		if(p==1){
			cout<<'0';
			return 0;
		}
		for(int i=0;i<n/2;i++){
			if(a[i]!=2){
				cout<<'0';
				return 0;
			}
		}
	}else{
		for(int i=0;i<n;i++){
			cin>>k;
			if(k%2==1){
				p=0;
			}
			a[k/2]++;
		}
		if(a[0]!=1||p==1){
			cout<<'0';
			return 0;
		}
		for(int i=1;i<n/2;i++){
			if(a[i]!=2){
				cout<<'0';
				return 0;
			}
		}
	}
	for(int i=0;i<n/2;i++){
		res*=2;
		res=res%1000000007;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) (v).begin() (v).end()
#define m 998244353
#define pb push_back
#define sz(v) (v).size()
#define ll long long

int main()
{
        ll n,d;
        cin>>n>>d;
 d=2*d+1;
    cout<<(n+d-1)/d;
        
}





Measured memory_bytes: 256
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;

int main(){
    int N; cin >> N;
    int i;
    map<string,int> S;
    string key;
    int value;
    int cnt_max=0;
    for(i=0;i<N;i++){
        cin >> key;
        S[key]+=1;
        cnt_max = max(cnt_max,S[key]);
    }

//    for(auto iter = S.begin(); iter != S.end(); iter++){
//        cout << "key : " << iter->first << "    value : " << iter->second << endl;
//    }
    
    
    
    for(auto iter = S.begin(); iter != S.end(); iter++){
        if(iter->second==cnt_max){
            cout << iter->first << endl;
        }
    }
    
    return 0;
 
}


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

int main() {
	int N, n, count, k;
	cin >> N;
	vector<pair<string, int>> vec(N), copy(N);
	for (int i = 0; i < N; i++)
		cin >> vec.at(i).first >> vec.at(i).second;
	copy = vec;
	sort(vec.begin(), vec.end());
	count = 1;
	if (N == 1)cout << 1 << endl;
	else {
		for (int i = 0; i < N; i++) {
			if (i != 0 && i != N - 1 && vec.at(i).first == vec.at(i - 1).first) count++;
			else {
				if (i == N - 1 && vec.at(i).first == vec.at(i - 1).first) count++;
				if (count > 1) {
					if (i == N - 1 && vec.at(i).first == vec.at(i - 1).first) k = i;
					else k = i - 1;
					n = count;
					vector<int> num(n);
					for (int j = 0; j < n; j++)
						num.at(j) = vec.at(k - j).second;
					for (int j = 0; j < n; j++)
						vec.at(k + 1 - n + j).second = num.at(j);
					count = 1;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)
				if (copy.at(j) == vec.at(i)) cout << j + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		if (b>a+2 && k>=a+1) {
			System.out.println(a+((k-a+1)/2)*(b-a)+(k-a+1)%2);
		} else {
			System.out.println(k+1);
		}
	}



}


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

const int MAXN = 100010;

int n, k, a[MAXN];
int ans = 0x7FFFFFFF;

int main()
{
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int l = 1, r = l + k - 1; r <= n; ++l, ++r)
	{
		ans = min(ans, abs(a[l]) + abs(a[r] - a[l]));
		ans = min(ans, abs(a[r]) + abs(a[r] - a[l]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans = (ans+v[i])/2;
    }
    cout << fixed << setprecision(12) << ans << endl;
}


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

int GCD(int m,int n){
	int remain;
	if((remain = m % n) == 0)return n;
	else return GCD(n,remain);
}

int main(){
	int N,X;
	cin >> N >> X;
	int x[N];
	REP(i,N) cin >> x[i];
	REP(i,N) x[i] -= X;
	int res = x[0];
	for(int i = 1; i < N; i++){
		res = GCD(res, x[i]);
	}
	cout << abs(res) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    
        lli n;
        cin>>n;
         map<lli, sl> temp;
        for(lli i=0;i<n;i++){
        	lli x;
        	cin>>x;
        	temp[x].insert(i);
        }
        lli in=-1,t=1;
        while(1){
        	if(temp.find(t)!=temp.end()){
        		auto x=temp[t].upper_bound(in);
        		if(x==temp[t].end())break;
        		else{
        			t++;
        			in=*x;
        		}
        	}
        	else break;
        }
        t--;
        
        if(t==0)
        	cout<<-1;
        	else cout<<n-t;
     
}

Measured memory_bytes: 30464
#include<stdio.h>
int N,B[100010]={0};
void bset(int n){for(N=1;N<n;N+=2);}
void badd(int i,int n){for(;i<=N;i+=i&-i)B[i]+=n;}
int  bsum(int i){
  int s=0;
  for(;i;i-=i&-i)s+=B[i];
  return s;
}          
int main(){
  int n,m,a,b,c;
  scanf("%d %d",&N,&m);
  //bset(n);
  while(m--){
    scanf("%d %d %d",&a,&b,&c);
    a?printf("%d\n",bsum(c)-bsum(b-1)):badd(b,c);
  }    
  return 0;
}

Measured memory_bytes: 2184
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;
string s,t;

int main() {
	cin >> n;
	int ans = 0;
	VI b(n+1);
	b[0] = INF;b[n] = INF;
	rep(i,n-1) cin >> b[i+1];
	for (int i = 0; i < n; i++)
	{
		ans += min(b[i], b[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
struct BinaryIndexedTree{
    vector<int> bit;
    BinaryIndexedTree(int n){
        bit.assign(++n,0);
    }
    int sum(int k){
        int res=0;
        for(++k;k>0;k-=k&-k){
            res+=bit[k];
        }
        return res;
    }
    void add(int k,int x){
        for(++k;k<bit.size();k+=k&-k){
            bit[k]+=x;
        }
    }
};
int main(){
    ll n;cin>>n;
    ll a[100010];
    ll m=((n+1)*n)/2;
    m=m/2+1;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ok=INF,ng=0;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        BinaryIndexedTree bit(2*n+10);
        int b[100010];
        int base=n+5;
        for(int i=0;i<n;i++){
            if(a[i]<=mid){
                b[i]=1;
            }else{
                b[i]=-1;
            }
        }
        bit.add(base,1);
        for(int i=1;i<n;i++){
            b[i]+=b[i-1];
        }
        ll res=0;
        for(int i=0;i<n;i++){
            res+=bit.sum(b[i]+base-1);
            bit.add(b[i]+base,1);
        }
        if(res>=m){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define y1 ________y1
ld x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
ll Q;
bool flx,fly;
signed main(){
	scanf("%Lf%Lf%Lf%Lf",&x1,&y1,&x2,&y2);
	if (y1==y2) flx=true;
	else if(x1==x2) fly=true;
	else slope=(y2-y1)/(x2-x1);
	x2-=x1,y2-=y1;
	scanf("%lld",&Q);while (Q--){
		scanf("%Lf%Lf",&xp,&yp);
		if(flx) printf("%.10Lf %.10Lf\n",xp,y1);
		else if(fly) printf("%.10Lf %.10Lf\n",x1,yp);
		else{
			ansx=(yp*x2*y2+xp*x2*x2-y1*y2*x2+x1*y2*y2)/(y2*y2+x2*x2);
			ansy=(-x2*ansx+yp*y2+xp*x2)/y2;
			printf("%.10Lf %.10Lf\n",ansx,ansy);
		}
	}
	fclose(stdin);fclose(stdout);return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    vector<int> l(n);
    int max_l = 0;
    int sum_l = 0;
    int index;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        sum_l += l[i];
        if(max_l < l[i]){
            max_l = l[i];
            index = i;
        }
    }
    if(max_l < sum_l - l[index]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

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

    int right = L + N - 1;
    int eat;
    if (right <= 0) eat = right;
    else if (L >= 0) eat = L;
    else eat = 0;

    int ans = (right + L) * (right - L + 1) / 2 - eat;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    int N;
    std::cin >> N;

    std::vector<ll> A(N), B(N), C(N);
    for (auto i=0; i<N; ++i)
        std::cin >> A[i];

    for (auto i=0; i<N; ++i)
        std::cin >> B[i];

    for (auto i=0; i<N; ++i)
        std::cin >> C[i];

    ll result = 0;
    std::sort(A.begin(), A.end());
    std::sort(C.begin(), C.end());
    for (auto i=0; i<B.size(); ++i)
    {
        auto b = B[i];
        auto aLimit = std::upper_bound(A.begin(), A.end(), b - 1);
        auto aPos = std::distance(A.begin(), aLimit);

        auto cLimit = std::lower_bound(C.begin(), C.end(), b + 1);
        auto cPos = std::distance(cLimit, C.end());

        result += aPos * cPos;
    }

    std::cout << result << std::endl;
}


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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	
	for(long long int i=0;i<n;i++){
		cin>>a[i];
	}
	for(long long int i=0;i<n;i++){
		cin>>b[i];
	}
	for(long long int i=0;i<n;i++){
		cin>>c[i];
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	long long int ans=0;
	
	long long int up=0;
	
	long long int j=0;
	long long int k=0;
	
	for(long long int i=0;i<n;i++){
		while(a[j]<b[i]&&j<n){
			j++;
		}
		while(b[i]>=c[k]&&k<n){
			k++;
		}
		//cout<<j<<" "<<(n-k)<<endl;
		ans+=j*(n-k);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1536
import itertools
from collections import Counter
import math

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

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

B = itertools.accumulate(A)
B = [0] + list(B)
C = Counter(B)
ans = 0
for v in C.values():
    if v > 1:
        ans += combinations_count(v, 2)
print(ans)

Measured memory_bytes: 115116
def main():
    s = input()
    K = int(input())
    ranks = ["~"] * K
    for l in range(len(s)):
        for r in range(l+1, min(len(s)+1, l+6)):
            target = s[l:r]
            if target in ranks:
                continue
            if target < ranks[K-1]:
                ranks[K-1] = target
            for i in range(K-1, 0, -1):
                if ranks[i] < ranks[i-1]:
                    tmp = ranks[i]
                    ranks[i] = ranks[i-1]
                    ranks[i-1] = tmp
    print(ranks[K-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 39664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        // board[i][j]: 迷路
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = str.charAt(j);
            }
        }
        
        Set<Integer> ngr = new HashSet<Integer>();
        for (int i = 0; i < h; i++) {
            boolean ng = true;
            for (int j = 0; j < w; j++) {
                if (board[i][j] == '#') {
                    ng = false;
                    break;
                }
            }
            
            if (ng) {
                ngr.add(i);
            }
        }
        Set<Integer> ngc = new HashSet<Integer>();
        for (int j = 0; j < w; j++) {
            boolean ng = true;
            for (int i = 0; i < h; i++) {
                if (board[i][j] == '#') {
                    ng = false;
                    break;
                }
            }
            
            if (ng) {
                ngc.add(j);
            }
        }
        
        for (int i = 0; i < h; i++) {
            if (ngr.contains(i)) continue;
            for (int j = 0; j < w; j++) {
                if (ngc.contains(j)) {
                    
                } else {
                    System.out.print(board[i][j]);
                }
                
                if (j != w - 1) {
                } else {
                    System.out.println();
                }
            }
        }
        
    }
}

Measured memory_bytes: 24428
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(LL a=b;a<=c;++a)
#define rl(a,b,c) for(LL a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL a[100001+10];
LL v[100000+10];
LL each[100000+10];
LL n;
void dfs(LL now,LL ths){
	if(now>n) now-=n;
	if(v[now]) return;
	v[now]=1;
	each[now]=ths;
	LL nes=now+1;
	if(nes>n) nes-=n;
//	cout<<nes<<" "<<now<<","<<a[nes]<<" "<<a[now]<<endl;
	dfs(now+2,ths+(a[(nes)]-a[now])*2);
}
int main(){
	
	scanf("%lld",&n);
	LL SUM=0;
	rb(i,1,n) scanf("%lld",&a[i]),SUM+=a[i];
	dfs(1,0);
	LL MM=INF;
	rb(i,1,n)	MM=min(MM,each[i]);
	rb(i,1,n) each[i]-=MM;
	LL tot=0;
	rb(i,1,n) tot+=each[i];
//	cout<<tot<<endl;
	SUM-=tot;
	SUM/=n;
	rb(i,1,n) {
		printf("%lld ",each[i]+SUM);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    ll h;
    cin >> n >> h;
    ll a[n],b[n];
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    sort(b, b + n);
    reverse(b, b + n);
    ll mx = 0;
    REP(i,n){
        mx = max(mx, a[i]);
    }
    int ans = 0;
    REP(i,n){
        if(h <= 0 || b[i] < mx) break;
        h -= b[i];
        ans++;
    }
    if(h <= 0){
        cout << ans << endl;
        return 0;
    }
    ans += (h - 1) / mx + 1;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
}




Measured memory_bytes: 3632
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = []
    x = (sum(A[0::2]) - sum(A[1::2])) // 2
    X.append(2 * x)
    for i in range(N - 1):
        x = A[i] - x
        X.append(2 * x)
    print(' '.join(str(i) for i in X))

main()


Measured memory_bytes: 19136
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int A,B;
  cin>>A>>B;
  if(A%2==1 && B%2==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){int i,j,n=1001,r=0;int[][]a=new int[n][n];for(Scanner s=new Scanner(System.in);(n=s.nextInt())>0;System.out.println(r),r=0)for(j=i=0;i++<n;j=0)for(char c:s.next().toCharArray())r=Math.max(r,a[i][++j]=c>45?Math.min(a[i-1][j-1],Math.min(a[i-1][j],a[i][j-1]))+1:0);}}

Measured memory_bytes: 16000
n=int(input())
from collections import Counter as co
var=co(list(map(int,input().split()))).items()
f,s=0,0
for k,v in var:
	if v>=4:
		if f<k:
			f,s=k,max(k,f)
		else:
			s=max(s,k)
	if v>=2:
		if f<k:
			f,s=k,f
		else:s=max(s,k)
print(f*s)

Measured memory_bytes: 18600
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        if ((r * 100 + g * 10 + b) % 4 == 0) {
            // 出力
            System.out.println("YES");
        } else {
            // 出力
            System.out.println("NO");
        }

    }
}


Measured memory_bytes: 21844
# ABC 062
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def gcd(x, y): # 最大公約数
    m = max(x,y)
    n = min(x,y)
    while m%n != 0:
        w = m%n
        m = n
        n = w
    return n

def lcm(x, y): return x*y//gcd(x,y) # 最小公倍数
def db(x): 
    global debug
    if debug: print(x)
debug = False
N = getInt()
TA = zeros(N)
for i in range(N):
    TA[i] = getIntList()
db(TA)
real = TA[0]
for i in range(1,N):
#    if real[0]>real[1]:
    if real[0]/TA[i][0] > real[1]/TA[i][1]:
        lc = (real[0]+TA[i][0]-1)//TA[i][0]*TA[i][0]
        real[0] = lc 
        real[1] = lc * TA[i][1] // TA[i][0]  
    else:
        lc = (real[1]+TA[i][1]-1)//TA[i][1]*TA[i][1]
        real[1] = lc 
        real[0] = lc * TA[i][0] // TA[i][1]  
    db((lc,real))
print(sum(real))



Measured memory_bytes: 3188
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    val1,val2 = map(int,input().split())
    s.append(val1)
    c.append(val2)
 
if n == 1:
    start = 0
    end = 10
elif n == 2:
    start = 10
    end = 100
else:
    start = 100
    end = 1000
 
ans = []
 
for i in range(start, end):
    num = str(i)
    flg = 1
    for j in range(m):
        if num[s[j] - 1] == str(c[j]) and len(num) == n:
            flg = 1
        else:
            flg = 0
            break
    if flg == 1:
        ans.append(i)
 
if ans:
    print(min(ans))
else:
    print(-1)

Measured memory_bytes: 3064
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<string.h>
using namespace std;
struct Node{
	int x,y,loc;
	Node(){
	}
	Node(int a,int b):x(a),y(b){
	}
	void re(int a,int b){
		x = a;
		y = b;
	}
}; 
inline bool cmp_X(const Node &x,const Node &y){
	return x.x<y.x;
}
inline bool cmp_Y(const Node &x,const Node &y){
	return x.y<y.y;
}
const int maxn = 500009;
int n;
Node data[maxn];
int mark[4*maxn];
void build(int i,int l,int r,int d){
	if(l>=r)return;
	int mid = (l+r)/2;
	if(d&1)sort(data+l,data+r,cmp_X);
	else sort(data+l,data+r,cmp_Y);
/*	if(d&1){
		printf("sort x\n");
		for(int i = 0;i<n;++i)printf("(%d , %d) ",data[i].x,data[i].y);
		printf("\n");
	}
	else{
		printf("sort y\n");
		for(int i = 0;i<n;++i)printf("(%d , %d) ",data[i].x,data[i].y);
		printf("\n");
	}*/
	mark[i] = mid;
	mark[2*i+1] = -1;
	mark[2*i+2] = -1;
	build(2*i+1,l,mid,d+1);
	build(2*i+2,mid+1,r,d+1);
}
void construct(){
	build(0,0,n,0);
}
int sx, tx, sy, ty;
priority_queue<int> qu;
int find(int d,int i){
	int ans = 0;
	if(data[mark[i]].loc==2){
		++ans;
	}
	if(mark[i]==-1)return 0;
	int x = data[mark[i]].x;
	int y = data[mark[i]].y;
//	printf("当前结点: %d %d\n",x,y);
	if(sx<=x&&x<=tx&&sy<=y&&y<=ty)qu.push(-1*data[mark[i]].loc);
	if(d&1){
	//	printf("x层\n");
		if(x>=sx){
		//	printf("x:%d>=sx:%d 进入左子树\n",x,sx);
			ans+=find(d+1,2*i+1);
		}
		if(x<=tx){
		//	printf("x:%d<=tx:%d 进入右子树\n",x,tx);
			ans+=find(d+1,2*i+2);
		}
	}
	else
	{
	//	printf("y层\n");
		if(y>=sy){
		//	printf("y:%d>=sy:%d 进入左子树\n",y,sy);		
			ans+=find(d+1,2*i+1);
		}
		if(y<=ty){
	//		printf("y:%d<=ty:%d 进入右子树\n",y,ty);
			ans+=find(d+1,2*i+2);
		}
	}
	return ans;
}
void show(int i,int d){
	for(int i = 0;i<d;++i)printf("\t");
	printf("%d: %d,%d\n",i,data[mark[i]].x,data[mark[i]].y);
	if(mark[2*i+1]!=-1){
		for(int i = 0;i<d;++i)printf("\t");
		printf("left:\n");
		show(2*i+1,d+1);
	}
	if(mark[2*i+2]!=-1)
	{
		for(int i = 0;i<d;++i)printf("\t");
		printf("right:\n");
		show(2*i+2,d+1);
	}
}
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	int x,y,x1,y1,q;
	scanf("%d",&n);
	for(int i = 0;i<n;++i){
		scanf("%d %d",&x,&y);
		data[i].re(x,y);
		data[i].loc = i;
	}
	construct();
//	show(0,0);
	scanf("%d",&q);
	while(q--){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		while(qu.size())qu.pop();
		find(0,0);
		while(qu.size()){
			printf("%d\n",-1*qu.top());
			qu.pop();
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 12352
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define int long long //Strong Power
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) for (decltype(n) i = (a); i < (n); i += (d))
#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, d) for (decltype(a) i = (a); i >= (n); i -= (d))
// -----
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

void solve()
{
  const int n = 2019;
  lint l, r;
  cin >> l >> r;

  int ml = l % n, dl = l / n;
  int mr = r % n, dr = r / n;

  lout << l << "," << r << endl;

  int ans = 2 << 24;
  if (dl < dr)
  {
    ans = 0;
  }
  else
  {
    rep(j, ml, mr + 1) rep(i, ml, j)
    {
      lout << "i,j:" << i << "," << j << endl;
      lout << i * j << endl;

      ans = min(ans, (i * j) % n);
    }
  }

  cout << ans << endl;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
function next() { return +cin[cid++]; }
//input from catoonさん
var UnionFind = /** @class */ (function () {
    function UnionFind(n) {
        this.p = [];
        this.sizes = [];
        for (var i = 0; i < n; i++) {
            this.p.push(i);
            this.sizes.push(1);
        }
        this.tmpsize = n;
    }
    UnionFind.prototype.find = function (x) {
        if (this.p[x] === x) {
            return x;
        }
        else {
            var tmp = this.find(this.p[x]);
            return tmp;
        }
    };
    UnionFind.prototype.unite = function (x, y) {
        if (this.find(x) === this.find(y))
            return;
        var _a = this.sizes[this.find(x)] >= this.sizes[this.find(y)] ? [this.find(x), this.find(y)] : [this.find(y), this.find(x)], large = _a[0], small = _a[1];
        this.p[small] = large;
        this.sizes[large] += this.sizes[small];
        this.tmpsize--;
    };
    UnionFind.prototype.is_same = function (x, y) {
        return this.find(x) === this.find(y);
    };
    return UnionFind;
}());
function main() {
    var n = next();
    var q = next();
    var uf = new UnionFind(n);
    while (q--) {
        var condition = next();
        var tmp = next();
        var tmp1 = next();
        if (condition === 0) {
            uf.unite(tmp, tmp1);
        }
        else {
            if (uf.is_same(tmp, tmp1)) {
                console.log(1);
            }
            else {
                console.log(0);
            }
        }
    }
    return;
}
main();


Measured memory_bytes: 104944
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	
	int a, b;

	cin >> a >> b;

	if (a * b % 2 != 0) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;

	}
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,a,b;
    cin >> n >> a >> b;

    int sum = 0;
    for(int i=1;i<=n;i++){
        int tmp_num = i;
        int digit_sum = 0;
        while(tmp_num){
            digit_sum = digit_sum + (tmp_num % 10);
            tmp_num = tmp_num / 10;
        }
        if(a <= digit_sum && digit_sum <= b) {
            sum = sum + i;
        }
    }

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

Measured memory_bytes: 256