akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {os << "{" <<p.first << ", " << p.second << "}";return os;}
struct fast_ios{ fast_ios(){cin.tie(0);ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#ifdef DEBUG
#define dump(x) cerr<<#x<<": "<<x<<endl;
#else
#define dump(x)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll G = A[0];
    rep(i,N)G = gcd(G, A[i]);
    vector<int> cnt(1010101, 0);
    bool ok = true;
    rep(i,N){
        auto v = factorize(A[i]);
        for(auto p: v){
            dump(cnt[p.first]);
            cnt[p.first]++;
            if(cnt[p.first] >= 2)ok = false;
        }
    }

    if(ok)cout << "pairwise coprime" << endl;
    else if(G == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}


Measured memory_bytes: 15072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    ll ans=x-1;
    long double k=sqrt(x*y-0.75)-x+0.5;
    ll lk=k;
    ans+=k+(x*y-1)/(x+k);
    if(x==y)cout<<ans<<endl;
    else cout<<ans-1<<endl;
  }
}


Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DXORWorld solver = new DXORWorld();
        solver.solve(1, in, out);
        out.close();
    }

    static class DXORWorld {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong(), b = in.nextLong();

            long answer = compute(b);
            if (a != 0) {
                answer ^= compute(a - 1);
            }

            out.println(answer);
        }

        static long compute(long x) {
            long answer = 0;
            if (x % 4 == 1 || x % 4 == 2) {
                answer += 1;
            }
            for (long bit = 2; bit <= x; bit *= 2) {
                long cur = x % (2 * bit);
                if (cur >= bit && cur % 2 == 0) {
                    answer += bit;
                }
            }
            return answer;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23380
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int N = 1e3 + 50;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);
const double EPS = 1e-9;
const double PI = 3.1415926535;

int h,w;
char s[N][N];
const int px[4] = {0,0,1,-1};
const int py[4] = {1,-1,0,0};

int main(){
    scanf("%d%d",&h,&w);
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            scanf(" %c",&s[i][j]);
        }
    }
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            int cnt = 0;
            for(int k = 0;k<4;k++){
                int ni = i + px[k];
                int nj = j + py[k];
                if(ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
                if(s[ni][nj] == '#') cnt++;
            }
            if(s[i][j] == '#' && cnt == 0){
                printf("No\n");return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
import math

def main():
    num_str = input()
    num_list = list(map(int, list(num_str)))
    num = int(num_str)

    count = 0
    for ele in num_list:
        count += ele
    if num % count == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

const double EPS = 1e-8;

using R = long double;
using P = complex<R>;
using L = pair<P,P>;
using G = vector<P>;
struct C {
  P c; R r;
  C() {}
  C(const P &a, const R &b) : c(a), r(b) {}
};
struct S : public L {
  S() {}
  S(const P &a, const P &b) : L(a,b) {}
};

inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
inline R dot(const P& a, const P& b) {
  return real(a)*real(b) + imag(a)*imag(b);
}
inline R det(const P& a, const P& b) {
  return real(a)*imag(b) - imag(a)*real(b);
}
inline P vec(const L& l) {return l.second - l.first;}
namespace std {
	bool operator < (const P& a, const P& b) {
		return sgn(real(a-b)) ? real(a-b) < 0 : sgn(imag(a-b)) < 0;
	}
	bool operator == (const P& a, const P& b) {
		return sgn(real(a-b)) == 0 && sgn(imag(a-b)) == 0;
	}
  bool cmp_y (const P& a, const P& b) {
    return sgn(imag(a-b)) ? imag(a-b) < 0 : sgn(real(a-b)) < 0;
  }
}

// P,L,Sについて入力
inline istream& operator>>(istream& is, P& p) {
  R x, y;
  is >> x >> y;
  p = P(x, y);
  return is;
}
inline istream& operator>>(istream& is, L& l) {
  P a, b;
  is >> a >> b;
  l = L(a, b);
  return is;
}
inline istream& operator>>(istream& is, S& s) {
  P a, b;
  is >> a >> b;
  s = S(a, b);
  return is;
}

inline bool parallel(L a, L b) {return sgn(det(vec(a), vec(b))) == 0;}

P p[55];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) cin >> p[i];

  if(n%2) {
    cout << "NA" << endl;
    return 0;
  }

  bool flag = true;
  REP(i, n) {
    // p[i]-p[i+1] と p[i+n/2]-p[i+n/2+1] について
    L l1(p[i], p[(i+1)%n]), l2(p[(i+n/2)%n], p[(i+n/2+1)%n]);
    if(!parallel(l1, l2) || sgn(abs(vec(l1))-abs(vec(l2))) != 0) {
      flag = false;
    }
  }

  cout << fixed << setprecision(9) << endl;
  if(flag) cout << (p[0].real()+p[n/2].real())/2.0 << " " << (p[0].imag()+p[n/2].imag())/2.0 << endl;
  else cout << "NA" << endl;

  return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main()
{
	ll a,p;
	cin>>a>>p;

	ll ans = 3*a + p;

	cout<<ans/2<<endl;

}	

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        long[] x = LongLine();
        long a = (x[1] / x[2]) + 1;
        long b = (x[0] % x[2] == 0 ? x[0] / x[2] : x[0] / x[2] + 1);
        Console.WriteLine(a - b);
    }
}

public class AtCoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

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

bool visited[10] ;
int cost[10][10]  , v , A[300][300] , mn[10] , ans ;

void backtrack(int u , int sum) {
    if(u == 1){
        ans = min(ans , sum) ;
        return ;
    }
    visited[u] = true ;
    for(int i = 0 ; i<10 ; i++){
        if((cost[u][i] + sum < ans) && 
                !visited[i]) {
            sum+=cost[u][i] ;
            backtrack(i , sum) ;
            sum-= cost[u][i] ;
        }
    }
    visited[u] = false ;
}

int main() {
    int h , w ;
    ll sum = 0LL ;
    scanf("%d %d" ,&h , &w) ;

    for(int i = 0 ;i<10 ; i++) 
        for(int j = 0 ; j<10 ; j++) 
            scanf("%d" ,&cost[i][j]) ;
    for(int i = 0 ; i<h ; i++) 
        for(int j = 0 ; j<w ;j++) 
            scanf("%d" ,&A[i][j]) ;

    for(int i = 0 ;i<10 ; i++) {
        if(i == 1) mn[i] = 0 ;
        else {
            ans = cost[i][1] ;
            v = i ;
            backtrack(i , 0) ;
            mn[i]  = ans ;
        }
    }

    for(int i = 0 ; i<h ;i++)
        for(int j = 0 ; j<w ; j++) 
            if(A[i][j] != -1) sum+=(ll)mn[A[i][j]] ;

    printf("%lld\n" , sum) ;

    return 0 ;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct edge{
    vector<int> to;
    int kouho;
    int ko;
    int oya;
    int dist;
};

int main() {
    int n; cin >> n;
    int u, v; cin >> u >> v; // v = oni,ne
    u--; v--;
    vector<edge> ar(n);
    rep(i,n-1){
        int a, b; cin >> a >> b;
        ar[a-1].to.emplace_back(b-1);
        ar[b-1].to.emplace_back(a-1);
    }
    int ans = 0;
    rep(i,n){
        ar[i].ko = -1;
        ar[i].kouho = 0;
    }
    stack<int> st;
    st.push(v);
    ar[v].oya = -1;
    ar[v].dist = 0;
    while (!st.empty()){
        int g = st.top(); st.pop();
        if (g == -1) break;
        ar[g].ko = -2;
        bool t = true;
        vector<int> kesu;
        rep(i,ar[g].to.size()){
            int c = ar[ar[g].to[i]].ko;
            if (c == -1){
                st.push(ar[g].to[i]);
                ar[ar[g].to[i]].oya = g;
                ar[ar[g].to[i]].dist = ar[g].dist+1;
                t = false;
                break;
            }
            else if (c != -2){
                ar[g].kouho = max(ar[g].kouho,c+1);
                kesu.emplace_back(i);
            }
        }
        rep(i,kesu.size()){
            ar[g].to.erase(ar[g].to.begin()+kesu[kesu.size()-1-i]);
        }
        if (t){
            ar[g].ko = ar[g].kouho;
            st.push(ar[g].oya);
        }
    }
    int nu = u;
    rep(i,(ar[u].dist-1)/2){
        nu = ar[nu].oya;
        ans++;
    }
    if ((ar[u].dist-1) % 2 == 0){
        ans += ar[nu].ko;
    }
    else {
        ans += ar[nu].ko+1;
    }
    cout << ans << endl;
}

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

int main()
{
	std::set<long> s;
	long n, m;

	cin >> n;

	for (long i = 0; i < n; i++) {
		long t;
		cin >> t;
		s.insert(t);
	}

	cin >> m;

	for (long i = 0; i < m; i++) {
		long t;
		cin >> t;
		if (s.find(t) != s.end())
			s.erase(t);
	}

	for (std::set<long>::iterator itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << endl;

	return 0;
}


Measured memory_bytes: 12488
X,N= map(int,input().split())
p= list(map(int,input().strip().split()))

ans_1=X
ans_2=X


for j in range(100):
    for i in range(N):
        if ans_1 in p:
            ans_1+=1
        else:
            break


for j in range(100):
    for i in range(N):
        if ans_2 in p:
            ans_2-=1
        else:
            break



if abs(ans_2-X)-abs(ans_1-X)>0:
    print(ans_1)
else:
    print(ans_2)


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

using namespace std;

int main() {
  long long n; cin >> n;
  long long x;
  long long sum = 0;
  for(int i=0; i<n; i++) {
    cin >> x;
    sum += x;
  }
  cout << sum / n << endl;
  return 0;
}

Measured memory_bytes: 1156
a, b, c = map(int, input().split())


if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
else:
    ans = 0
    done = set((a, b, c))
    while True:
        ans += 1
        s = a // 2
        t = b // 2
        u = c // 2
        a, b, c = t + u, s + u, s + t
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            print(ans)
            break
        elif (a, b, c) in done:
            print(-1)
            break
        else:
            done.add((a, b, c))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int r; cin >> r;
	cout << (r < 1200 ? "ABC" : (r < 2800 ? "ARC" : "AGC")) << endl;
}



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

long long beki(int a);

int main(){
  int a[200001],n;
  long long x=0,y=0,X=0;
  long long ans = beki(9) * ( 2 * beki(5) - 1 );

  cin >> n; //how many cards
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    X += a[i]; //all sum
  }
  
  for ( int i = 0; i < n - 1; i++ ) { //at least 1 card
    x += a[i]; //sum of player 1
    y = X - x;
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
  return 0;
}

long long beki(int a){
  long long b = 1;
  for ( int i = 0; i < a; i++ ) {
    b *= 10;
  }
  return b;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

var N, A, B, C int
var l []int

func main() {
	fmt.Scan(&N, &A, &B, &C)
	l = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&l[i])
	}
	fmt.Println(dfs(0, 0, 0, 0))

}
func dfs(i, a, b, c int) int {
	if i == N {
		if a == 0 || b == 0 || c == 0 {
			return math.MaxInt32
		}
		return Abs(a-A) + Abs(b-B) + Abs(c-C)
	}

	r0 := dfs(i+1, a, b, c)
	var wa, wb, wc int
	if a > 0 {
		wa = 10
	}
	if b > 0 {
		wb = 10
	}
	if c > 0 {
		wc = 10
	}
	r1 := dfs(i+1, a+l[i], b, c) + wa
	r2 := dfs(i+1, a, b+l[i], c) + wb
	r3 := dfs(i+1, a, b, c+l[i]) + wc
	return Min(Min(Min(r0, r1), r2), r3)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(int argv, char* argc[])
{
    FASTIO

    int n,ans=0;
    cin>>n;
    vii a(n),b(n);
    rep(i,n)
    {
        cin>>a[i]>>b[i];
    }
    sort(all(a)),sort(all(b));
    int ind = n/2;

    if(n&1)
    {
        int l = a[ind];
        int r = b[ind];
        ans = r-l+1;
    }
    else
    {
        double l = (double)(a[ind]+a[ind-1])/2;
        double r = (double)(b[ind]+b[ind-1])/2;
        if(l != ceil(l))
            ++ans;
        l = ceil(l);
        if(r != floor(r))
            ++ans;
        r = floor(r);
        ans += r-l+1;
        ans += (r-l);
    }
    cout<<ans;


    return 0;
}



Measured memory_bytes: 4772
using System;
using System.Globalization;
using System.Linq;

namespace AOJ0018
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine(string.Join(" ", (Console.ReadLine() ?? "").Split(' ').Select(int.Parse).OrderByDescending(i => i).Select(i => i.ToString(CultureInfo.InvariantCulture)).ToArray()));
        }
    }
}

Measured memory_bytes: 6448
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long n = read.to!long;
	char[][] ss;
	for(int i = 0; i < n; i ++) ss ~= readln.chomp.to!(char[]);
	
	int[char] count;
	foreach(c; "abcdefghijklmnopqrstuvwxyz") count[c] = int.max;
	foreach(s; ss){
		int[char] tempcount;
		foreach(c; s){
			tempcount[c] += 1;
			}
		foreach(c; count.keys){
			if(c in tempcount){
				if(tempcount[c] < count[c]) count[c] = tempcount[c];
				}
			else count[c] = 0;
			}
		}
	
	string ans;
	foreach(c; "abcdefghijklmnopqrstuvwxyz") for(int i = 0; i < count[c]; i ++) ans ~= c;
	
	ans.writeln;
	}


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



int main()
{
    ll n,k,x=0;
    cin>>n>>k;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
    }
    sort(l1+1,l1+n+1,greater<int>());
    for(int i=1;i<=k;i++){
        x+=l1[i];
    }
    cout<<x;

    return 0;
}


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

using namespace std;

bool cmp(int x, int y);

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	vector <int> v(n);
	for (int i = 0; i < n; ++i){
		v[i] = l + i;
	}
	sort(v.begin(),v.end(),cmp);
	int ans = 0;
	for (int i = 1; i < n; ++i){
		ans+=v[i];
	}
	cout << ans;
	return 0;
}

bool cmp(int x, int y){
	return abs(x) < abs(y);
}



Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a = int(input())
b = int(input())
c = int(input())
x = int(input())

l = []
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            l.append([i,j,k])


ans = 0
for i in range(len(l)):
    temp = l[i][0]*500 + l[i][1]*100 + l[i][2]*50
    if (temp == x):
        ans += 1
print(ans)



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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k, d, x;
	set<int> cnt;
	cin>>n>>k;
	while(k--) {
		cin>>d;
		while(d--) {
			cin>>x;
			cnt.insert(x);
		}
	}
	cout<<n-cnt.size();
}



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

A,B,C,D=input().split()

A=int(A)
B=int(B)
C=int(C)
D=int(D)

while(1):
    C-=B
    if C <= 0:
        ans="Yes"
        break
    A-=D
    if A <= 0:
        ans="No"
        break
    

print(ans)


Measured memory_bytes: 9180
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
typedef pair<double,double>d_d;
#define inf 100000000//10^8

/////////////////////////////////


int main(){
    ll x,y;cin>>x>>y;
    int ans=0;
    ll n=y/x;
    while(n>0){
        ans++;
        n=n/2;
    }
    cout<<ans<<endl;
    
    return 0;
}


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


int main() {
	string s,s2;
	cin >> s;
	s2=s;
	reverse(s2.begin(),s2.end());
	for(int i=0;i<s2.size();i++){
		if(s2[i]=='b') s2[i]='d';
		else if(s2[i]=='d') s2[i]='b';
		else if(s2[i]=='p') s2[i]='q';
		else if(s2[i]=='q') s2[i]='p';
	}
	
	cout << (s==s2?"Yes":"No") << endl;
	return 0;
}
 

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

using namespace std;

int main()
{
    int n, inc, dec;
    scanf("%d %d %d", &n, &inc, &dec);
    if(inc>n || dec>n){
        printf("-1\n");
        return 0;
    }
    bool swapped=false;
    if(inc<dec)
    {
        swap(inc,dec);
        swapped=true;
    }
    vector<int> v;
    for(int i=n-inc+1; i<=n; i++) v.push_back(i);
    int nb_times_done=0;
    if(dec!=1)
    {
        if(dec-1>=n-inc+1)
        {
            printf("-1\n");
            return 0;
        }
        int start=dec-1;
        int down_to=1;
        while(true)
        {
            for(int i=start; i>=down_to; i--) v.push_back(i);
            nb_times_done++;
            if(start==n-inc+1-1) break;
            down_to=start+1;
            start=min(start+dec-1, n-inc+1-1);
        }
    }
    else
    {
        if(inc != n)
        {
            printf("-1\n");
            return 0;
        }
    }
    if(nb_times_done>inc)
    {
        printf("-1\n");
        return 0;
    }
    if(swapped) reverse(v.begin(), v.end());
    for(int i=0; i<v.size(); i++)
    {
        if(i != 0) printf(" ");
        printf("%d", v[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int N=1000;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T&a,const T&b){return b<a?a=b,1:0;}
template<typename T>inline bool chkmax(T&a,const T&b){return a<b?a=b,1:0;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int n,s1[N],s2[N],ans;
int main()
{
	int x;
	file();
	read(n);
	For(i,1,n)read(x),s1[i]=s1[i-1]+x;
	For(i,1,n)read(x),s2[i]=s2[i-1]+x;
	For(i,1,n)chkmax(ans,s1[i]+s2[n]-s2[i-1]);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
n , m = map(int, input().split())

switch = []
for i in range(m):
    line = list(map(int, input().split()))
    k, s = line[0], line[1::]
    switch.append(s)

is_on_off = list(map(int, input().split()))

# print("######################################")
res = 0
for i in range(1 << n):
    on_off_state = []
    for index in range(n):
        if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
    for ki in range(m):
        on_off_counter = 0
        for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
        if on_off_counter % 2 != is_on_off[ki]:
            break
    else:
        res += 1
    # print(res, i)

print(res)



Measured memory_bytes: 9112
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()

ans = 0
ans += a[0]
d = n-2
m = d//2
l = d%2
ans  += sum(a[1:1+m])*2
if l == 1:
    ans += a[1+m]
print(ans)

Measured memory_bytes: 94196
#include<bits/stdc++.h>
#define gc getchar()
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
const int mod = 1e9+7,base=3;
inline int read(){char ch=gc;int w=1,s=0;while(!isdigit(ch)){if(ch=='-') w=-1;ch=gc;};while(isdigit(ch)){s=s*10+ch-'0';ch=gc;} return w*s;}
int Sum[1000100],A[1000010],n,nxt[1000100][3];
int f[1000010];
char ch[1000010]; 
inline int add(int a,int b){a+=b;if(a>=mod) a-=mod;return a;}
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);
	int fl=0;
	for(rint i=1;i<=n;++i) A[i]=ch[i]=='a'?1:2;
//	for(rint i=1;i<=n;++i) cout<<A[i]<<"\n";
	for(rint i=1;i<=n;++i) Sum[i]=(Sum[i-1]+A[i])%base;
	for(rint i=1;i<n;++i) if(A[i]==A[i+1]) fl=1;
	if(!fl)
	{
	//	cout<<1<<"\n";
		cout<<"1";return 0;
	}
	for(rint i=n;i;--i) memcpy(nxt[i],nxt[i+1],sizeof(nxt[i+1])),nxt[i][Sum[i]]=i;
	f[0]=1;
	for(rint i=0;i<n;++i)
	{
		for(rint j=0;j<base;++j)
		{
			if(j!=Sum[i])
			{
				int tmp=nxt[i+1][j];
				if(tmp) f[tmp]=add(f[i],f[tmp]);
			}
		}
	}int res=0;
	for(rint i=1;i<=n;++i) if(Sum[i]==Sum[n]) res=add(res,f[i]);
	cout<<res<<"\n";
	return 0;
}
/*
by was_n
2018.9.17
*/



Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef unsigned long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll a,b;
ll n;
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>n;
	n--;
	cin>>a>>b;
	ll x,y;
	repd(i,1,n)
	{
		cin>>x>>y;
        ll mid;
        ll l=1ll;
        ll r=max(2e18/y,2e18/x)+1;
        ll v=1ll;
        while(l<=r)
        {
            mid=(l+r)/2ll;
            if(x*mid>=a&&y*mid>=b)
            {
                v=mid;
                r=mid-1ll;
            }else
            {
                l=mid+1ll;
            }
        }
        a=x*v;
        b=y*v;
	}
	cout<<a+b<<endl;




    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, cnt int
	fmt.Scan(&x)
	if x < 7 {
		fmt.Println(1)
		return
	}
	x -= 6
	cnt++
	cnt += (x / 11) * 2
	if x%11 > 0 {
		cnt++
		if x%11 > 5 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

// M, A, R, C, H
char P[10] = {'M', 'M', 'M', 'M', 'M', 'M', 'A', 'A', 'A', 'R'};
char Q[10] = {'A', 'A', 'A', 'R', 'R', 'C', 'R', 'R', 'C', 'C'};
char R[10] = {'R', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'H'};

signed main() {
  int n = read(), ans = 0;
  map<char, int> cnt;
  REP(i, n) {
    string s = readString();
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
      cnt[s[0]]++;
  }
  for (int i = 0; i < 10; i++) {
    ans += cnt[P[i]] * cnt[Q[i]] * cnt[R[i]];
  }
  print(ans);
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int minum=1000001,maxnum=-1000001;
    long long sum=0;
    int time;
    cin>>time;
    for(int i=0;i<time;++i){
        int input;
        cin>>input;
        minum = min(minum,input);
        maxnum = max(maxnum,input);
        sum+=input;
    }
    cout<<minum<<" "<<maxnum<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
using namespace std;
class Dice
{
public:
	enum side{top,front,right,left,rear,bottom};
private:
	int dice[6];
public:
	Dice()
	{
		for (int i = 0; i < 6; i++)
			dice[i] = 0;
	}
	Dice(int set[])
	{
		for (int i = 0; i < 6; i++)
			dice[i] = set[i];
	}
	int* getDice()
	{
		return dice;
	}
	void turnNorth()
	{
		int tmp = dice[top];
		dice[top] = dice[front];
		dice[front] = dice[bottom];
		dice[bottom] = dice[rear];
		dice[rear] = tmp;
	}
	void turnSouth()
	{
		int tmp = dice[top];
		dice[top] = dice[rear];
		dice[rear] = dice[bottom];
		dice[bottom] = dice[front];
		dice[front] = tmp;
	}
	void turnEast()
	{
		int tmp = dice[top];
		dice[top] = dice[left];
		dice[left] = dice[bottom];
		dice[bottom] = dice[right];
		dice[right] = tmp;
	}
	void turnWest()
	{
		int tmp = dice[top];
		dice[top] = dice[right];
		dice[right] = dice[bottom];
		dice[bottom] = dice[left];
		dice[left] = tmp;
	}
};
int main()
{
	int set[6];
	for (int i = 0; i < 6; i++)
		cin >> set[i];
	cin.get();
	Dice D(set);
	string command;
	getline(cin, command);
	for (int i = 0; i < command.length(); i++)
	{
		char direct = command[i];
		if (direct == 'N')
			D.turnNorth();
		else if (direct == 'S')
			D.turnSouth();
		else if (direct == 'E')
			D.turnEast();
		else if (direct == 'W')
			D.turnWest();
	}
	cout << D.getDice()[Dice::top] << endl;
}


Measured memory_bytes: 3164
def main():
    from itertools import cycle

    n = int(input())
    *a, = sorted(int(input()) for _ in range(n))

    half = n // 2
    h = reversed(a[:half])
    t = reversed(a[-half:])

    if n % 2 == 0:
        lis = []
        for e, o in zip(h, t):
            lis.append(e)
            lis.append(o)

        it = iter(lis)
        p = next(it)

        ret = 0
        for x in it:
            ret += abs(p - x)
            p = x

        print(ret)

    else:
        # 昇順ソートされたaを2つの山に分ける
        # xxx yy : 小を多く取る -> xyxyx
        # yは順序を気にしない
        # yとの差が小さくなるようなx（大きい方から2つ）を両端に置く
        # zz www : 大を多く取る -> wzwzw
        # zは順序を気にしない
        # zとの差が小さくなるようなw（小さい方から2つ）を両端に置く

        xs, ys = a[:-half], a[-half:]

        x = xs.pop()
        xs = [x] + xs

        cycl = cycle((xs, ys))

        p = next(cycl).pop()

        ret = 0
        for _ in range(n - 1):
            e = next(cycl).pop()
            ret += abs(p - e)
            p = e

        zs, ws = a[:half], a[half:]

        w, *ws = ws
        ws.append(w)

        cycl = cycle((ws, zs))

        p = next(cycl).pop()

        buf = 0
        for _ in range(n - 1):
            e = next(cycl).pop()
            buf += abs(p - e)
            p = e

        ret = max(ret, buf)

        print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 9316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;

int main () {
    int n,r;
    cin >> n >> r;
    if(n>=10) cout << r;
    else cout << r+100*(10-n);
}

Measured memory_bytes: 256
s = input()

ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        count = 1
        for j in range(i+1, len(s)):
            if s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T':
                count += 1
            else:
                break
        if ans <= count:
            ans = count
print(ans)

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

const int FIRST = -1;
const int LAST = -2;

typedef struct dl {
  int value;
  struct dl *next;
  struct dl *prev;
} dlist;

dlist first = (dlist){ FIRST, NULL, NULL };
dlist last  = (dlist){ LAST, NULL, NULL };

void dl_insert(int x)
{
  dlist *p = (dlist *)malloc(sizeof(dlist));
  p->value = x;

  dlist *f = first.next;

  p->next = f;
  p->prev = &first;
  f->prev = p; 
  first.next = p;
}

void dl_delete(int x)
{
  dlist *p = &first;
  while (p != &last) {
    if (p->value == x) {
      dlist *pp = p->prev;
      dlist *n = p->next;

      pp->next = n;
      n->prev = pp;
      free(p);
    
      break;
    }
    p = p->next;
  }
}

void dl_delete_first()
{
  dlist *f = first.next; 
  dlist *n = f->next;

  first.next = n;
  n->prev = &first;
  free(f);
}

void dl_delete_last()
{
  dlist *l = last.prev;
  dlist *p = l->prev;

  last.prev = p;
  p->next = &last;
  free(l);
}

void output()
{
  dlist *p = first.next;
  for (;;) {
    cout << p->value;
    // printf("%x(%d, %x, %x) ", p, p->value, p->next, p->prev);
    if (p->next == &last) {
      cout << endl;
      break;
    } else {
      cout << ' ';
      p = p->next;
    }
  }
}

int main()
{
  int n; scanf("%d", &n);

  first.next = &last;
  last.prev = &first;

  while (n--) {
    char op[50];
    scanf("%s", op);
    if (strcmp(op, "insert") == 0) {
      int x; scanf("%d", &x);
      dl_insert(x);
    } else if (strcmp(op, "delete") == 0) {
      int x; scanf("%d", &x);
      dl_delete(x);
    } else if (strcmp(op, "deleteFirst") == 0) {
      dl_delete_first();
    } else if (strcmp(op, "deleteLast") == 0) {
      dl_delete_last();
    } else {
      cerr << "error: " << op << endl;
    }
  }

  output();

  return EXIT_SUCCESS;
}




Measured memory_bytes: 34408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int N,K;
#define mod 998244353
#define MN 2005
ll fac[MN<<1],inv[MN<<1],p2[MN<<1];
ll quick_pow(ll x,ll m){
	ll res=1;
	while(m){
		if(m&1) m^=1,res=res*x%mod;
		else m>>=1,x=x*x%mod;
	}
	return res;
}
ll C(int m,int n){
	if(n<0||n>m) return 0;
	return (1LL)*fac[m]%mod*inv[n]%mod*inv[m-n]%mod;
}
ll f(int n,int k,int j){
	register int l;
	ll ans=0;
	for(l=0;l<=k;l++) ans=(ans+(p2[l]*C(n+j-1,l+j-1)%mod)*C(k,l)%mod)%mod;
	return ans;
}
ll calc(int i){
	if(K*2<=i) return 0;
	return (i-1)/2-max(0,i-1-K);
}
int main(){
	register int i;
	p2[0]=1;for(i=1;i<=4005;i++) p2[i]=p2[i-1]*2%mod;
	fac[0]=1;for(i=1;i<=4005;i++) fac[i]=fac[i-1]*i%mod;
	inv[4005]=quick_pow(fac[4005],998244351);for(i=4004;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	scanf("%d%d",&K,&N);
	for(i=2;i<=K*2;i++){
		ll box=calc(i);
		if(i&1) printf("%lld\n",f(N,box,K-box*2)%mod);
		else printf("%lld\n",(f(N,box,K-1-box*2)+f(N-1,box,K-1-box*2))%mod);
	}
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

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

        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            String n=in.next();
            int sum=0;
            for(char a:n.toCharArray()){
                int c=Character.getNumericValue(a); 
                sum+=c;
            }

            if(sum%9==0)
            out.println("Yes");
            else
            out.println("No");
        }
    }
}

Measured memory_bytes: 36596
#!/usr/bin/env pypy3
import collections
import itertools as it
import math
#import numpy as np
 
s = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

sp = s[:len(s)//2]
sn = s[len(s)//2:]

#if len(sp) == len(sn):
#    sn = sn[1:]

ans = 0
#print(sp, sn[::-1])
for sp_, sn_ in zip(sp, sn[::-1]):
    #print(sp_, sn_)
    if sp_ != sn_:
        ans += 1

print(ans)


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll inf = 1000000000000000000;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T=1;
    //cin >> T;
    while(T--){
        ll n,W;
        cin>>n>>W;
        ll v[n],w[n];
        rep(i,n) cin>>w[i]>>v[i];
        ll dp[100005][n];
        rep(i,100005){
            rep(j,n){
                dp[i][j]=inf;
            }
        }
        dp[0][0]=0;
        dp[v[0]][0]=w[0];
        rep_a(i,1,n){
            rep(j,v[i]) dp[j][i]=dp[j][i-1];
            rep_a(j,v[i],100005){
                dp[j][i]=min(w[i]+dp[j-v[i]][i-1], dp[j][i-1]);
            }
        }
        rev(i,100004){
            if(dp[i][n-1]<=W){
                cout<<i<<el;
                break;
            }
        }

    }

    return 0;
}

Measured memory_bytes: 78336
#include<stdio.h>

int main(void){
	int N;
	do{
		scanf("%d", &N);
	}while(N < 10 || N > 99);

	if(N / 10 == 9 || N % 10 == 9)	printf("Yes\n");
	else	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
S = str(input())
T = str(input())
tempcount = 0
mincount = 0

for i in range(len(S) - len(T)+1):
    for j in range(len(T)):
        if S[i + j] != T[j]:
            tempcount += 1
    if i == 0:
        mincount = tempcount
    elif tempcount < mincount:
        mincount = tempcount
    tempcount = 0
    
print(mincount)



Measured memory_bytes: 9120