akhauriyash/Code-Regression huggingface dataset:
# input
h, w = map(int, input().split())

alist = [list(map(int, input().split())) for i in range(h)]
blist = [list(map(int, input().split())) for i in range(h)]

# process
dlist = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        dlist[i][j] = (abs(alist[i][j] - blist[i][j]))

l = [[0]*w for i in range(h)]
l[0][0] = (1<<80+dlist[0][0]) | (1<<80-dlist[0][0])
for i in range(h):
    for j in range(w):
        if i > 0:
            l[i][j] |= l[i-1][j]<<80+dlist[i][j] 
            l[i][j] |= l[i-1][j]<<80-dlist[i][j]
        if j > 0:
            l[i][j] |= l[i][j-1]<<80+dlist[i][j] 
            l[i][j] |= l[i][j-1]<<80-dlist[i][j]

dblist=list(bin(l[h-1][w-1]))[::-1]
m = 80*(h+w-1)
ans = m
for i in range(len(dblist)):
    if dblist[i] == "1":
        ans = min(ans, abs(m-i))

# output
print(ans)


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

using namespace std;

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	string x;
	cin >> x;

	for(int i = 0; i < (int)x.size(); ++i)
		cout << 'x';
	cout << '\n';
	


	return 0;
}

Measured memory_bytes: 256
//package EducationalDPContest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 

	public static void main(String[] args) {
		FastReader sc=new FastReader();
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		
		//Top-Down //Memoization;
		int dp[]=new int[n+1];
		Arrays.fill(dp, -1);
		int res=solve(a,n-1,dp);
		//System.out.println(res);
		
		//Bottom-Up //Tablulation;
		
		//solve2 means dp2 tabluation
		int res2=solve2(a,n);
		System.out.println(res2);
		
	}
	
	
	//Recursion code with memoization;
	
	public static int solve(int a[], int i,int dp[])
	{
		if(i<=0)
		{
			//no items are left;
			return 0;
		}
		if(dp[i]!=-1)
		{
			return dp[i];
		}
		//taking next element
		int option1=Math.abs(a[i]-a[i-1])+solve(a,i-1,dp);
		int option2=Integer.MAX_VALUE;
		if(i>1)
		{
			//you can take two steps;
			option2=Math.abs(a[i]-a[i-2])+solve(a,i-2,dp);
		}
		return dp[i]=Math.min(option1,option2);
		
	}
	
	//Bottom up Approach: Tabulation;
	public static int solve2(int a[], int n)
	{
		int dp[]=new int[n+1];
		Arrays.fill(dp, 0);
		for(int i=1;i<n;i++)
		{
			int option1=Math.abs(a[i]-a[i-1])+dp[i-1];
            int option2 = (i>1) ?  Math.abs(a[i]-a[i-2])+dp[i-2] : Integer.MAX_VALUE;
            dp[i]=Math.min(option1,option2);
		}
		return dp[n-1];
	}

}


Measured memory_bytes: 55804
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;

void main() {
    int n;
    readf("%d\n", &n);
    auto ds = readln().split.map!(to!int);

    auto sum = 0;
    foreach (i; 0 .. n) {
        foreach (j; i + 1 .. n) {
            sum += ds[i] * ds[j];
        }
    }
    writeln(sum);
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    d = [0]*n
    for _ in range(k):
        LI()
        a = LI()
        for i in a:
            d[i-1] = 1
    print(n-sum(d))
    return

#Solve
if __name__ == "__main__":
    solve()


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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main(){
    int N;
    cin>>N;
    graph g(N,vector<int>(N));
    vector<int> exi(N*N);
    rep(i,N*N) cin>>exi[i];
    rep(i,N){
        rep(j,N) {
            g[i][j]=min(min(i,j),min(N-1-i,N-1-j));
        }
    }
    vector<vector<bool>> seat(N,vector<bool>(N,true));
    int ans = 0;
    rep(i,N*N){
        int t = exi[i];
        t--;
        int x = t/N,y=t%N;
        ans += g[x][y];
        seat[x][y]=false;
        queue<P> bfs;
        bfs.push(make_pair(x,y));
        while(!bfs.empty()){
            P p = bfs.front();
            bfs.pop();
            int nx = p.first;
            int ny = p.second;
            if(seat[nx][ny]){
                rep(i,4){
                    int nnx = nx+dx[i];
                    int nny = ny+dy[i];
                    if(nnx<0||nnx>=N||nny<0||nny>=N) continue;
                    if(g[nnx][nny]>g[nx][ny]+1){
                        g[nnx][nny]= g[nx][ny]+1;
                        bfs.push(make_pair(nnx,nny));
                    }
                }
            }
            else{
                rep(i,4){
                    int nnx = nx+dx[i];
                    int nny = ny+dy[i];
                    if(nnx<0||nnx>=N||nny<0||nny>=N) continue;
                    if(g[nnx][nny]>g[nx][ny]){
                        g[nnx][nny] = g[nx][ny];
                        bfs.push(make_pair(nnx,nny));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5252
// SeeAlso: 

#include <bits/stdc++.h>

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 MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
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; }

const long long INF = 1LL<<60;

int main() {
    ll n,x;
    cin >> n >> x;

    ll ans = 0;

    vector<ll> a;
    rep(i,n) {
        ll t;
        cin >> t;
        if(t>x) ans += (t-x);
        chmin(t,x);
        a.push_back(t);
    }

    rep(i, n) {
        ll sum = a[i] +a[i+1];
        if(sum>x) {
            ll temp = sum - x;
            a[i+1] = (a[i+1]-temp>0) ? (a[i+1]-temp) : 0;
            ans+= temp;
        }
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < n; i++)
using namespace std;
int dp[3001][3001];
int s_size, t_size;
string s, t;

string solve() {
	FOR(i, t_size + 1) dp[0][i] = 0;
	FOR(i, s_size + 1) dp[i][0] = 0;
	for(int i = 1; i <= s_size; i++) {
		for(int j = 1; j <= t_size; j++) {
			if(s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
		}
	}
	
	string result = "";
	int i = s_size;
	int j = t_size;
	while(i > 0 && j > 0) {
		if(s[i - 1] == t[j - 1]) {
			result += s[i - 1];
			--i;
			--j;
		} else {
			if(dp[i - 1][j] > dp[i][j - 1]) --i;
			else --j;
		}
	}
	reverse(result.begin(), result.end());
	return result;
}

int main() {
	cin>>s>>t;
	s_size = s.size();
	t_size = t.size();
	memset(dp, -1, sizeof(dp));
	string result = solve();
	cout<<result<<"\n";
	return 0;
}

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

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_A&lang=jp

struct Edge {
  int dst,weight;
};

int TravelingSalesmanProblem(int V,int E,vector<int> s,vector<int> t,vector<int> d) {
  vector<vector<Edge> > G(V);
  vector<int> cost(V,INT_MAX);
  cost[0] = 0;
  for(int i=0;i<E;++i) {
    G[s[i]].push_back((Edge){t[i],d[i]});
    if( t[i] == 0 ) {
      cost[s[i]] = min(cost[s[i]],d[i]);
    }
  }
  vector<vector<int> > dp((1<<V),vector<int>(V,INT_MAX));
  dp[1][0] = 0;
  for(int state=0;state<(1<<V);++state) {
    for(int cur=0;cur<V;++cur) if( dp[state][cur] != INT_MAX ) {
        for(int i=0;i<(int)G[cur].size();++i) {
          Edge &e = G[cur][i];
          if( (state>>e.dst) & 1 ) continue;
          dp[state|(1<<e.dst)][e.dst] = min(dp[state|(1<<e.dst)][e.dst],
                                            dp[state][cur]+e.weight);
        }
      }
  }

  int mini = INT_MAX;
  for(int i=0;i<V;++i) if( dp[(1<<V)-1][i] != INT_MAX && cost[i] != INT_MAX ) {
    mini = min(mini,dp[(1<<V)-1][i]+cost[i]);
  }
  return (mini!=INT_MAX)?mini:-1;
}

int main() {
  int V,E;
  cin >> V >> E;
  vector<int> s(E), t(E), d(E);
  for(int i=0;i<E;++i) cin >> s[i] >> t[i] >> d[i];
  cout << TravelingSalesmanProblem(V,E,s,t,d) << endl;
  return 0;
}

Measured memory_bytes: 4436
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    int x, y;
    scanf("%d", &n);
    x = 800 * n;
    y = floor(n/15) * 200;
    printf("%d\n", x-y);
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef long long lint;

const lint MOD = (lint)1e9 + 7;

lint gcd(lint _a, lint _b) {
	return _b != 0 ? gcd(_b, _a % _b) : _a;
}

lint lcm(lint _a, lint _b) {
	return _a / gcd(_a, _b) * _b;
}

typedef pair< lint, lint > Val;

class SegTree {
private:
	int t_size;
	vector< Val > data;
	
	int right_t(int k) {
		return 2 * k + 2;
	}
	
	int left_t(int k) {
		return 2 * k + 1;
	}
	
public:
	SegTree(int size_) {
		t_size = 1;
		while (t_size < size_) t_size *= 2;
		data.assign(2 * t_size - 1, Val(1, 0));
	}
	
	Val calculation(Val v1, Val v2) {
		lint vf1 = v1.first, vf2 = v2.first;
		lint lcm_ = lcm(vf1, vf2);
		lint mul1 = lcm_ / vf1 % MOD, mul2 = lcm_ / vf2 % MOD;
		return Val(lcm_, (mul1 * v1.second + mul2 * v2.second) % MOD);
	}
	
	void update(int k, Val v) {
		k += t_size - 1;
		data[k] = v;
		
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = calculation(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	Val query(int a, int b) {
		return query(a, b, 0, 0, t_size);
	}
	
	Val query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return Val(1, 0);
		if (a <= l && r <= b) return data[k];
		return calculation(query(a, b, left_t(k), l, (l + r) / 2),
						   query(a, b, right_t(k), (l + r) / 2, r));
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	
	vector< int > p(N), x(N);
	
	for_(i,0,N) {
		cin >> p[i]; --p[i];
		x[i] = i;
	}
	
	SegTree segt(N);
	
	vector< int > hit(N, 0), sum(N, 0);
	
	for_(i,1,41) {
		vector< int > y(N);		
		for_(j,0,N) y[j] = p[x[j]];
		
		for_(j,0,N) {
			x[j] = y[j];
			sum[j] += x[j] + 1;
			
			if (x[j] == j && hit[j] == 0) {
				segt.update(j, Val(i, sum[j]));
				hit[j] = 1;
			}
		}
	}
	
	for_(i,0,Q) {
		int l, r;
		cin >> l >> r;
		
		Val ans = segt.query(l-1,r);
		
		cout << ans.second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7052
use strict;
use warnings;

my $N = <>;
my @A = glob(<>);
my $APPROVED = 1;

foreach (@A) {
    if ($_ % 2 == 0) {
        if ($_ % 3 != 0 && $_ % 5 != 0) {
            $APPROVED &= 0;
        }
    }
}

if ($APPROVED) {
    print("APPROVED\n");
}
else {
    print("DENIED\n");
}

Measured memory_bytes: 768
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if ((a * b) % 2 == 0){
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 22612
n = int(input())
list = input().split()

for t in range(len(list)):
    list[t] = int(list[t])

cnt = 0

for idx in range(n):
    
    # 高さ：0 <= h <=100
    for t in range(101):
        if 0 != list[idx]:
            # 最小値が0以外の場合
            idx2 = n
            t_cnt = min(list[idx:n])
            
            # 最小値が0の場合
            # 0までの最小値を求める
            if t_cnt == 0:
                idx2 = list[idx:n].index(0) + idx
                t_cnt = min(list[idx:idx2])

            for idx3 in range(idx,idx2):
                list[idx3] = list[idx3] - t_cnt
            cnt += t_cnt
        else:
            break
        
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

bool search(const vector<int> &v, int key) {
	int left, right, mid;
	left = 0;
	right = v.size();
	while (left < right) {
		mid = (left + right) / 2;
		if (v[mid] == key) {
			return true;
		} else if (key < v[mid]) {
			right = mid;
		} else if (key > v[mid]) {
			left = mid + 1;
		}
	}
	return false;
}	

int main() {
	int n;
	cin >> n;
	vector<int> na(n);
	for(int i=0;i<n;++i) scanf("%d", &na[i]); 
	int q;
	cin >> q;
	int sum = 0;
	for(int i=0;i<q;++i) {
		int t;
		cin >> t;
		sum += search(na, t) ? 1 : 0;
	}	
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000007;
const int maxn = 1005;
const int maxw = 10005;

int a[maxn], b[maxn];
int Index[maxw];
bool vis[maxw];


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

	int min_w = inf;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		b[i] = a[i];
		min_w = min(min_w, a[i]);
	}
	sort(b, b + n);

	for (int i = 0; i < n; ++i) Index[b[i]] = i;

	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (vis[i]) continue;

		int cnt = 0, sum = 0;
		int cur = i;
		int minm = inf;

		while (true) {
			if (vis[cur]) break;
			int x = a[cur];
			++cnt; sum += x;
			minm = min(minm, x);
			vis[cur] = true;
			cur = Index[x];
		}

		res += min(sum + (cnt - 2) * minm, sum + minm + (cnt + 1) * min_w);
	}
	printf("%d\n", res);
	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        List<Integer> cList = new ArrayList<>();
        List<Integer> tList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            cList.add(sc.nextInt());
            tList.add(sc.nextInt());
        }
        Integer minCost = null;
        for (int i = 0; i < n; i++) {
            if (tList.get(i) > t) {
                continue;
            }
            int cost = cList.get(i);
            if (minCost == null || cost < minCost) {
                minCost = cost;
            }
        }
        if (minCost == null) {
            System.out.println("TLE");
            return;
        }
        System.out.println(minCost);
    }

}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      cout << i << 'x' << j << '=' << i*j << endl;
    }
  }
  return 0;
}




Measured memory_bytes: 3084
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *


N = INT()
A = LIST()
A.sort()

if N%2:
	for i in range(N):
		if A[i] != -(-i//2) *2:
			print(0)
			break
	else:
		print(pow(2, N//2, mod))

else:
	for i in range(N):
		if A[i] != i//2*2 +1:
			print(0)
			break
	else:
		print(pow(2, N//2, mod))


Measured memory_bytes: 15960
#time gap
n=int(input())
lists=list(map(int,input().split()))
if n>24:
    print(0)
else:
    timelist=[0 for i in range(13)]
    #timelist[i]ってところでi=0,1,2,....12に代入する
    for i in lists:
        timelist[i]+=1
    flag=True
    for j in range(13):
        if j==0:
            if timelist[j]>0:
                flag=False
        else:
            if timelist[j]>2:
                flag=False
    if flag:
        uselist1=[]
        uselist2_=[]
        for i in range(13):
            if timelist[i]==1:
                uselist1.append((i))
            if timelist[i]==2:
                uselist2_.append((i))
            else:
                continue
        uselist2=[]
        for j in uselist2_:
            uselist2.append(j)
            uselist2.append(24-j)
        uselist2=list(set(uselist2))
        lens=len(uselist1)
        minilist=[]
        for i in range(2**lens):
            sublist=[0]
            mini=100
            sublist=sublist+uselist2
            j=format(i,"0%ib"%lens)
            for k in range(lens):
                if j[k]=="0":
                    sublist.append(uselist1[k])
                else:
                    sublist.append(24-uselist1[k])
            sublists=sorted(sublist)
            lenss=len(sublists)
            for k in range(1,lenss):
                mini=min(mini,sublists[k]-sublists[k-1])
            mini=min(mini,24-sublists[-1],sublists[-1])
            minilist.append(mini)  
        else:
            print(max(minilist))
    if not flag:
        print(0)

Measured memory_bytes: 3188
def slove(ab_list, k):
    num_list = []
    count = 0
    for a, b in sorted(ab_list, key=lambda x: x[0]):
        count += b
        if count >= k:
            break

    return a

if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    ab_list = [[int(i)for i in input().split()] for i in range(n)]
    print(slove(ab_list, k))

Measured memory_bytes: 23640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	typedef tuple<int, int, int> Data;

	cin.sync_with_stdio(false);
	int T, P, R;
	while (cin >> T >> P >> R, T)
	{
		vector<vi> wa(T, vi(P));
		vi ac(T), penalty(T);
		REP(i, R)
		{
			int tid, pid, time; string mes;
			cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT")
			{
				ac[tid]++;
				penalty[tid] += wa[tid][pid] * 1200 + time;
			}
			else
			{
				wa[tid][pid]++;
			}
		}
		vector<Data> v;
		REP(i, T) v.emplace_back(-ac[i], penalty[i], i + 1);
		sort(ALL(v));
		REP(i, T) cout << get<2>(v[i]) << " " << -get<0>(v[i]) << " " << get<1>(v[i]) << endl;
	}
	return 0;
}

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

const int N = (int)1e6;
int connected;
int par[N],sz[N];

void init(int n)
{
    for (int i=1; i<=n; ++i)
    par[i]=i,sz[i]=1;
    connected = n;
}

int getPar(int k)
{
    while(k!=par[k])
    {
        par[k]=par[par[k]];
        k = par[k];
    }
    return k;
}

int getSize(int k)
{
    return sz[ getPar(k) ];
}

void unite(int u,int v)
{
    int par1 = getPar(u);
    int par2 = getPar(v);

    if (par1==par2)
        return;
    
    connected--;

    if (sz[par1]>sz[par2])
        swap(par1,par2);
    
    sz[par2]+=sz[par1];
    sz[par1] = 0;
    par[par1] = par[par2];
}

signed main()
{
    int n,m;
    cin>>n>>m;
    init(n);
    for (int i=1; i<=m; ++i)
    {
        int u,v;
        cin>>u>>v;
        unite(u,v);
    }
    int ans = 0;
    for (int i=1; i<=n; ++i)
        ans = max(ans,getSize(i));
    
    cout<< ans <<endl;
}


Measured memory_bytes: 5136
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define MAXCHAR 255

using namespace std;

int main()
{
	int input = 0;
	string output;
	cin >> input;

	int N = input % 10;
	if (N == 3)
	{
		output = "bon";
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8)
	{
		output = "pon";
	}
	else
	{
		output = "hon";
	}

	cout << output << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <chrono>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std::chrono;
using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define maxn 100001
#define MOD   1000000007
#define int long long
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;
int dp[101][maxn];
void me(){
memset(dp,-1,sizeof(dp));
}
int a[101];
int val[101];
int n;
int state(int idx,int w){
   //choose
   if(idx>=n)
    return 0;
   if(dp[idx][w]+1)
    return dp[idx][w];
   int f=-1;
   if(w>=a[idx])
      f=val[idx]+state(idx+1,w-a[idx]);
   int s=state(idx+1,w);
  return dp[idx][w]=max(f,s);
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  me();
  int w;
  cin>>n>>w;
  for(int i=0;i<n;i++)
    cin>>a[i]>>val[i];
  cout<<state(0,w);
}


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

using namespace std;

int main()
{
    long N, Sum = 0;
    vector<long> v;
    vector<long> a;

    cin >> N;

    for (int i = 1; i <= N; i++)
    {
        v.push_back(i);
    }

    for (int i = 0; i <= v.size(); i++)
    {
        if (v[i] % 3 == 0 || v[i] % 5 == 0)
        {
            a.push_back(0);
        }

        else
        {
            a.push_back(v[i]);
        }
    }

    for (int i = 0; i < a.size(); i++)
    {
        Sum += a[i];
    }

    cout << Sum;
}

Measured memory_bytes: 23372
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> vp;
    for(int i=0; i<n; i++){
        int x,v;
        cin>>x>>v;
        vp.push_back({v,x});
    }
    sort(vp.begin(),vp.end());
    
    vector<pair<int,int>> ranges(n,{0,0});
    
    vector<int> LHelp(n,0);
    for(int i=1; i<n; i++){
        if(vp[i].second>vp[LHelp[i-1]].second){
            LHelp[i]=i;
        }
        else{
            LHelp[i]=LHelp[i-1];
        }
    }
    
    vector<int> RHelp(n,n-1);
    for(int i=n-2; i>=0; i--){
        if(vp[i].second<vp[RHelp[i+1]].second){
            RHelp[i]=i;
        }
        else{
            RHelp[i]=RHelp[i+1];
        }
    }
    
    for(int i=0; i<n; i++){
        int l=0, r=i;
        while(l<r){
            int mid=(l+r)/2;
            if(vp[LHelp[mid]].second>=vp[i].second){
                r=mid;
            }
            else{
                l=mid+1;
            }
            
        }
        ranges[i].first=LHelp[l];
        
        l=i, r=n-1;
        while(l<r){
            int mid=(l+r)/2;
            if(vp[RHelp[mid+1]].second<=vp[i].second){
                l=mid+1;
            }
            else{
                r=mid;
            }
            
        }
        ranges[i].second=RHelp[l];
        //cout<<ranges[i].first<<" ";
    }
    
    /*
    for(auto p:ranges){
        cout<<p.first<<" "<<p.second<<endl;
    }
    */
    
    sort(ranges.begin(),ranges.end());
    vector<long long> dp(n,0), sum(n,0);
    int pos=0;
    dp[0]=1;
    sum[0]=1;
    
    for(int i=1; i<n; i++){
        dp[i]=!ranges[i].first;
        while(ranges[pos].second<ranges[i].first-1){
            pos++;
        }
        dp[i]+=sum[i-1];
        if(pos) dp[i]-=sum[pos-1];
        sum[i]=sum[i-1]+dp[i];
        dp[i]+=MOD;
        dp[i]%=MOD;
        
        sum[i]+=MOD;
        sum[i]%=MOD;
    }
    long long ans=0;
    for(int i=0; i<n; i++){
        if(ranges[i].second==n-1){
            ans+=dp[i];
            ans%=MOD;
        }
    }
    
    cout<<ans;
    
}

Measured memory_bytes: 8048
#include <stdio.h>

int main(void)
{
	int m, f, r;
	int i;

	for (i = 0; i < 50; i++)
	{

		scanf("%d %d %d", &m, &f, &r);

		if ((m == -1) && (f == -1) && (r == -1))
		{
			break;
		}

		if ((m == -1) || (f == -1))
		{
			printf("F\n");
		}
		else if((m + f >= 80))
		{
			printf("A\n");
		}
		else if ((m + f >= 65) && (m + f < 80))
		{
			printf("B\n");
		}
		else if ((m + f >= 50) && (m + f < 65))
		{
			printf("C\n");
		}
		else if ((m + f >= 30) && (m + f < 50))
		{
			if (r >= 50)
			{
				printf("C\n");
			}
			else if(r < 50)
			{
				printf("D\n");
			}
		}
		else
		{
			printf("F\n");
		}
	}

	return 0;
}


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

int main(){
    long long int n,k;
    long long int ans=0;
    scanf("%lld",&n);
  
  if(n%2){
    printf("0");
    return 0;
  }
 for(int i=0;i<10000;i++){
   k=pow(5,i+1);
   if(n/k>=1){
    ans += n/(2*k);
   }
 }
  
  printf("%lld",ans);
  return 0;
}



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

int main(){
  int K, N;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  if (N<=K){
    printf("1\n");
  } else {
    printf("%d\n", 1+(N-K+(K-2))/(K-1));
  }
  return 0;
}


Measured memory_bytes: 1016
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>


using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;



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

    int r = 0;
    set<int> s;

    int ans = 0;
    REP(i, N) {
        int a;
        cin >> a;
        if(s.find(a) != s.end()) {
           r ^= 1;
        } else {
            s.insert(a);
            ++ans;
        }
    }

    cout << ans - r << endl;
}


Measured memory_bytes: 4992
/* ex 9_2
   person_A */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node  **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}


int main(void){
    //最初のノードの指す先
    node *first = NULL;
    char top,cube;
    int i,count=0;
    
    while(1){
        //赤色のキューブ'0'と青色のキューブ'1'を下の方から入力
        scanf("%c",&cube);
        //改行文字で終了
        if(cube=='\n'){
            break;
        }
        else{
            //机の上にキューブがなければ、一つを置くだけ
            if(first==NULL){
                push(&first,cube);
            }
            else{
                top=pop(&first);
                //先頭と異なる色であれば、カウントする
                if(top!=cube){
                    count+=2;
                }
                //先頭と同じ色であれば、二つを机の上に置き戻す
                else{
                    push(&first,top);
                    push(&first,cube);
                }
            }
        }
    }
    

    //結果の出力
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll a, b, n;
	cin>>a>>b>>n;
	if(b==n){
		cout<<(a*(n-1))/b;
	}
	else if(b<n){
		cout<<(a*(b-1))/b;
	}
	else {
		cout<<(a*n)/b;
	}
	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long> hs;
  hs.resize(n);
  for (int i = 0; i < n; i++) { cin >> hs[i]; }

  sort(hs.begin(), hs.end());

  long sum = 0;
  for (int i = 0; i < n - k; i++) { sum += hs[i]; }

  cout << sum << endl;
}



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

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = Enumerable.Range(0, input[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
            var b = Enumerable.Range(0, input[1]).Select(_ => int.Parse(Console.ReadLine())).ToArray();

            foreach (var item in a.Select(q => q.Select((qi, i) => qi * b[i]).Sum())) {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 9760
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

const p = 998244353

func Solve() {
  var N int
  NextInt(&N)
  var R, G, B []int
  S := NextLine()
  for i, s := range S {
    if s == 'R' { R = append(R, i) }
    if s == 'G' { G = append(G, i) }
    if s == 'B' { B = append(B, i) }
  }
  RGB := make([][]int, N)
  C := make([]int, 3 * N)
  for i := range RGB {
    RGB[i] = []int{R[i], G[i], B[i]}
    sort.Ints(RGB[i])
    C[RGB[i][0]] = 0
    C[RGB[i][1]] = 1
    C[RGB[i][2]] = 2
  }
  F, _, _ := Factorial(N)
  ans := 1
  cnt := make([]int, 3)
  for _, c := range C {
    cnt[c]++
    if c < 1 { continue }
    ans *= cnt[c - 1] - cnt[c] + 1
    ans %= p
  }
  Write(ans * F[N] % p)
  return
}

func main() {
  Solve()
  Output()
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<int>
#define vpi vector< pi > 
const int N = 100010;
ll A[N],B[N],ans1[N],ans2[N],res[N],n;
struct graph{
    ll v,a,b;
};
vector<graph> v[N];
void bfs(int src,ll a[],int typ)
{
    priority_queue< pi, vector <pi> , greater<pi> > pq;
 
    vector<ll> dist(N, 1000000000000000ll);
 
    // Insert source itself in priority queue and initialize
    // its distance as 0.
    pq.push(make_pair(0, src));
    dist[src] = 0;
 
    /* Looping till priority queue becomes empty (or all
      distances are not finalized) */
    while (!pq.empty())
    {
        // The first vertex in pair is the minimum distance
        // vertex, extract it from priority queue.
        // vertex label is stored in second of pair (it
        // has to be done this way to keep the vertices
        // sorted distance (distance must be first item
        // in pair)
        int x = pq.top().second;
        pq.pop();
 
        // 'i' is used to get all adjacent vertices of a vertex
        
        for (auto g:v[x])
        {
            // Get vertex label and weight of current adjacent
            // of u.
            int y = g.v;
            ll weight;
            if(typ==0)
                weight=g.a;
            else
                weight=g.b;
 
            //  If there is shorted path to v through u.
            if (dist[y] > dist[x] + weight)
            {
                // Updating distance of v
                dist[y] = dist[x] + weight;
                pq.push(make_pair(dist[y], y));
            }
        }
    }
    for(int i=1;i<=n;i++)
        a[i]=dist[i];
}
int main()
{
    int m,s,t,x,y,a,b;
    cin>>n>>m>>s>>t;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y>>a>>b;
        v[x].pb({y,a,b});
        v[y].pb({x,a,b});
    }
    ll val=100000000;
    val=val*10000000;
    bfs(s,ans1,0);
    bfs(t,ans2,1);
    res[n+1]=0;
    for(int i=n;i>0;i--)
    {
        res[i]=max(val-ans1[i]-ans2[i],res[i+1]);
    }
    for(int i=1;i<=n;i++)
        cout<<res[i]<<"\n";
    return 0;
}

Measured memory_bytes: 15756
IDENTIFICATION DIVISION.
PROGRAM-ID. 162B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC  9(7) COMP.
01 I          PIC  9(7) COMP.
01 S          PIC  9(6) COMP.
01 A1         PIC  9(1).
01 A2         PIC  9(1).
01 GK         PIC  9(18) COMP.
01 OUT        PIC  Z(17)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    DIVIDE I BY 3 GIVING S REMAINDER A1
    DIVIDE I BY 5 GIVING S REMAINDER A2
*>
    IF (A1 NOT = 0) AND (A2 NOT = 0)
      ADD I TO GK
    END-IF
  END-PERFORM.
*>
  MOVE GK TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

char s[1000000];
int n;

int main(){
  cin>>s;
  n = strlen(s);

  if(n%2==0^s[0]==s[n-1])
    cout<<"Second"<<endl;
  else
    cout<<"First"<<endl;

  return 0;
}


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

using namespace std;

#define int long long
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int N; cin >> N;
  vector<int> A(N);
  vector<int> used(N+1, 0);
  rep(i, N) {
    cin >> A[i];
    used[A[i]]++;
  }
  bool flag = false;
  for(int i = !(N%2); i < N; i += 2) {
    if(i == 0 && used[i] != 1) flag = true;
    else if(i != 0 && used[i] != 2) flag = true;
  }
  int ans = 1LL;
  rep(i, N/2) {
    ans = (ans * 2LL) % mod;
  }

  if(!flag) cout << ans << endl;
  else cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 1792
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec1, vec2;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    vec1.push_back(a);
    vec2.push_back(b);
  }  
  sort(vec1.begin(), vec1.end());
  sort(vec2.begin(), vec2.end());
  int l = vec1[n / 2], r = vec2[n / 2];

  if (n % 2 == 0) {
    l = vec1[(n - 1) / 2] + vec1[n / 2];
    r = vec2[(n - 1) / 2] + vec2[n / 2];
  }

  cout << r - l + 1 << endl;

  return 0;
}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c[3][3];
    rep(i,3)
    rep(j,3)cin >> c[i][j];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	string s; cin >> s;
	int n = s.size();
	rep(i, n) rep(j, i) {
		if (s[j] == 'C' && s[i] == 'F') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256