akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
ll power(ll a,ll n)
{
    ll p;
    if(n==0)
    {
        return 1;
    }
    p=power(a,n/2);
    p=p*p;
    if(n%2==1)
    {
        p=p*a;
    }
    return p;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    sort(a,a+n,greater<ll>());
    for(int i=k;i<n;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<'\n';
    return 0;
}

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

long long MOD = 1e9 + 7;
int a[24][24];
long long dp[(1<<21) + 20];
long long solve(long long mask, int n){
    //cout<<mask<<"\n";
    int in = __builtin_popcount(mask) + 1;
    if(in==n+1) return 1;
    if(dp[mask]!=-1) return dp[mask];
    int w;
    long long ans = 0;
    for(w=0;w<n; w++) {
        if(a[in-1][w] && !(mask&(1<<w)) )
            ans+=solve(mask|(1<<w), n), ans%=MOD;
    }
    return dp[mask] = ans;
}
int main() {
	int n;
	cin>>n;
	int i, j;
	for(i=0;i<n;i++) 
	    for(j=0;j<n;j++)
	        cin>>a[i][j];
    for(i=0;i<(1<<(n))+12;i++)
        dp[i]=-1;
    long long ans = 0;
    for(i=0;i<n;i++)
        if(a[0][i])
            ans +=solve(1<<i, n), ans%=MOD;
    cout<<ans<<"\n";
            
	return 0;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
int n,m,pen[100010];
bool solved[100010];
int main() {
  cin>>n>>m;
  int penalty=0, correct=0;
  for (int i=1; i<=m; ++i) {
    int p; string s; cin>>p>>s;
    if (s=="AC") {
      if (!solved[p]) {
        correct++;
        solved[p]=true;
        penalty+=pen[p];
      }
    }
    else {
      pen[p]++;
    }
  }
  cout<<correct<<" "<<penalty<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include<math.h>
typedef long long int ll;
int main()
{
  ll n,K;
  cin>>n>>K;
  ll i,a[n];
  for(i=0;i<n;i++)
  {
      cin>>a[i];
  }
  ll ans=0;
  for(i=0;i<n;i++)
  {
      if(a[i]>=K)
        ans++;
  }
  cout<<ans;

}


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

public class Main{
	  public static void main(String[] args){
		  Scanner sc = new Scanner(System.in);
		  int N = sc.nextInt();
		  int[] lst = new int[N];
		  int alice_point = 0;
		  int bob_point = 0;

		  for(int i = 0; i < N; i++) {
			  lst[i] = sc.nextInt();
		  }

		  lst = sortDesc(lst);

		  for(int i = 0; i < N; i++) {
			  if(i % 2 == 0) {
				  alice_point += lst[i];
			  } else {
				  bob_point += lst[i];
			  }
		  }
		  System.out.println(alice_point - bob_point);
	  }

	  static int[] sortDesc(int[] lst) {
		  Arrays.sort(lst);

		  int[] lst_temp = new int[lst.length];

		  for(int i = 0; i < lst.length; i++) {
			  lst_temp[i] = lst[lst.length - 1 - i];
		  }

		  for(int i = 0; i < lst.length; i++) {
			  lst[i] = lst_temp[i];
		  }
		  return lst;
	  }
}

Measured memory_bytes: 21716
b = true
a = Array.new
count = 0

while b
	num = gets.to_i
	b = false if num == 0
	if b
		a.push num
	end
	count += 1
end

a.each_with_index{|num, index|
	puts "Case "+(index+1).to_s+": "+num.to_s
}

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

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];

    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++)
        sum += p[i];

    cout << sum << endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N,w[1010],s[1010];
ll v[1010],dp[1010][20010] = {};
vector<pair<int,int>> u;

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> w[i] >> s[i] >> v[i];
		u.push_back({w[i]+s[i],i});
	}
	sort(u.begin(),u.end());
	ll ans = 0;
	for(int i=1;i<=N;i++){
		int a = u[i-1].second;
		for(int j=0;j<=20010;j++){
			if(j>=w[a] && j-w[a]<=s[a]) dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[a]]+v[a]);
			else dp[i][j] = dp[i-1][j];
			ans = max(ans,dp[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 157824
#include<stdio.h>
int main(){
 int N,Y,x,y,z,flag=0;
 scanf("%d%d",&N,&Y);
 for(x=0;x<=N;x++){
  for(y=0;y<=N-x;y++){
   for(z=0;z<=N-x-y;z++){
    if(1000*z+5000*y+10000*x==Y&&x+y+z==N){
     flag=1;
     printf("%d %d %d\n",x,y,z);
     N=-1;
    }  
   }
  }
 }
 if(flag==0) printf("-1 -1 -1\n");
 return 0;
}

Measured memory_bytes: 256
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n+1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Measured memory_bytes: 7680
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int n,a[100005];
map <int,int> m[2];
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		++m[i%2][a[i]];
	}
	vector <pair <int,int> > v[2];
	for (int i=0;i<2;++i)
	{
		for (auto j:m[i]) v[i].emplace_back(n/2-j.second,j.first);
		sort(v[i].begin(),v[i].end());
		v[i].emplace_back(n/2,-i);
	}
	if (v[0][0].second==v[1][0].second) printf("%d\n",min(v[0][0].first+v[1][1].first,v[0][1].first+v[1][0].first));
	else printf("%d\n",v[0][0].first+v[1][0].first);
	return 0;
}

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

int main() {
    string text;
    cin >> text;
    //int score ;

    int len = text.length();

        int count = 0;
        for(int i = 0; i < len / 2; ++i) {
            if(text[i] != text[len - i - 1])
                //cout << text[i] << text[len - i -1];
                ++count;
        }
    cout << count;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	int n; cin>>n;
	vvl v(n,vl(n)); fore(i,0,n)fore(j,0,n)cin>>v[i][j];
	vl mask(1<<n,0);
	fore(i,0,1<<n)fore(j,0,n)if(i & (1<<j))fore(k,j+1,n)if(i & (1<<k))mask[i]+=v[j][k];
	vl dp(1<<n,-INF);
	dp[0]=0;
	fore(i,1,1<<n)for(int j=i;j; j=((j-1)&i))dp[i]=max(dp[i],dp[i^j]+mask[j]);
	cout<<dp[(1<<n)-1]<<ENDL;


}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 4248
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <iomanip>
using namespace std;
int main() {
    double  n,m;
    double ret=0.0;
    cin>> n>>m;
    double prob=(double)1/n;
    //cout<<prob<<endl;
    for(int i=1;i<n+1;i++){
      double num=0;
      double tmp=i;
      while(tmp<m){
        num++;
        tmp=2*tmp;
        }
        //cout<<num<<endl;
      ret+= prob*pow(0.5,num);
      //cout<<ret<<endl;
      }
    cout<<setprecision(11)<< ret<<endl;
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool prime( long int n)
{
    int i;
    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) return 0;

    }
    return 1;
}
int main()
{
     int a;
    cin>>a;
    while(1)
    {
        if(prime(a)==0)
            a++;
        if(prime(a)==1) {cout<<a<<endl;return 0;}
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<List<Integer>> A = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			ArrayList<Integer> B = new ArrayList<>();
			A.add(B);
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int x = sc.nextInt();
			if (x == 0) {
				int y = sc.nextInt();
				int z = sc.nextInt();
				A.get(y).add(z);
			} else if (x == 1) {
				int y = sc.nextInt();
				if (A.get(y).size() != 0) {
					System.out.println(A.get(y).get(A.get(y).size() - 1));
				}
			} else if (x == 2) {
				int y = sc.nextInt();
				if (A.get(y).size() != 0) {
					A.get(y).remove(A.get(y).size() - 1);
				}
			}
		}
		sc.close();

	}

}




Measured memory_bytes: 166988
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define pll pair<ll,ll>
using namespace std;

int main() 
{
	int a,b;
	cin>>a>>b;
	if(2*b>=a)
	{
		cout<<0;
	}
	else
	{
		cout<<a-2*b;
	}
	return 0;
}


Measured memory_bytes: 256
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv
input = sys.stdin.readline


def dump(*objects):
    if len(args) == 2 and args[1] == "DEBUG":
        print(*objects, file=sys.stderr)


N = int(input())
A = [0] + list(map(int, input().split())) + [0]
dump(N, A)
B = cp.deepcopy(A)
C = cp.deepcopy(A)
for i in range(1, len(A)):
    dump(i)
    B[i] = B[i - 1] + abs(A[i] - A[i - 1])
for i in range(len(A) - 2, -1, -1):
    dump(i)
    C[i] = C[i+1] + abs(A[i]-A[i+1])
dump(A, B, C)
for i in range(1, N+1):
    dump(i, B[i-1] + B[N+1] - B[i+1] + abs(A[i-1]-A[i+1]))
    print(B[i-1] + C[i+1] + abs(A[i-1]-A[i+1]))

exit(0)


Measured memory_bytes: 16564
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >> n;
string txt;
  cin >> txt;
  for(int i=0;i<txt.size();i++){
  txt.at(i)+=n;
  if(txt.at(i)>=91)txt.at(i)-=26;}
cout << txt <<endl;
}

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


    do{
    cin >> a >> op >> b ;
    if(op == "+"){
        c = 1 ;
    }
    else if(op == "-"){
        c = 2 ;
    }
    else if(op == "*"){
        c = 3 ;
    }
    else if(op == "/"){
        c = 4 ;
    }
    else{
        break;
    }
    
        switch(c){
            case 1:
                cout << a + b << endl; 
            break ;
            case 2:
                cout << a - b << endl; 
            break ;
            case 3:
                cout << a * b << endl; 
            break ;
            case 4:
                cout << a / b << endl; 
            break ;
            default:
                cout << endl; 
            break ;
        }
    }while((op == "+")||(op == "-")||(op == "*")||(op == "/"));



}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int ans, n, k, a[N];
vector<int> son[N];
// returns the max dep of subtree
int dfs(int x, int d) {
  int mxd = d;
  for (int to : son[x]) {
    mxd = max(mxd, dfs(to, d + 1));
  }
  if (a[x] != 1 && mxd - d >= k - 1) {
    ++ ans;
    return 0;
  }
  return mxd;
}
int main(int argc, char const *argv[]) {
  n = read(); k = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
  }
  if (a[1] != 1) {
    ++ ans;
    a[1] = 1;
  }
  for (int i = 2; i <= n; ++ i) {
    son[a[i]].push_back(i);
  }
  dfs(1, 0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 12288
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
        self.rank = [0] * n
    def find(self, i):
        if self.parents[i] == i:
            return i
        else:
            #self.parents[i] = self.find(self.parents[i])
            #return self.parents[i]
            return  self.find(self.parents[i])
    def unite(self, i, j):
        pi = self.find(i)
        pj = self.find(j)
        if self.rank[pi] < self.rank[pj]:
            self.sizes[pj] += self.sizes[pi]
            self.parents[pi] = pj 
        else: 
            self.sizes[pi] += self.sizes[pj]
            self.parents[pj] = pi 
            if self.rank[pi] == self.rank[pj]:
                self.rank[pi] += 1
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.sizes[px] * uf.sizes[py]
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


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

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

    bool ans = false;

    rep(i, 26) {
        rep(j, 15) {
            if (N == 4 * i + 7 * j) {
                ans = true;
                break;
            }
        }
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m, q = list(map(int, input().split()))
lr = [[0 for i in range(501)] for i in range(501)]
for i in range(m):
  lt, rt = list(map(int, input().split()))
  lr[lt][rt] += 1
for i in range(1, 501):
  for j in range(1, 501):
    lr[i][j] += lr[i][j-1]
for i in range(q):
  lt, rt = list(map(int, input().split()))
  ans = 0
  for j in range(lt, rt+1):
    ans += lr[j][rt]-lr[j][j-1]
  print(ans)

Measured memory_bytes: 54180
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val b = readLine()!!.split(" ").map(String::toInt)

    println(op140c(n, b))
}

fun op140c(n: Int, b: List<Int>): Int {
    return (mutableListOf(b[0]) + b.mapIndexed { index, i ->
        when (index) {
            b.lastIndex -> b.last()
            else -> Math.min(b[index], b[index + 1])
        }
    }).sum()
}


Measured memory_bytes: 37904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    vector<string> v;
    rep(i, SZ(s)) {
        string tmp = s;
        rep(j, SZ(t)) {
            if (s[i + j] != t[j] && s[i + j] != '?') break;
            tmp[i + j] = t[j];
            if (j == SZ(t) - 1) {
                v.eb(tmp);
            }
        }
    }
    if (SZ(v) == 0) { out("UNRESTORABLE"); return 0; }
    sort(all(v));
    rep(i, SZ(v[0])) if (v[0][i] == '?') v[0][i] = 'a';
    out(v[0]);
}


Measured memory_bytes: 256
#include<stdio.h>
long int lbs(long int a){return a>0?a:-a;}
int main(){
  long int n,a[200000],k=0,s=0,i,m=1L<<60L;
  scanf("%ld",&n);
  for(i=0;i<n;i++){scanf("%ld",&a[i]);s+=a[i];}
  for(i=0;i<n;i++){k+=a[i];if(i+1<n)m=lbs(s-k*2L)<m?lbs(s-k*2L):m;}
  printf("%ld",m);
}


Measured memory_bytes: 1664
N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]
INF = 10**9
d = [[INF]*N for _ in [0]*N]
for i in range(N):
    d[i][i] = 0
for a,b,c in ABC:
    d[a-1][b-1] = c
    d[b-1][a-1] = c
def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
Warshall_Floyd(d,N)
print(sum(d[a-1][b-1]!=c for a,b,c in ABC))

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

using namespace std;

int main(void) {
  string w; cin >> w;
  
  bool isOdd[26];
  memset(isOdd, false, sizeof(isOdd));
  for (int i = 0; i < w.size(); i++) {
    isOdd[(int)(w[i]-'a')] = !isOdd[(int)(w[i]-'a')];
  }

  string ans = "Yes";
  for (int i = 0; i < 26; i++) {
    if (isOdd[i]) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.nextLine();
        String t = sc.nextLine();

        Map<Character, Character> m1 = new HashMap<>();
        Map<Character, Character> m2 = new HashMap<>();

        boolean ok = true;
        for (int i = 0; i < s.length(); i++) {
            if (m1.containsKey(s.charAt(i))) {
                if (m1.get(s.charAt(i)) != t.charAt(i)) {
                    ok = false;
                    break;
                }
            }
            else {
                m1.put(s.charAt(i), t.charAt(i));
            }

            if (m2.containsKey(t.charAt(i))) {
                if (m2.get(t.charAt(i)) != s.charAt(i)) {
                    ok = false;
                    break;
                }
            }
            else {
                m2.put(t.charAt(i), s.charAt(i));
            }
        }

        System.out.println(ok ? "Yes" : "No");

        sc.close();
    }
}

Measured memory_bytes: 27908
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b,c,d=map(int, readline().rstrip().split())
    tHP=a
    tATC=b
    aHP=c
    aATC=d
    while 1:
        aHP-=tATC
        if aHP<=0:
            print("Yes")
            return
        tHP-=aATC
        if tHP<=0:
            print("No")
            return
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16180
N, M = map(int, input().split())

if N % 2 == 1:
  for i in range(1,M+1):
    print(i, N-i)
else: # for an even N 
  for i in range(1, M+1):
    if i % 2 == 1:
      k = i // 2 
      print(k+1, N-k)
    else: # i%2=0
      k = i // 2
      print( N // 2 + k, N // 2 - k)

Measured memory_bytes: 9280
import sys
import bisect
from heapq import heappop, heappush, heapify
input = sys.stdin.readline
from itertools import chain
sys.setrecursionlimit(10**9)
N,Q= map(int,input().split())
STX = [list(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

inf = 10**15
TEMP = [[(s-x,True,x),(t-x,False,x)] for s,t,x in STX] + [[(-inf,True,inf),(inf,False,inf)]]
PFX = sorted(list(chain(*TEMP)))

addq = [inf]
delq = [inf+1]
D.append(inf)
iterD = iter(D)

d = next(iterD)
for p,f,x in PFX:
    while d < p:
        ans = addq[0] if not addq[0] == inf else -1
        print(ans)
        d = next(iterD)
        if d == inf:
            exit()
    if f:
        heappush(addq, x)
    else:
        heappush(delq, x)
    while addq[0] == delq[0]:
        heappop(addq)
        heappop(delq)






Measured memory_bytes: 194848
#include <stdio.h>

int main(void){
  int r,c,i,j;
  static int s[101][101];

  scanf("%d%d",&r,&c);

  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }

  return 0;
}


Measured memory_bytes: 2760
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N;
  int64 d1;
  int64 d10;
  int64 d100;

  get_N(&N);

  d1   = N%10;
  d10  = (N%100)/10;
  d100 = N/100;

  if ((d1   == 7) ||
      (d10  == 7) ||
      (d100 == 7)) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}



Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;

int main(){
  fast;
  string s;
  cin>>s;
  bool a0=0,b0=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a0 = 1;
    }else{
      b0=1;
    }
  }
  cout<<(b0 && a0 ? "Yes\n":"No\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    ll N;
    cin >> N;
    VLL X(N),Xt(N);
    rep(i,N){
        cin >> X.at(i);
        Xt[i]=X[i];
    }
    sort(all(Xt));
    rep(i,N){
        int target=X[i];
        if(N%2!=0){
            if(target==Xt[N/2]){
                cout << (Xt[N/2-1]+Xt[N/2+1])/2 << endl;            
            }
            else if(target>Xt[N/2]){
                cout << (Xt[N/2]+Xt[N/2-1])/2 << endl;
            }
            else{
                cout << (Xt[N/2]+Xt[N/2+1])/2 << endl;
            }
        }
        else{
            if(target==Xt[N/2]){
                cout << Xt[N/2-1] << endl;            
            }
            else if(target>Xt[N/2]){
                cout << Xt[N/2-1] << endl;
            }
            else{
                cout << Xt[N/2] << endl;
            }
        }
    }    
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int n, v[101010];
int occ[101010];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++)cin >> v[i];
    for(int i = 0; i < n; i += 2){
        occ[v[i]]++;
    }
    int m11 = -1, v11 = -1, m12 = -1, v12 = -1;
    for(int i = 0; i < 101010; i++){
        if(occ[i] > m11){
            m12 = m11;
            v12 = v11;
            m11 = occ[i];
            v11 = i;
        }
        else if(occ[i] > m12){
            m12 = occ[i];
            v12 = i;
        }
    }
    m11 = n / 2 + n % 2 - m11;
    m12 = n / 2 + n % 2 - m12;

    memset(occ, 0, sizeof occ);
    for(int i = 1; i < n; i += 2){
        occ[v[i]]++;
    }
    int m21 = -1, v21 = -1, m22 = -1, v22 = -1;
    for(int i = 0; i < 101010; i++){
        if(occ[i] > m21){
            m22 = m21;
            v22 = v21;
            m21 = occ[i];
            v21 = i;
        }
        else if(occ[i] > m22){
            m22 = occ[i];
            v22 = i;
        }
    }
    m21 = n / 2 - m21;
    m22 = n / 2 - m22;

    if(v11 != v21)cout << m11 + m21 << endl;
    else{
        if(m11 + m22 < m12 + m21)cout << m11 + m22 << endl;
        else cout << m12 + m21 << endl;
    }

}


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

int main() {
  // Collatz Problem
  int s; cin >> s;
  map<int,int> am;
  int n = s;
  int i=1, m = 0;
  while(i<=1000000) {
    am[n] = i;
    if (n % 2 == 0) n /= 2;
    else n = 3 * n + 1;
    i++;
    if (am.count(n)) {
      m = i;
      break;
    }
  }
  cout << m << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }

    int res = b[0];
    for (int i = 0; i < n-2; ++i) {
        res += min(b[i], b[i+1]);
    }
    res += b[n-2];

    cout << res << endl;
}

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

int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
	for(int j=0;j<s.size();j++){
      if( i == j ) continue;
	  if( s.at(i) == s.at(j) ){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
  return 0;
  
}

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

/*
#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

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        printf("%d\n",qu[i].ans);
    }
}


Measured memory_bytes: 35072
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(i, n) for(int i = n-1; i >= 0; i--)
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define rloop(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, val) memset(a, val, sizeof a);
#define test int t; cin>> t; while(t--)
#define all(v) v.begin(),v.end()
#define ll long long
#define ld long double
#define mp_ make_pair
#define pb push_back
#define sz(s) (int)s.size()
const int MAX = 1e5 + 5;
const int inf = 1e9+1;
const ll OO = 1e18;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
int n, k, a[MAX], dp[MAX];
int solve(int i = 0){
    if(i == n - 1) return 0;

    if(dp[i] < 1e9) return dp[i];

    int mn = inf;

    loop(j, i+1, i+k)
        if(j < n)
            mn = min(mn, solve(j) + abs(a[j] - a[i]));

    return dp[i] = mn;
}
int main()
{
    cin>> n >> k;
    lp(i, n)
        cin>> a[i];

    mem(dp, 63);
    cout<< solve() <<"\n";

    return 0;
}


Measured memory_bytes: 9008
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
long long pp[100005];
main()
{
	int t,p;
	long long w,v;
	scanf("%d%d",&t,&p);
	for(int i = 1;i <= 100004;i++)
	{
		pp[i]=1e14;
	}
	for(int i = 0;i < t;i++)
	{
		scanf("%lld%lld",&w,&v);
		for(int j = 100004;j >= 0;j--)
		{
			if(j+v<=100004)
			pp[j+v]=min(pp[j+v],pp[j]+w);
		}
	}
	long long mx=0;
	for(int i = 0;i <= 100004;i++)
	{
		if(pp[i]<=p)
		mx=max(mx,(long long)i);
	}
	printf("%lld",mx);
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int sheeps = sc.nextInt();
        int wolves = sc.nextInt();
        System.out.println(sheeps <= wolves ? "unsafe" : "safe");
    }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int gcd (int a, int b) {
  int d=a;
  if (b!=0) {
    d=gcd(b, a%b);
  }
  return d;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> T(N);
  for (int i=0; i<N; i++) {
    cin >> T[i];
  }
  
  ll s=1;
  for (int i=0; i<N; i++) {
    s=lcm(T[i], s);
  }
  cout << s << endl;
}
 

Measured memory_bytes: 3612
a, b, c, k = map(int, input().split())
if k%2==0:
    if b-a < 10**18:
        print(a-b)
    else:
        print("Unfair")
else:
    if a-b < 10**18:
        print(b-a)
    else:
        print("Unfair")

Measured memory_bytes: 38256
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {
	int x[10][10] = {};
	int n, d,count=0; cin >> n >> d;
	for (int i = 0; i < n; ++i) {
		float distance = 0;
		for (int j = 0; j < d; ++j) {
			cin >> x[i][j];
			/*if (i == 0)continue;
			distance+=pow(x[i-1][j] - x[i][j],2);
		}
		cout << pow(distance, 0.5) << endl;
		if(pow(distance,0.5)==floor(pow(distance, 0.5))) count++;
	}
	int distance = 0;
	for (int j = 0; j < d; ++j) {
		distance += pow(x[n-1][j] - x[0][j], 2);
	}
	if (pow(distance, 0.5) == floor(pow(distance, 0.5))) count++;
	*/
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j =  1; j < n-i; ++j) {
			float distance=0;
			for (int g = 0; g < d; ++g) {
				distance += pow(x[i+j][g] - x[i][g], 2);

			}
			//cout << pow(distance, 0.5) << endl;

			if (pow(distance, 0.5) == floor(pow(distance, 0.5))) count++;

		}
	}
	cout << count << endl;


	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	double ans=0;
	for (int i=1; i <= n; ++i){
        int t = i, p = 1;
        while (t < k){
            t <<= 1;
            p <<= 1;
        }
        ans += 1.0 / n / p;
	}
	printf("%.12f\n",ans);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

int main() {
    ios::sync_with_stdio(false);
    int l;
    cin >> l;
    double d = (double)l / 3.0;

    printf("%.10f\n", d * d * d);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long gcd(long long i,long long j){
    if(j==0){
        return i;
    }else{
        return gcd(j,i%j);
    }
}
int main(void){
    long long N,M; cin>>N>>M;
    string S,T; cin>>S>>T;
    long long a=gcd(N,M);
    long long b=N*M/a;
    for(int i=0;i<a;i++){
        if(S[i*b/M]!=T[i*b/N]){
            cout<<-1<<endl; 
            return 0;
        }
    }
    cout<<b<<endl;
    
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll a[N];
  ll sum = 0;
  for(int i=0;i<N;++i) {
    cin>>a[i];
    sum ^= a[i];
  }
  for(int i=0;i<N;++i) {
    cout<<(sum^a[i])<<" ";
  }
  cout<<endl;
}



Measured memory_bytes: 5124
n,m,v[10000],w[2500],W[2500],o;x,y,r;F(a,b){r=1;for(b=m;b--;)for(a=m;a--;)if(~w[a+m*b]&&v[x+a+n*(y+b)]-w[a+m*b])r=0;}main(d,t,f){for(;scanf("%d%d",&n,&m)*n;printf(f<n*n?"%d %d\n":"NA\n",1+f%n,1+f/n)){for(f=0;f<n*n;f++)scanf("%d",v+f);for(x=0;x<m*m;x++)scanf("%d",w+x);for(d=4;d--;){memcpy(W,w,4*m*m);for(x=m*m;x--;o=~w[x]?x:o)w[x]=W[m-1-x/m+x%m*m];for(y=0;y+m<=n;y++)for(x=0;x+m<=n;x++)if(F(),r&&(t=x+o%m+(n+o/m)*y)<f)f=t;}}}

Measured memory_bytes: 472
can = (1,1,1)
cca = (2,1,0)
ccc = (3,0,0)

sb (a,b,c) (d,e,f) = (a-d,b-e,c-f)
ml n (a,b,c) = (n*a,n*b,n*c)

dv x@(a,b,c) y@(d,e,f) =
  if a>=d && b>=e && c>=f
  then 1 + dv (sb x y) y
  else 0

ans a =
  let n1 = dv a  can
      r1 = sb a  $ ml n1 can
      n2 = dv r1 cca
      r2 = sb r1 $ ml n2 cca
      n3 = dv r2 ccc
      r3 = sb r2 $ ml n3 ccc
  in
    n1+n2+n3

main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      i'= map (\[a,b,c] -> (a,b,c)) i
      o = map ans i'
  mapM_ print o

Measured memory_bytes: 4184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int K = Int32.Parse(args[1]);
		Dictionary<int,int> dict = new Dictionary<int,int>(N);

		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
		{
			int A = Int32.Parse(args[i]);
			int num = 0;
			dict.TryGetValue(A, out num);
			dict[A] = num + 1;
		}

		List<int> nums = new List<int>(N);
		foreach(int key in dict.Keys)
		{
			nums.Add(dict[key]);
		}
		nums.Sort((x,y) => y - x);

		int sum = 0;
		for(int i = 0; i < K; i++)
		{
			sum += nums[i];
			if(sum == N)
				break;
		}
		Console.WriteLine(N - sum);
	}	
}





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

int main(){
  int N, a, b, ans, s, t;
  cin >> N;
  vector<int> A, B;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ans = 0;
  vector<int>::iterator itr1, itr2;
  for (int i = N + 1; i > 0; --i) {
    itr1 = lower_bound(A.begin(),A.end(),i+1);
    itr2 = lower_bound(B.begin(),B.end(),i);
    s = distance(A.begin(), itr1);
    t = distance(B.begin(), itr2);
    if (s-t >= i-1) {
      ans = i-1;
      break;
    }
  }
  cout << ans << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}
template<class T>bool chmin(T &a, const T &b) {return (b<a)?(a=b,1):0;}
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}

using R=long double; // __float128
const R EPS = 1E-11; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

using P=complex<R>;
using VP=vector<P>;
using L=struct{P s,t;};
using VL=vector<L>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

namespace std{
	bool operator <  (const P& a,const P& b){ return sgn(real(a-b))?real(a-b)<0:sgn(imag(a-b))<0;}
	bool operator == (const P& a,const P& b){ return sgn(real(a-b))==0 && sgn(imag(a-b))==0;}
}

inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

P cross(L a,L b){
	R s1=det(a.s,b.s,b.t);
	R s2=s1+det(a.t,b.t,b.s);
	return a.s+s1/s2*(a.t-a.s);
}

int main(void){
	int n;
	while(cin >> n,n){
		VL lines;
		
		rep(i,n){
			P a,b;
			cin >> a >> b;
			lines.push_back({a,b});
		}

		int ans=1;
		rep(j,n){
			VP cross_ponit;
			rep(i,j){
				P p=cross(lines[i],lines[j]);
				if(sgn(real(p)+100.0)<=0 ||sgn(real(p)-100.0)>=0) continue;
				if(sgn(imag(p)+100.0)<=0 ||sgn(imag(p)-100.0)>=0) continue;
				cross_ponit.push_back(p);
			}
			uniq(cross_ponit);
			ans+=1+int(cross_ponit.size());
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i *= 2)
		if (i == n) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	cout << "1 2\n2 3\n";
	cout << 3 << ' ' << n + 1 << endl;
	cout << n + 1 << ' ' << n + 2 << endl;
	cout << n + 2 << ' ' << n + 3 << endl;
	for (int i = 4; i + 1 <= n; i += 2)
	{
		printf("%d %d\n", i, i + 1);
		printf("%d %d\n", n + 1, i + 1);
		printf("%d %d\n", n + i, n + i + 1);
		printf("%d %d\n", n + 1, n + i);
	}
	if (!(n & 1))
	{
		int i = 1;
		while (i * 2 <= n)i *= 2;
		cout << n << ' ' << n+i << endl;
		i ^= n ^ 1;
		cout << n + n << ' ' << i << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
N, K = map(int, input().split())

ans = 0
if K == 0:
    ans = N * N
else:
    for i in range(K+1, N+1):
        hoge = N // i
        ans += (i - K) * hoge
        fuga = N % i
        ans += max(0, fuga-K+1)

print(ans)


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

int main(void)
{
  int a;
  cin >> a;
  vector<int> data(a);
  for(int i = 0; i < a; i++)
  {
    cin >> data[i];
  }
  int res = 0;
  int cnt = 0;
  for(int i = 0; i < a - 1; i++)
  {
    if(data[i] >= data[i+1])
    {
      cnt++;
    }else{
       if(cnt > res)
      {
        res = cnt;
      }
      cnt = 0;
    }
  }
  if(cnt > res)
    res = cnt;
  cout << res << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
constexpr int MAX = 200200;
constexpr int MOD = 1000000007;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

struct Combination {
    vector<ModInt<MOD>> fact;
    Combination(int n) : fact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i-1] * i);
        }
    }
    ModInt<MOD> operator() (int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]/(fact[n-r]*fact[r]);
    }
};

int main() {
    using mint = ModInt<MOD>;
    Combination com(MAX);
    long long n, m, k;
    cin >> n >> m >> k;
    
    mint ans = 0;
    for (int _ = 0; _ < 2; _++) {
        for (int d = 1; d < n; d++) {
            mint res = ((n - d) * m * m);
            res *= com(n * m - 2, k - 2);
            ans += (res * d);
        }
        swap(n, m);
    }
    
    cout << ans << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        string s; cin >> s;
        if (s.back() == 's') s += "e";
        s += "s";
        cout << s;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  for (auto &z: p) cin >> z;
  for (auto &z: q) cin >> z;
  for (auto &z: r) cin >> z;

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());

  priority_queue<ll, vector<ll>, greater<ll> > pque, qque;
  for (int i = 0; i < x; i++) pque.push(p[i]);
  for (int i = 0; i < y; i++) qque.push(q[i]);
  for (int i = 0; i < c; i++) {
    ll pmin = pque.top();
    ll qmin = qque.top();
    if (pmin < qmin) {
      if (pmin < r[i]) {
        pque.pop();
        pque.push(r[i]);
      }
      else break;
    }
    else {
      if (qmin < r[i]) {
        qque.pop();
        qque.push(r[i]);
      }
      else break;
    }
  }

  ll ans = 0;
  while (!pque.empty()) {
    ll now = pque.top();
    pque.pop();
    ans += now;
  }
  while (!qque.empty()) {
    ll now = qque.top();
    qque.pop();
    ans += now;
  }

  cout << ans << endl;

  return 0;
}


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

const int N = 110;

char str[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	cin >> str;
	int len = strlen(str);
	str[len - 8] = 0;
	cout << str << "\n";
	
	return 0;
}


Measured memory_bytes: 3548