akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n,a[N];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<ll>());
    vector< pair<ll,ll> > ans;
    for(ll i=1;i<n-1;i++){
        if(a[i]>=0)ans.push_back({a[n-1],a[i]}),a[n-1]-=a[i];
        else ans.push_back({a[0],a[i]}),a[0]-=a[i];
    }
    ans.push_back({a[0],a[n-1]});
    cout<<a[0]-a[n-1]<<"\n";
    for(auto &ele:ans)cout<<ele.first<<" "<<ele.second<<"\n";
}

Measured memory_bytes: 4336
#include<cstdio>

int main(){
    int N;
    scanf("%d",&N);
    
    int A[N];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    
    int cnt=0;
    int ans=0;
    while(1){
        for(int i=0;i<N;i++){
            if(A[i]%2==0){
                A[i] = A[i]/2;
                cnt++;
            }else{
                break;
            }
        }
        if(cnt == N){
            ans++;
            cnt = 0;
        }else{
            break;
        }
    }
    
    printf("%d",ans);
    
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

double a, b;
int main() {
	cin >> a >> b;
	cout << ceil((a + b) / 2);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,k,n;
  cin >> h >> k >> n;
  int d=max(h,k);
  if(n<=h || n<=k)cout << 1 << endl;
  else if(n%d)cout << n/d+1 << endl;
  else cout << n/d << endl;
}


Measured memory_bytes: 3580
//
//  main.cpp
//  Nikkei09Qual
//
//  Created by 原大曜 on 2019/01/27.
//  Copyright © 2019年 原大曜. All rights reserved.
//

#include <iostream>
#include <vector>
#include <deque>

using namespace std;

void probA()
{
    int N,A,B;
    cin >> N >> A >> B;
    cout << std::min(A,B) << " " << std::max(0,(A + B - N)) << endl;
}

void probB()
{
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int sum = 0;
    for(int i=0;i<N;i++)
    {
        if(A[i]==B[i] && B[i]==C[i])
        {
            
        }
        else if(A[i] == B[i] && B[i] != C[i])
        {
            sum += 1;
        }
        else if(A[i] != B[i] && B[i] == C[i])
        {
            sum+=1;
        }
        else if(A[i] != B[i] && A[i] == C[i])
        {
            sum+=1;
        }
        else
        {
            sum+=2;
        }
    }
    cout << sum << endl;
}

void probC()
{
    int N;
    vector<pair<int,int>> takahashi;
    cin >> N;
    for(int i=0;i<N;i++)
    {
        int t,a;
        cin>>t>>a;
        takahashi.emplace_back(t,a);
    }
    sort(takahashi.begin(), takahashi.end(), [](const pair<int, int>& l, const pair<int, int>& r){return l.first + l.second > r.first + r.second;});

    long sum = 0;
    bool isT = true;
    for(const auto& pair: takahashi)
    {
        sum += isT ? pair.first : -1 * pair.second;
        isT = !isT;
    }
    
    cout << sum << endl;
}

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



Measured memory_bytes: 1400
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//


#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <sstream>

#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for (long long i=(b)-1;i>=(a);i--)
#define REP(i,n) for (unsigned long long i=0;i<(n);i++)
#define RREP(i,n) for (long long i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define llinf LLONG_MAX/3
#define LLINF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define VL vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SCD second

using namespace std;

signed main()
{
	ll N = 0;
	cin >> N;
	VL A(N);
	FOR(i, 0, N) {
		cin >> A[i];
	}
	A.push_back(0);

	ll C = 0;
	FOR(i, 0, N) {
		ll c;
		c = A[i] / 2;
		C += c;
		A[i] -= c * 2;
		c = min(A[i], A[i + 1]);
		C += c;
		A[i] -= c;
		A[i+1] -= c;
	}


	cout << C;

	return 0;
}


Measured memory_bytes: 1920
N = int(input())
S = input()
R = S.count("R")
G = S.count("G")
B = S.count("B")
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        if j*2-i < N:
            if (S[i] != S[j]) and (S[i] !=S[(j*2)-i]) and (S[j] != S[(j*2)-i]):
                cnt += 1
            else:
                pass
        else:
            pass
print(R*G*B - cnt)

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

int n;
int a,b,c;
int num;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> num;
        if(num % 4 == 0){
            a++;
        }else if(num % 2 == 0){
            b++;
        }else{
            c++;
        }
    }
    int t = 0;
    if(b >= 1) t = 1;
    if(a >= c + t - 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }
}

Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
S=input()

a=set([S.count(l) for l in "qwertyuiopasdfghjklzxcvbnm"])

if all(i%2==0 for i in a):
	print("Yes")
else:
	print("No")


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

int N, K;
int dp[1 << 18][59];
pair<int, int> A[1 << 18];

int hantei(vector<int> R) {
	for (int i = 1; i <= N; i++) dp[R.size()][i] = R.size();
	for (int i = R.size() - 1; i >= 0; i--) {
		for (int j = 1; j <= N; j++) {
			dp[i][j] = dp[i + 1][j];
			if (R[i] == j) dp[i][j] = i;
		}
	}

	int cx = 0, cnts = -1;
	while (cx < R.size()) {
		int maxn = 0;
		for (int i = 1; i <= N; i++) maxn = max(maxn, dp[cx][i]);
		cx = maxn; cnts++;
	}
	return cnts;
}

int getmin(int idx) {
	int minx = (1 << 30), pos = -1;
	for (int i = 1; i <= N; i++) {
		if (i == idx) continue;
		if (A[i].first < minx) { minx = A[i].first; pos = i; }
	}
	return pos;
}

int main() {
	// 入力
	cin >> N >> K; int r = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i].first; r += A[i].first;
		A[i].second = i;
	}

	// 構築
	vector<int> vec; int cx = getmin(-1);
	for (int i = 1; i <= N; i++) {
		if (i == cx) continue;
		if (A[i].first >= 1) { A[i].first--; vec.push_back(i); r--; }
	}
	while (r > 0) {
		int nex = getmin(cx);
		if (A[cx].first >= 1) { A[cx].first--; vec.push_back(cx); r--; }
		for (int i = 1; i <= N; i++) {
			if (i == cx || i == nex) continue;
			if (A[i].first >= 1) { A[i].first--; vec.push_back(i); r--; }
		}
		cx = nex;
	}

	// 判定
	int V = hantei(vec);
	if (V > K) {
		cout << vec.size() << endl;
		for (int i = 0; i < vec.size(); i++) {
			if (i) cout << " ";
			cout << vec[i];
		}
		cout << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}

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

int main() {
  string s,t;
  cin>>s;
  t=s+s;
  int n;
  cin >>n;
  long long kotae=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      s[i+1]='A';
      kotae++;
    }
  }
  long long sa=0;
  for(int i=0;i<t.size()-1;i++){
    if(t[i]==t[i+1]){
      t[i+1]='B';
      sa++;
    }
  }
  sa-=2*kotae;
  long long ans=kotae*n+sa*(n-1);
  if(kotae==s.size()/2&&s.size()%2==1){
    ans=kotae*n+sa*(n-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;
static const int MAX = 1000;


int main() {
    int A[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

    for (int i = 0; i < n; ++i) {
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;

        for (int k = 0; k < n; ++k) {
            cout << A[k];
            if(k < n - 1) cout << " ";
        }
        if(i < n) cout << endl;
    }
}


Measured memory_bytes: 3108
n = int(input())
ccc = list(map(int, input().split()))
ccc.sort()
MOD = 10 ** 9 + 7
ans = 0
others = pow(4, n - 1, MOD)
for i, c in enumerate(ccc):
    ans = (ans + others * c * (n - i + 1)) % MOD
print(ans)


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


int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == (i + 1)){cnt++;i++;}
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  ll k,q;
  cin>>k>>q;
  vector<ll>d(5009);
  rep(i,k)cin>>d[i];
  rep(i,q){
    ll n,x,m;
    cin>>n>>x>>m;
    vector<ll>nd;
    nd=d;
    ll cnt=0;
    rep(i,k){
      nd[i]%=m;
      if(nd[i]==0)cnt++;
    }
    x%=m;
    ll ln=(n-1)/k;
    ll rn=(n-1)%k;
    cnt*=ln;
    ll asum=0,bsum=0;
    rep(i,k){
      asum+=nd[i];
      if(i<rn){
        bsum+=nd[i];
        if(nd[i]==0)cnt++;
      }
    }
    ll last=x+asum*ln+bsum;
    cout<<n-1-last/m-cnt<<endl;
  }
  return(0);
}


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

int main () {
  int R;
  cin >> R;
  if (R < 1200) cout << "ABC" << endl;
  else if (R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e6+5;
const ll mod =   1e9+7;
int n,m,k,x3,y3,x2,y2;
int dx[4]={1,-1,0,0};int dy[4]={0,0,1,-1};
int main()
{  fast
cin>>n>>m>>k>>x3>>y3>>x2>>y2;x3--;y3--;x2--;y2--;
string s[n];
for(int i=0;i<n;i++)
cin>>s[i];
vector<vector<int> > g(n,vector<int> (m,1e9));
queue<pair<int,int> > q;
q.push({x3,y3});
g[x3][y3]=0;
while(!q.empty()){
	int x=q.front().fi;int y=q.front().se;
	q.pop();
	int val=g[x][y]+1;
	 for(int dir=0;dir<4;dir++){int xx=x;int yy=y;
	 	for(int i=1;i<=k;i++){
	 	  xx +=dx[dir]; yy+=dy[dir];
	 	if(xx<0||yy<0||xx>=n||yy>=m||s[xx][yy]=='@'||g[xx][yy]<val)
	 	break;
	 	if(g[xx][yy]>val){

	 	g[xx][yy]=val;
	 	q.push({xx,yy});}}
	 }
}
if(g[x2][y2]==1e9){
	cout<<-1;
}
else{
	cout<<g[x2][y2];
}
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int Q;
    cin >> Q;
    vector<vector<int>> data(Q, vector<int>(2));
    for (int i = 0; i < Q; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int MAX = 100001;
    vector<int> bit(MAX + 1,0);
    for (int i = 2; i * i <= MAX; i++) {
        if (bit.at(i) != 0) {
            continue;
        }
        for (int j = i * 2; j <= MAX; j += i) {
            bit.at(j)++;
        }
    }
    vector<int> judge(MAX + 1, 0);
    for (int i = 3; i < MAX + 1; i++) {
        if (bit.at(i) == 0 && bit.at((i + 1) / 2) == 0) {
            judge.at(i)++;
        }
    }
    vector<int> rsum(MAX + 1, 0);
    int sum = 0;
    for (int i = 1; i < MAX + 1; i++) {
        sum += judge.at(i);
        rsum.at(i) = sum;
    }
    int ans;
    for (int i = 0; i < Q; i++) {
        ans = rsum.at(data.at(i).at(1)) - rsum.at(data.at(i).at(0) - 1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 9844
import sys
from itertools import product
N, A, B, C = map(int, sys.stdin.readline().rstrip().split())
L = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
ans = 10**4

for cmb in product(range(4), repeat=N):
    a_sum = 0
    b_sum = 0
    c_sum = 0
    flag_a = 0
    flag_b = 0
    flag_c = 0
    cnt = 0
    for c, l in zip(cmb, L):
        if c == 0:
            a_sum += l
            if flag_a:
                cnt += 1
            else:
                flag_a = 1
        elif c == 1:
            b_sum += l
            if flag_b:
                cnt += 1
            else:
                flag_b = 1
        elif c == 2:
            c_sum += l
            if flag_c:
                cnt += 1
            else:
                flag_c = 1
    if flag_a == flag_b == flag_c == 1:
        ans = min(ans, 10 * cnt + abs(a_sum - A) + abs(b_sum - B) + abs(c_sum - C))
print(ans)

Measured memory_bytes: 48236
#include <stdio.h>

int	main()
{
	int	x;
	int	max;
	int	N;
	char	S[101];

	x = 0;
	max = 0;
	scanf("%d\n%s\n", &N, S);
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'I')
			x++;
		else
			x--;
		if (x > max)
			max = x;
	}
	printf("%d\n", max);
	return (0);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W; 
  cin >> H >> W;
  
  vector<vector<int>> v(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >> v[i][j];

  vector<string> ans;
  REP(i, H){
    if(i%2 == 0){
      REP(j, W){
        if(i == H-1 && j == W-1) break;
        if(v[i][j]%2){
          if(j != W-1){
            ans.emplace_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+2));
            v[i][j+1]++;
          }else{
            ans.emplace_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+2)+" "+to_string(j+1));
            v[i+1][j]++;
          }
        }
      }
    }else{
      RREP(j, W){
        if(i == H-1 && j == 0) break;
        if(v[i][j]%2){
          if(j != 0){
            ans.emplace_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j));
            v[i][j-1]++;
          }else{
            ans.emplace_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+2)+" "+to_string(j+1));
            v[i+1][j]++;
          }
        }
      }
    }
  }

  cout << ans.size() << "\n";
  REP(i, ans.size()){
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 12916
d,m=1e9+7,p[10001][200]={1};i,j,k,x,I;char s[11111];main(L){scanf("%s%d",s,&d);for(;j<2?:(j=0,++i<strlen(s));j++)for(x=L=j?9:s[i]-48,k=0;k<d?:(k=0,x--);k++)p[i+1][I=(j|x<L)*d+(k+x)%d]+=p[i][j*d+k],p[i+1][I]%=m;printf("%d",(*p[i]+p[i][d]-1+m)%m);}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,N,L;
  string ans="";
  cin >> N >> L;
  vector<string> v(N);
  for(i = 0;i < N;i++)
    cin >> v[i];
  sort(v.begin(),v.end());
  for(i = 0;i < N;i++)
    ans += v[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    if N % 2 == 0:
        A = deque([i+1 for i in range(N)])
        for i in range(1, M+1):
            if (N-i)-i > N//2:
                print(A[i], A[N-i])
            else:
                print(A[i], A[N-i-1])
    else:
        A = deque([i for i in range(N)])
        for i in range(1, M+1):
            print(A[i], A[N-i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 85256
n = int(input())
s = input()
list = s.split(" ")
total = 0
min_diff = 101

for i in range(n):
  list[i]= int(list[i])
  total = total+list[i]
sum1 = 0
for i in list:
  sum1 = sum1 + i
  sum2 = total - sum1
  diff = abs(sum1- sum2)
  if min_diff > diff:
    min_diff = diff
print(min_diff)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

int N;
double a[MAX];
int b[MAX];
int c[MAX];
int d[MAX];

void solve() {
	cin >> N;
	rep(i, N) {
		cin >> a[i];
		d[i] = (int)((a[i] + eps) * 1000);
		b[d[i]]++;
	}

	c[0] = 0;
	rep2(i, 1, 10000) {
		c[i] = c[i - 1] + b[i - 1];
	}
	
	rep(i, N) {
		cout << c[d[i]] * 3 + b[d[i]] - 1 << endl;
	}
}

signed main() {
	srand(time(NULL));
	int T = (int)1e15;
	solve();
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 4696
import math
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += math.sqrt((P[i][0] - P[j][0])**2 + (P[i][1] - P[j][1])**2)

ans *= 2/N
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    int ans = B / A;
    if(ans>C){
        ans = C;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(" ")
                .Select(i => long.Parse(i)).ToArray();
            var n = nm[0];
            var tenbous = new long[n];
            var m = nm[1];
            var heights = Console.ReadLine().Split(" ")
                .Select(i => long.Parse(i)).ToArray();
            for (var i = 0; i < m; i++)
            {
                var connects = Console.ReadLine().Split(" ")
                    .Select(m => int.Parse(m)).ToArray();
                var connect0 = connects[0] - 1;
                var connect1 = connects[1]- 1;
                tenbous[connect0] = Math.Max(tenbous[connect0], heights[connect1]) ;
                tenbous[connect1] = Math.Max(tenbous[connect1], heights[connect0]);
            }

            var count = 0;
            for (var i = 0; i < tenbous.Length; i++)
            {
                
                if (tenbous[i] == 0)
                {
                    count++;
                    continue;
                }

                if (tenbous[i] < heights[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

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

int main() {
  	int n;
  	cin >> n;
  
  	vector<int> d(n);
  	rep(i, n) cin >> d.at(i);
  
  	int ans=0;
  	rep(i, n) rep(j, n){
      if(i>=j) continue;
      else{
        ans += d.at(i)*d.at(j);
      }
    }
  	cout << ans << endl;
  	return 0;  
}


Measured memory_bytes: 3628
#include <cstdio>
#include <vector>

using namespace std;

vector <int> v[1000];

int main() {
    int n, c = 1, i, j, k;
    
    scanf("%d", &n);
    
    if (n == 1) {
        puts("Yes");
        puts("2");
        puts("1 1");
        puts("1 1");
    } else {
        for (i = 1; i * (i - 1) <= n * 2; i++) {
            if (i * (i - 1) == n * 2) {
                puts("Yes");
                printf("%d\n", i);
                
                for (j = 0; j < i; j++) {
                    for (k = j + 1; k < i; k++) {
                        v[j].push_back(c);
                        v[k].push_back(c);
                        c++;
                    }
                }
                
                for (j = 0; j < i; j++) {
                    printf("%d", v[j].size());
                    for (k = 0; k < v[j].size(); k++) printf(" %d", v[j][k]);
                    puts("");
                }
                
                return 0;
            }
        }
        
        puts("No");
    }
    
    return 0;
}


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

int main(){
    char a,b,c;
    cin>>a>>b>>c;
    if(a == 'R'){
        if(a == b){
            if(b==c){
                printf("3");
            }   
            else{
                printf("2");
            }
        }
        else{
            printf("1");
        }
    }
    else{
        if(a==b){
            if(c==b){
                printf("0");
            }
            else{
                printf("1");
            }
        }
        else{
            if(b==c) printf("2");
            else printf("1");
        }
    }
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var s int64
	fmt.Scan(&s)

	const bil = 1000000000
	y1 := (bil - (s % bil)) % bil
	y2 := (s + y1) / bil

	fmt.Print(bil)
	fmt.Print(" ")
	fmt.Print(y1)
	fmt.Print(" 1 ")
	fmt.Print(y2)
	fmt.Println(" 0 0")
}

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

long long n, a, b;

int main(){
	cin >> n;
	for(long long i=1; i<=sqrt(n); i++)
		if (n%i==0){
			a=i-1;
			b=n/i-1;
		}
	cout<<a+b;	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int main() {
   int n;
   cin >> n;
   double sum=0;
   rep(i,n){
      int a;
      cin >> a;
      sum+=1.0/a;
   }
   double ans=1/sum;
   printf("%.10f\n",ans);
}

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

int main(void){
  int D;
  cin >> D;
  cout << "Christmas";
  switch(D){
  case 22:
    cout << " Eve Eve Eve" << endl;
    break;
  case 23:
    cout << " Eve Eve" << endl;
    break;
  case 24:
    cout << " Eve" << endl;
    break;
  case 25:
    cout << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

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

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n;
	cin>>n;
	int a[114];
	rep0(n)cin>>a[i];
	sort(a,a+n);
	printint(a[n-1]-a[0]);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int abcmax = max(a, max(b, c));
    cout << a+b+c-abcmax << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    ll tmp = 0;
    vector<ll> a(n);

    rep(i,n){
        cin >> a[i];
        tmp ^= a[i];
    }

    rep(i,n){
        ll ans = tmp ^ a[i];
        cout << ans << " ";
    }
    cout << endl;

}

Measured memory_bytes: 4840
n = gets.chomp.to_i
c = gets.chomp.split('')
e = Array.new; e.fill(0, 0..n)
w = Array.new; w.fill(0, 0..n)
1.upto(n - 1) do |i|
        w[i] = w[i - 1]
        if c[i - 1] == 'W' then w[i] += 1 end
end
(n - 2).downto(0) do |i|
        e[i] = e[i + 1]
        if c[i + 1] == 'E' then e[i] += 1 end
end
min = n
n.times do |i|
        if min > e[i] + w[i] then min = e[i] + w[i] end
end
puts min

Measured memory_bytes: 32140
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int ans = 0;
  bool f = true;
  int mx = 0;
  rep(i,s.size()) {
    if(s[i] == 'A' || s[i] == 'G' || s[i] == 'T' || s[i] == 'C') {
      if (f) {
        ans++;
      } else {
        ans = 1;
        f = true;
      }
    } else {
      f = false;
    }
    mx = max(mx, ans);
  }
  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
    //freopen("output.txt", "w", stdout);
    int n; cin >> n;
    map<int, int> mp;
    for (int i=1; i<n; i++) {
        int x; cin >> x;
        mp[x]++;
    }
    for (int i=1;i<=n; i++) {
        cout << mp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13012
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int m, nm, nx;
    cin >> m >> nm >> nx;
    if(m == 0) break;
    vector<int> cs;
    for(int i = 0; i < m; i++) {
      int p;
      cin >> p;
      cs.push_back(p);
    }
    int dx = 0;
    int nn = nm;
    for(int i = nm - 1; i < nx; i++) {
      int d = cs[i] - cs[i+1];
      if(d >= dx) {
        dx = d;
        nn = i + 1;
      }
    }
    cout << nn << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
S = input()
f,e = int(S[:2]),int(S[2:])
if (f > 12 or f == 0) and 0 < e <= 12:
   print('YYMM')
elif 0 < f <= 12 and (e > 12 or e == 0):
   print('MMYY')
elif 0 < f <= 12 and 0 < e <= 12:
   print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
char s[15];
bool used[10005];
int main(){
	int n,i,j,l,ans=0,sa=0,sb=0;
	bool flag=0,ok=0;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%s",s);
		l=strlen(s);
		for(j=0;j<l-1;++j)if(s[j]=='A'&&s[j+1]=='B')++ans;
		if(s[l-1]=='A')++sa;
		if(s[0]=='B')++sb;
		if(s[l-1]=='A'&&s[0]=='B')flag=1;
		else if(s[l-1]=='A'||s[0]=='B')ok=1;
	}
	ans+=sa<sb?sa:sb;
	if(sa==sb&&flag&&!ok)--ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main (void){
    int a,ans;
    for(;;){
        ans=0;
        scanf("%d",&a);
        if(a==0)break;
        a=1000-a;
        if(a-500>=0){
            a=a-500;
            ans++;
        }
        for(;;){
            if(a-100>=0){
                a=a-100;
                ans++;
            }
            else break;
        }
        if(a-50>=0){
            a=a-50;
            ans++;
        }
        for(;;){
            if(a-10>=0){
                a=a-10;
                ans++;
            }
            else break;
        }
        if(a-5>=0){
            a=a-5;
            ans++;
        }
        for(;;){
            if(a-1>=0){
                a=a-1;
                ans++;
            }
            else break;
        }
        printf("%d\n",ans);
    }
return 0;
}

Measured memory_bytes: 600
/*
 * @Author: Kaizyn
 * @Date: 2020-05-30 20:11:07
 * @LastEditTime: 2020-05-30 20:52:28
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const long long INF = 1e18;
const int N = 1e5+7;

int n;
int a[N];
long long b[N];

inline void solve() {
  cin >> n;
  for (int i = 0; i <= n; ++i) cin >> a[i];
  long long cur = 1;
  for (int i = 0; i <= n; ++i) {
    if (a[i] > cur) return cout << -1 << endl, void();
    b[i] = cur;
    cur -= a[i];
    cur = min(cur*2, INF);
  }
  cur = 0;
  long long res = 0;
  for (int i = n; i >= 0; --i) {
    cur += a[i];
    cur = min(cur, b[i]);
    res += cur;
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int64 INF = 1LL << 33;
  
int64 N, P[200014];
int64 Sum[200014];
  
bool Check(int64 value)
{
  int End1 = 0, End2 = 0;
  int64 Sum1 = 0, Sum2 = 0;
  
  for(int i = 0; i < N; i++) {
    while(Sum1 < value) {
      Sum1 += P[End1];
      if(End1 < End2) Sum2 -= P[End1];
      ++End1;     
    }
    if(i == 0) {
      Sum2 = 0, End2 = End1;
    }
    while(Sum2 < value) {
      Sum2 += P[End2];
      ++End2;
    }
    if(Sum[i + N] - Sum[End2] >= value) {
      return(true);
    }
    Sum1 -= P[i];
  }
  return(false);
}
  
int main()
{
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%lld", &P[i]);
    P[i + N] = P[i];
  }
  for(int i = 1; i <= 2 * N; i++) {
    Sum[i] = Sum[i - 1] + P[i - 1];
  }
  int64 low = 0, high = Sum[N + N] / 3;
  while(high - low > 0) {
    int64 mid = (low + high + 1) / 2;
    if(Check(mid)) low = mid;
    else high = mid - 1;
  }
  printf("%lld\n", low);
}

Measured memory_bytes: 4312
#include<string>
#include<vector>
#include <algorithm>
#include<iostream>
using namespace std;
int main() {
	int a,b;
	cin >> a >> b;
	vector<int>p(a);
	for (int i = 0; i < a; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	long long c = 0;
	for (int j = 0; j < a - b; j++) {
		c += p[j];
	}
	cout << c;
	return 0; 
}

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

l = []

for i in range(k):
    l.append(str(s))
    
for i in range(n-k):
    if s == 1000000000:
        l.append(str(1))
    else:
        l.append(str(s+1))
        
print(' '.join(l))

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

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

	ll N, A, B;
	cin >> N >> A >> B;

	if(A > B || (A != B && N == 1)) {
		cout << 0 << endl;
		return 0;
	}

	ll a = B * (N - 1) + A, b = A * (N - 1) + B;
	cout << a - b + 1 << endl;
}

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

int _n = 2e5 + 10;
vector<ll> Fact(_n), Inv(_n);
int kmod = 1000000007;

ll mul(ll a, ll b)
{
	return a * b % kmod;
}

ll power(int base, int index)
{
	if (index == 0)
		return 1;
	ll temp = power(base, index / 2);
	temp = mul(temp, temp);
	if (index & 1)
		temp = mul(temp, base);
	return temp;
}

void pre()
{
	Fact[0] = 1;
	for (int i = 1; i < _n; ++i)
		Fact[i] = mul(Fact[i - 1], i);
	Inv[_n - 1] = power(Fact[_n - 1], kmod - 2);
	for (int i = _n - 2; i >= 0; --i)
		Inv[i] = mul(Inv[i + 1], (1 + i));
}

ll ncr(int n, int r)
{
	if (n < 0 || r < 0 || n - r < 0)
		return 0;
	// db(n, r, n - r);
	return mul(Fact[n], mul(Inv[r], Inv[n - r]));
}

void sub_self(ll &a, ll b)
{
	a -= b;
	if (a < 0)
		a += mod;
}

void solve()
{
	pre();
	int h, w, n;
	cin >> h >> w >> n;
	vector<pair<int, int>> Blocked(n);
	for (int i = 0; i < n; ++i)
		cin >> Blocked[i].f >> Blocked[i].s;
	Blocked.emplace_back(h, w);
	sort(Blocked.begin(), Blocked.end());
	vector<ll> dp(n + 1);
	for (int i = 0; i <= n; ++i)
	{
		dp[i] = ncr(Blocked[i].f - 2 + Blocked[i].s, Blocked[i].s - 1);
		for (int j = 0; j < i; ++j)
			if (Blocked[j].f <= Blocked[i].f && Blocked[j].s <= Blocked[i].s)
				sub_self(dp[i], mul(dp[j], ncr(Blocked[i].f - Blocked[j].f + Blocked[i].s - Blocked[j].s, Blocked[i].s - Blocked[j].s)));
		db(dp[i]);
	}
	cout << dp[n];
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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

int sortfnc(const void *a,const void *b){
    if(*(int*)a == *(int*)b){return 0;}
    if(*(int*)a < *(int*)b){return -1;}
    return 1;
}

int main(void){
	int n,c,k,t[131072],i,mf,r=0,p;
	scanf("%d%d%d",&n,&c,&k);
	for(i = 0;i < n;i++){scanf("%d",&t[i]);}
	qsort(t,n,sizeof(int),sortfnc);
	p = 1;
	mf = t[0];
	for(i = 1;i < n;i++){
		if(p+1 <= c && mf+k >= t[i]){
			p++;
		}
		else{
			r++;
			p = 1;
			mf = t[i];
		}
	}
	r++;
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n;
int T,A;
int a[1005];
double b[1005];
double tmp=0x3f3f3f3f;
int ans;
int main(){
	scanf("%d",&n);
	scanf("%d%d",&T,&A);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=T*1.0-a[i]*0.006;
		if(fabs(b[i]-A*1.0)<tmp){
			tmp=fabs(b[i]-A*1.0);
			ans=i;
		}
	} 
	printf("%d\n",ans);
	return 0; 
}

Measured memory_bytes: 256
w,a,b = map(int, input().split())
if b == a:
    print(0)
elif b > a:
    if b - (a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a - (b+w) < 0:
        print(0)
    else:
        print(a-(b+w))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define ll long long
#define i1 int128_t
#define vi vector<long long>
#define st set<long long>
#define uset unordered_set<long long>
#define si set<long long>:: iterator
#define pb push_back
#define mp make_pair
#define fi(i,a,b) for(long long i=a; i<b; i++)
#define fd(i,a,b) for(long long i=a; i>=b; i--)
#define fs(i,a,s) for(long long i=a; s[i]!='\0'; i++)
#define endl "\n"

int main(){

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t,ans=0,d;
	cin>>t>>d;
	while(t--){
		double x,y;
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d)
			ans++;
	}
	cout<<ans;
	// fclose(stdin);
	// fclose(stdout);
}


Measured memory_bytes: 3856
// Created by Nikolay Budin

#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }

const int MOD = 1000000007;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

void solve() {
	int n;
	cin >> n;
	vector<int> arr;
	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		arr.push_back(num);
	}
	map<int, int> sum;
	int cur = 1;
	for (int i = 0; i < n; ++i) {
		int tmp = sum[arr[i]];
		if (i == 0 || (i > 0 && arr[i - 1] != arr[i])) {
			add(sum[arr[i]], cur);
		}
		if (i > 0 && arr[i - 1] != arr[i]) {
			add(cur, tmp);
		}
		// cerr << i << " " << cur << " " << sum[arr[i]] << endl;
	}

	cout << cur << "\n";
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
const int N=1e2+5;
int n,a[N],b[N],c[N],d[N],e[N][N];
int mk[N],vis[N];
bool dfs(int u)
{
	for(int i=1;i<=n;i++)
	{
		if(e[u][i]&&!vis[i])
		{
			vis[i]=1;
			if(!mk[i]||dfs(mk[i]))
			{
				mk[i]=u;
				return true;			
			}
		}
	}
	return false;
}
void calc()
{
	int res=0;
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		if(dfs(i))
			res++;
	}
	printf("%d\n",res);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++)
		cin>>c[i]>>d[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[i]<c[j]&&b[i]<d[j])
				e[i][j]=1;	
	calc();
	return 0;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
s = 0
ans = 0
for i in range(N):
    if i - s + 1 > C or T[i] - T[s] > K:
        s = i
        ans += 1
print(ans+1)


Measured memory_bytes: 81092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL count = 0,log_count;
    string n,n_at;
    cin >> n;
    n_at = n.substr(0,1);
//    cout << "n.substr(0,1) :" << n.substr(0,1) << endl;
    for(int i = 1; i < 4; i++) {
//        cout << "n.substr(i,1) :" << n.substr(i,1) << endl;
        if(n_at == n.substr(i,1)){
            count++;
            if(count >= 2) {
            break;
            }
        }else{
            count = 0;
        }
        n_at = n.substr(i,1);
    }
//    cout << "count :" << count << endl;
    if(count >= 2) {
        cout << "Yes" << endl;        
    }else{
        cout << "No" << endl;
    }


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
long long saikou(long long a,long long b){
	long long aa,bb;
	aa=a;
	bb=b;
	while(a!=0&&b!=0){
		if(a>b){
			a%=b;
		}
		else b%=a;
	}
	long long gcd=max(a,b);
	return aa/gcd*bb;
}
int main() {
	long long ans,n;
	cin>>n;
	cin>>ans;
	for(long long i=1;i<n;i++){
		long long t;
		cin>>t;
		ans=saikou(ans,t);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> stack = new Stack<Integer>();
		String[] str = br.readLine().split(" ");
		int a = 0 ;
		for(int i = 0 ; i < str.length ; i ++){
			if(str[i].equals("+")){
				stack.push(stack.pop()+stack.pop());
			}
			else if(str[i].equals("-")){
				stack.push(-1*stack.pop()+stack.pop());
			}
			else if(str[i].equals("*")){
				stack.push(stack.pop()*stack.pop());
			}
			else if(str[i].equals("/")){
				a = stack.pop();
				stack.push(stack.pop()/a);
			}
			else{
				//System.out.println(str[i]+": push now");
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
}

Measured memory_bytes: 16908
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	if (a%b == 0) {
		cout << '0' << "\n";
	}
	else {
		cout << '1' << "\n";
	}
	
	std::cin >> e;
}

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

int main() {
	long int n;
	cin >> n;
	long long int a,min,max;
	max = -1000000001;
	cin >> a;
	min = a;
	for (int i = 1;i < n;i++) {
		cin >> a;
		if (max <= a -min) {
			max = a - min;
		}
		if (min>=a) {
			min = a;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define LOCAL
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;
//#define int long long

int32_t main(){_
	int n,k ;
	cin >> n ;
	vi a(n) ;
	inp(a) ;
	sort(all(a)) ;
	int md = n/2 ;
	int ans = a[md] - a[md-1] ;
	cout << ans << endl ;
}


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

using namespace std;

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

  for (int64_t i = sqrt(N); i >= 1; i--) {
    if (N % i == 0) {
      int64_t j = N / i;
      cout << i + j - 2 << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int h[100005][3] = { 0 };
int main()
{
	int n;
	cin >> n;
	int a, b;
	for (int i = 1; i <= n / 2; i++) {
		cin >> a >> b;
		h[a][1]++;
		h[b][2]++;
	}
	int ma = 0;
	int mb=0;
	int sa=0;
	int sb=0;
	int ma2=-1;
	int mb2 = -1;
	int sa2 = 0;
	int sb2 =0;
	for (int i = 1; i <= 100000; i++) {
		if (h[i][1] > ma) {
			sa = i;// 数字iが最も多い
			ma = h[i][1];//ma iの数
		}
	}
	h[sa][1] = 0;
	ma2 = 0;
	for (int i = 1; i <= 100000; i++) {
		if (h[i][1] > ma2) {
			sa2 = i;// 数字iが最も多い
			ma2 = h[i][1];//ma2 iの数
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (h[i][2] > mb) {
			sb = i;// 数字iが最も多い
			mb = h[i][2];//mb iの数
		}
	}
	h[sb][2] = 0;
	mb2 = 0;
	for (int i = 1; i <= 100000; i++) {
		if (h[i][2] > mb2) {
			sb2 = i;// 数字iが最も多い
			mb2 = h[i][2];//mb2 iの数
		}
	}
	//cout << sa << " " << ma << " " << sb << " " << mb << endl;////////////////////
	//cout << sa2 << " " << ma2 << " " << sb2 << " " << mb2 << endl;////////////////////
	if (sa == sb)cout<<n-(max(ma+mb2,mb+ma2))<<endl;
	else cout << n - (ma + mb) << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 405;
LL a[N];
LL dp[N][N];
LL p[N];

LL solve(int i, int j) {
  if(dp[i][j] != -1) return dp[i][j];
  LL ret = LONG_LONG_MAX;
  if(i == j) return 0;
  for(int k = i; k < j; k ++) {
    LL v = solve(i,k) + solve(k+1,j) + p[j] - p[i-1];
    ret = min(ret, v);
  }
  return dp[i][j] = ret;
}

int main()
{     
  int n;
  in(n);
  for(int i = 1; i <= n; i ++) {
    in(a[i]);
  }
  for(int i = 1; i <= n; i ++) p[i] = p[i-1] + a[i];
  memset(dp,-1,sizeof dp);
  cout << solve(1,n);
}




Measured memory_bytes: 1536