akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int a, b, c, d, n;
	d = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (n = a; n <= b; n++) {
		if (c % n == 0) {
			d++;
		}
		else;
	}
	printf("%d\n", d);

	return 0;
}


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

unsigned short calculate_num_monitor (const unsigned short* const num_tree_all, const unsigned short* const num_range)
{
	// variable for this function
	register unsigned short num_tree_monitored;
	register unsigned short num_monitor;

	num_tree_monitored = (unsigned short)(2) * *num_range + (unsigned short)(1);
	num_monitor        = *num_tree_all / num_tree_monitored;

	if ( *num_tree_all % num_tree_monitored != (unsigned short)(0) ) { num_monitor += (unsigned short)(1); }

	return num_monitor;
}

int main (void)
{
	// variables for main process
	unsigned short N;
	unsigned short D;
	int            rtvl_scanf;

	// STEP.01
	// read out the given data
	rtvl_scanf = scanf("%d %d", &N, &D);

	// STEP.02
	// output the answer of this task
	printf("%d\n", calculate_num_monitor(&N, &D));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int keta(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n /=10;
    }
    return sum;
}
int main(void){
    // Your code here!
    int N,a,b,ans=0;
    cin>>N>>a>>b;
    for (int i=1; i<=N; i++){
        
        if(a<=keta(i)&&keta(i)<=b){
            ans +=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 888
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

//0-index
vector<int> seqv;
int seqv_n;
int gcd(int a,int b){
    if(a<b) return gcd(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void seg_debug(){
    cout<<"---------seg_debug------n="<<seqv_n<<endl;
    int k=1;
    for(int i=0;i<(seqv_n+1)*2-1;i++){
        if(k==i) {
            cout<<endl;
            k=k*2+1;
        }
        cout<<seqv[i]<<" ";
    }
    cout<<endl<<"------------------------------"<<endl;
}

void seg_init(int N,int a){
    seqv.clear();
    int n=1;
    while(n<N) n*=2;
    seqv_n=n-1;
    n*=2;
    n=n-1;
    for(int i=0;i<n;i++){
        seqv.push_back(a);
    }
}

void seg_update(int n,int a){
    int k=n+seqv_n;
    seqv[k]=a;
    while(k>0){
        k=(k-1)/2;
        if(seqv[k*2+1]==LLONG_MAX) seqv[k]=seqv[k*2+2];
        else if(seqv[k*2+2]==LLONG_MAX) seqv[k]=seqv[k*2+1];
        else seqv[k]=gcd(seqv[k*2+1],seqv[k*2+2]);
    }
}


int seg_find(int x,int y){
    struct segF{
        static int segfind(int x,int y,int k,int l,int r){
            //cout<<x<<","<<y<<","<<k<<","<<l<<","<<r<<endl;
            if(r<x||l>y) return LLONG_MAX;
            if(l>=x&&r<=y) return seqv[k];
            else{
                int segl=segfind(x,y,k*2+1,l,(l+r)/2);
                int segr=segfind(x,y,k*2+2,(l+r)/2+1,r);
                if(segl==LLONG_MAX) return segr;
                if(segr==LLONG_MAX) return segl;
                return gcd(segl,segr);
            }
        }
    };
    return segF::segfind(x,y,0,0,seqv_n);
}

signed main(){
    int n;
    cin>>n;
    seg_init(n,LLONG_MAX);
    for(int i=0;i<n;i++){
        int A;
        cin>>A;
        seg_update(i,A);
    }

    int ans=seg_find(0,n-1);
    for(int i=0;i<n;i++){
        int a=seg_find(i,i);
        seg_update(i,LLONG_MAX);
        ans=max(ans,seg_find(0,n-1));
        seg_update(i,a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4916
/*
      author : nishi5451
      created: 11.08.2020 00:15:27
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a==1) a=14;
    if(b==1) b=14;
    if(a>b) cout << "Alice" << endl;
    else if(a==b) cout << "Draw" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a[309][309],b[309][309];bool c[309][309];int d[309],e[309];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){cin>>a[i][j];a[i][j]--;b[i][a[i][j]]=j;}
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<n;j++){for(int k=0;k<m;k++)c[j][k]=false;d[j]=0;}
        int cnt=0;
        while(cnt<m){
            for(int j=0;j<m;j++)e[j]=0;
            for(int j=0;j<n;j++)e[a[j][d[j]]]++;
            bool OK=false;
            for(int j=0;j<m;j++){
                if(e[j]>i){
                    OK=true;
                    for(int k=0;k<n;k++)c[k][b[k][j]]=true;
                    break;
                }
            }
            //for(int j=0;j<m;j++)cout<<e[j]<<' ';cout<<endl;
            for(int j=0;j<n;j++){
                while(c[j][d[j]]==true)d[j]++;
            }
            if(OK==false)break;
            cnt++;
        }
        if(cnt!=m){cout<<i<<endl;break;}
    }
    return 0;
}

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

int main(){
    int h, w;

    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0)
            break;

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0 || i == h - 1 || j == 0 || j == w - 1){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout <<'\n';
        }
        cout << '\n';
    }
    return 0;
}

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

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

    vector<int> A(N), B(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        B[i] = A[i];
    }

    sort(begin(B), end(B));

    for(int i = 0; i < N; ++i){
        if(B[N-1] == A[i]){
            cout << B[N-2] << endl;
        }else{
            cout << B[N-1] << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
int main(void)
{
	char x[200001];
	int l, ct = 0, cs = 0, ans = 0;
	std::cin >> x;
	l = std::strlen(x);
	while(x[ct] == 'T') ct++;
	for(int i = ct; i != l; i++){
		if(x[i] == 'S'){
			cs++;
		}else{
			if(cs > 0) cs--;
			else ans++;
		}
	}
	std::cout << ct + ans + cs << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    set<ll> s;
    ll a, b;
    cin>>a>>b;
    ll val = __gcd(a, b);
    ll n = val;
    while (n % 2 == 0){
        s.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i += 2){
        while (n % i == 0){
            s.insert(i);
            n /=i;
        }
    }

    if (n > 2)
        s.insert(n);

    cout<<s.size()+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    ll h,w;
    cin>>h>>w;
    if(h==1 or w==1){
        cout<<1<<endl;
        return 0;
    }
    if(h%2==1 and w%2==1){
        ll a,b,c,d;
        a=(h+1)/2;
        b=(w+1)/2;
        c=(h-1)/2;
        d=(w-1)/2;
        cout<<(a*b+c*d)<<endl;
    }
    else{
        if(h%2==0){
            h/=2;
        }
        else{
            w/=2;
        }
        cout<<(h*w)<<endl;
    }
    return 0;
}

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

using namespace std;
double II(double val)
{
	if(val<0) return -val;
	return val;
}
int main()
{
	double N,T,A;
	double H[1000];
	double ans=114514;
	double tem;
	int i;
	int num;
	cin>>N;
	cin>>T>>A;
	for(i=0;i<N;i++){
		cin>>H[i];
		tem=II((T-A)-H[i]*0.006);
		ans=min(ans,tem);
		if(ans==tem) num=i;
	}
	cout<<num+1<<endl;
	
}


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

using namespace std;

static string ns[100];
static int ms[100];

bool check(const string &n, const string &m)
{
	for (int i = n.length() - 1; i >= 0; --i)
	{
		if (n[i] == '*') break;
		else if (n[i] != m[i])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int N,M;
	while(cin>>N>>M,N)
	{
		for (int i = 0; i < N; i++) cin>>ns[i]>>ms[i];

		int sum = 0;
		for (int i = 0; i < M; i++)
		{
			string s;
			cin>>s;
			for (int j = 0; j < N; j++)
			{
				if (check(ns[j], s)) sum += ms[j];
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 924
H, W = map(int, input().split())
a = [input() for _ in range(H)]
#print(a)

def compress(b, h, w):
  b = [c for c in b if '#' in c]
  b = [''.join(x) for x in zip(*b)]
  b = [c for c in b if '#' in c]
  b = [''.join(x) for x in zip(*b)]
  if len(b) == h and len(b[0]) == w:
    return b
  return compress(b, len(b), len(b[0]))

r = compress(a, H, W)
for i in range(len(r)):
  print(r[i])


Measured memory_bytes: 38384
import itertools
import math
N = int(input())
cities = []
indexes = []
for i in range(N):
    cities.append(list(map(int, input().split())))
    indexes.append(i)


indexes_permutaions = list(itertools.permutations(indexes))
costs = []
for indexes_permutaion in indexes_permutaions:
    cost = 0
    for i in range(len(indexes_permutaion) - 1):
        index = indexes_permutaion[i]
        next_index = indexes_permutaion[i + 1]
        num = math.sqrt((((cities[next_index][0] - cities[index][0])
                          ** 2) + ((cities[next_index][1] - cities[index][1]) ** 2)))
        cost += num
    costs.append(cost)
print(float(sum(costs)) / len(costs))


Measured memory_bytes: 46956
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int ori=1000;
    int i=1;int cnt=0;
    while(i<n){
        while(a[i-1]==a[i]) i++;
        if(a[i-1]<a[i]){
            cnt+=ori/a[i-1];
            ori=ori-(ori/a[i-1])*a[i-1];
        }
        else{
            ori+=cnt*a[i-1];cnt=0;
        }
        i++;
    }
    if(cnt>0) ori+=a[n-1]*cnt;
    cout<<ori; 
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3600
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (10 ** 9 + 7)


if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    n = int(input())    # 数字
    aList = list(map(int, input().split()))     # スペース区切り連続数字

    # ------ 処理 ------#
    sum = 0
    for i in range(0, n):
        sum += aList[i]

    pro = 0
    for i in range(0, n):
        ai = aList[i]
        sum = sum - ai
        pro += sum * aList[i]

    out = resultSur97(pro)

    # ------ 出力 ------#
    print("{}".format(out))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")


Measured memory_bytes: 31732
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int binary_search(vector<int> &A, int x, bool t) {
  int l = -1, r = A.size();
  while (r - l > 1) {
    int mid = l + (r - l) / 2;
    if ((t && x > A[mid]) || (!t && x >= A[mid])) {
      l = mid;
    } else {
      r = mid;
    }
  }
  // t=trueなら、たかい
  return r;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  REP(i, N) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  ll ans = 0;
  REP(i, N) {
    int tmp = B[i];
    ll tmp2 = binary_search(A, tmp, true);
    ll tmp3 = binary_search(C, tmp, false);
    tmp3 = N - tmp3;
    ans += tmp2 * tmp3;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4572
//mangesh2102000

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000007

int n,m;
vector <int> g[100005];
int dp[100005];
bool vis[100005];

void dfs(int node)
{
    vis[node]=true;
    for(int i=0;i<g[node].size();i++)
    {
        if(!vis[g[node][i]])
            dfs(g[node][i]);

        dp[node] = max(dp[node],1+dp[g[node][i]]);
    }
}

void solve(int t)
{
    cin >> n >> m;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin >> x >> y;
        g[x].pb(y);
    }

    memset(dp,0,sizeof(dp));
    memset(vis,false,sizeof(vis));

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }

    int ans = -1;
    for(int i=1;i<=n;i++)
    {
       // cout << i << "-" << dp[i] << "\n";
        ans = max(ans,dp[i]);
    }

    cout << ans;


    //cout << "Case #" << t << ": ";    
}   


int32_t main()
{
    IOS;
    int t;
    t=1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 8704
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>
#include<queue>
using namespace std;
int main(){
    int q1,b,c1,c2,q2;
    while(cin>>q1,q1){
        cin>>b>>c1>>c2>>q2;
        int x,y;
        x=min(b/c1,q2);

        for(int i=x;i>=0;i--){
            if(i==0)cout<<"NA"<<endl;
            else if(i+(b-i*c1)/c2>=q1){
                cout<<i<<" "<<(b-i*c1)/c2<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	//cout<<setprecision(50);
    ll x;
    cin>>x;
    
    int ans=1;
    ll temp=100;
    
    while(floor(temp*1.01)<(x)){
    	ans++;
    	temp=floor(temp*1.01);
    	//cout<<x<<endl;
    	//cout<<temp<<endl;
	}
	
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3688
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] cs = sc.next().toCharArray();
        long[] ls = new long[26];
        long t = 1;
        for(int i = 0 ;i < ls.length;++i){
            ls[i] = 1;
        }
        for(int i = 0;i < cs.length;++i){
            ++ls[cs[i] - 'a'];
        }
        for(int i = 0 ;i < ls.length;++i){
            t *= ls[i];
            t %= 1000000007;
        }
        --t;
        System.out.println(t);
    }

}




Measured memory_bytes: 27760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int ans = 0;
	for (int i = 0; i <= 3000; i++) {								//iはRの数
		for (int j = 0; j <= 3000; j++) {
			int k = R * i + G * j;
				if (N >= k && (N - k) % B == 0) {
					ans++;
				}
										
			}
	}
	cout << ans  << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n1, n2, n3;

    scanf("%d %d %d", &n1, &n2, &n3);

    if (n1 <= n2 && n2 <= n3)
    {
        printf("%d %d %d\n", n1, n2, n3);
    }
    else if (n1 <= n3 && n3 <= n2)
    {
        printf("%d %d %d\n", n1, n3, n2);
    }
    else if (n2 <= n1 && n1 <= n3)
    {
        printf("%d %d %d\n", n2, n1, n3);
    }
    else if (n2 <= n3 && n3 <= n1)
    {
        printf("%d %d %d\n", n2, n3, n1);
    }
    else if (n3 <= n1 && n1 <= n2)
    {
        printf("%d %d %d\n", n3, n1, n2);
    }
    else if (n3 <= n2 && n2 <= n1)
    {
        printf("%d %d %d\n", n3, n2, n1);
    }

    return 0;
}


Measured memory_bytes: 2712
#include <stdio.h>
//#include <iostream>
//#include <cstdlib>
//#include <cstring>

//using namespace std;

int main() {
  
  int n,a,b,c;
  int i;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    scanf("%d %d %d",&a,&b,&c);

    if(a*a+b*b==c*c || b*b+c*c==a*a || c*c+a*a==b*b) printf("YES\n");
    else printf("NO\n");
  }
  
  return 0;
}

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

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

int main() {
  int L;
  cin >> L;
  printf("%.12f\n", (double)L * L * L / 27);
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def prob_a(s):
    chars = list(s)
    tmpc = chars[0]
    for c in chars[1:]:
        if c == tmpc:
            continue
        else:
            print('Yes')
            return 0
    print('No')

if __name__ == '__main__':
    s = input()
    prob_a(s)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 998244353  

void func()
{
    ll n;
    cin>>n;
    vector<ll> v(100001);
    ll sum=0;
    loop(i,0,n){
        ll t;
        cin>>t;
        sum+=t;
        v[t]++;
    }
    ll q;
    cin>>q;
    ll ans=sum;
    while(q--){
        ll a,b;
        cin>>a>>b;
        if(v[a]==0){
            cout<<ans<<"\n";
            continue;
        }
        else{
            ans=ans-a*v[a]+b*v[a];
            v[b]=v[b]+v[a];
            v[a]=0;
        }
        cout<<ans<<"\n";
    }
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3964
#include <iostream>
#include <math.h>
using namespace std;

const int N = 1e5+5;
int a, b, q;
int main()
{
    cin >> q;
    while(q--)
    {
        cin >> a >> b;
        int cc = sqrt(1LL*a*b);
        int tmp = 2*(cc-1);
        if (cc*1LL*cc == a*1LL*b && a != b)
            tmp--;
        if (cc*1LL*(cc+1)<a*1LL*b)
            tmp++;
        cout << tmp << endl;
    }
}
/*
7
1 4
10 5
3 3
4 11
8 9
22 40
8 36
*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,c1,c2,c3,c4;
    c1=c2=c3=c4=0;
    cin>>n;
    string x;
    for (int i=0;i<n;i++)
    {
        cin>>x;
        if(x=="AC")
            c1++;
        else if (x=="WA")
            c2++;
        else if (x=="TLE")
            c3++;
        else c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
    return 0;
}


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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, x; cin >> n >> x;
	if (x == 2 * n - 1 || x == 1) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		vector<int> v(2 * n - 1);
		v[n - 1] = x;
		v[n - 2] = x - 1;
		v[n] = x + 1;
		int t = 1;
		rep(i, 2 * n - 1) {
			while (t == x || t == x - 1 || t == x + 1) {
				t++;
			}
			if (!v[i]) {
				v[i] = t++;
			}
		}
		for (int item : v) cout << item << endl;
	}
	system("pause");
}

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

struct Node{
  int key;
  Node *p, *l, *r;
};

int n;

Node *NIL, *root;

void preorder(Node *u){
  if(u == NIL) return;
  cout << ' ' << u->key;
  preorder(u->l);
  preorder(u->r);
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->l);
  cout << ' ' << u->key;
  inorder(u->r);
}

/*void Postorder(int u){
  if(u == -1) return;
  Postorder(T[u].l);
  Postorder(T[u].r);
  cout << ' ' << u;
}
*/

void insert(int k){
  Node *y = NIL;
  Node *x = root;

  Node *z;

  z = new Node[1];

  z->key = k;
  z->p = NIL;
  z->r = NIL;
  z->l = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }

  z->p = y;

  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}

void find(int k){
  Node *x = root;
  while(x != NIL){
    if(k == x->key) break;
    else if(k > x->key) x = x->r;
    else x = x->l;
  }

  if(x == NIL) cout << "no" << endl;
  else cout << "yes" << endl;
}


int main(){


  int x;

  string s;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> s;
    if(s ==  "insert"){

      cin >> x;

      insert(x);
    }

    else if(s == "find"){
      cin >> x;
      find(x);
    }

    else{
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }


/*  for(int k = 0; k < n; k++){

    cin >> x;

    for(int i = 0; i < 2; i++){
      cin >> y;
      T[y].parent = x;
      if(i == 0){
      T[x].l = y;
      }
      else{
        T[x].r = y;
      }
    }
  }

/*
  cout << "Inorder" << endl;
  Inorder(r);
  cout << endl;


  cout << "Preorder" << endl;
  Preparse(r);
  cout << endl;


  cout << "Postorder" << endl;
  Postorder(r);
  cout << endl;
*/

  return 0;
}



Measured memory_bytes: 21848
#include <iostream>
using namespace std;
int fun(int x,int n=0){
    if(x%2==0)
        {n++;return fun(x/2,n) ;}
        return n;
}

int main(){
    int n;
    while(cin>>n)
    {  int i,a[105],max=1,t=0;
       for(i=1;i<=n;i++)
       {
           a[i]=fun(i);

           if(a[i]>t)
           {t=a[i]; max=i;}

       }
       cout<<max<<endl;
    }
return 0;
    }








Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )

using namespace std;

typedef unsigned long long int ull;

int mid(int a,int b, int c){
	int temp,MIN,MAX,MID;
	MIN = min(a,b);
	MIN = min(MIN,c);
	MAX = max(a,b);
	MAX = max(MAX,c);
	if( a != MIN && a != MAX ) MID = a;
	if( b != MIN && b != MAX ) MID = b;
	if( c != MIN && c != MAX ) MID = c;
	return MID;
	
}

int main(void) {


	int N;
	INPUT(N);
	vector<int> p(N);
	REPEAT(i,N) INPUT(p[i]);

	int count=0;
	for(int i=1;i<N-1;i++ ){
		if( mid(p[i-1],p[i],p[i+1]) == p[i] ) count++;
	}
	
	OUTPUT(count);
}

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

int main(){
	int N;
	cin >> N;
	int k=0;
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		if(x%2==1) k++;
	}
	if(k%2==0) cout << "YES" <<endl;
	else cout << "NO" <<endl;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  
  int i,j,k,l=0;
  for(i=0; i<S.size(); i++){
    k=0;
    for(j=0; j<S.size(); j++){
      if(S.at((i+j)%S.size()) == T.at(j%S.size())){
        k++;
      }
      if(k == S.size()){
        l++;
      }
    }
  }
  
  if(l!=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



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

int mul[] = {1000, 100, 10, 1};
char op[] = {'m', 'c', 'x', 'i'};

string toMCXI(int x){
  string res = "";

  for(int i = 0; i < 4; i++){
    if(x < mul[i]) continue;

    int div = x / mul[i];
    x %= mul[i];

    if(div != 1){
      res += (char)(div + '0');
    }
    res += op[i];
  }
  return res;
}

int toInt(const string &s){
  int n = s.length();
  int res = 0;

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < n; j++){
      if(s[j] != op[i]) continue;

      if(j - 1 < 0 || !isdigit(s[j - 1])){
        res += mul[i];
      } else{
        res += mul[i] * (s[j - 1] - '0');
      }

      break;
    }
  }
  return res;
}

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

  while(T--){
    string a, b;
    cin >> a >> b;
    cout << toMCXI( toInt(a) + toInt(b) ) << endl;
  }
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
    int i,y,z;
    int a[6];
    for(i=0;i<6;i++){
        if(i==5){
            scanf("%d",&a[5]);
        }
        scanf("%d ",&a[i]);
    }
    char x[100];
    scanf("%s",x);
    y=strlen(x);
    for(i=0;i<y;i++){
        if(x[i]=='S'){
            z=a[1];
            a[1]=a[0],a[0]=a[4],a[4]=a[5];
            a[5]=z;
        }else if(x[i]=='N'){
            z=a[1];
            a[1]=a[5],a[5]=a[4],a[4]=a[0];
            a[0]=z;
        }else if(x[i]=='E'){
            z=a[5];
            a[5]=a[2],a[2]=a[0],a[0]=a[3];
            a[3]=z;
        }else{
            z=a[2];
            a[2]=a[5],a[5]=a[3],a[3]=a[0];
            a[0]=z;
        }
    }
    printf("%d\n",a[0]);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct Node{ int parent,left,right;}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left !=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right !=NIL) h2=setHeight(T[u].right)+1;
  return H[u] = (h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);

  for(i = 0;i<n;i++) T[i].parent = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l!=NIL) T[l].parent = v;
    if(r!=NIL) T[r].parent = v;
  }

  for(i = 0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int A,B;
	A=max(a,c);
	B=min(b,d);
	if(B>A){
		cout<<B-A<<endl;
	}
	else{
		cout<<0<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define inf 2018
 
int main(){
  int l, r;
  cin >> l >> r;
  if(r-l>=2019){
    cout << 0 << endl;
    return 0;
  }
  int ans = inf;
  int pro;
  for(int i=l; i<r; ++i){
    for(int j=i+1; j<=r; ++j){
      pro = ((i%2019)*(j%2019))%2019;
      ans = min(pro,ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9+7

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n-i) * modinv(i+1, mod) % mod
    return res

for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        print((combination(N-K+1, i) * combination(K-1, i-1)) % mod)

Measured memory_bytes: 43740
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int L;
    cin>>L;
    int cur=0;
    int xx=0;
    vc<tuple<int,int,int>> edge;
    while(cur+(1<<xx)<L)
    {
        cur+=1<<xx;
        xx++;
        edge.emplace_back(xx,xx+1,1<<(xx-1));
        edge.emplace_back(xx,xx+1,0);
    }
    int d=L-1-cur;
    for(int i=0;i<xx;i++)
    {
        if(d>>i&1)
        {
            edge.emplace_back(i+1,xx+1,cur+1);
            cur+=1<<i;
        }
    }
    assert(cur==L-1);
    cout<<xx+1<<" "<<edge.size()<<'\n';
    for(auto u:edge)
    {
        int x,y,z;
        tie(x,y,z)=u;
        cout<<x<<" "<<y<<" "<<z<<'\n';
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A-Z-
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = 'A' + sc.next();
		int count = 0;

		for (int i = 1; i < S.length(); i++) {
			if (S.charAt(i) <= S.charAt(i - 1)) count++;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 26284
defmodule Main do
  def main() do
    [a, b, c, x] = for _ <- 1..4, do: IO.gets("") |> String.trim() |> String.to_integer()
    coins(a, b, c, x)
    |> IO.puts()
  end
  def coins(n500, n100, n50, total) do
     for i <- 0..n50,
         j <- 0..n100,
         k <- 0..n500 do
       i * 50 + j * 100 + k * 500
     end
     |> Enum.count(&(&1 == total))
   end
end


Measured memory_bytes: 40628
// AOJ ALDS1_14_C Pattern Search
// 2018.5.13 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
}

typedef unsigned long long ull;
#define C1  401
#define C2  397

#define MAX_L 1005
char text[MAX_L][MAX_L]; int H, W;
char pat[MAX_L][MAX_L]; int R, C;
ull a[MAX_L][MAX_L], b[MAX_L][MAX_L];
ull t[MAX_L][MAX_L];

void genHash(ull res[MAX_L][MAX_L], char s[MAX_L][MAX_L], int h, int w)
{
	int r, c;
	ull x, y, k;

//	memset(t, 0, sizeof(t));
//	memset(res, 0, sizeof(res));

	x = 1, y = 1;
	for (c = 0; c < C; c++) x *= C1;
	for (r = 0; r < R; r++) y *= C2;

	for (r = 0; r < h; r++) {
		k = 0;
		for (c = 0; c < C; c++) k = k*C1 + s[r][c];
		for (c = 0; c <= w-C; c++) {
			t[r][c] = k;
			if (c + C < w) k = k*C1-s[r][c]*x+s[r][c+C];
		}
	}

	for (c = 0; c < w; c++) {
		k = 0;
		for (r = 0; r < R; r++) k = k*C2+t[r][c];
		for (r = 0; r <= h-R; r++) {
			res[r][c] = k;
			if (r+R < h) k = k*C2-t[r][c]*y+t[r+R][c];
		}
	}
}

int main()
{
	int  r, c;
	char ch, *p;
	ull  f;

	H = in(), W = in();
	for (r = 0; r < H; r++) {
		p = text[r];
		while ((ch = gc()) > ' ') *p++ = ch;
		*p = 0;
	}

	R = in(), C = in();
	for (r = 0; r < R; r++) {
		p = pat[r];
		while ((ch = gc()) > ' ') *p++ = ch;
		*p = 0;
	}

	genHash(a, text, H, W);
	genHash(b, pat, R, C);
	f = b[0][0];

	for (r = 0; r <= H-R; r++) for (c = 0; c <= W-C; c++) {
		if (f == a[r][c]) {
			out(r), pc(' '), out(c), pc('\n');
		}
	}
	return 0;
}


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

n, d, a = list(map(int, input().split()))
xh = []
for line in sys.stdin:
    x, h = map(int, line.split())
    xh.append((x, 0, h))
heapify(xh)
atk_cnt = 0
ans = 0
while xh:
    x, t, h = heappop(xh)
    if t == 0:
        if atk_cnt * a >= h:
            continue
        remain = h - atk_cnt * a
        new_atk = (remain - 1) // a + 1
        heappush(xh, (x + 2 * d, 1, new_atk))
        ans += new_atk
        atk_cnt += new_atk
    else:
        atk_cnt -= h
print(ans)


Measured memory_bytes: 35656
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = f.read_int_list()

    ma = max(a)
    mi = min(a)
    ans = []
    if ma+mi >= 0:
        ind = a.index(ma)
        for i in xrange(n):
            if i == ind: continue
            ans.append("%d %d"%(ind+1, i+1))
        for i in xrange(1, n):
            ans.append("%d %d"%(i, i+1))
    else:
        ind = a.index(mi)
        for i in xrange(n):
            if i == ind: continue
            ans.append("%d %d"%(ind+1, i+1))
        for i in xrange(n-1, 0, -1):
            ans.append("%d %d"%(i+1, i))

    return "%d\n%s"%(len(ans), "\n".join(ans))


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

typedef long long ll;

const ll inf = 10000000;

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    ll total = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        total += a[i];
    }
    int x = total/N; 
    int y = ceil((double)total/(double)N);
    int c1 = 0;
    int c2 = 0;
    for (int i = 0; i < N; i++) {
        c1 += pow((a[i]-x), 2);
        c2 += pow((a[i]-y), 2);
    }
    cout << min(c1, c2) << endl;
}


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

#define MAXN 400
int H,W;
long long Ans;
bool vis[MAXN+5][MAXN+5];
char str[MAXN+5][MAXN+5];

struct node{
    int x,y;
};

const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
pair<int,int> bfs(int Sx,int Sy){
    queue<node> Q;
    Q.push((node){Sx,Sy});
    vis[Sx][Sy]=1;
    int cnt1=0,cnt2=0;
    while(!Q.empty()){
        node u=Q.front();Q.pop();
        cnt1+=str[u.x][u.y]=='.',cnt2+=str[u.x][u.y]=='#';
        for(int i=0;i<4;i++){
            int x=u.x+dir[i][0],y=u.y+dir[i][1];
            if(x>=1&&x<=H&&y>=1&&y<=W){
                if(!vis[x][y]&&str[x][y]!=str[u.x][u.y]){
                    vis[x][y]=1;
                    Q.push((node){x,y});
                }
            }
        }
    }
    return make_pair(cnt1,cnt2);
}

int main(){
    scanf("%d%d",&H,&W);
    for(int i=1;i<=H;i++)
        scanf("%s",str[i]+1);
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
            if(str[i][j]=='.'&&!vis[i][j]){
                pair<int,int> num=bfs(i,j);
                Ans+=1ll*num.first*num.second;
            }
    printf("%lld",Ans);
}


Measured memory_bytes: 512
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val As = List.fill(N)(in.nextInt)

  println(
    As.zip(As.tail).foldLeft(1000L){case (money, (now, next)) =>
      if (now <= next) money / now * next + money % now
      else money
    }
  )
}


Measured memory_bytes: 55572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
int main()
{
    // 3+2+2+10+10+10+10+10+10
    int n, t;
    cin >> n >> t;
    vector<int> vec(n);
    rep(i, n) cin >> vec[i];
    ll ans = 0;
    rep(i, n - 1) {
        if(vec[i + 1] - vec[i] < t) {
            ans += vec[i + 1] - vec[i];
        }
        else {
            ans += t;
        }
    }
    cout << ans + t << endl;
    return 0;
}

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

int main(){
    //入力
    int N,K;

    cin >> N;
    cin >> K;

    //処理
    int ans=1;
    for(int i=0;i<N;i++){
        ans=min(ans*2,ans+K);
    }

    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc123/tasks/abc123_c

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

minimum = min(a, b, c, d, e)

if n % minimum != 0:
    diff = n // minimum + 1
else:
    diff = n // minimum

print(diff+4)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N, ans;
int a[100], b[100], c[100], d[100];
vector<vector<int> > v(101, vector<int>(101));

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

  for (int i = 0; i < N; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] < c[j] && b[i] < d[j]) {
        v[j][N]++;
        v[N][i]++;
        v[j][i] = 1;
      }
    }
  }
  while (true) {
    int ite = N;
    for (int i = 0; i < N; i++) {
      if (v[i][N] > 0) {
        if (ite == N) {
          ite = i;
        } else {
          if (v[ite][N] > v[i][N]) {
            ite = i;
          }
        }
      }
    }
    if (ite == N) {
      break;
    }
    int i = N;
    for(int j=0;j<N;j++){
      if(v[ite][j]==1){
        if(i==N){
          i=j;
        }else{
          if(v[N][i]>v[N][j]){
            i=j;
          }
        }
      }
    }
    ans++;
    for(int j=0;j<N;j++){
      v[ite][j]=0;
    }
    v[ite][N]=0;
    for (int j = 0; j < N; j++) {
      if (v[j][i] == 1) {
        v[j][i] = 0;
        v[j][N]--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }
  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int[] ax = new int[n];
      long sum = 0;

      int m;
      int offset=0,next=0;
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0; isContinue; i++) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        m = Integer.parseInt(line.substring(offset,next));
        m -= i;
        ax[i] = --m;
        offset = ++next;
      }

      Arrays.parallelSort(ax);
      int b = ax[n/2];

      for (int i : ax) {
        sum += Math.abs(i-b);
      }

      System.out.println(sum);

    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 45780
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_V=1e5;
const int MAX_M=2e5;
const int INF=INT_MAX;

typedef pair<int,int> PS;
struct edge{PS to;long cost;};
typedef pair<long,PS> P;//firstは最短距離,secondは頂点番号

int V;
map<PS,vector<edge>> G;
map<PS,long>d;

void dijkstra(PS s){
    priority_queue<P,vector<P>,greater<P> > que;
    d[s]=0;
    que.push(P(0,s));
    
    while(!que.empty()){
        P p=que.top();que.pop();//仮の最短距離が短い順に取り出す
        auto v=p.second;
        if(d.find(v)!=d.end()&&d[v]<p.first)continue;
        if(G.find(v)!=G.end())REP(i,G[v].size()){
            edge e=G[v][i];
            if(d.find(e.to)==d.end()||d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));//仮の最短距離と頂点の組を更新が行われる度に追加していく
            }
        }
    }
}

vector<int>eki[MAX_M];
int main(){
    ios::sync_with_stdio(false);
    LL N,M;cin>>N>>M;
    REP(i,M){
        int p,q,c;
        cin>>p>>q>>c;
        p--;q--;c--;
        G[PS{q,c}].PB(edge{PS{p,c},0});
        G[PS{p,c}].PB(edge{PS{q,c},0});
        G[PS{p,c}].PB(edge{PS{p,-1},0});
        G[PS{q,c}].PB(edge{PS{q,-1},0});
        eki[p].PB(c);eki[q].PB(c);
    }
    REP(i,N)REP(j,SZ(eki[i]))G[PS{i,-1}].PB(edge{PS{i,eki[i][j]},1});
    dijkstra(PS{0,-1});
    if(d.find(PS{N-1,-1})==d.end()){
        cout<<-1<<"\n";
    }else{
        cout<<d[PS{N-1,-1}]<<"\n";
    }
    return 0;
}
//出るタイミングで加算
//

Measured memory_bytes: 109808
import numba
import numpy as np
N = int(input())
P = np.array([int(c)-1 for c in input().split()])

#from random import shuffle
#N = 500
#P = list(range(N*N))
#shuffle(P)
#P = np.array(P)

@numba.njit("i8(i8,i8[:])")
def proc(N, P):
    ans = 0
    Removed = np.zeros((500, 500), dtype=np.int8)
    Mat = np.zeros((500, 500), dtype=np.int16)
    Dy, Dx = [1,0,-1,0], [0,1,0,-1]

    for y in range(N):
        for x in range(N):
            Mat[y, x] = min(y, N-1-y, x, N-1-x)
    #print(Mat)
    Buf = [(0, 0) for _ in range(1<<17)]
    Buf_idx = 0
    for i in range(N*N):
        p = P[i]
        y, x = divmod(p, N)
        ans += Mat[y,x]
        Removed[y,x] = 1
        Buf[Buf_idx] = (y, x)
        Buf_idx += 1
        while Buf_idx:
            Buf_idx -= 1
            vy, vx = Buf[Buf_idx]
            vr = Removed[vy,vx]
            val = Mat[vy,vx]
            #for dy, dx in zip(Dy, Dx):
            for j in range(4):
                uy, ux = vy + Dy[j], vx + Dx[j]
                if not (0<=uy<N and 0<=ux<N):
                    continue
                ur = Removed[uy,ux]
                if vr:
                    if Mat[uy,ux] >= val+1:
                        Mat[uy,ux] = val
                        Buf[Buf_idx] = (uy, ux)
                        Buf_idx += 1
                else:
                    if Mat[uy,ux] >= val+2:
                        Mat[uy,ux] = val+1
                        Buf[Buf_idx] = (uy, ux)
                        Buf_idx += 1
    # for m in Mat:
    #     print(m)
    return ans
print(proc(N, P))



Measured memory_bytes: 122080
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 var L = parseInt(lines[0],10);
 var H = lines[1].split(' ');
var count = 0;

  
  for(var i=0;i<L;i++){
    var H = parseInt(lines[1].split(' ')[i],10);
	if((i+1)%2 ===1){
    	if(H%2 ===1 ){
        	count++;
        }
    }
  }
console.log(count);
  
});

Measured memory_bytes: 29932
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var input = test.ConvertIntArray(test.ReadInput());
            if(input[0] * 500 >= input[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }       

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main()
{
	int x, y,a[101],z=0;
	cin >> x>>y;
	for (int i = 0; i < x; i++) {
		cin >> a[i];
		z += a[i];
	}
	for (int i = 0; i < x; i++) {
		for (int j =i; j < x; j++) {
			if (a[i] > a[j]) {
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	
	cout << ((y - z) / a[0]) + x;
}

Measured memory_bytes: 3584