akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int f;
    int g;
    int h;

    int w = 10*a+b+c;
    int x = a+(10*b+c);
    int y = 10*c+b+a;
    int z = c+(10*b+a);

    f = Math.max(w,x);
    g = Math.max(f,y);
    h = Math.max(g,z);

    System.out.println(h);

  }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	ll n, k, x[50], y[50], a, b, c, d, e, x1, x2, y1, y2, s, m, x3, y3, f = 0;

	cin >> n >> k;
	for (a = 0; a < n; a++) {
		cin >> x[a] >> y[a];
	}

	for (a = 0; a < n - 1; a++) {
		for (b = a + 1; b < n; b++) {
			for (c = 0; c < n - 1; c++) {
				for (d = c + 1; d < n; d++) {
					x1 = min(x[a], x[b]);
					x2 = max(x[a], x[b]);
					y1 = min(y[c], y[d]);
					y2 = max(y[c], y[d]);

					s = 0;
					for (e = 0; e < n; e++) {
						if (x1 <= x[e] && x[e] <= x2 && y1 <= y[e] && y[e] <= y2) {
							s++;
						}
					}

					if (s >= k) {

						x3 = x2 - x1;
						y3 = y2 - y1;
						if (x3 < 0) {
							x3 = -x3;
						}
						if (y3 < 0) {
							y3 = -y3;
						}

						if (f == 0) {
							m = x3 * y3;
							f = 1;
						}
						else {
							m = min(x3 * y3, m);
						}
					}
				}
			}
		}
	}

	cout << m << endl;

	return 0;
}

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

int main(){
  long n,m = 0,a = 0,r = 0,c = 0,h = 0;
  cin >> n;
  vector<string> s(n);
  for(long i = 0;i < n;i++){
    cin >> s.at(i);
    if(s.at(i).at(0) == 'M'){
      m++;
    }
    if(s.at(i).at(0) == 'A'){
      a++;
    }
    if(s.at(i).at(0) == 'R'){
      r++;
    }
    if(s.at(i).at(0) == 'C'){
      c++;
    }if(s.at(i).at(0) == 'H'){
      h++;
    }
  }
  long kekka = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  cout << kekka << endl;
}
  
  

Measured memory_bytes: 6144
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
a4, b4 = map(int, input().split())
a5, b5 = map(int, input().split())
a6, b6 = map(int, input().split())
a7, b7 = map(int, input().split())

print(a1-b1)
print(a2-b2)
print(a3-b3)
print(a4-b4)
print(a5-b5)
print(a6-b6)
print(a7-b7)


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

using namespace std;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    for (int cnt = 0; cnt <= x; ++cnt) {
        if (2 * cnt + 4 * (x - cnt) == y) {
            cout << "Yes";
            exit(0);
        }
    }
    cout << "No";
    return 0;
}



Measured memory_bytes: 3656
#include <stdio.h>
#include <math.h>

int main() {

  double a,b,c;
  double S,L2, L, h;

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

  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;

  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {
 
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n)    cin >> a.at(i);
    rep(i,n)    cin >> b.at(i);
 
    ll ac=0,bc=0;
    rep(i,n) {
        if(a[i]<b[i]) {
            ll c=b[i]-a[i];
            if(c%2==0) {
                ac+=c/2;
            }
            else {
                ac+=((c+1)/2);
                bc++;
            }
        }
        else    bc+=(a[i]-b[i]);
    }
 
    if(ac>=bc)  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
 
 return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int c[15],x[15][15],now[15]; 
int n,m,need,ans=1e9;
void dfs(int step,int sum){
	if(step>n){
		for(int i=1;i<=m;i++)
		if(now[i]<need)
		return ;
		ans=min(ans,sum);
		return ;
	}
	dfs(step+1,sum);
	for(int i=1;i<=m;i++)
	now[i]+=x[step][i];
	dfs(step+1,sum+c[step]);
	for(int i=1;i<=m;i++)
	now[i]-=x[step][i];
}
int main(){
	cin>>n>>m>>need;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++)
		cin>>x[i][j]; 
	}
	dfs(1,0);
	if(ans!=1e9)
	cout<<ans;
	else
	cout<<-1;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n);
    //10^6orderで以上長さlistの作成
    int m[1002];
    m[0]=0;
    long long int cnt=n;
    int k=0;
    for(int i=1;i<1002;i++){
        while(i>l[k]&&k<n){
            cnt--;
            k++;
        }
        m[i]=cnt;
    }
    cnt=0;
    //10^6orderで組み合わせ.ただし最長が同じ長さのものは除く
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(l[i]+l[j]>1000){
                cnt=cnt+m[l[j]+1];
            }
            else{
                cnt=cnt+m[l[j]+1]-m[l[i]+l[j]];
            }
        }
    }
    //最長が同じものを計算
    long long int x=0;
    for(int i=2;i<1001;i++){
        x=m[i]-m[i+1];
        if(x>1){
            //長さiのものが2本以上
            cnt=cnt+(n-m[i])*x*(x-1)/2;
            //長さi未満
        }
    }
    //全て同じ長さを計算
    for(int i=1;i<1001;i++){
        x=m[i]-m[i+1];
        if(x>2){
            cnt=cnt+x*(x-1)*(x-2)/6;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    ans = 0

    for i, j, k in itertools.product(range(a+1), range(b+1), range(c+1)):
        if 500*i + 100*j + 50*k == x:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  set<int> a;
  bool flag = true;
  rep(i, n) {
    int temp;
    cin >> temp;
    flag &= a.count(temp) == 0;
    a.insert(temp);
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define ffor(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) ffor(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define TC(t) while (t--) 
#define N 200005
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 

ll binpow(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1) res = (res*x)%MOD;
        y= y>>1;
        x = (x*x)%MOD;
    }
    return res%MOD;
}

int main(){
    fast;
    ll l,r,i,j,m,k,a,b,c,q,t,x,y,d,n;
    cin>>n;
    vl v(n+1);
    rep(i,n-1){
        cin>>j;
        v[j]++;
    }
    rep(i,n) pp(v[i+1]);
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int x,y,z;
  x = a-b;
  y = a+b;
  z = a*b;
  if(x >= y && x >= z){
    cout << x << endl;
  }
  else if(y >= x && y >= z){
    cout << y << endl;
  }
  else if(z >= x && z >= y){
    cout << z << endl;
  }
  
  return 0;
}

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

using namespace std;

int main() {
    unsigned long n;
    vector<unsigned long> vec;
    string s;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s;
        vec.push_back(atoi(s.c_str()));
    }

    unsigned long result = 0;
    for (int i = 1; i < (int)vec.size(); i++) {
        int buf = vec[i - 1] - vec[i];
        if (buf > 0) {
            result += buf;
            vec[i] += buf;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5336
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll f(ll n) {
    if(n%2 == 0) {
        return n/2;
    }
    else {
        return 3*n + 1;
    }
}

int main() {
    ll s;
    cin >> s;

    set<ll> st;
    ll a = s;
    st.insert(a);
    for(ll i = 2; ; i++) {
        a = f(a);
        st.insert(a);
        if(st.size() < i) {
            out(i);
            re0;
        }
    }

    re0;
}

Measured memory_bytes: 256
#include<stdio.h>
int LinearSearch(int);
int N,A[10000];
int main(){
  int i,M,key,l=0,c;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&key);
    c=LinearSearch(key);
    if(c>=0 && c<=10000)
      l++;
  }
  printf("%d\n",l);
  return 0;
}

int LinearSearch(int key){
  int i;
  for(i=0;i<N-1;i++){
    if(A[i]==key) return i;
  }
  if(A[N-1]!=key) return -1;
}

Measured memory_bytes: 632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


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


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  long int n,x,m;
  scanf("%ld%ld%ld",&n,&x,&m);

  if(x==1){
    printf("%ld\n",n);

    return 0;
  }

  long int A[m];
  long int B[m];
  for(int i=0;i<m;i++){
    A[i]=0;
    B[i]=0;
  }

  A[0]=x;
  B[x]++;

  int zero=0;
  int roopP=m;
  int roopV=0;

  long int all=0;
  for(int i=1;i<m;i++){
    A[i]=modpow(A[i-1],2,m);
    B[A[i]]++;
    all+=A[i];

    if(A[i]==0){
      zero=1;
      break;
    }

    if(B[A[i]]==2){
      roopP=i;
      roopV=A[i];
      break;
    }
  }


  long int ans=0;
  if(n<=m){
    for(int i=0;i<n;i++){
      ans+=A[i];
    }

    printf("%ld\n",ans);
    
    return 0;
  }

  if(zero==1){
    for(int i=0;i<m;i++){
      ans+=A[i];
    }

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

    return 0;
  }

  int l=-1,r=-1;
  for(int i=0;i<m;i++){
    if(A[i]==roopV && l==-1){
      l=i;
      continue;
    }

    if(A[i]==roopV && r==-1){
      r=i;
    }
  }

  for(int i=0;i<l;i++){
    ans+=A[i];
  }

  n-=l;

  if(roopP!=m){
    all=0;
    for(int i=l;i<r;i++){
      all+=A[i];
    }
  }

  ans+=(n/(r-l))*all;
  n%=(r-l);

  for(int i=l;i<l+n;i++){
    ans+=A[i];
  }

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

  return 0;
}

Measured memory_bytes: 3292
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> s = nextCharArray();
      long output = 0;
      int count = 0;
      for(int i = 0; i < s.size(); i++){
        if(s.get(i).equals("B")){
          count++;
        }else{
          output += count;
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

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

  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }

  int sum = 0;
  for(int x : A){
    sum += x;
  }

  cout << (sum >= H ? "Yes" : "No") << endl;

}


Measured memory_bytes: 640
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, ans;
string s;

int main() {
    fast_io; cout_precision;
    cin >> n >> s;
    ans = 0;
    for (ll i = 0, x = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
C = Counter(D)

if D[0] != 0 or C[0] != 1:
    print(0)
    exit()

pat = 1
for i in range(1,max(D)+1):
    if C[i] == 0:
        print(0)
        exit()
    for _ in range(C[i]):
        pat *= C[i-1]
        pat %= 998244353

print(pat)


Measured memory_bytes: 19936
a, b, c, d = map(int, input().split())
if c%b ==0 :
    e = c//b - 1
else:
    e = c//b
    
if a%d ==0:
    f = a//d 
else:
    f = a//d +1
if f >e:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
//4/
typedef unsigned long long ull;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i < (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fill_2(a,b)  memset(a, 0, sizeof (a));memset(b, 0, sizeof (b));
#define fill_n(a) memset(a,-1,sizeof(a))
#define fst first
#define snd second
#define mpr make_pair
#define pb push_back
#define mod 1000000007
#define endl "\n"
//#define int long long
 
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> pip;
typedef pair<pii, ll> ppi;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<ll,ll> mpl;
 
inline ll exp(ll x,ll n){ll r=1;x=x%mod;while(n){if(n%2)r=(r*x)%mod;x=(x*x)%mod;n=n/2;}return r;}
inline ll mmi(ll a){return exp(a,mod-2)%mod;}
inline ll fact(ll n){ll res=1;repA(i,1,n+1){res=(res*i)%mod;}return res;}
inline ll inv_fact(ll n){ll par=fact(n);ll res=mmi(par);return res;}

struct triplet{ll a,b,c;};
bool operator < (const triplet &t1,const triplet &t2){
	if(t1.a<t2.a)return true;
	if(t1.a==t2.a && t1.b <t2.b)return true;
	if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)
		return true;return false;}
 

pair<ll,pii > ex_gcd(ll a,ll b)
{   if(b==0){return mpr(a,mpr(1,0));}
    pip p=ex_gcd(b,a%b);
	ll gcd=p.fst;ll x1=p.snd.fst;ll y1=p.snd.snd;
    ll x=y1;ll y=x1-(a/b)*y1;
	return mpr(gcd,mpr(x,y));
} 


int main()
{
	IOS;
	ll k,n;
	cin>>k>>n;
	ll a[n];
	repA(i,0,n)  cin>>a[i];
	vi v;
	v.pb(k-a[n-1]+a[0]);
	repA(i,1,n)
	{
		v.pb(a[i]-a[i-1]);
	}
	sort(v.rbegin(),v.rend());
	cout<<k-v[0]<<endl;
}

Measured memory_bytes: 3956
n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]

q, k = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(q)]

inf = 10 ** 18
connect = [{} for _ in range(n)]
for a, b, c in edge:
    connect[a-1][b-1] = c
    connect[b-1][a-1] = c

k -= 1

dis = [inf] * n
dis[k] = 0
search = {k}
ng = set()
while search:
    v = search.pop()
    for w, c in connect[v].items():
        if w not in ng:
            dis[w] = c + dis[v]
            search.add(w)
    ng.add(v)

for x, y in query:
    print(dis[x-1] + dis[y-1])

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

int main() {
  string str;
  int t;
  map<string, vector<int>, less<string> > mp;
  
  for(;cin>>str>>t;mp[str].push_back(t));
  
  for(map<string, vector<int> >::iterator it=mp.begin();it!=mp.end();it++) {
      cout << (*it).first << endl;
      sort((*it).second.begin(), (*it).second.end());
      for(int i=0;i<(*it).second.size()-1;i++) {
	cout << (*it).second[i] << " ";
      }
      cout << (*it).second[(*it).second.size()-1] << endl;
    }
	
  return 0;
}

Measured memory_bytes: 1244
N = gets.to_i
A = gets.split.map(&:to_i)
A << 0
x = 1000
y = 0
N.times{|d|
    if A[d] < A[d + 1]
        a = x / A[d]
        y += a
        x -= a * A[d]
    elsif A[d] > A[d + 1]
        x += y * A[d]
        y = 0
    end
}
puts x


Measured memory_bytes: 14344
package main

import (
	"fmt"
	"math"
)

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	if A-K >= 0 {
		fmt.Println(A-K, B)
	} else {
		fmt.Println(0, max(0, B-(K-A)))
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> sum1(n + 1), sum2(n + 1);
    sum1[0] = sum2[0] = 0;
    for (int i = 0; i * 2 < n - 2; i++) {
        sum1[i + 1] = sum1[i] + a[2 * i];
        sum2[i + 1] = sum2[i] + a[2 * i + 1];
    }
    for (int i = 0; i < n; i++) {
        int ans;
        if (i == 0) {
            ans = (sum1[(n - 1) / 2] - sum1[1]) -
                  (sum2[(n - 1) / 2] - sum2[0]) + a[0] + a[n - 1];
        } else if (i == n - 1) {
            ans = (sum2[(n - 1) / 2 - 1] - sum2[0]) -
                  (sum1[(n - 1) / 2] - sum1[0]) + a[n - 1] + a[n - 2];
        } else if (i % 2) {
            ans = (sum1[i / 2] - sum1[0]) +
                  (sum2[(n - 1) / 2] - sum2[(i + 1) / 2]) -
                  (sum1[(n - 1) / 2] - sum1[(i + 1) / 2]) -
                  (sum2[i / 2] - sum2[0]) - a[n - 1] + a[i] + a[i - 1];
        } else {
            ans = (sum1[(n - 1) / 2] - sum1[i / 2 + 1]) +
                  (sum2[(i - 1) / 2] - sum2[0]) - (sum1[i / 2] - sum1[0]) -
                  (sum2[(n - 1) / 2] - sum2[i / 2]) + a[n - 1] + a[i] +
                  a[i - 1];
        }
        cout << ans << " ";
    }
    cout << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,k;
int l[200005],r[200005];
 
int dp[2000005];
 
int main() {
  scanf("%d %d",&n,&k);
  for(int i=1;i<=k;i++) {
    scanf("%d %d",&l[i],&r[i]);
  }
  dp[1]=1;
  dp[2]=-1;
  for(int i=1;i<=n;i++) {
    dp[i]=(dp[i]+dp[i-1])%mod;
    for(int j=1;j<=k;j++) {
      dp[i+l[j]]=(dp[i+l[j]]+dp[i])%mod;
      dp[i+r[j]+1]=(dp[i+r[j]+1]-dp[i]+mod)%mod;
    }
  }
  printf("%d",dp[n]);
  return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
//int g(int x){
//	x=modpow(x,MOD-2);
//	return x;
//}
string s;
int k;
int func(string x){
	int ans=0;
	int now=1;
	int cnt=1;
	while(now<x.size()){
		if(x[now]==x[now-1])cnt++;
		else{
			ans+=cnt/2;
			cnt=1;
		}
		now++;
	}
	ans+=cnt/2;
	return ans;
}
signed main(){
	cin>>s>>k;
	bool flag=1;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1])flag=false;
	}
	if(flag){
		cout<<s.size()*k/2<<endl;
		return 0;
	}
	string t=s+s;
	int a=func(s);
	int b=func(t);
	cout<<a+(b-a)*(k-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
    val n = readLine()!!.takeLast(1).toInt()
    if (n==2||n==4||n==5||n==7||n==9) {
        println("hon")
    } else if (n==0||n==1||n==6||n==8) {
        println("pon")
    } else {
        println("bon")
    }
}

Measured memory_bytes: 35900
n = int(input())
aas = list(map(int, input().split()))
cnts = [0]*(n+1)
for i in range(n):
    cnts[aas[i]] += 1
t = 0
for i in range(1,n+1):
    tmp = cnts[i]
    t += tmp*(tmp-1)//2
for i in range(n):
    tmp = cnts[aas[i]]
    print(int(t-tmp*(tmp-1)/2*(1-1/tmp*(tmp-2))))

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 2007
#define MAX_M 300007
#define V std::vector

int N, M, cur;
int cnt[MAX_N][MAX_N], vis[MAX_N];
bool con[MAX_N][MAX_N];
V<int> G[MAX_N];

struct edge{
    int u, v;
}e[MAX_M];

void dfs(int x, int s, int S) {
    if (cnt[S][x] > 1 || vis[x] == cur) return;
    con[S][x] = true;
    cnt[S][x]++;
    if (cnt[S][x] == 1) vis[x] = cur;
    for(int y : G[x]) 
        if (cnt[S][y] < 2 && y != s) {
            dfs(y, s, S);
        }
}

void solve() {
    Rep(i, M) {
        int u = e[i].u, v = e[i].v;
        bool flga = con[v][u], flgb = (cnt[u][v] > 1);
        puts((flga ^ flgb) ? "diff" : "same");
    }
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(M);
    int u, v;
    Rep(i, M) {
        read(u), read(v);
        e[i] = (edge){u, v};
        G[u].push_back(v);
    }
    Rep(i, N) {
        cnt[i][i] = 10000;
        for (int j : G[i]) 
            ++cur, dfs(j, j, i);
    }
    solve();
    return 0;
}


Measured memory_bytes: 16640
s = input()
if s != s[::-1]:
    print('No')
    exit()
n = len(s)
s1 = s[:((n-1)//2)]
s2 = s[((n+3)//2)-1:n]
if s1 != s1[::-1] and s2 != s2[::-1]:
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 9076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

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

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
/*		FastScanner sc = new FastScanner("6 6 \r\n" +
				"..#..#\r\n" +
				"......\r\n" +
				"#..#..\r\n" +
				"......\r\n" +
				".#....\r\n" +
				"....#.");*/
    	//FastScanner sc = new FastScanner("1000000000000");
		//long n = Long.parseLong(sc.next());
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		PrintWriter out = new PrintWriter(System.out);
		//for(long i = 1; i < n; i++)
		//{
		//	if(n/i==n%i)
		//	{
		//		out.println(n + ":" + i + ":" + n/i + ":" + n%i+":"+ (n/(n%i)-1));
		//	}
		//}
		int l = 1;
		int r = n;
		int nl;
		int nr;
		for (int i = 0; i < m; i++)
		{
			nl = Integer.parseInt(sc.next());
			nr = Integer.parseInt(sc.next());
			if(nl > l)
			{
				l = nl;
			}
			if(nr < r)
			{
				r = nr;
			}
		}

		if (r-l>=0) 
		{
			out.println(r-l+1);
		}
		else
		{
			out.println(0);
		}
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  vector<int> v;
  rep(i, n) v.eb(i);

  double sum = 0;

  do {
    rep(i, n - 1) {
      int xx = x[v[i + 1]] - x[v[i]];
      int yy = y[v[i + 1]] - y[v[i]];
      sum += sqrt(xx * xx + yy * yy);
    }
  } while (next_permutation(all(v)));

  rep(i, n) sum /= (i + 1);

  printf("%.10f\n", sum);
}


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

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// end of #define 

// define globals ...


//write function from here ...



int Main(){


int n;
cin>>n;
string s;
cin>>s;

vector < int > cnt(n+1,0);

for(int i = n-1;i>=0;i--)
{
	cnt[i]= cnt[i+1];
	
	if(s[i]=='R')
	cnt[i]+= 1;
	
}

int check =0 ;
for(int i=0;i<n;i++)
{
	cnt[i]-=check;
	if(s[i]=='W')
	{
		if(cnt[i]>0)
		check++;
	}
	
	
}

cout<<check<<endl;




return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 4400
#include<iostream>
#include<cstring>
#define INF 1000001
using namespace std;
int main(){
	int m,n;
	bool HAM[INF];
	memset(HAM,false,sizeof(HAM));
	for(int i=1;i<INF;i*=2){
		for(int j=i;j<INF;j*=3){
			for(int k=j;k<INF;k*=5){
				HAM[k] = true;
			}
		}
	}
	while(cin >> m&&m){
		cin >> n;
		int cnt=0;
		for(int i=m;i<=n;i++){
			if(HAM[i]) cnt++;
		}
		cout << cnt << endl;
	}
}

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

int main()
{
    int yy, mm, dd;
    char c1, c2;
    cin >> yy>>c1>>mm>>c2>>dd;

    if (mm>4){
        cout << "TBD" << endl;
        
    }
    else{
        cout << "Heisei" << endl;
    }

}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def f(x):
    cnt = 0
    while True:
        if x%2:
            return cnt
        else:
            x //= 2
            cnt += 1
n = inp()
a = inpl()
res = 0
for i in a:
    res += f(i)
print(res)

Measured memory_bytes: 42092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    int n;
    int a[200005], b[200005];
    cin >> n;
    rep(i, n) {
        cin >> a[i + 1] >> b[i + 1];
    }
    sort(a + 1, a + n + 1), sort(b + 1, b + n + 1);
    if (n % 2 == 1) {
        cout << abs(b[(n + 1) / 2] - a[(n + 1) / 2]) + 1 << endl;
    }
    else {
        cout << abs((a[n / 2] + a[n / 2 + 1]) - (b[n / 2] + b[n / 2 + 1])) + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 6736
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        Array.Sort(s);
        bool f = s[0] == s[1] && s[2] == s[3] && s[1] != s[2];
        Console.WriteLine(f ? "Yes" : "No");
    }
}

Measured memory_bytes: 13396
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#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 <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    int A = N%10;
    if(A == 2 || A == 4 || A == 5 || A == 7 || A == 9) cout << "hon" << endl;
    else if(A == 0 || A == 1 || A == 6 || A == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>

int main(){
   std::string S;
   std::cin >> S;
   size_t N = S.size();
   int min = 753;
   for (int i=0; i<=N-3; i++){
      std::string subS = S.substr(i, 3);
      int X = atoi(subS.c_str());
      int tmp = std::abs(X - 753);
      min = std::min(min, tmp);
   }
   std::cout << min << std::endl;

}



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

string S="AKIHABARA";
signed main(){
	int c=0;
	string a;cin>>a;
    for(int i=0;i<9;i++){
		if(S[i]==a[c]){c++;}
		else if(S[i]=='A'){}
		else {puts("NO");return 0;}
		}
	if(c!=a.length()){puts("NO");return 0;}	
	puts("YES");	
	}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

LL a, b, n;

int main() {
    cin >> a >> b >> n;
    if (n >= b) n = b - 1;
    cout << a * n / b << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int n, m, q;

int a[50];
int b[50];
int c[50];
long long d[50];

int ases[11];

long long answer = 0;


void Calculate(vector<int> aaa, int index) {

	if (index == 1) {
		for (int i = 1; i <= m; i++) {
			aaa[index] = i;
			Calculate(aaa, 2);
		}
		return;
	}
	else if (index < n) {
		for (int i = aaa[index - 1]; i <= m; i++) {
			aaa[index] = i;
			Calculate(aaa, index + 1);
		}
		return;
	}
	else {
		for (int i = aaa[index - 1]; i <= m; i++) {
			aaa[index] = i;

			long long ans = 0;
			for (int j = 0; j < q; j++) {
				if (aaa[b[j]] - aaa[a[j]] == c[j]) {
					ans += d[j];
				}
			}

			answer = max(answer, ans);
		}

	}
}

int main()
{
	cin >> n >> m >> q;


	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	vector<int> aaa(n + 1);

	Calculate(aaa, 1);
	
	cout << answer << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	REP(i,N){
		string S=in<string>();
		reverse(ALL(S));
		string T=in<string>();
		reverse(ALL(T));
		int SN=S.size(),TN=T.size();
		if(SN>TN){
			REP(j,SN-TN) T.push_back('0');
		}
		else{
			REP(j,TN-SN) S.push_back('0');
		}
		SN=S.size();
		if(SN>80){
			out("overflow");
			continue;
		}
		bool flag = SN==80?true:false,overflow=false;
		string R(SN+1,'0');
		REP(j,SN){
			int v=(S[j]-'0')+(T[j]-'0')+(R[j]-'0');
			if(v>9){
				if(j==SN-1 && flag){
					overflow = true;
					break;
				}
				R[j+1] = '1';
				R[j] = (v-10)+'0';
			}
			else R[j] = v+'0';
		}
		if(overflow){
			out("overflow");
		}
		else{
			reverse(ALL(R));
			auto itr=find_if(ALL(R),[](char ch){return ch!='0';});
			if(itr==R.end()) --itr;
			while(itr!=R.end()){
				cout << *itr;
				++itr;
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3164
N = int(input())

if N == 10 ** 5:
    count = 10 ** 5 - 10 ** 4 + 10 ** 3 - 10 ** 2 + 10 - 1
elif N >= 10 ** 4:
    count = N - 10 ** 4 + 1 + 10 ** 3 - 10 ** 2 + 10 - 1
elif N >= 10 ** 3:
    count = 10 ** 3 - 10 ** 2 + 10 - 1
elif N >= 10 ** 2:
    count = N - 10 ** 2 + 1 + 10 - 1
elif N >= 10:
    count = 10 - 1
else:
    count = N

print(count)


Measured memory_bytes: 3060