akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int[] A=cin.ReadIntArray(2);
            if (A[0] == A[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define pb push_back

ll N,M;
ll p[100005];
ll pp[100005];
ll ans;
ll gp;
ll chk[100005];
vector<vector<ll> > vv(100005);

void dfs(ll node){
	if(chk[node]) return;
	chk[node]=gp;
	rep(i,vv[node].size()){
		ll to=vv[node][i];
		dfs(to);
	}
	return;
}

int main(){

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

cin>>N>>M;

rep(i,N){
	cin>>p[i];
	pp[p[i]]=i+1;
}

rep(i,M){
	ll x,y;
	cin>>x>>y;
	vv[x].pb(y);
	vv[y].pb(x);
}

for(ll i=1; i<=N; i++){
	if(chk[i]==0){
		gp++;
		dfs(i);
	}
}

for(ll i=1; i<=N; i++){
	if(chk[i]==chk[pp[i]]) ans++;
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 10112
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[100020] = {};
int main() {
	int x;
	cin >> x;
	int s = x / 100;
	int k = x - s*100;
	if (x < 100) {
		cout << 0;
		return 0;
	}
	if (s * 5 >= k) {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main(){
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    int m;
    cin >> m;
    rep(loop_count,m){
        set<string> c;
        string s;
        cin >> s;
        REP(i,1,s.size()){
            string a = s.substr(0,i);
            string b = s.substr(i,s.size()-i);
//            cout << "----" << endl;
//            cout << a << endl;
//            cout << b << endl;
            c.insert(a+b);
            c.insert(b+a);
            reverse(a.begin(),a.end());
            c.insert(a+b);
            c.insert(b+a);
            reverse(b.begin(),b.end());
            c.insert(a+b);
            c.insert(b+a);
            reverse(a.begin(),a.end());
            c.insert(a+b);
            c.insert(b+a);
        }
//        for(auto a:c){
//            cout << a << endl;
//        }
        cout << c.size() << endl;
    }

    return 0;
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

long x; 
long y; 
long n; // パターン1の移動回数
long m; // パターン2の移動回数

const ll M = 1000000007;

vector<ll> fac(666666); //n!(mod M)
vector<ll> ifac(666666); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
    
    // 入力
    cin >> x;
    cin >> y;
    m = (2*x-y)/3;
    n  = x - 2*m;
    
    ll ans=0;
    
    if((x+y)%3==0&&m>=0&&n>=0){

        //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
        fac[0] = 1;
        ifac[0] = 1;
        for(ll i = 0; i<666666; i++){
            fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
            ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
        }
        ans = comb(m+n, n)%M;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
  long long n, k, a[200009];
  cin >> n >> k;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=k;i<n;i++){
    cout << (a[i-k]<a[i]?"Yes":"No") << endl;
  }
}


Measured memory_bytes: 5180
#include <stdio.h>
int main(void){
    // Your code here!
    int i,d[6],b;
    char a[101];
    
    for(i=0;i<6;i++){
        scanf("%d", &d[i]);
    }
    
    scanf("%s",a);
    
    for(i=0;a[i]!='\0';i++){

            if(a[i]=='S'){
                b=d[0];
                d[0]=d[4];
                d[4]=d[5];
                d[5]=d[1];
                d[1]=b;
            }
            if(a[i]=='E'){
                b=d[0];
                d[0]=d[3];
                d[3]=d[5];
                d[5]=d[2];
                d[2]=b;
            }
            if(a[i]=='W'){
                b=d[0];
                d[0]=d[2];
                d[2]=d[5];
                d[5]=d[3];
                d[3]=b;
            }
            if(a[i]=='N'){
                b=d[0];
                d[0]=d[1];
                d[1]=d[5];
                d[5]=d[4];
                d[4]=b;
            }
    }
    printf("%d\n", d[0]);
    
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define PI 3.1415926535897932
#define MOD 1000000007
using namespace std;

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

int main(){
	int S;
	cin>>S;
	vector<long long> dp(S+1);
	
	dp[0]=1;
	for(int i=1;i<=(S);i++){
		for(int j=0;j<=(i-3);j++){
			dp[i] += dp[j];
			dp[i]%=MOD;
		}
	}
	cout<<dp[S]<<endl;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  string str;
  for (int i = 0; i < W + 2; i++)
    cout << "#";
  cout << endl;
  for (int i = 0; i < H; i++){
    cin >> str;
    cout << "#";
    for (int j = 0; j < W; j++)
      cout << str.at(j);
    cout << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++)
    cout << "#";
  cout << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
main(){
  char a[5],b[5];
  int i,j,hit,blow;

  while(1){

    scanf("%s %s",a,b);
    if(a[0]=='0' && a[1]=='\0' && b[0]=='0' && b[1]=='\0') break;

    hit=blow=0;

    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(a[i]==b[j]){
	  if(i==j) hit++;
	  else blow++;
	}
      }
    }

    printf("%d %d\n",hit,blow);
  }

  return 0;
}

Measured memory_bytes: 540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.programmingContestCalculation();
		return;
	}
	
	//プログラミングコンテストの結果を計算し、表示する
	private void programmingContestCalculation() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		LinkedList<Integer> testScoreWList = new LinkedList<Integer>();
		LinkedList<Integer> testScoreKList = new LinkedList<Integer>();
		
		try {
			
			//W大学の参加者の得点
			for (int i = 0; i < 10; i++) {
				String inputStr = bufferedReader.readLine();
				testScoreWList.add(Integer.parseInt(inputStr));
			}
			
			//K大学の参加者の得点
			for (int i = 0; i < 10; i++) {
				String inputStr = bufferedReader.readLine();
				testScoreKList.add(Integer.parseInt(inputStr));
			}
			
			//それぞれの大学の上位三名の得点を取得する
			LinkedList<Integer> topThreeScoreWList = this.extractionListOfTheTopThree(testScoreWList);
			LinkedList<Integer> topThreeScoreKList = this.extractionListOfTheTopThree(testScoreKList);
			
			int topThreeScoreW = 0;
			int topThreeScoreK = 0;
			
			for (int i = 0; i < 3; i++) {
				
				topThreeScoreW += topThreeScoreWList.get(i);
				topThreeScoreK += topThreeScoreKList.get(i);
				
			}
			
			System.out.printf("%d %d\n", topThreeScoreW, topThreeScoreK);
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
	
	//上位三名の得点をリストから抽出し、戻り値として返す
	private LinkedList<Integer> extractionListOfTheTopThree(LinkedList<Integer> beingProcessedList) {
		
		LinkedList<Integer> topThreeScoreList = new LinkedList<Integer>();
		
		Collections.sort(beingProcessedList);
		Collections.reverse(beingProcessedList);
		
		for (int i = 0; i < 3; i++) {
			topThreeScoreList.add(beingProcessedList.get(i));
		}
		
		return topThreeScoreList;
	}
}

Measured memory_bytes: 17052
N, Y = map(int, input().split())

max_10000 = Y // 10000
for x in range(max_10000 + 1):
    rem = Y - 10000 * x

    if x > N:
        continue

    max_5000 = rem // 5000

    if max_5000 == 0:
        if x + rem // 1000 == N:
            print('{} {} {}'.format(x, 0, rem // 1000))
            exit()
    else:
        for y in range(max_5000 + 1):
            if x + y > N:
                continue

            rem_2 = rem - 5000 * y
            if x + y + rem_2 // 1000 == N:
                print('{} {} {}'.format(x, y, rem_2 // 1000))
                exit()


print('{} {} {}'.format(-1, -1, -1))


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X, Y, A, B, C;
int p[101010], q[101010], r[101010];
ll smpq[201010];
ll smr[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> Y >> A >> B >> C;
	rep(i, 0, A) cin >> p[i];
	rep(i, 0, B) cin >> q[i];
	rep(i, 0, C) cin >> r[i];

	vector<int> pq;
	sort(p, p + A, greater<int>());
	rep(i, 0, X) pq.push_back(p[i]);
	sort(q, q + B, greater<int>());
	rep(i, 0, Y) pq.push_back(q[i]);
	sort(all(pq), greater<int>());

	smpq[0] = 0;
	rep(i, 0, X + Y) smpq[i + 1] = smpq[i] + pq[i];

	sort(r, r + C, greater<int>());
	smr[0] = 0;
	rep(i, 0, C) smr[i + 1] = smr[i] + r[i];

	ll ans = 0;
	rep(c, 0, min(C, X + Y) + 1) chmax(ans, smr[c] + smpq[X + Y - c]);
	cout << ans << endl;
}







Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int m,n,l;
    in(m,n,l);
    vector2d(ll,mat1,m,n);
    vector2d(ll,mat2,n,l);
    vector2d(ll,mat3,m,l,0);
    in(mat1,mat2);
    //rep(i,mat1.size())out(mat1[i]);
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<n;k++){
                mat3[i][j]+=mat1[i][k]*mat2[k][j];
            }
        }
    }
    rep(i,mat3.size())out(mat3[i]);
}


Measured memory_bytes: 3300
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  print(choice+1)
  #print(score)

Measured memory_bytes: 9396
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI p(n);
  INPUT(p);
  int MIN = p[0];
  int ans = 0;
  REP(i, n)
  {
    if (MIN >= p[i]) ans++;
    chmin(MIN, p[i]);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << a * b / 2<< endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

struct DICE {
	int top;
	int north;
	int south;
	int east;
	int west;
	int bottom;
};
struct DICE dice;
struct DICE dice2;

void N() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[1]; dice.south = num[5]; dice.east = num[2];
	dice.west = num[3]; dice.north = num[0]; dice.bottom = num[4];
}
void S() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[4]; dice.south = num[0]; dice.east = num[2];
	dice.west = num[3]; dice.north = num[5]; dice.bottom = num[1];
}
void E() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[3]; dice.south = num[1]; dice.east = num[0];
	dice.west = num[5]; dice.north = num[4]; dice.bottom = num[2];
}
void W() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[2]; dice.south = num[1]; dice.east = num[5];
	dice.west = num[0]; dice.north = num[4]; dice.bottom = num[3];
}

int Roll(int T, int F) {
	int cnt = 0;
	if (dice.east == F || dice.west == F) E();
	while (dice.south != F) {
		N();
		cnt++;
		if (cnt > 5) return -1;
	}
	cnt = 0;
	while (dice.top != T) {
		W();
		cnt++;
		if (cnt > 5)return -1;
	}
	return 0;
}

int main() {
	int nums[6];
	int flag;
	for (int i = 0; i < 6; i++) {
		scanf("%d", &nums[i]);
	}
	dice.top = nums[0]; dice.south = nums[1]; dice.east = nums[2];
	dice.west = nums[3]; dice.north = nums[4]; dice.bottom = nums[5];
	for (int i = 0; i < 6; i++) {
		scanf("%d", &nums[i]);
	}
	dice2.top = nums[0]; dice2.south = nums[1]; dice2.east = nums[2];
	dice2.west = nums[3]; dice2.north = nums[4]; dice2.bottom = nums[5];

	flag = Roll(dice2.top, dice2.south);
	if (flag == -1)printf("No\n");
	else if (flag == 0) {
		if (dice2.east == dice.east&&dice2.west == dice.west&&dice2.north == dice.north&&dice2.bottom == dice.bottom) {
			printf("Yes\n");
		}
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		string c[n];
		vector<int> a[n*m+1];
		for(int i=0;i<n;i++){
			cin>>c[i];
		}
		int cnt=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(c[i][j]=='#'){
					cnt++;
				continue;}
				if(i!=0&&c[i-1][j]=='.')
				a[cnt].push_back(cnt-m);
				if(i!=n-1&&c[i+1][j]=='.'){
				a[cnt].push_back(cnt+m);}
				if(j!=0&&c[i][j-1]=='.')
				a[cnt].push_back(cnt-1);
				if(j!=m-1&&c[i][j+1]=='.'){
				a[cnt].push_back(cnt+1);}
			/*	cout<<cnt<<" ";
				for(auto k:a[cnt])
				cout<<k<<" ";
				cout<<endl;*/
				cnt++;
			}
		}
		int ma=0;
		int vis[n*m];
		for(int i=0;i<n*m;i++){
			if(a[i].size()==0)
			continue;
			memset(vis,-1,sizeof(vis));
			vis[i]=0;
			queue<int> q;
			q.push(i);
			while(q.empty()==false){
				int z=q.front();
				q.pop();
				if(a[z].size()==0)
				continue;
				for(auto k:a[z]){
					if(vis[k]==-1||vis[k]>vis[z]+1){
						vis[k]=vis[z]+1;
						q.push(k);
					}
				}
			}
			for(int i=0;i<n*m;i++){
				ma=max(ma,vis[i]);
			}
		}
		
		
		cout<<ma;
	}
	return 0;
	}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  
  int cnt = 0, a_cnt = 0, b_cnt = 0, double_cnt = 0;
  string s;
  for (int i = 0;i < N;i++) {
    cin >> s;
    
    for (int j = 0;j < s.length();j++) {
      if (s[j] == 'A') {
        if (s[j+1] == 'B') cnt++;
      }
    }
    
    if (s[0] == 'B') b_cnt++;
    if (s[s.length() - 1] == 'A') a_cnt++;
    if (s[0] == 'B' && s[s.length() - 1] == 'A') double_cnt++;
  }
  
  if (double_cnt == a_cnt && a_cnt == b_cnt) {
    a_cnt = max(0, a_cnt-1);
    b_cnt = max(0, b_cnt-1);
  }
  cout << cnt + min(a_cnt, b_cnt) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> fd(n + 1);
    rep(i, 0, m)
    {
        int t1, t2;
        cin >> t1 >> t2;
        fd[t1].push_back(t2);
        fd[t2].push_back(t1);
    }
    int ans = 0;
    vector<bool> checked(n + 1, 0);
    rep(i, 0, n)
    {
        queue<int> q;
        if (!checked[i])
        {
            q.push(i);
            checked[i] = 1;
        }
        int count = 0;
        while (!q.empty())
        {
            int cr = q.front();
            q.pop();
            count++;
            for (int x : fd[cr])
            {
                if (!checked[x])
                {
                    checked[x] = 1;
                    q.push(x);
                }
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    int m;
    int l;
 
   cin >> n >> m >> l;
  
   if (n == m){
     cout << l << endl;
   }else if(n == l){
     
     cout << m << endl;
   }else if(m == l){
      cout << n << endl;
   }
  
   
  
   
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i, h, j) for(int i = h; i <= j; ++i)
using namespace std;

typedef long long ll;
const ll mod = 998244353;
const int N = 3e5 + 10;
ll n, a, b, k, ans, fac[N];

ll ksm(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}

ll C(ll n, ll m) { 
	if(n < m) return 0;
	return fac[n] * ksm(fac[m], mod - 2) % mod * ksm(fac[n - m], mod - 2) % mod; }

int main() {
	fac[0] = fac[1] = 1;
	For(i, 2, N - 5) fac[i] = 1ll * i * fac[i - 1] % mod;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);	
	if(k == 0) return printf("1\n"), 0;
	if(a == 0 && b == 0) return printf("0\n"), 0;
	if(a == 0 || b == 0) {
		if(b == 0) swap(a, b);
		ll u = k / b;
		if(k % b == 0)return printf("%lld\n", C(n, u));
		else return printf("0\n"), 0;
	}
	For(i, 0, n) {
		ll u = 1ll * i, res = k - u * a, v = res / b;
		if(res < 0) break;
		if(res % b != 0) continue;
		(ans += C(n, u) * C(n, v) % mod) %= mod;	
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N - 1));
    rep(i, N) {
        rep(j, N - 1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
    }

    vector<P> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return; // 対戦する試合がない場合
        int j = a[i].back(); // 対戦相手を取得
        if (a[j].size() == 0) return; // 対戦相手の対戦がない場合

        if (a[j].back() == i) { // i,jが対戦できるとき
            P p(i, j);
            if (p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };
    rep(i, N) {
        check(i);
    }
    int day = 0;
    while (q.size() > 0) {
        day++;

        // 重複を削除する
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());

        vector<P> prevQ;
        swap(prevQ, q);
        for (P p: prevQ) {
            int i = p.first;
            int j = p.second;
            // 試合を消化
            a[i].pop_back();
            a[j].pop_back();
        }

        for (P p: prevQ) {
            int i = p.first;
            int j = p.second;
            // 次の試合ができるかチェック
            check(i);
            check(j);
        }
    }

    rep(i, N) {
        if (a[i].size() != 0) { // 未消化の試合がある場合
            puts("-1");
            return 0;
        }
    }
    cout << day << endl;
}


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

#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5)

#define maxn (long long int) (2147483647);

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;


int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;

    int rw=-1,rr=-1;

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'W')
        {
            rw = i;
            break;
        }
    }

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

    if (rw == -1 || rr == -1)
    {
        cout << 0;
        return 0;
    }   

    int ans = 0;
    bool got = false;
    while(rw < rr)
    {
        got = false;
        ans++;
        swap(s[rw],s[rr]);

        for (int i = rw+1; i < n; ++i)
        {
            if (s[i] == 'W')
            {
                got = true;
                rw = i;
                break;
            }
        }

        if(!got)
            break;

        got = false;

        for (int i = rr-1; i >= 0; --i)
        {
            if (s[i] == 'R')
            {
                got = true;
                rr = i;
                break;
            }
        }

        if (!got)
        {
            break;
        }
    }

    cout << ans++;
    return 0;
}


















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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->



int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

   int n;
   cin>>n;

   char s;

   set<char>se;

   while(n--)
   {
      cin>>s;

      se.insert(s);
   }

   if(se.size() == 3)
   {
    cout<<"Three";
   }

   else
   {
    cout<<"Four";
   }


}


Measured memory_bytes: 3620
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = ss `divMod` 60
  ; let (h,m)  = mm `divMod` 60
  ; putStrLn (intercalate ":"(map show [h,m,s]))
  }

getInts :: IO [Int]
getInts = do
  { line <- getLine
  ; let ints = map readInt (words line)
  ; return ints
  }

getInts' :: IO [Int]
getInts' = do
  { line <- getLine
  ;return (map readInt (words line))
  }

getInts'' :: IO [Int]
getInts'' = map readInt . words <$> getLine
readInt :: String -> Int
readInt = read

Measured memory_bytes: 3528
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];

        if(K == 1)
        {
            Console.WriteLine(0);
            return;
        }

        Console.WriteLine(N - K);
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int n,budget,price[30];
int dp[1000001];
bool is_prime[1000001];

void sieve() {
  for(int i=0;i<1000001;i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;

  for(int i=0;i*i<1000001;i++) {
    if(is_prime[i]) {
      for(int j=2*i;j<1000001;j+=i) {
        is_prime[j] = false;
      }
    }
  }
}

void solve() {
  for(int j=0;j<=budget;j++) {
    dp[j] = 0;
  }

  for(int i=0;i<n;i++) {
    for(int j=0;j<=budget;j++) {
      if(j-price[i]>=0) {
        dp[j] = max(dp[j], dp[j-price[i]] + price[i]);
      }
      else {
        dp[j] = dp[j];
      }
    }
  }
  for(int i=0;i<budget;i++) {
    if(is_prime[dp[budget-i]]) {
      cout << dp[budget-i] << endl;
      return;
    }
  }
  cout << "NA" << endl;
  return;
}

int main() {
  sieve();
  while(cin >> n >> budget) {
    if(n==0&&budget==0) break;
    for(int i=0;i<n;i++) {
      cin >> price[i];
    }
    solve();
  }
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
//AtCoder解説動画(https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be)からもらった
// (https://atcoder.jp/contests/abc157/submissions/10472433)
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {} //このコロンってなんですか
	int find(int x){
		if (d[x] < 0) return x; //x:根
		return d[x] = find(d[x]);//x:子 -> xの親の根を返す
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//根同士をくっつける。
		if ( x ==  y) return false ; 
		/*連結成分が一致してるんだったらfalse返す。
			minimum spanning tree (クラスカル法と言うのをやるときに、くっつけたかどうかを取れると嬉しい.
			chmin/chmaxみたいなノリかな
		 */
		if ( d[x] > d[y]) swap(x,y);//xの方が大きいようにする（ただしサイズは負デモっているので不等号が逆）
		d[x] += d[y] ; //xにyをくっつける.
		d[y] = x;
		return true; 
	}
	bool same(int x, int y) { return find(x) == find(y) ; }
	int size(int x) { return -d[find(x)];}
};
int main()
{
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		uf.unite(a,b);
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans,uf.size(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#define rg register
using namespace std;
long long kans(long long a)
{
    if(a==0)
        return 0;
    if(a%2==1)
	{
        if(((a-1)/2)%2==1)
            return 0;
        else
            return 1;
    }
    else
	{
        if(((a-2)/2)%2==1)
            return a;
        else
            return 1^a;
    }
}
signed main()
{
	long long a,b;
	cin>>a>>b;
	if(a==0&&b==0)
	  cout<<(0^0)<<endl;
	else if(a==0)
	  cout<<(kans(b)^0)<<endl;
	else
	  cout<<(kans(b)^kans(a-1))<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b=0,c=0;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a==5)
      b++;
    if(a==7)
      c++;
  }
  if(c==1&&b==2)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
#define MAX_CHAR 256 
//int dp[1000001] = {0};
int fact(int n) { 
	return (n <= 1) ? 1 : n * fact(n - 1); 
} 
void populateAndIncreaseCount(int* count, string str) 
{ 
	int i; 

	for (i = 0; str[i]; ++i) 
		++count[str[i]]; 

	for (i = 1; i < MAX_CHAR; ++i) 
		count[i] += count[i - 1]; 
} 
void updatecount(int* count, char ch) { 
	int i; 
	for (i = ch; i < MAX_CHAR; ++i) 
		--count[i]; 
} 
int findRank(string str) { 
	int len = sz(str); 
	int mul = fact(len); 
	int rank = 1, i; 

	int count[MAX_CHAR] = { 0 }; 
	populateAndIncreaseCount(count, str); 

	for (i = 0; i < len; ++i) { 
		mul /= len - i; 
		rank += count[str[i] - 1] * mul; 

		updatecount(count, str[i]); 
	} 

	return rank; 
} 
void solve(){
	int n;
	cin>>n;
	string s="", ss="", b;
	char arr[n], arr2[n];
	FOR(i, 0, n){ 
		cin>>arr[i];
		s+=(arr[i]);
	}
	FOR(i, 0, n){
		cin>>arr2[i];
		ss+=(arr2[i]);
	}
	cout<<abs(findRank(s)-findRank(ss))<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n);
    VI l(n), r(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
    }
    sort(ALL(l));
    sort(ALL(r));
    if (n % 2 == 1) {
        cout << r[n / 2] - l[n / 2] + 1;
    } else {
        int lsm = l[n / 2 - 1] + l[n / 2];
        int rsm = r[n / 2 - 1] + r[n / 2];
        cout << rsm - lsm + 1;

    }


    return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int s1,s2;
	while(cin>>s1>>s2&&!(s1==0&&s2==0)){
		vector<pair<int,char> > v;
		v.push_back(make_pair(s1+s2,'A'));
		for(int i = 0; i < 4; i++){
			cin>>s1>>s2;
			v.push_back(make_pair(s1+s2,'B'+i));
		}
		sort(v.begin(),v.end(),greater<pair<int,char> >());
		cout<<v[0].second<<" "<<v[0].first<<endl;
	}


	return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll V, E, ans=0, tmp=0;
vector<pair<ll, pair<ll,ll> > > G;

struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

void kruskal() {
    UnionFind tree(V);
    sort(G.rbegin(), G.rend());
    while(!G.empty()) {
        pair<ll,pair<ll,ll> > pp = G.back();
        G.pop_back();
        if(tree.isSame(pp.second.first, pp.second.second)) continue;
        ans += pp.first;
        tree.unite(pp.second.first, pp.second.second);
    }

}

signed main(){
    cin >> V >> E;
    for(int i=0;i<E;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        G.push_back(make_pair(c, make_pair(a, b)));
    }
    kruskal();
    cout << ans << endl;
    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b, c; cin >> a >> b >> c;
    int aa = abs(a-b), bb = abs(b-c), cc = abs(c-a);
    cout << min(aa+bb, min(bb+cc, cc+aa)) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			if (0 == (m % n)) {
				System.out.println(m / n);
			} else {
				System.out.println(getResult(n, m));
			}
		}
	}

	/**
	 * m/n より小さい最大のmの約数を計算する
	 * 
	 * @param n
	 * @param m
	 * @return m/n より小さい最大のmの約数
	 */
	private static int getResult(int n, int m) {
		for (int i = m / n; i >= 1; i--) {
			if (0 == (m % i)) {
				return i;
			}
		}
		return 1;
	}
}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e6 + 5, oo = 1e9;
const double pi = acos(-1);
using namespace std;

int main()
{
    assem99
    int n, m; cin>>n>>m;
    ll ans = 0, cnt = 1, sum = 0;
    map<int, int> freq;
    freq[0] = 1;
    for(int i = 0; i < n; i++)
    {
        ll a; cin>>a;
        sum += a;
        sum %= m;
        ans += freq[sum]++;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 6492