akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#include <iomanip>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n, fa[N], sz[N];
struct _ {
	int x,y,id;
} a[N];
int Find(int x) {return fa[x]?fa[x]=Find(fa[x]):x;}

int main() {
	scanf("%d", &n);
	REP(i,1,n) sz[i] = 1;
	REP(i,1,n) scanf("%d%d", &a[i].x, &a[i].y),a[i].id=i;
	sort(a+1,a+1+n,[](_ a,_ b){return a.x<b.x;});
	set<pii> s;
	s.insert({a[1].y,a[1].id});
	REP(i,2,n) {
		int mi = a[i].y;
		while (s.size()&&a[i].y>s.begin()->x) {
			auto u = *s.begin();
			s.erase(s.begin());
			int L = Find(u.y), R = Find(a[i].id);
			if (L!=R) fa[L] = R, sz[R] += sz[L];
			mi = min(mi, u.x);
		}
		s.insert({mi,a[i].id});
	}
	set<pii,greater<pii>> ss;
	ss.insert({a[n].y,a[n].id});
	PER(i,1,n-1) {
		int ma = a[i].y;
		while (s.size()&&a[i].y<s.begin()->x) {
			auto u = *s.begin();
			s.erase(s.begin());
			int L = Find(u.y), R = Find(a[i].id);
			if (L!=R) fa[L] = R, sz[R] += sz[L];
			ma = max(ma, u.x);
		}
		s.insert({ma,a[i].id});
	}
	REP(i,1,n) printf("%d\n", sz[Find(i)]);
}


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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {

  ll N, X, M;
  cin >> N >> X >> M;

  vector<ll> tmp(M);
  tmp[0] = X;
  ll sum = 0;
  map<int, int> m;
  m[tmp[0]] = 0;
  ll loop_s = 0;
  ll loop_e = 0;

  for(int i = 1; i < N; i++){
    tmp[i] = tmp[i - 1] * tmp[i - 1] % M;
    if(m.find(tmp[i]) != m.end()){
      loop_s = m[tmp[i]];
      loop_e = i;
      break;
    }else{
      m[tmp[i]] = i;
    }
  }

  if(loop_e == 0){
    for(int i = 0; i < N; i++){
      sum += tmp[i];
    }
  }else{
    for(int i = 0; i < loop_s; i++){
      sum += tmp[i];
    }
    ll tmpsum = 0;
    for(int i = loop_s; i < loop_e; i++){
      tmpsum += tmp[i];
    }
    sum += tmpsum * ((N - loop_s) / (loop_e - loop_s));
    for(int i = loop_s; i < loop_s + (N - loop_s) % (loop_e - loop_s); i++){
      sum += tmp[i];
    }
  }
  cout << sum << endl;
}

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

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
        }

        System.out.println(solve(N, a, b, c));

        sc.close();
    }

    static String solve(int N, int[] a, int[] b, int[] c) {
        long[] distances = new long[N];
        Arrays.fill(distances, Long.MIN_VALUE);
        distances[0] = 0;

        for (int round = 0; round < N - 1; ++round) {
            for (int i = 0; i < a.length; ++i) {
                if (distances[a[i]] != Long.MIN_VALUE) {
                    distances[b[i]] = Math.max(distances[b[i]], distances[a[i]] + c[i]);
                }
            }
        }

        boolean[] infinites = new boolean[N];
        for (int i = 0; i < a.length; ++i) {
            if (distances[a[i]] != Long.MIN_VALUE && distances[a[i]] + c[i] > distances[b[i]]) {
                infinites[b[i]] = true;
            }
        }

        for (int round = 0; round < N - 1; ++round) {
            for (int i = 0; i < a.length; ++i) {
                if (infinites[a[i]]) {
                    infinites[b[i]] = true;
                }
            }
        }

        return infinites[N - 1] ? "inf" : String.valueOf(distances[N - 1]);
    }
}

Measured memory_bytes: 28432
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long W = sc.nextLong();
        long w1 = 0;

        ArrayList<Long>[] items = new ArrayList[4];

        for (int i = 0; i < 4; i++) {
            items[i] = new ArrayList<>();
        }

        for (int i = 0; i < N; i++) {
            long w = sc.nextLong();
            long v = sc.nextLong();

            if (i == 0) {
                w1 = w;
                items[0].add(v);
            } else {
                items[(int) (w - w1)].add(v);
                // System.out.println("DEBUG:addV:" + items[(int) (w - w1)]);
            }
        }

        for (int i = 0; i < 4; i++) {
            Collections.sort(items[i], Comparator.reverseOrder());

            for (int j = 1; j < items[i].size(); j++) {
                items[i].set(j, items[i].get(j - 1) + items[i].get(j));
            }
        }

        final int s0 = items[0].size();
        final int s1 = items[1].size();
        final int s2 = items[2].size();
        final int s3 = items[3].size();
        long max = 0;

        for (int i = -1; i < items[0].size(); i++) {
            for (int j = -1; j < items[1].size(); j++) {
                for (int k = -1; k < items[2].size(); k++) {
                    for (int l = -1; l < items[3].size(); l++) {
                        if (w1 * (i + 1) + (w1 + 1) * (j + 1) + (w1 + 2) * (k + 1) + (w1 + 3) * (l + 1) <= W) {
                            long a = (i == -1) ? 0 : items[0].get(i);
                            long b = (j == -1) ? 0 : items[1].get(j);
                            long c = (k == -1) ? 0 : items[2].get(k);
                            long d = (l == -1) ? 0 : items[3].get(l);
                            max = Math.max(max, a + b + c + d);
                        }
                    }
                }
            }
        }

        System.out.println(max);

    }

}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  bool ans=false;
  if(n==3){
    ans=true;
  }
  if(n==5){
    ans=true;
  }
  if(n==7){
    ans=true;
  }
  cout << (ans?"YES":"NO") << endl;
}


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

int main()
{
    int n;
    scanf("%d",&n);
    int a;
    int mn=1e9;
    int mx=-1e9;
    long long int sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(mn>=a)
            mn=min(mn,a);
        if(mx<=a)
            mx=max(mx,a);
        sum=sum+a;
    }

    printf("%d %d %lld\n",mn,mx,sum);

    return 0;
}



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

int main(void)
{
  int i, j, k = 0, q;
  char str[1001], tmp;
  scanf("%s %d", str, &q);
  int a[q], b[q];
  char order[q][8], p[q][1001];
  for(i = 0; i < q; i++) {
    scanf("%s %d %d", order[i], &a[i], &b[i]);
    if(strcmp(order[i], "replace") == 0) {
      scanf("%s", p[i]);
    }
  }
  for(i = 0; i < q; i++) {
    if(strcmp(order[i], "print") == 0) {
      for(j = a[i]; j <= b[i]; j++) {
	printf("%c", str[j]);
      }
      printf("\n");
    } else if(strcmp(order[i], "reverse") == 0) {
      k = b[i];
      for(j = a[i]; j < 1001; j++) {
	if( j>=k ) break;
	tmp = str[j];
	str[j] = str[k];
	str[k] = tmp;
	k--;
      }
    } else if(strcmp(order[i], "replace") == 0) {
      k = 0;
      for(j = a[i]; j <= b[i]; j++) {
	str[j] = p[i][k];
	k++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
    int A, B, N;
    int sum = 0;
    cin >> N >> A >> B;
    string number;
    int sum_sums = 0;
    for(int i = 0; i < N + 1; i++)
    {   
        number = to_string(i);
        for (int j = 0; j < number.size(); j++)
        {
            sum += (int)( number[j] - '0' );
        }
        if(A <= sum && sum <= B)
        {
            sum_sums += i;
        }
        sum = 0;
    }

    cout << sum_sums << endl;
}

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

constexpr int INF = 1e9;

using graph = vector<vector<int>>;

int N, K;

int dfs(int v, int prev, graph const& g, int& res) {
    int h = 0;
    for(auto to : g[v]) {
        h = max(h, dfs(to, v, g, res) + 1);
    }
    if(h == K - 1 && prev != 0 && v != 0) {
        res += 1;
        h = -1;
    }
    return h;
}

int main() {
    cin >> N >> K;
    graph g(N);
    int res = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        a--;
        if(i == 0) {
            res += a != 0;
        } else {
            g[a].push_back(i);
        }
    }
    dfs(0, -1, g, res);
    cout << res << endl;
}


Measured memory_bytes: 13568
#include<stdio.h>

#define SIZE 100001
#define MAX 1000000007

unsigned long long perm(int n, int r){
  unsigned long long y = 1;
  for(unsigned long long i=0; i<r; i++){
    y *= n-i;
    y = y%MAX;
  }
  return y;
}

unsigned long long power(long a, long n){
  unsigned long long y = 1;
  for(long i=0; i<n; i++){
    y *= a;
  }
  return y;
}



int main(){
  int n,m;
  scanf("%d", &n);
  scanf("%d", &m);

  if(m>n){
    int tmp = n;
    n = m;
    m = tmp;
  }

  if(m-n>=2){
    printf("0\n");
    return 0;
  }
  
  unsigned long long ans;
  if(m-(n-1)==0){
    ans = ( perm(n,n)*perm(m,n-1) ) % (1000000007);
  }
  else{
    //    printf("n=%d, m=%d, perm(n,n)=%ld, perm(m,n-1)=%ld\n", n,m, perm(n,n), perm(m,n-1));
    ans = ( perm(n,n)*perm(m,n-1)*2 ) % (1000000007);
  }

  printf("%llu\n", ans);

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
class Program{
  static void Main(string[] args){
    var n = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    int minP = 100, maxP = 1;
    foreach(var i in input){
      if(i<minP) minP=i;
      if(i>maxP) maxP=i;
    }
    var vList = new int[maxP+1];
    var minpos8 = -1;
    var minV8 = 100*100*100;
    for(var i=minP; i<=maxP; i++){
      if(i%8==0){
        var v = input.Sum(a => (a-i)*(a-i));
        vList[i] = v;
        if(v<minV8){
          minpos8=i;
          minV8 = v;
        }
      }
    }
    int minV=minV8,minLast=100*100*100;
    for(var i=Math.Max(minP,minpos8-15); i<=Math.Min(maxP,minpos8+15); i++){
      var v = input.Sum(a => (a-i)*(a-i));
      if(v>minLast)break;
      if(v<minV){
        minV=v;
        minLast=v;
      }
    }
    Console.WriteLine(minV);
  }
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#define xs 1000+5
#define ys 1000+5
using namespace std;
int l[xs][ys];
void lcs(string a,string b){
	int a_size=a.size();int b_size=b.size();
	a=' '+a;b=' '+b;
	for(int i=0;i<=a.size();i++){
		l[i][0]=0;
	}
	for(int i=0;i<=b.size();i++){
		l[0][i]=0;
	}
	for(int i=1;i<=a.size();i++){
		for(int j=1;j<=b.size();j++){
			if(a[i]==b[j]) {
				l[i][j]=l[i-1][j-1]+1;
			}else{
				l[i][j]=max(l[i-1][j],l[i][j-1]);
			}
		}
	}
}
int main(){
	int num;
	scanf("%d",&num);string a,b;
	for (int i=0;i<num;i++){
		
		cin>>a>>b;
		lcs(a,b);
		cout<<l[a.size()][b.size()]<<'\n';
	}
	
}


Measured memory_bytes: 7132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int r;
int main(){
  cin>>r;
  prin(3*r*r);
  return 0;
}


Measured memory_bytes: 256
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
      for(var j=i+i;j<=max;j+=i){
         arr[j]=false;
      }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(999999);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var a=Arr[i];
   if(a==0)break;
   var sum=0;
   for(var j=0;j<a;j++){
      sum+=p[j];
   }
   console.log(sum);
}

Measured memory_bytes: 28868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 1e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , q , ans; string s ;
int t[101000] , sum[101000];

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

    map < char , char > occ ;
    occ['A'] = 'T';
    occ['T'] = 'A';
    occ['C'] = 'G';
    occ['G'] = 'C';
    char c ;
    cin >> c ;
    cout << occ[c] << '\n';


     return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

bool check(int y, int m) {
	return 1 <= m && m <= 12;
}


void proc() {
	LOAD(int, S);
	const int upper = S / 100;
	const int lower = S % 100;
	if (check(upper, lower)) {
		if (check(lower, upper)) {
			cout << "AMBIGUOUS";
		}
		else {
			cout << "YYMM";
		}
	}
	else {
		if (check(lower, upper)) {
			cout << "MMYY";
		}
		else {
			cout << "NA";
		}
	}
}


#endif


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

//#define DEBUG

#ifdef DEBUG
using std::endl;
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#endif // DEBUG
#ifndef DEBUG
using namespace std;
#endif // DEBUG
#define MOD_N 1000000007
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


uint64_t consec_sum(uint64_t start, uint64_t end){
    if( (start + end) % 2){
        uint64_t terms = (end + 1 - start ) / 2;
        return terms * (end + start);
    }else{
        uint64_t invariant = (start + end) / 2;
        return (end + 1 - start) * invariant;
    }
}

void func_to_create(){
    long N, K ;
     cin >> N >> K;

    unsigned long ans = 0;
    for(int i = K ; i <= N + 1 ; i++){
        unsigned long count = (consec_sum(N - i + 1, N) - consec_sum(0 , i - 1) + 1) % MOD_N;
        ans =  (ans + count) % MOD_N ;
    }
    cout << ans << endl;

}
int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 3;
    while(TEST_CASES--){
    #endif // DEBBUG

    func_to_create();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


// A lesson learnt, instead using implicit long long 
//use uint32_t

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

typedef pair<int,int> P;
int N;
int W,H;
vector<int> Y[100005];
vector<int> T[100005];


struct uni {
  int d[ 50000 ];
  void init(){ memset( d,-1,sizeof( d ) ); }
  int find( int a ) { return d[a]<0?a:(d[a] = find( d[a] )); }
  void merge( int a,int b ){
    a = find(a); b = find(b);
    if( a == b ) return;
    if( d[a] > d[b] ) swap( a, b );
    d[a] += d[b]; d[b] = a;
  }
  int size(int a){ return -d[find(a)]; }
};

uni U;
bool used[ 50000 ];
int main(){
  cin >> N >> W >> H;
  int hj = 0;
  for(int i=0;i<N;i++){
    int x,y; cin >> x >> y;
    if( x == 1 || x == W || y == 1 || y == H ) hj=1;
    Y[ y ].push_back( i );
    T[ x ].push_back( i );
  }
  
  U.init();
  for(int i=1;i<=W;i++) {
    for(int j=1;j<(int)T[i].size();j++)
      U.merge( T[i][j-1], T[i][j] );
  }
  for(int i=1;i<=H;i++)
    for(int j=1;j<(int)Y[i].size();j++)
      U.merge( Y[i][j-1], Y[i][j] );


  int cnt = 0;
  int res = 0;
  for(int i=0;i<N;i++){
    int a = U.find( i );
    if( used[ a ] ) continue;
    used[ a ] = true;
    res += U.size( a )-1;
    cnt++;
  }
  if( cnt == 1 ) cout << res << endl;
  else cout << res + cnt + cnt-1 - hj << endl;
}

Measured memory_bytes: 10040
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

long long arr[500005];

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>n;
    i=0;
    k=0;
    while(n>0)
    {
        n=n/2;
        k+=PW2(i);
        i++;
    }

    cout<<k<<endl;



    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	set<int> s;
	int k;
	for(int i=0; i<3; ++i){
		cin>>k;
		s.insert(k);
	}
	cout<<s.size()<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    string s;cin >> s;
    REP(i,s.size())cout << 'x';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
/*
 * 高橋君は 1 辺の長さが N の 3 枚の鏡を正三角形状に組み合わせました。 三角形の頂点をそれぞれ a,b,c とします。
 * 
 * 高橋君は、辺 ab 上の頂点 a から X の点から、辺 bc と平行に不思議な光を発射しました。
 * 不思議な光は、普通の光と同じように真っすぐ進み、鏡に当たると反射するのですが、不思議な光がすでに通った点に当たったときにも反射をします。
 * 例えば、N=5,X=2 のとき、不思議な光の軌跡は図の黄色い矢印のようになります。
 * 
 * このように不思議な光を発射した時、不思議な光は必ず発射した点に戻ってくることが証明できます。 このとき、光の軌跡の長さが全体でいくらになるかを求めて下さい。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            long n = Long.parseLong(sc.next());
            long x = Long.parseLong(sc.next());
            long ret = n;
            
            n -= x;
            
            while(n%x != 0 && x%n != 0){
            	if(n>x){
            		ret += 2 * x * (n/x);
            		n -= x * (n/x);
            	}else{
            		ret += 2 * n * (x/n);
            		x -= n * (x/n);
            	}
            }
            
            //出力
            System.out.println(ret + Math.max(n, x) * 2 - Math.min(n,  x));
            sc.close();
        }
    }
	

Measured memory_bytes: 23636
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
	ll a, b, k;
	cin >> a >> b >> k;
	if(a >= k) {
		a = a - k;
		k = 0;
	}
	else {
		k = k - a;
		a = 0;
	}
	b = b - k;
	if(b < 0) b = 0;
	cout << a << " " << b << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n,m;cin>>n>>m;
  vector<vector<int>> v(m);
  rep(i,m){
    int k;cin>>k;
    v[i] = vector<int>(k);
    rep(j,k){
      cin>>v[i][j];
    }
  }
  vector<int> p(m);rep(i,m)cin>>p[i];
  int ans = 0;
  rep(bit,1<<n){
    bitset<10> bs(bit);
    bool ok = true;
    rep(i,m){
      int tmp = 0;
      rep(j,v[i].size()){
        tmp += bs[v[i][j]-1];
      }
      ok &= (tmp%2 == p[i]);
    }
    if(ok)ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b, c;

signed main() {
	cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
}

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

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

  int cnt=0, cnt_i=0;

  string s;
  cin >> s;

  for(int i=0; i<n; i++)
  {
    if(s.at(i)=='a')
    {
      if(cnt<a+b){
        cout << "Yes" << endl;
        cnt++;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else if(s.at(i)=='b')
    {
      if(cnt<a+b && cnt_i<b)
      {
        cout << "Yes" << endl;
        cnt++, cnt_i++;
      }
      else
      {
        cout << "No" << endl;
      }
    }
    else
    {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3740
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))

k = 0
while True:
    if a[0] % 2:
        break
    a[0] = a[0] // 2
    k += 1
base = 2 ** k

f = 0
for i in range(1,n):
    if a[i] % base:
        f = 1
        break
    a[i] = a[i] // base
    if a[i] % 2 == 0:
        f = 1
        break
if f:
    print(0)
else:
    LCM = a[0]
    for ai in a:
        LCM = LCM * ai // fractions.gcd(LCM, ai)
    LCM *= base // 2
    print(((m // LCM) + 1) // 2)


Measured memory_bytes: 89580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,q,k,x,y,i;
  cin>>n;
  map<pair<int,int>,int64_t> m;
  vector<vector<int>> g(n);
  for(i=0;i<n-1;i++){
    cin>>a>>b>>c;
    a--;b--;
    m[make_pair(a,b)]=c;
    m[make_pair(b,a)]=c;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
  }
  cin>>q>>k;
  k--;
  vector<int64_t> d(n,-1);
  queue<int> qu;
  d.at(k)=0;
  qu.push(k);
  while(!qu.empty()){
    int u=qu.front();
    qu.pop();
    for(auto z:g.at(u)){
      if(d.at(z)==-1){
        d.at(z)=d.at(u)+m.at(make_pair(u,z));
        qu.push(z);
      }
    }
  }
  for(i=0;i<q;i++){
    cin>>x>>y;
    x--;y--;
    cout<<d.at(x)+d.at(y)<<endl;
  }
}

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



int main(){
    string S;
    cin >> S;
    ll cnt = 0;
    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    for(int i = 2; i < S.size() - 1; i++){
        if(S[i] == 'C') cnt++;
    }
    if(cnt != 1){
        cout << "WA" << endl;
        return 0;
    }  

    for(int i = 0; i < S.size() ; i++){
        if(0 >  S[i] - 'a' && S[i] - 'a' >= -32) cnt++;
    }

    if(cnt == 3)  cout << "AC" << endl;
    else cout << "WA" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
int H,W;
vector<vector<int>> f;

vector<vector<int>> dp;
vector<vector<int>> ok;

int main(){
  cin >> H >> W;
  f.resize(H,vector<int>(W));
  dp.resize(H,vector<int>(W,-1));
  ok.resize(H,vector<int>(W,0));

  vector<int> X(H * W);
  vector<int> Y(H * W);

  rep(i,0,H - 1){
    rep(j,0,W - 1){
      cin >> f[i][j];
      f[i][j]--;
      X[f[i][j]] = i;
      Y[f[i][j]] = j;
    }
  }
  int dx[] = {1,-1,0,0};
  int dy[] = {0,0,1,-1};

  int res = 0;

  rep(i,0,H * W - 1){
    int x = X[i];
    int y = Y[i];
    set<int> st;
    int flag = 0;
    int sz = 0;
    rep(j,0,3){
      int nx = X[i] + dx[j];
      int ny = Y[i] + dy[j];
      if(0 <= nx && nx < H && 0 <= ny && ny < W){
        if(f[nx][ny] <= i){
          st.insert(dp[nx][ny]);
          flag = flag | ok[nx][ny];
          sz++;
        }
      }
    }
    if(sz == 0){dp[x][y] = i;continue;}
    if(st.size() >= 2){
      flag = 1;
    }
    ok[x][y] = flag;
    dp[x][y] = *st.begin();
    if(ok[x][y]) res++;
  }

  cout << res << endl;
}



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

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

    int K; cin >> K;
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5,
                     2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15,
                     2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[K-1] << "\n";
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double d;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    string s;
    cin>>n>>s;
    vector<ll> E(n,0);
    vector<ll> W(n,0);
    if(s[0]=='E')
    {
        E[0]=1;
        W[0]=0;
    }
    else
    {
        E[0]=0;
        W[0]=1;
    }
    for(ll i=1;i<n;i++)
    {
        if(s[i]=='E')
        {
            E[i]=E[i-1]+1;
            W[i]=W[i-1];
        }
        else
        {
            E[i]=E[i-1];
            W[i]=W[i-1]+1;
        }
    }
    ll MinPer=INT_MAX;
    for(ll i=0;i<n;i++)
    {
        ///0..i-1
        ll x1,x2;
        if(i==0)
        {
            x1=0;
        }
        else
        {
            x1=W[i-1];
        }
        ///i+1...n
        x2=E[n-1]-E[i];
        MinPer=min((x1+x2),MinPer);
    }
    cout<<MinPer<<endl;
    return 0;
}



Measured memory_bytes: 5396
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {

    let a: i32 = get_input().parse().unwrap();
    let b: i32 = get_input().parse().unwrap();
    let c: i32 = get_input().parse().unwrap();
    let x: i32 = get_input().parse().unwrap();


    let mut ans = 0;
    for _a in 0..a+1 {
        for _b in 0..b+1 {
            for _c in 0..c+1 {
                let sum = 500 * _a + 100 * _b + 50 * _c;
                if sum == x {
                    ans = ans + 1;
                }
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
import sys
import queue
import bisect

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main_b1():
	n, a, b = IN()
	al = [int(input()) for _ in range(n)]
	if len(al)==1:
		return (al[0] + a -1)//a
	
	al.sort()
	max_value = al[-1]
	min_value = al[0]
	dd_queue = queue.PriorityQueue()
	for v in al:
		dd_queue.put((-v, v))
		
	cc=0
	dmage_diff = a-b
	while True:
		_, max_hp=dd_queue.get()
		if max_hp-(b*cc) <= 0:
			return cc
			
		_, second_max_hp = dd_queue.get()
		nb = ((max_hp-second_max_hp)+dmage_diff-1)//dmage_diff
		
		if max_hp <= nb * a:
			return (max_hp + a - 1)//a
		
		cc += nb
		next_hp=max_hp-dmage_diff*nb
		dd_queue.put((-next_hp, next_hp))
		dd_queue.put((-second_max_hp, second_max_hp))

def is_ok(sorted_list, c, a, b):
	ii=bisect.bisect_right(sorted_list,b*c)
	count=c
	diff=a-b
	for v in sorted_list[ii:]:
		nokori = v - c*b
		count -= (nokori+diff-1)//diff
		if count < 0:
			return False
	return True

def main():
	n, a, b = IN()
	al = [int(input()) for _ in range(n)]
	al.sort()
	
	ok = (al[-1]+b-1)//b
	ng = 0
	while ok-ng > 1:
		mm=(ok+ng)//2
		if is_ok(al, mm, a, b):
			ok = mm
		else:
			ng = mm
	return ok
		
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 67032
#include <cstdio>
int main (){
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
	for (int i = sy; i < ty; i++)
		printf("U");
	for (int i = sx; i < tx; i++)
		printf("R");
	printf("UL");
	for (int i = sx; i < tx; i++)
		printf("L");
	for (int i = sy; i < ty; i++)
		printf("D");
	printf("DR");
	for (int i = sx; i < tx; i++)
		printf("R");
	for (int i = sy; i < ty; i++)
		printf("U");
	printf("RD");
	for (int i = sy; i < ty; i++)
		printf("D");
	for (int i = sx; i < tx; i++)
		printf("L");
	printf("LU");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

typedef struct{
	char c;
	int v;
}Card;

void setCard(Card *card, char _c, int _v){
	card->c = _c;
	card->v = _v;
	return;
}

void swapCard(Card *c0, Card *c1){
	Card temp;
	setCard(&temp, c0->c, c0->v);
	setCard(c0, c1->c, c1->v);
	setCard(c1, temp.c, temp.v);
	return;
}

int partition(Card A[], int p, int r){
	int x = A[r-1].v;
	int i = p-1, j;
	for( j = p; j < r-1; j++ ){
		if( A[j].v <= x ){
			i++;
			swapCard(&A[i], &A[j]);
		}
	}
	swapCard(&A[i+1], &A[r-1]);
	return i+1;
}

void quickSort(Card A[], int p, int r){
	if( p < r ){
		int q = partition(A, p, r);
		quickSort(A, p, q);
		quickSort(A, q+1, r);
	}
	return;
}

int main(){
	int n, i, j, isStable = 1;
	char t;
	Card card[100000], iCard[100000];
	scanf("%d", &n);
	scanf("%c", &t);
	for( i = 0; i < n; i++ ){
		scanf("%c %d", &card[i].c, &card[i].v);
		setCard(&iCard[i], card[i].c, card[i].v);
		scanf("%c", &t);
	}
	quickSort(card, 0, n);
	int bv = -1;
	for( i = 0; i < n; i++ ){
		if( card[i].v != bv ){ j = 0; }
		bv = card[i].v;
		for( ; j < n; j++ ){
			if( card[i].v == iCard[j].v ){
				if( card[i].c == iCard[j].c ){
					j++;
					break;
				}else{
					isStable = 0;
					break;
				}
			}
		}
	}
	printf("%s\n", (isStable?"Stable":"Not stable"));
	for( i = 0; i < n; i++ ){ printf("%c %d\n", card[i].c, card[i].v); }
	return 0;
}

Measured memory_bytes: 2168
x, k, d = map(int,input().split())
x = x if x>=0 else -x
if k >= x//d:
    if (x//d)%2 == k%2:
        print(x%d)
    else:
        print(min(abs(x%d-d),abs(x%d+d)))
else:
    print(abs(x-d*k))
    

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */


signed main(){

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

    int n, k; cin >> n >> k;

    vi x(n);
    vi y(n);
    rep(i,0,n){
        int tx, ty; cin >> tx >> ty;
        x[i] = tx;
        y[i] = ty;
    }

    int ans = inf;
    rep(t,0,n){//topy
        rep(b,0,n){//bottomy
            rep(l,0,n){//lefty
                rep(r, 0, n){//righty
                    if(y[t] > y[b] && x[l] < x[r]){
                        int cnt = 0;
                        rep(p,0,n){
                            if(y[b] <= y[p] && y[p] <= y[t] && x[l] <= x[p] && x[p] <= x[r]) cnt++;
                        }
                        if(cnt >= k) chmin(ans, abs(y[t] - y[b]) * abs(x[r] - x[l]));
                    }
                }
            }
        }
    }

    print(ans);


    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

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

  if(N == 0){
    cout << '0' << endl;
    return 0;
  }
  
  string ans = "";  
  
  while(N != 0){
    if(N & 1){
      --N;
      ans += "1";
    }else{
      ans += "0";
    }
    N /= -2;
  }

  reverse(begin(ans),end(ans));

  cout << ans << endl;
}

Measured memory_bytes: 256
/**
* Copyri(c)
* All ris reserved.
* Author : Mingzhe
* Description : sample
*/
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <sstream>
#include <memory.h>
#define MAXN 2005
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;

char s[MAXN][MAXN];

int up[MAXN][MAXN];
int down[MAXN][MAXN];
int le[MAXN][MAXN];
int ri[MAXN][MAXN];

int main(){
    int n,m;
    cin>>n>>m;
    memset(up,0,sizeof(up));
    memset(down,0,sizeof(down));
    memset(le,0,sizeof(le));
    memset(ri,0,sizeof(ri));
    getchar();
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%c",&s[i][j]);
        }
        getchar();
    }

    int maxone = 0;
    // up
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                up[i][j] = 0;
            }
            else{
                if(i==0){
                    up[i][j] = 1;
                }
                else{
                    up[i][j] = up[i-1][j] + 1;
                }
            }
        }
    }

    /*down*/
     for(int i=n-1;i>=0;i--){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                down[i][j] = 0;
            }
            else{
                if(i==n-1){
                    down[i][j] = 1;
                }
                else{
                    down[i][j] = down[i+1][j] + 1;
                }
            }
        }
    }

    /*le*/
     for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                le[i][j] = 0;
            }
            else{
                if(j==0){
                    le[i][j] = 1;
                }
                else{
                    le[i][j] = le[i][j-1] + 1;
                }
            }
        }
    }

    /*ri*/
     for(int i=0;i<n;i++){
        for(int j=m-1;j>=0;j--){
            if(s[i][j]=='#'){
                ri[i][j] = 0;
            }
            else{
                if(j==m-1){
                    ri[i][j] = 1;
                }
                else{
                    ri[i][j] += ri[i][j+1] + 1;
                }
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int cal = 0;
            if(s[i][j]=='.'){
                cal += up[i][j];
                cal += down[i][j];
                cal += le[i][j];
                cal += ri[i][j];
            }
            maxone = max(maxone,cal-3);
        }
    }
    cout<<maxone<<endl;
    return 0;
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
    vector<bool> upd;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        upd.resize(2*n-1,false);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = max(node[i*2+1],node[i*2+2]);
    }

    void eval(int k,int l,int r) {
        if (upd[k]) {
            node[k] = lazy[k];
            if (r-l > 1) {
                lazy[2*k+1] = lazy[2*k+2] = lazy[k];
                upd[2*k+1] = upd[2*k+2] = true;
            }
            lazy[k] = 0;
            upd[k] = false;
        }
    }

    void update(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            upd[k] = true;
            eval(k,l,r);
        } else {
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }

    ll getmax(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getmax(a,b,k*2+1,l,(l+r)/2);
        ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    LazySegmentTree seg(vector<ll>(n,INT_MAX));
    for (int i = 0;i < q;++i) {
        int c;
        cin >> c;
        if (c) {
            int a;
            cin >> a;
            cout << seg.getmax(a,a+1) << endl;
        } else {
            int s,t,x;
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    int n, m;
    string s[100], t[100];
    cin >> n;
    rep(i, n) cin >> s[i];
    cin >> m;
    rep(i, m) cin >> t[i];

    map<string, int> mp;
    rep(i, n) {
        if (mp.count(s[i])) mp[s[i]]++;
        else mp[s[i]] = 1;
    }
    rep(i, m) {
        if (mp.count(t[i])) mp[t[i]]--;
        else mp[t[i]] = -1;
    }
    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans = max(ans, itr->second);
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(){
  faster();
  int n;
  cin >> n;
  int a[20];
  int x[20][20],y[20][20];
  for(int i=1;i<=n;i++){
    cin >> a[i];
    for(int j=1;j<=a[i];j++){
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for(int bits=1;bits<(1<<n);bits++){
    bool flag = true;
    for(int i=0;i<=n;i++){
      if(!(bits & (1 << (i-1)))) continue;
      for(int j=1;j<=a[i];j++){
        if((bits >> (x[i][j]-1) & 1) ^ y[i][j]) flag = false;
      }
    }
    if(flag) ans = max(ans , counter(bits));
  }
  cout << ans << endl;
}






























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

Measured memory_bytes: 256