akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int n, start;
vector<pair<int, bool> > v[100004];
int isGrouped[100004];
int ans[100004];

int isGroup(int node) {
	int res=1;
	for (int i=0; i<v[node].size(); i++) {
		if (!v[node][i].second) {
			if (!isGrouped[v[node][i].first]) {
				isGrouped[v[node][i].first]=start;
				res+=isGroup(v[node][i].first);
			}
			isGrouped[v[node][i].first]=start;
		}
		else break;
	}
	return res;
}

int main() {
	int m, k; scanf("%d%d%d",&n,&m,&k);
	while (m--) {
		int a, b; scanf("%d%d",&a,&b);
		v[a].push_back({b, 0});
		v[b].push_back({a, 0});
	}
	while (k--) {
		int a, b; scanf("%d%d",&a,&b);
		v[a].push_back({b, 1});
		v[b].push_back({a, 1});
	}
	for (int i=1; i<=n; i++) {
		if (!isGrouped[i]) {
			start=i; isGrouped[i]=i; ans[i]=isGroup(i);
		}
		int dd=ans[isGrouped[i]]-1-v[i].size();
		for (int j=v[i].size()-1; j>=0; j--) {
			if (!v[i][j].second) break;
			if (isGrouped[i]!=isGrouped[v[i][j].first]) dd++;
		}
		printf("%d ",dd);
	}
	return 0;
}

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



signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int k;
    cin>>k;
    int tot=0;
    int tt=0;
    for(int i=1;i<=5000000;i++)
    {
        tt*=10;
        tt%=k;
        tt+=7;
        tt%=k;
        if(tt==0)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}


Measured memory_bytes: 3632
def read_i
  gets.chomp.split(' ').map(&:to_i)
end

minutes = []
5.times do |i|
  minutes << read_i[0]
end

non_just_minutes = minutes.select { |minute| minute % 10 != 0 }
just_minutes = minutes.select { |minute| minute % 10 == 0 }

sorted_minutes = non_just_minutes.sort_by do |minute|
  minute % 10
end

time = 0

just_minutes.each do |num|
  time += num
end

if sorted_minutes.count > 0
  last = sorted_minutes.shift

  sorted_minutes.each do |num|
    time += ((num * 0.1).ceil * 10)
  end

  time += last
end

puts time


Measured memory_bytes: 1788
#include<stdio.h>
#include<map>
#include<algorithm>
#include<iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>

#define MODULO 1000000007ll

using namespace std;


int cnt[1000];
int cn4,cn2,cn1;
int main() {
    std::ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j <s.size() ; ++j) {
            cnt[s[j]-'a']++;
        }
    }
    if(h%2==1&&w%2==1){cn1++;
        cn2 = h + w - 2;
        cn4 = h * w - cn2 - cn1;
    }
    else if(h%2==1){
        cn2 = w;
        cn4 = h * w - cn2 - cn1;
    }
    else if (w%2==1){
        cn2 = h;
        cn4 = h * w - cn2 - cn1;
    }
    else{
       cn4 = h * w;
//        cn4 = h * w - cn2 - cn1;
    }
//    cn2/=2;
//    cn4/=4;
//    cout <<cn1<<cn2<<cn4<<endl;
    for (int k = 0; k < 28; ++k) {
        int t = cnt[k];
//        cout << t << endl;
        while(cnt[k]>0){
            if(cn4>3&&cnt[k]>=4){
                cn4-=4;
                cnt[k]-=4;
            }
            else if(cn2>1&&cnt[k]>=2){
                cn2-=2;
                cnt[k]-=2;
            }
            else if(cn1>0){
                cn1-=1;
                cnt[k]-=1;
            }
            else{
//                cout << t <<cnt[k]<< cn2<<cn4<<cn1<<endl;
                cout <<"No"<<endl;
                return 0;
            }
        }

    }
    cout << "Yes"<<endl;
    return 0;
}

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

ans = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        d = min(j-i, abs(X-1-i)+abs(Y-1-j)+1)
        ans[d-1] += 1

for a in ans:
    print(a)

Measured memory_bytes: 74516
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String nyuryoku = sc.nextLine();
 	String[] kari = nyuryoku.split(" ",0);
	int a = Integer.parseInt(kari[0]);
	int b = Integer.parseInt(kari[1]);

        System.out.println(a*b + " " + (a+b) * 2);
    }
}

Measured memory_bytes: 26056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = h1 * 60 + m1;
	int t2 = h2 * 60 + m2;
	int d = t2 - t1;
	cout << d - k << '\n';
	return 0;
}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a == 1)
            a = 14;
        if (b == 1)
            b = 14;

        if (a>b)
            System.out.println("Alice");
        else if (b>a)
            System.out.println("Bob");
        else
            System.out.println("Draw");

    }
}


Measured memory_bytes: 35724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        
        int sum = 0;
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < N; i++) {
            int m = sc.nextInt();
            X -= m;
            sum++;
            min = Math.min( min, m );
        }
        sum += X / min;
        System.out.println(sum);
    }
}


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

int main(){
  int n,k;
  cin>>n>>k;
  ll ans=0;
  for(int b = k+1; b<=n; b++){
    if(n%b<k) ans+=n/b*(b-k);
    else ans+=n/b*(b-k)+n%b-k+1;
  }
  if(k==0) ans-=n;
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long  a[n];
  for(long long i=0;i<n;i++){
    cin >> a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  long long sum=0;
  for(long long i=0;i<n;i++){
    sum+=abs(a[i]-a[n/2]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
def main():
    n = int(input())
    p = [int(i) for i in input().split()]
    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            count += 1
    return count

if __name__ == '__main__':
    print(main())

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

int countDivisor(int n) {
    int ct = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) ct++;
    }
    return ct;
}

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

    int ans = 0;
    for (int i = 1; i <= n; i = i + 2) {
        if (countDivisor(i) == 8) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K;cin>>N>>K;string S;cin>>S;
  
  vector<int> cumsum(1,1);
  for(int i=1;i<N;i++){
    if(S[i]!=S[i-1])cumsum.push_back(cumsum[cumsum.size()-1]);
    cumsum[cumsum.size()-1]++;
  }
  if(2*K-(S[0]=='0')>=cumsum.size()){cout<<N;return 0;}
  int s=cumsum[2*K-(S[0]=='0')];
  
  int ans=s;
  int l=(S[0]=='1'),r=2*K-(S[0]=='0')+2;
  while(r<cumsum.size()){
    ans=max(ans,cumsum[r]-cumsum[l]);
    l+=2;r+=2;
  }
  if(S[N-1]=='0'){
    ans=max(ans,cumsum[cumsum.size()-1]-cumsum[cumsum.size()-1-2*K]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;

bool is_prime[2000100];
int cnt[2000100];

int main(){
	fill(is_prime, is_prime + 1000000, 1);
	is_prime[0] = 0;
	is_prime[1] = 0;
	for (int i = 2; i <= (int)1e6; i++){
		if (is_prime[i]){
			for (int j = i * 2; j <= (int)1e6; j += i){
				is_prime[j] = 0;
			}
		}
	}
	FOR(i, 1, 2000000+10){
		if (is_prime[i])cnt[i]++;
		cnt[i] += cnt[i - 1];
	}
	//REP(i, 10){
	//	cout << i << " " << cnt[i] << endl;
	//}
	//for (int i = 999983 - 20; i <= 999983 + 20; i++){
	//	cout << i << " " << cnt[i] << endl;
	//}
	while (cin >> n&&n){
		int ans = 0;
		REP(i, n){
			int p, m;
			cin >> p >> m;
			int x = cnt[p + m];
			if (p - m - 1 >= 0)x -= cnt[p - m - 1];
			ans += (x - 1);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 11784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n,0),y(n,0);

  rep(i,n) {
    cin >> x[i];
    y[i] = x[i];
  }
  sorti(y);
  int ave1 = y[n / 2];
  int ave2 = y[n/2 -1];

  rep(i,n) {
    if (x[i] <= ave2) {
      cout << ave1 << endl;
    } else {
      cout << ave2 << endl;
    }
  }
}


Measured memory_bytes: 5376
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    vector<bool> S(13);
    vector<bool> H(13);
    vector<bool> C(13);
    vector<bool> D(13);
    int n;
    read(n);
    rep(i,n){
        char c;
        int n;
        read(c);
        read(n);
        switch(c){
            case 'S':
                S.at(n - 1) = true;
                break;
            case 'H':
                H.at(n - 1) = true;
                break;
            case 'C':
                C.at(n - 1) = true;
                break;
            case 'D':
                D.at(n - 1) = true;
                break;
        }
    }
    rep(i,13){
        if(S.at(i) == false){
            print("S");
            print(" ");
            print(i + 1);
            printn;
        }
    }
    rep(i,13){
        if(H.at(i) == false){
            if(H.at(i) == false){
                print("H");
                print(" ");
                print(i + 1);
                printn;
            }
        }
    }
    rep(i,13){
        if(C.at(i) == false){
            if(C.at(i) == false){
                print("C");
                print(" ");
                print(i + 1);
                printn;
            }
        }
    }
    rep(i,13){
        if(D.at(i) == false){
            if(D.at(i) == false){
                print("D");
                print(" ");
                print(i + 1);
                printn;
            }
        }
    }
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3216
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll MAXN = 1010; 
const ll MOD = 1e9 + 7; 

ll n , m ;
char grid[MAXN][MAXN] ; 
ll dp[MAXN][MAXN] ; 
ll dfs(ll x,ll y){
	if ( x >= n || y >= m ) return 0 ; 
	if ( x == n-1 && y == m-1 ){
		return 1 ; 
	}
	if ( grid[x][y] == '#' ) return 0 ; 
	if ( dp[x][y] != -1 ) return dp[x][y] ; 
	ll ans = 0 ;
	ans += (dfs(x+1,y) + dfs(x,y+1)) % MOD  ; 
	return dp[x][y] = ans % MOD ; 
}
int main(){
    fastio
    memset(dp,-1,sizeof dp) ; 
    cin >> n >> m ;
    for(ll i=0;i<n;i++){
    	for(ll j=0;j<m;j++){
    		cin >> grid[i][j] ;
    	}
    }
    cout << dfs(0,0) << endl;
    return 0 ;
}


Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	string s, t;
	cin >> s >> t;
	vector<vector<int> > hash(30);
	rep(i, s.length()){
		hash[s[i]-'a'].push_back(i);
	}

	ll ans = 0;
	int now = -1;
	rep(i, t.length()){
		int tmp = t[i]-'a';
		if(hash[tmp].size() == 0){
			cout << "-1" << endl; //その文字はない
			return 0;
		}

		bool flag = false;
		/*
		rep(j, hash[tmp].size()){
			if(now < hash[tmp][j]){
				now = hash[tmp][j];
				flag = true;
				break;
			}
		}
		*/
		if(upper_bound(hash[tmp].begin(), hash[tmp].end(), now) == hash[tmp].end()){
			ans += s.length();
			now = hash[tmp][0];
		} else{
			now = *upper_bound(hash[tmp].begin(), hash[tmp].end(), now);
		}
		//if(!flag){
		//	ans += s.length();
		//	now = hash[tmp][0];
		//}
	}
	ans += now + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
 #include <limits.h>
int main(void)
{
    int X;
    scanf("%d",&X);
    printf("%d",NextPrime(X,INT_MAX));
    return 0;
}
/*素数を判定する関数
 * 素数であれば1を返し、素数でなければ0を返す
 */
int prime(int n) {
	int i;

	if (n <= 1)/*1以下の場合は0を返す*/
	{
		return 0;/*素数ではない*/
	}
	/*nまでの数値を繰り返し、余りがあれば0を返す*/
	for (i = 2; i < n; i++) {
		if (n % i == 0) {
			return 0;/*素数ではない*/
		}
	}

	return 1;/*素数である*/
}
int NextPrime(int value,int max)
{
        int i;
    for( i=value;i<max;++i ) {
    if( prime(i)==1 ) {
      return i;
    }
  }
  return -1;

}

Measured memory_bytes: 128
import sys, math
A, B, H, M = map(int, sys.stdin.readline().split())


th = (H*30 + (M/60)*30) -(6*M)
#print(th)
ans = A**2 + B**2 -2*A*B*math.cos(math.radians(th))
print(math.sqrt(ans))

Measured memory_bytes: 9572
from collections import defaultdict


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    d = defaultdict(int)
    s = sum(A)
    for a in A:
        d[a] += 1
    
    for i in range(Q):
        B, C = map(int, input().split())
        num = d[B]
        d[B] = 0
        d[C] += num
        s += num * (C - B)
        print(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	//島の配列
	static int[][] intIsland = new int[12][12];

	//未開拓の土地の配列
	static boolean[][] blNotPass = new boolean[12][12];


	public static void main(String[] args){

		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> answerList = new ArrayList<Integer>();

		try{
			String strLine = "";
			for(int intTurn = 0; intTurn < 20; intTurn++){

				blNotPass = new boolean[12][12];

				for(int i = 0; i < 12; i++){

						strLine = insBR.readLine();
						String[] strIsland = strLine.split("");
						for(int j = 0; j < 12; j++){
							intIsland[i][j] = Integer.parseInt(strIsland[j]);

							//島がある場合。
							if(intIsland[i][j] == 1){

								//未開拓地として扱うため、trueにする。
								blNotPass[i][j] = true;

							}
						}


				}

				//島の数の変数を用意、同時にforループで通った際に初期化。
				int intCount = 0;

				//島の数を数える。
				for(int intGyou = 0; intGyou < 12; intGyou++){
					for(int intRetsu = 0; intRetsu < 12; intRetsu++){

						if(blNotPass[intGyou][intRetsu]){

							//島の数をカウント。
							intCount++;

							//開拓メソッドへ。
							pioneer(intGyou, intRetsu);

						}
					}
				}

				//回答をリストに格納。
				answerList.add(intCount);

				//空行を読み取る。
				strLine = insBR.readLine();
				if(strLine == null){
					break;
				}


			}
		}catch(IOException e){

		}



		//出力
		for(Integer answer: answerList){
			System.out.println(answer);
		}

	}

	//数値を読み取るメソッド。
	/*public static int[][] island() {
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		try{
			for(int i = 0; i < 12; i++){
				String[] strIsland = insBR.readLine().split("");
				for(int j = 0; j < 12; j++){
					intIsland[i][j] = Integer.parseInt(strIsland[j]);

					//島がある場合。
					if(intIsland[i][j] == 1){

						//未開拓地として扱うため、trueにする。
						blNotPass[i][j] = true;

					}
				}

			}

		}catch(IOException e){
		 	e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
		return intIsland;

	}*/


	//島を開拓するメソッド。
	public static void pioneer(int intGyou, int intRetsu){
		if(0 <=intGyou && intGyou < 12 && 0 <= intRetsu && intRetsu < 12){
			if(blNotPass[intGyou][intRetsu]){

				//開拓したので、falseにする。メソッド内では上書きできている。
				blNotPass[intGyou][intRetsu] = false;

				int[] intY = {0, -1, 0, 1};
				int[] intX = {1, 0 , -1, 0};

				//再帰処理で開拓していく。
				for(int i = 0; i < 4; i++){
					pioneer(intGyou + intY[i], intRetsu + intX[i]);
				}
			}
		}
	}

}



Measured memory_bytes: 25580
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(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 CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

class B81 {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        FOR(x,1,10)FOR(y,1,10)if(x*y == n){
            out << "Yes" << endl;
            return;
        }
        out << "No" << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    B81 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    in.tie(0);
    out << std::fixed << std::setprecision(10);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int dp1[3010][3010];
int dp2[3010][3010];

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  rep(i, n) { cin >> a[i] >> b[i]; }

  int ans = 0;

  for (int w = 0; w <= t-1; ++w) {dp1[0][w] = 0;}
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= t-1; ++w) {
      if (w >= a[i]) dp1[i+1][w] = max(dp1[i][w-a[i]] + b[i], dp1[i][w]);
      else dp1[i+1][w] = dp1[i][w];
    }
  }
  for (int w = 0; w <= t-1; ++w) {dp2[n-1][w] = 0;}
  for (int i = n-1; i > 0; --i) {
    for (int w = 0; w <= t-1; ++w) {
      if (w >= a[i]) dp2[i-1][w] = max(dp2[i][w-a[i]] + b[i], dp2[i][w]);
      else dp2[i-1][w] = dp2[i][w];
    }
  }
  rep(o,n){
    rep(w2,t){
      ans = max(ans,dp1[o][w2]+dp2[o][t-1-w2]+b[o]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(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;
}

vl dp(202020,-1);
vl siz(202020,0);
vvl G(202020);
vl ans(202020,-1);
ll n;

P cp(ll u, ll p){
	if(dp[u] != -1) return P(dp[u],siz[u]);
	ll res = 1;
	vl sz;
	for(auto v : G[u]){
		if(v == p) continue;
		if(res == 0) res = 1;
		P p = cp(v,u);
		res *= p.first;
		res %= mod;
		siz[u] += p.second + 1;
		sz.push_back(p.second + 1);
	}
	res *= fac[siz[u]];
	res %= mod;
	for(auto i : sz){
		res *= finv[i];
		res %= mod;
	}
	dp[u] = res;
	return P(dp[u],siz[u]);
}

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}


void dfs(ll u, ll p){
	ans[u] = dp[u];
	if(p != -1){
		ans[u] *= siz[u] + 1;
		ans[u] %= mod;
		ans[u] *= ans[p] * modpow(dp[u],mod-2,mod) % mod;
		ans[u] %= mod;
		ans[u] *= inv[n-1-siz[u]];
		ans[u] %= mod;
	}
	for(auto v : G[u]){
		if(v != p) dfs(v,u);
	}
}

int main(){
	cin >> n;
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	comInit();
	cp(0,-1);
	dfs(0,-1);
	rep(i,n) cout << ans[i] << "\n";
}

Measured memory_bytes: 32624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;

int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int l = max(a, c);
	int r = min(b, d);
	printf("%d\n", r - l >= 0 ? r - l : 0);
	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll d; cin >> d;
    vector<ll> c(26);
    for(int i = 0; i < 26; i++) cin >> c[i];
    vector s(d, vector<ll>(26));
    rep(i,0,d)rep(j,0,26){
        cin >> s[i][j];
    }
    vector<ll> t(d);
    for(int i = 0; i < d; i++){
        cin >> t[i];
        t[i]--;
    }
    vector last(d+1, vector<ll>(26,-1));
    vector<ll> v(d+1);
    ll ans = 0;
    rep(i,0,d){
        ans += s[i][t[i]];
        rep(j,0,26)last[i+1][j] = last[i][j];
        last[i+1][t[i]] = i;
        ll sum = 0;
        rep(j,0,26)
            sum += c[j] * (i - last[i+1][j]);
        ans -= sum;
        v[i+1] = ans;
    }
    debug(v, last);
    ll m; cin >> m;
    while(m--){
        ll day,q; cin >> day >> q;
        q--;day--;
        t[day] = q;
        ans = v[day];
        rep(i,day,d){
            ans += s[i][t[i]];
            rep(j,0,26)last[i+1][j] = last[i][j];
            last[i+1][t[i]] = i;
            ll sum = 0;
            rep(j,0,26)
                sum += c[j] * (i - last[i+1][j]);
            ans -= sum;
            v[i+1] = ans;
        }
        debug(v,last);
        cout << v[d] << "\n";
    }
}

Measured memory_bytes: 3764
package main

import (
	"fmt"
	"os"
)

func sum(s []int) int {

	var sums int = 0

	for i := 0; i < len(s); i++ {
		sums += s[i]
	}
	return sums

}

func min(j []int) int {

	var min_value int = j[0]

	for v := 1; v < len(j); v++ {

		if j[v] < min_value {
			min_value = j[v]

		}
	}

	return min_value

}

func main() {

	var types int
	var max int
	var i int = 0
	var pauder [10010]int
	var rest int
	var result int

	fmt.Scan(&types)
	fmt.Scan(&max)

	if types < 2 && 1000 < types {
		fmt.Println(" types is 2 < types < 1000")
		os.Exit(0)

	}

	if 100000 < max {
		fmt.Println("overflow")
		os.Exit(0)

	}

	for ; i < types; i++ {
		fmt.Scan(&pauder[i])

	}

	pauder_arry := pauder[:types]

	sums := sum(pauder_arry)
	min_value := min(pauder_arry)

	// rest
	rest = max - sums

	// rest
	rest_value := rest / min_value

	result = types + rest_value

	fmt.Println(result)

}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){


    int n, d;
    cin >> n >> d;

    int ans = 0;
    for(int i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;

        long double D = sqrt(x*x + y*y);
        if(D <= double(d)){
            ans ++;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n-1);
  rep(i,n-1) cin>>a[i];
  vll b(n);
  rep(i,n-1){
    b[a[i]-1]++;
  }
  rep(i,n){
    COUT(b[i]);
  }
}


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

int main(){

  ll N=0;
  cin>>N;
  
  int a;
  map<int,int> mp;
  
  rep(i,N){

    cin>>a;
    
    mp[a+1]++;
    mp[a]++;
    mp[a-1]++;
    
  }
  
  int res=-2;
  for( auto x: mp){

    res=max(res, x.second );

  }
	
  cout<<res<<endl;
  

}

Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#define ll long long
#define re register
inline int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
inline ll gl(){
	ll sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
int gcd(int n,int m){
	if(!m)return n;
	return gcd(m,n%m);
}
using namespace std;
char s1[100010],s2[100010];
int n,m;
int main(){
	cin>>n>>m>>s1>>s2;
	ll d=1ll*n*m/gcd(n,m);
	int l1=0,l2=0;
	while(l1<n){
		while(l2*(d/m)+1<l1*(d/n)+1 && l2<m)l2++;
		if(l2>=m)break;
		if((l2*(d/m)==l1*(d/n)) && s1[l1]!=s2[l2]){
			puts("-1");return 0;
		}
		l1++;
	}
	printf("%lld\n",d);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;
ll n,y;

int main(){
	cin >> n >>y;
	auto d=vector<v>(n,v(n,0));
	auto f = false;
	ll i = 0;
	ll j = 0;
	for (i = 0; i <= n; i++)
	{
		for (j = 0; j <= n; j++)
		{
			if(i+j>n) break;
			if(i*10000+j*5000==y-(n-i-j)*1000){
				f=true;
				break;
			}
		}
		if(f) break;
	}
	if(f){
		cout <<i<<" "<<j<<" "<<n-i-j;
	}else{
		cout <<-1<<" "<<-1<<" "<<-1;
	}
}


Measured memory_bytes: 16000
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    min = abs(a - h[0])
    i = 0

    for x in h:
        i += 1
        t_x = t - x * 0.006
        if abs(a - t_x) < min:
            min = abs(a - t_x)
            ans = i

    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;

int main()
{
	int mp[105][105];
	int w, h, n;
	int ans = 0;
	memset(mp,0,sizeof(mp));
	cin >> w >> h >> n;
	while(n--)
	{
		int x ,y ,ai;
		cin >> x >> y >> ai;
		if(ai == 1){
			for(int i = 0 ; i < x ; i++)
				for(int j = 0 ; j < h;j++)
				mp[i][j] = 1;
			}
		if(ai == 2)
		{
			for(int i = x ; i < w ; i++)
				for(int j = 0 ; j < h;j++)
				mp[i][j] = 1;
			}
		if(ai == 3)
		{
			for(int i = 0 ; i < w ; i++)
				for(int j = 0 ; j < y;j++)
				mp[i][j] = 1;
			}
		if(ai == 4)
		{
			for(int i = 0 ; i < w ; i++)
				for(int j = y ; j < h;j++)
				mp[i][j] = 1;
			}
		}
	for(int i = 0 ; i < w ; i++)
		for(int j = 0 ; j < h ; j++)
			ans += mp[i][j];
		int ans1;
		ans1 = w*h - ans;
			cout <<ans1 <<endl;
	return 0;
	}

Measured memory_bytes: 256
import collections

n = int(input())
c = collections.Counter(input())
for _ in range(n-1):
    sc = set(c.keys())
    nc = collections.Counter(input())
    snc = set(nc.keys())
    inter = sc & snc
    r = dict()
    for i in inter:
        r[i] = min(c[i], nc[i])
    c = r
if len(c) == 0:
    print('')
else:
    l = []
    for i in sorted(c.items(), key=lambda x: x[0]):
        l.append(i[0]*i[1])
    print(''.join(l))

Measured memory_bytes: 3316
import java.util.*;

class Main {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ans;
		ans=x-a;
		while(ans>=b)
		ans=ans-b;
		System.out.println(ans);
		
		
	}
}

Measured memory_bytes: 22228
from bisect import bisect_left, bisect_right

N, M, K = map(int, input().split())
A0 = [int(x) for x in input().split()]
B0 = [int(x) for x in input().split()]

A = [0] * N
B = [0] * M
a = 0
for i in range(N):
    a += A0[i]
    A[i] = a
b = 0
for i in range(M):
    b += B0[i]
    B[i] = b
import sys
#print(A[-1], B[-1], file=sys.stderr)
answer = max(bisect_right(A, K), bisect_right(B, K))
for a in range(N):
    if A[a] <= K:
        Kb = K - A[a]
        b = bisect_right(B, Kb) # Kb < B[b]
        #print(a, b, A[a], B[min(M-1, b)], A[a]+ B[min(M-1, b)])
        answer = max(answer, a+b+1)
    else:
        break
print(answer)


Measured memory_bytes: 47716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
/*
「std::string 文字列名(char* first, char* last);」と記述すると、
first から last が指す先までの文字列で初期化する。 
厳密に言うと、last は最後の文字の次を指す。
[first, last) の範囲を元に、文字列を初期化する。
通常文字列でデータを指定し、それを元に文字列を構築出来る。
*/
bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

int main() {
	string S, frontstr, reerstr;
	cin >> S;
  	int N = S.length();
  
    if(is_palindrome(S) && is_palindrome(S.substr(0,(N-1)/2)) && is_palindrome(S.substr((N+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  

}





Measured memory_bytes: 256
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = ip()                                     #入力整数1つ
#r,x,y= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!
#これを消すとなぜかWAになる呪い
b = sorted(a)
leftmed = b[n//2-1]
rightmed = b[n//2]
for i in range(n):
    if a[i] >= rightmed:
        print(leftmed)
    else:
        print(rightmed)


Measured memory_bytes: 27236
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#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;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

void solve(){
	ll n ;
	cin>> n ;
	vector<ll>A(n) , B(n);
	ll mx=0 , mn=0;
	for(ll i=0;i<n ;i++)cin>>A[i]>>B[i];
	sort(A.begin() , A.end());
	sort(B.begin(),B.end());
	if(n&1)mx=B[n/2] , mn=A[n/2];
	else mx=B[(n-1)/2]+B[n/2] , mn=A[(n-1)/2]+A[n/2];
	cout<<mx-mn+1<<endl;
}
int main(){
	//mahakal(),fast;
	ll t=1 ;
	// cin>> t;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin>>s;
    
    int c1=0,c2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0) {
            if(s[i]!='0') c1++;
        }else{
            if(s[i]!='1') c1++;
        }
    }
    for(int i=0;i<s.size();i++){
        if(i%2==0) {
            if(s[i]!='1') c2++;
        }else{
            if(s[i]!='0') c2++;
        }
    }
    cout<<min(c1,c2)<<endl;
}

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

int main() {

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

  map<string, string> m;
  m["ARC"] = "ABC";
  m["ABC"] = "ARC";

  string s;
  cin >> s;

  cout << m[s] << '\n';
}

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

int main(){
  long long int n, a, b; cin >> n >> a >> b;
  long long int m = n-n/(a+b)*(a+b), o = n/(a+b)*a;
  if(m < a) cout << o+m << endl;
  else cout << o+a << endl;
  //cout << m << " " << o << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sd second
#define ft first
#define pr pair
#define vl vector<ll>
#define vs vector<string>
#define vmp vector<pair<ll,ll>>
#define en "\n"
#define lb lower_bound
#define ub upper_bound
#define vll vector<vector<ll>>
#define vmpl vector<vector<pair<ll,ll>>>
#define st size()
#define al(v) v.begin(),v.end()
#define cast static_cast<char>
#define ins insert
#define fata_fat ios_base::sync_with_stdio(false); cin.tie(NULL);
ll M=1e9+7,MAX=1e18,MIN=-1e18;
void bhaag()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{   
     bhaag(); fata_fat;
    ll n,i,x,c=0; cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x; if(x%2&&i%2)c++;
    }
    cout<<c;
     
}

 

Measured memory_bytes: 3564
#include<cstdio>

int main(void) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=0; i<10000; i++) {
        int test=60*i+c;
        if( test%(a+b) <= a ) {
            printf("%d\n",test);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int k,s ;
    cin >> k >> s ;
    int ans = 0 ;
    for(int x=0;x<=k;x++){
         for(int y=0;y<=k;y++){
              if(0<=s-x-y&&s-x-y<=k){
                   ans++ ;
              }
         }
    }
    cout << ans ;
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;

int main(){
        ll prime[100000];
        for(ll i=1; i<1e5; i++) prime[i] = 1;
        prime[0] = prime[1] =  0;
        for(ll i=2; i<1e5; i++){
                if(prime[i]){
                        for(ll j=2*i; j<1e5; j+=i) prime[j]=0;
                }
        }

        ll good[100000];
        for(ll i=0; i<1e5; i++) good[i]=0;
        for(ll i=1; i<1e5; i+=2){
                if(prime[i] && prime[(i+1)/2]) good[i]=1;
        }
        for(ll i=1; i<1e5; i++) good[i] += good[i-1];

        ll q;
        scanf("%lld", &q);

        for(ll i=0; i<q; i++){
                ll l, r;
                scanf("%lld %lld", &l, &r);
                printf("%lld\n", good[r]-good[l-1]);
        }
        return 0;
}

Measured memory_bytes: 2176
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,a[200005];
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);for(int i=1;i<=n;i++)in(a[i]);
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
	if(a[i]==a[i-1]){
		cout<<"NO"<<endl;return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int search(int res, int a, int b, int c, int d, int e){
    if(a == -1 && b == -1 && c == -1 && d == -1 && e == -1){
        return res;
    }
    int res_a = 10000000;
    int res_b = 10000000;
    int res_c = 10000000;
    int res_d = 10000000;
    int res_e = 10000000;
    if(res % 10 != 0){
        res = ((res / 10)+1)*10;
    }
    if(a != -1){
        res_a = search(res + a, -1, b, c, d, e);
    }
    if(b != -1){
        res_b = search(res + b, a, -1, c, d, e);
    }
    if(c != -1){
        res_c = search(res + c, a, b, -1, d, e);
    }
    if(d != -1){
        res_d = search(res + d, a, b, c, -1, e);
    }
    if(e != -1){
        res_e = search(res + e, a, b, c, d, -1);
    }
    return min(res_a, min(res_b, min(res_c, min(res_d, res_e))));
}

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << 
    min(search(a, -1, b, c, d, e), 
      min(search(b, a, -1, c, d, e), 
        min(search(c, a, b, -1, d, e),
         min(search(d, a, b, c, -1, e),search(e, a, b, c, d, -1))))) << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
	int check,count;
	int n;
	scanf("%d",&n);
	double h[n+1];

	for(int i=1;i<=n;i++){
		scanf("%lf",&h[i]);
	}
	count=1;
	for(int i=2;i<=n;i++){
		check=0;
		for(int j=1; j<i; j++){
			if(h[j]>h[i]) check=1;
		}
		if(check==0) count++;
	}
	printf("%d",count);
	return 0;
}


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

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] A = new int[N];
        int ans = 1;
        int sign = 0;
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt();

            if (i > 0 && A[i - 1] != A[i]) {
                if (sign == 0) {
                    sign = (A[i - 1] < A[i]) ? 1 : -1;
                } else if (sign == -1) {
                    if (A[i - 1] < A[i]) {
                        sign = 0;
                        ++ans;
                    }
                } else {
                    if (A[i - 1] > A[i]) {
                        sign = 0;
                        ++ans;
                    }
                }
            }
        }

        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 50280
N = int(input())
mod = 10**9 + 7

if N == 1:
  print(0)
else:
  a = 1
  b = 1
  c = 1
  for _ in range(N):
    a *= 10
    a %= mod
    b *= 9
    b %= mod
    c *= 8
    c %= mod
  
  ans = a % mod - (2 * b) % mod + c % mod
  print(ans % mod)

Measured memory_bytes: 9184