akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<ctime>
#include<cctype>
#include<queue>
#include<deque>
#include<stack>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-4
#define sq sqrt
#define S second
#define F first
using namespace std;
char *fs,*ft,buf[1<<15];
inline char gc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
	RE int x=0,f=1;RE char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
	return x*f;

}
const int MAXN=3010;
int n,mod;
int fac[MAXN],inv[MAXN];
int s[MAXN][MAXN];
inline int ksm(int b,int p,int M)
{
	int cnt=1;
	while(p)
	{
		if(p&1)cnt=(ll)cnt*b%M;
		b=(ll)b*b%M;p=p>>1;
	}
	return cnt;
}
inline int C(int a,int b){return (ll)fac[a]*inv[b]%mod*inv[a-b]%mod;}
int main()
{
	//freopen("1.in","r",stdin);
	get(n);get(mod);
	fac[0]=1;
	rep(1,n,i)fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=ksm(fac[n],mod-2,mod);
	fep(n-1,0,i)inv[i]=(ll)inv[i+1]*(i+1)%mod;
	s[0][0]=1;
	rep(1,n+1,i)rep(1,i,j)s[i][j]=(s[i-1][j-1]+(ll)s[i-1][j]*j)%mod;
	int op=-1,ans=0;
	rep(0,n,i)
	{
		op=-op;
		int cnt=ksm(2,n-i,mod-1);
		cnt=ksm(2,cnt,mod)*(ll)C(n,i)%mod;
		int sum=0;
		int c1=ksm(2,n-i,mod),c2=1;
		rep(0,i,k)
		{
			sum=(sum+(ll)c2*s[i+1][k+1])%mod;
			c2=(ll)c1*c2%mod;
		}
		ans=(ans+op*(ll)cnt*sum)%mod;
	}
	put((ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 31288
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int r,g,b,n;cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(n-i*r-j*g>=0&&(n-i*r-j*g)%b==0)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N=int(input())
num=[0]+list(map(int,input().split()))
for i in range(N):
    num[i+1]=num[i]+num[i+1]
num=sorted(num)+[-1]
count,n=0,0
flag=num[0]
for i in num:
    if i==flag:
        n +=1
    else:
        count +=(n*(n-1))//2
        flag=i
        n=1
print(count)

Measured memory_bytes: 25976
N = int(input())
A = list(map(int, input().split()))

cnt = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 != 0:
            break #forから抜ける
    else:
        A = [a/2 for a in A]
        cnt += 1
        continue
    break #whileから抜ける

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	vector<char>oup;
	for(int i=0;i<s.length();i++)
	{
		if((i+1)%2!=0)
		{
			cout<<s[i];
		}
	}
	cout<<"\n";
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
#define MO 1000000007
#define MAXN 200005
#define LL long long
LL inv[MAXN],s[MAXN];
int n;
LL PowMod(LL a,int b) {
    LL ret=1;
    while(b) {
        if(b&1) ret=ret*a%MO;
        a=a*a%MO;
        b>>=1;
    }
    return ret;
}
void Pre() {
    s[0]=1;
    for(int i=1; i<=n; i++)
        s[i]=s[i-1]*i%MO;
    inv[0]=1;
    inv[n]=PowMod(s[n],MO-2);
    for(int i=n-1; i>0; i--)
        inv[i]=inv[i+1]*(i+1)%MO;
}
LL C(int a,int b) {
    if(a<0||b<0) return 1;
    return s[a]*inv[b]%MO*inv[a-b]%MO;
}
int main() {
    int h,w,A,B;
    scanf("%d%d%d%d",&h,&w,&A,&B);
    n=h+w-2;
    Pre();
    LL ans=C(h+w-2,h-1);
    for(int i=1; i<=B; i++) {
        ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;
        ans=(ans%MO+MO)%MO;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define boost std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
constexpr int MAXN = 3e5 + 5;
constexpr int LOG = 25;
constexpr int BIT = 24;
using namespace std;
template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
vector <pair <int, int> > G[MAXN];
inline bool Canbe(string s, int st, int ed) {
    for (int i = st; i <= ed; i++)
        if (s[i] != s[ed - i + st]) return false;
    return true;
}
int main() {
    string s;
    cin >> s;
    int n = s.size();
    s = " " + s;
    bool judge = true;
    judge = judge && Canbe(s, 1, n);
    judge = judge && Canbe(s, 1, (n - 1) / 2);
    judge = judge && Canbe(s, (n + 3) / 2, n);
    judge ? puts("Yes") : puts("No");
    return 0;
}

Measured memory_bytes: 7296
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val c = next()
    println(if ("aiueo".contains(c)) "vowel" else "consonant")
}

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    double dp[n + 1][n + 1] = {};
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j]     += dp[i][j] * (1.0 - p[i]);
        }
    }

    int mid = n / 2 + 1;
    double ans = 0.0;
    for (int i = mid; i <= n; i++) ans += dp[n][i];
    cout << setprecision(15) << ans << endl;
    return 0;
}

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

int main () {
    int N;
    while (scanf("%d", &N) == 1) {
        for (int n = 1; n <= N; n++) {
            int res = 0;
            for (int x = 1; x * x <= n; x++) {
                for (int y = 1; x * x + y * y + x * y <= n; y++) {
                    int t = x * x + x * y + y * y;
                    for (int z = 1; z * z + z * x + z * y + t <= n; z++)
                        res += z * z + z * x + z * y + t == n;
                }    
            }
            printf("%d\n", res);
        }
    }
}



Measured memory_bytes: 3756
/*input
2
*/

#include <bits/stdc++.h>

using namespace std;

vector <int> a{2, 4, 5, 7, 9};
vector <int> b{0, 1, 6, 8};
vector <int> c{3};
int n;

int main() {
	cin >> n;
	if (count(a.begin(), a.end(), n % 10)) {
		cout << "hon\n";
	}
	else if (count(b.begin(), b.end(), n % 10)) {
		cout << "pon\n";
	}
	else cout << "bon\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
    int n,k; cin >> n >> k;
    vector<ll> v(n);
    for (int i = 0; i < n; i++ ) cin >> v[i];

    ll ans = 0;
    for (int l = 0; l <= min(n,k); l++) {
        for (int r = 0; r + l <= min(n,k); r++) {
            vector<ll> take;
            ll tot = 0;

            for (int i = 0; i < l ; i++) {
                tot += v[i];
                take.push_back(v[i]);
            }
            for (int i = 0; i < r; i++) {
                tot += v[n-i-1];
                take.push_back(v[n-i-1]);
            }
            
            sort(take.begin(),take.end());
            int lim = take.size();
            for (int i = 0; i < min(k - r - l, lim); i++) {
                if (take[i] < 0) tot -= take[i];
            }         
            ans = max(ans,tot);
        }
    }
    cout << ans << endl; 
}




Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	double ans = 0, x;
	string s;
	rep(i, n) {
		scanf("%lf", &x);
		cin >> s;
		if (s[0] == 'J')ans += x;
		else ans += x * 380000.0;
	}
	printdb(ans);

	Please AC;
}


Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int mod;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
const int N = 310;
int n,k;

int f[N][N][N];//填t,时间是i,一共j个了

int main()
{
	cin >> n >> k >> mod;
	f[k][0][0]=1;
	for(int t=k;t;t--){
		for(int i=n;~i;i--){
			for(int j=i;j<=n;j++)if(f[t][i][j]){
				// cout << t << "," << i << "," << j << ":" << f[t][i][j] << endl;
				if(i==0){
					f[t-1][j][j]=add(f[t-1][j][j],f[t][i][j]);
				}
				if(i>=0)f[t][i][j+1]=add(f[t][i][j+1],mul(f[t][i][j],i+1));
				// cout << f[t][i][j+1] << " " << mul(f[t][i][j],i+1) << endl;
				if(i>=1)f[t][i-1][j]=add(f[t][i-1][j],mul(f[t][i][j],1));
			}
		}
	}
	cout << f[0][n][n] << endl;
}

Measured memory_bytes: 112896
while True:
    try:
        a = input()
    except:
        break

    ans1 = 0
    ans2 = 0

    for i in range(len(a)-2):
        if a[i:i+3] == 'JOI':
            ans1 += 1
        elif a[i:i+3] == 'IOI':
            ans2 += 1
            
    print(ans1)
    print(ans2)


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
const int Maxn= +50,INF=0xfffffff;
int m,n,k,a[10][10],t,K;
char ch;

int main()
{
	cin >> m >> n >> K;
	memset(a, 0, sizeof a);
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
		{
			cin>>ch;
			if (ch == '#') {
				a[i][j] = 1;
				t++;
			}
		}
			
	int backup = t,ans = 0,bac[10][10];
	memcpy(bac , a ,sizeof a);
	for (int i = 0; i < 1 << m; i++)
		for (int j = 0; j < 1 << n; j++){
			t = backup;
			memcpy(a ,bac ,sizeof a);
			for (int k = 0; k < m; k++)
				if (i >> k & 1) 
				{
					for (int p = 0; p < n; p++)
						if (a[k][p] == 1){
							a[k][p] =0;
							t--;
						} 
				}
			for (int k = 0; k < n; k++)
				if (j >> k & 1) 
				{
					for (int p = 0; p < m; p++)
						if (a[p][k] == 1){
							a[p][k] =0;
							t--;
						} 
				}
			if (t == K)ans++;
		}
	cout << ans;
	
	//system("pause");
	return 0;
}


Measured memory_bytes: 3620
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,(a+b+r*1j*3**.5)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5916
n = int(input())

if n % 2 == 0:
    print(n * n // 2 - n)
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            if a + b != n + 1:
                print('{0} {1}'.format(a, b))
else:
    print((n - 1) ** 2 // 2)
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            if a + b != n:
                print('{0} {1}'.format(a, b))


Measured memory_bytes: 3336
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <vector>
#include <map>
#define mst(X,Y) memset(X,Y,sizeof X)
#define mp(X,Y) make_pair(X,Y)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
//typedef pair<ll,pll> plp;
typedef pair<pll,pii> ppp;
ll n,ns1,ns2,np1,np2,ms1,ms2,ans;
int nm[100005],mn[100005];
bool t;
int main()
{
	scanf("%lld",&n);
	ll m=n;
	while(n--){
		int ip;
		scanf("%d",&ip);
		nm[ip]++;
		if(nm[ip]>ns1){
			if(ip!=np1){
				ms1=ns1;
			np1=ip;
			}
			ns1=nm[ip];
		}else if(nm[ip]>ms1&&ip!=np1){
			ms1=nm[ip];
		}
		n--;
		scanf("%d",&ip);
		mn[ip]++;
		if(mn[ip]>ns2){
			if(ip!=np2){
				ms2=ns2;
			np2=ip;
			}
			ns2=mn[ip];
		}else if(mn[ip]>ms2&&ip!=np2){
			ms2=mn[ip];
		}
	}
	if(np1==np2){
		ans=max(ns1+ms2,ns2+ms1);
	}else ans=ns1+ns2;
	printf("%lld\n",m-ans);
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
		       #include <map>
		     using                 namespace
		  std;                          typedef
	    long          long ll;             int main(){
	  int                 n;ll a                 [212345];

	               a[0] = 0; cin >>
	                     n;     map
	                     <ll    ,ll
	                     >     mp;
	                     mp
	                    [0]
                     
	              =1;
	       for(int i
	             =1
	     ;i<=n;i++){cin
	    >>      a[i];       a[  i]+=a[i - 1];mp
	           [a [i]]      ++              ;}
	          ll  res =0     ;             for
	      (auto   i:         mp)          res
	    +=        i.         second       *(i.
	second        -1          )/2;       cout
	              <<           res<<endl;return
	             0;}
             

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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    while(k){

    if(a>=b){
        b=b*2;
        k--;
       //cout<<b<<k;
    }
    else if(b>=c){
        c=c*2;
        k--;
        //cout<<c<<k;
    }
    else{
        k--;
    }

    }
    if(a<b&&b<c){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  V<> a(26), b(26);
  int n = s.size();
  for (int i = 0; i < n; i++) a[s[i] - 'a']++;
  for (int i = 0; i < n; i++) b[t[i] - 'a']++;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool same = true;
  for (int i = 0; i < 26; i++) if (a[i] != b[i]) same = false;
  cout << (same ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 916
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d =a/b;
        int r =a%b;
        double f=1.0*a/b;
            System.out.println(d+" "+r+" "+String.format("%.5f",f));
    }
}


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



int main(){
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    int A=a-'0',B=b-'0',C=c-'0',D=d-'0';
    char v[2]={'+','-'};
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                int ans=A;
                if(i==0)
                    ans+=B;
                else
                    ans-=B;
                if(j==0)
                    ans+=C;
                else
                    ans-=C;
                if(k==0)
                    ans+=D;
                else
                    ans-=D;
                //cout<<ans<<endl;
                if(ans==7){
                    cout<<A<<v[i]<<B<<v[j]<<C<<v[k]<<D<<"=7\n";
                    return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
static const int MAX_WH = 70;

int W, H;
string C[MAX_WH];
string memo[MAX_WH][MAX_WH];

string lexicographical(string s, string t){
	if(s.length() > t.length()) return s;
	if(s.length() < t.length()) return t;
	return s > t ? s : t;
}

string dfs(int y, int x){
	if(y < 0 || y >= H || x < 0 || x >= W) return "";
	if(C[y][x] - '0' < 0 || C[y][x] - '0' > 9) return memo[y][x] = "";
	if(memo[y][x] != "") return memo[y][x];
	return memo[y][x] = C[y][x] + lexicographical(dfs(y + 1, x), dfs(y, x + 1));
}

int main(){
	for(;;){
		scanf("%d %d", &W, &H);
		if(W == 0 && H == 0) break;
		for(int i = 0; i < H; i++) cin >> C[i];
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++) memo[i][j] = "";
		}
		string res;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(C[i][j] - '0' < 1 || C[i][j] - '0' > 9) continue;
				memo[i][j] = dfs(i, j);
				res = lexicographical(res, memo[i][j]);
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3440
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e4+10;
const int mod = 1000000007;
using namespace std;

string K;
ll D,len;
ll f[maxn][105];

ll dfs(int pos,int sum,bool limit){
    if(!limit && f[pos][sum] != -1) return f[pos][sum];
    if(pos == len+1) return f[pos][sum] = sum == 0;
    int up = limit ? (K[pos] -'0') : 9;
    ll ans = 0;
    for(int i = 0;i<=up;i++){
        ans += dfs(pos+1,(sum+i)%D,limit && i == up);
        ans %= mod;
    }
    if(!limit) f[pos][sum] = ans;
    return ans;
}

int main(){
    // debug;
    ios;

    cin>>K>>D;
    len = K.length();
    K = '#'+K;
    memset(f,-1,sizeof f);
    cout<<(dfs(1,0,1) - 1 + mod) %mod<<'\n';
    return 0;
}


Measured memory_bytes: 9344
N = gets.to_i
A = gets.split.map(&:to_i)

ans = 0
xor, sum = A[0], A[0]
i = j = 0
while true
  if xor == sum
    j += 1
    ans += j
    xor ^= A[i+j] || break
    sum += A[i+j]
  else
    xor ^= A[i]
    sum -= A[i]
    i += 1
    j -=1
  end
end

puts ans


Measured memory_bytes: 15372
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    vector <int> qw (5);
    int q=0;
    for (int i=0; i<5; ++i)
    {
        cin >> qw[i];
        if (qw[i]==0)
            q=i+1;
    }
    cout << q << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  int ans = 1;
  for(int i = 0; i < N-1; i++) {
    if ( d.at(i) != d.at(i+1) )
      ans++;
  }
  cout << ans << endl;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

A,B,K = inputIL()

c = 0
for i in range(1,max(A,B)+1)[::-1]:
  if A%i == B%i == 0:
    c += 1
    if K == c:
      print(i)
      exit()


Measured memory_bytes: 64176
from collections import deque

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

p = deque()

for i in list:
  p.append([i[0] - i[1],i[0] + i[1]])
  
p = sorted(p,key = lambda x: x[1])

ex = []
ex.append(p.pop(0))




for i in range(len(p)):
  if(ex[-1][1] <= p[0][0]):
    ex.append(p.pop(0))
  else:
    p.pop(0)

print(len(ex))

Measured memory_bytes: 44452
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define LSone(S) ((S)&(-S))

int main()
{
	// std::ios::sync_with_stdio(false);
	for (int i = 1; i < 10; ++i)
	{
		/* code */
		for (int j = 1; j < 10; ++j)
		{
			/* code */
			cout<<i<<"x"<<j<<"="<<i*j<<"\n";
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

int main(){
	//input
	ll N,A; cin>>N>>A;
	vector<ll> X(N+1);
	rep1(i,N) cin>>X[i];

	ll dp[51][51][2501]; //dp[x][y][z]:x番目までy個選び和をzにする

	rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
	dp[1][0][0]=1;
	dp[1][1][X[1]]=1;

	FOR(i,2,51){
		rep(j,i+1){
			rep(k,2501){
				if(j!=0 && k>=X[i]) dp[i][j][k]+=dp[i-1][j-1][k-X[i]];
				dp[i][j][k]+=dp[i-1][j][k];
			}
		}
	}
	
	ll ans=0;
	rep1(i,50){
		if(i*A<=2500) ans+=dp[N][i][i*A];
	}

	cout<<ans;
}

Measured memory_bytes: 50944
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		boolean y=false;
		for(int i=0;i<3;i++){
			if(x/100==7){
				y=true;
				break;
			}else if((x%100)/10==7) {
				y=true;
				break;
			}else if(x%10==7) {
				y=true;
				break;
			}
		}
		if(y) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		

	}
}

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

signed main() {
  int n,d; cin >> n >> d;
  vector<vector<int>> xss;
  rep(y,n) {
    vector<int> xs(d);
    rep(x,d) {
      cin >> xs[x];
    }
    xss.push_back(xs);
  }
  int ans = 0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int dist = 0;
      rep(x,d) {
        dist += (xss[i][x]-xss[j][x]) * (xss[i][x]-xss[j][x]);
      }
      int sq = floor(sqrt(dist));
      if (sq*sq == dist) ans++;
    }
  }
  cout << ans << endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
ll V[100007];

int main(){
  cin >> A >> B >>  K;
  if(A<=K){
    cout << 0 << " " << max(0LL,A+B-K) << endl;
  }
  else{
    cout << A-K << " " << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<ll,ll>ch;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		ch[now]++;
		if(ch[now]==2){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	// your code goes here
	return 0;
}

Measured memory_bytes: 16024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  map<ll, vector<ll>> py;
  vector<ll> p(m);
  vector<ll> y(m);
  rep(i, m) {
    cin >> p[i] >> y[i];
    py[p[i]].push_back(y[i]);
  }

  for( auto i = py.begin(); i != py.end() ; ++i ) {
    sort(i->second.begin(), i->second.end());
  }

  rep(i, m) {
    ll no = lower_bound(py[p[i]].begin(), py[p[i]].end(), y[i]) - py[p[i]].begin() + 1;
    printf("%06lld%06lld\n", p[i], no);
  }

  return 0;
}


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

int main(){
  
  	int n, n1;
  	cin >> n;  
  	n1 = n%10;
  
  	if(n1==3){
      cout<<"bon"<<endl;
    }else if(n1==0 || n1==6 || n1==1 || n1==8){
      cout<<"pon"<<endl;
    }else{
      cout<<"hon"<<endl;
    }

      
}

Measured memory_bytes: 3552
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a,b = readline() |> split |> parseMap
	v = readline() |> split |> parseMap
	v = sort(v,rev=true)
	if a == n
		println(sum(v)/n)
		println(1)
	else
		if v[a]>v[a+1]
			println(sum(v[1:a])/a)
			println(1)
		else
			l = a
			r = a
			while l>=1&&v[l]==v[a]
				l -= 1
			end
			while r<=n&&v[r]==v[a]
				r += 1
			end
			x = r-l-1
			if v[1]>v[a]
				println(sum(v[1:a])/a)
				println(binomial(x,a-l))
			else
				println(v[1])
				s = 0
				for i in a:min(b,x)
					s += binomial(x,i)
				end
				println(s)
			end
		end
	end
end

main()

Measured memory_bytes: 117124
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int N,L;
    cin >> N >> L;
    int l,r;
    l = L;
    r = l + N - 1;

    int eat;
    if(l>=0)eat = l;
    else if(r<=0)eat = r;
    else eat = 0;
    cout << N*(l+r)/2-eat << endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int, int> ii;

//const ll mod = 1e9 + 7;
const ll mod = 998244353;
const ll INF = (1LL<<50);
const double EPSILON = 0.001;
const int N = 1000005;
ll dp[N];
ll add(ll a, ll b){
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}
ll sub(ll a, ll b){
	a -= b;
	if(a < 0)
		a += mod;
	return a;
}
int main(){
	fastio;
	int n, k;
	cin >> n >> k;
	vector<ii> v(k);
	dp[1] = 1;
	for(int i = 0; i < k; i++){
		cin >> v[i].fst >> v[i].snd;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < k; j++){
			int upp = max(0,min(i, i-v[j].fst));
			int dwn = max(0,min(upp, i-v[j].snd));
			dp[i] = add(dp[i], sub(dp[upp], (dwn>=1?dp[dwn-1]:0)));
		}
		ans = dp[i];
		dp[i] = add(dp[i], dp[i-1]);
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n;
    int k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i = 0;i < n;++i) {
        cin>>a[i];    }
        sort(a.begin(),a.end());
        int ans=0;
        for(int i = 0;i < k;++i) {
            ans+=a[i];
        }
        cout<<ans<<endl;
    return 0;
}


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

#define x first
#define y second

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll N,T,t,l,tot;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> T;
	l=-T;
	for (int i=0;i<N;i++) {
		cin >> t;
		tot+=T-max(0ll,T-(t-l));
		l=t;
	}
	cout << tot << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[44][1<<17];

int main(void){
	int n,m,x,y,z,haiku,i,j,k,t;
	ll ans = 1ll;
	std::cin >> n >> x >> y >> z;
	m = x+y+z; t = (1<<m)-1;
	--z; y += z; x += y;
	haiku = (1<<x)+(1<<y)+(1<<z);
	dp[0][0] = 1ll;
	for(i=0; i<n; ++i){
		mul_mod(ans,10ll);
		for(j=0; j<=t; ++j){
			if(!dp[i][j]){
				continue;
			}
			if((j&haiku)==haiku){
				dp[i][j] = 0ll;
				continue;
			}
			for(k=0; k<10; ++k){
				add_mod(dp[i+1][((j<<(k+1))+(1<<k))&t],dp[i][j]);
			}
		}
	}
	for(j=0; j<=t; ++j){
		if((j&haiku)==haiku){
			dp[n][j] = 0ll;
		}
		add_mod(ans,MOD-dp[n][j]);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 41216
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String b = sc.next();
    	if( b.equals("A") ) {
    		System.out.println("T");
    	}
    	else if( b.equals("T") ) {
    		System.out.println("A");
    	}
    	else if( b.equals("C") ) {
    		System.out.println("G");
    	}
    	else {
    		System.out.println("C");
    	}
    	sc.close();
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
//g++ -std==c++14
//setprecision(10)
int n;
string s;
vector < map <char, int> > mp;
int main(){
    cin >> n;
    mp = vector < map <char, int> > (n);
    rep(i, n){
        cin >> s;
        rep(j, s.size())
            mp[i][s[j]]++;
    }
    s = "";
    for(char i = 'a'; i <= 'z'; i++){
        int mini = inf;
        rep(j, n)
            mini = min(mini, mp[j][i]);
        rep(j, mini)
            s += i;
    }
    cout << s << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);

  int h, m; cin >> h >> m;
  int s = h * 60 + m;
  cin >> h >> m;
  int t = h * 60 + m;
  cin >> m;

  cout << t - s - m << '\n';

  return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
  sort(ALL(A));
  sort(ALL(B));
  ll l = A[(N - 1) / 2];
  ll r = B[N - 1 - (N - 1) / 2];
  if (N % 2 == 0) {
    ll l1 = A[(N - 1) / 2 + 1];
    ll r1 = B[N - 1 - (N - 1) / 2 - 1];
    cout << ((r + r1) - (l1 + l)) + 1 << endl;
  } else {
    cout << (r - l) + 1 << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


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

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

  int a[M];
  for(int i=0; i<M; i++){
    cin >> a[i];
  }

  int sum=0;
  for(int i=0; i<M; i++){
    sum += a[i];
  }

  int asobi;
  if(sum > N){
    asobi = -1;
  }
  else{
    asobi = N-sum;
  }

  cout << asobi << endl;

  return 0;
}


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

signed main() {
    int N;
    cin >> N;

    vector<int> A(N);
    int ans = 1e18;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i) {
            ans = min(ans, __gcd(A[i], A[i - 1]));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-

//   sort(vec.begin(),vec.end(),compare);
ll temp=0;
ll dp[100000000];
ll frog(ll *arr, ll a, ll tp){
	if(tp==0) return 0;
	if(tp==1) return abs(arr[tp-1]-arr[tp]);
	if(dp[tp]!=-1) return dp[tp];
	dp[tp]=min(abs(arr[tp-2]-arr[tp])+frog(arr,a,tp-2),abs(arr[tp-1]-arr[tp])+frog(arr,a,tp-1));
	return dp[tp];
	}

int main() {
	fast;
	memset(dp,-1,sizeof dp);
	read(a)
	ll arr[a+1];
	arr[a]=0;
	loop(j,0,a){
		read(f)
		arr[j]=f;
	}
	temp=a-1;
	cout<<frog(arr,a,temp);	
	return 0;
}


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

#define MOD (1.0e9 + 7)

using namespace std;

int main(void)
{
    int n;
    int p = 1;

    cin>>n;

    for(;p * 2 <= n;p *= 2)
	;

    cout<<p<<endl;

    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

var isPrime [55555 + 1]bool

func initPrimes() {
	for i := 0; i < len(isPrime); i++ {
		isPrime[i] = true
	}
	isPrime[0] = false
	isPrime[1] = false
	for i := 2; i*i <= len(isPrime); i++ {
		for j := i * 2; j < len(isPrime); j += i {
			if isPrime[j] {
				isPrime[j] = false
			}
		}
	}
}

func main() {
	initPrimes()
	p := make([]int, 0, 10000)
	for i := 2; i < len(isPrime); i++ {
		if isPrime[i] && (i%5 == 1) { // 5で割って1余る素数を抽出する
			p = append(p, i)
		}
	}
	// fmt.Println("len(p):", len(p))
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(p[i]) // pは1000個以上あるのでNの制約から配列外参照しない
	}
	fmt.Println()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
std::map<int, int> m;

void fj(int n){
	int i=2;
	while(n>1){
		if(n%i==0){
			m[i]++;
			n/=i;
		}
		else i++;
	}
}
int solve(int n){
	if(n==1)return 1;
	for(int i=2;i<=n;i++){
		fj(i);
	}
	long long ret=1;
	for(auto i=m.begin();i!=m.end();i++){
		int t=i->second;
		ret=ret*(t+1)%1000000007;
		//cout<<i->second<<" ";
	}
	return ret;
}
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	cout<<solve(n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>
using namespace std;

int k;

bool deep(vector<int> a,int r){
	vector<int> b;
	int l;
	for(int i = 0;i < a.size();i++){
		if(i == r){
			l = a[r];
		}
		else{
			b.push_back(a[i]);
		}
	}
	if(l >= k) return true;
	bool bp[5000] = {};
	bp[0] = true;
	for(int i = 1;i < 5000;i++){
		bp[i] = false;
	}
	for(int i = 0;i < b.size();i++){
		for(int j = 4999;j >= b[i];j--){
			if(bp[j-b[i]]){
				bp[j] = true;
			}
		}
	}
	for(int i = k-l;i < k;i++){
		if(bp[i]) return true;
	}
	return false;
}

int main(){
	int n;
	cin >> n >> k;
	vector<int> a;
	for(int i = 0;i < n;i++){
		int j;
		cin >> j;
		a.push_back(j);
	}
	sort(a.begin(),a.end());
	int l=0,r=n,c=n/2;
	for(int i = 0;r-l > 1;i++){
		c = (r-l)/2+l;
		if(deep(a,c)){
			r = c;
		}
		else{
			l = c;
		}
	}
	if(deep(a,l)) cout << l << endl;
	else cout << r << endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法


int main(void) {
	std::ios_base::sync_with_stdio(false);
	int P, Q, R;
	cin >> P >> Q >> R;
	cout << min(P + Q, min(Q + R, R + P)) << endl;
	return 0;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	int n ;
	cin >> n;

	cout << pow(n, 3);









	return 0;
}

Measured memory_bytes: 384