akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;

    int cnt = 0;
    rep(i, s.size()) {
        if (s[i] == '1')
            cnt++;
        else
            break;
    }

    if (cnt > 0) {
        if (cnt >= k)
            cout << '1' << endl;
        else
            cout << s[cnt] << endl;
    } else {
        cout << s[0] << endl;
    }

    return 0;
}

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

void pop(vector<int> &a,int &top);
int main(){
    int n;
    char ch[2];
    int x,y;
    std::vector<int> a;
    int top=-1;
    while((scanf("%s",ch))!=EOF){
        if(ch[0]=='+'){
           x=a.at(top-1);
           y=a.at(top);
           pop(a,top);
           x+=y;
           a.push_back(x);
        }
        else if(ch[0]=='-'){
           x=a.at(top-1);
           y=a.at(top);
           pop(a,top);
           x-=y;
           a.push_back(x);
        }
        else if(ch[0]=='*'){
           x=a.at(top-1);
           y=a.at(top);
           pop(a,top);
           x*=y;
           a.push_back(x);
        }
        
        else{
            n=atoi(ch);
            a.push_back(n);
            top++;
        }
    }
        cout<<a.at(top)<<endl;
    return 0;
}

void pop(vector<int> &a,int &top){
    a.pop_back();
    a.pop_back();
    top--;
}


Measured memory_bytes: 3212
n = int(input())
a = list(map(int,input().split()))
ans = 0
cnt = 0
for i in range(0,n-1):
    if a[i]<a[i+1]:
        ans = max(cnt,ans)
        cnt = 0
    else:
        cnt+=1
ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 63984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int n;
  cin >> n;
  lol a[n + 5];
  rep(i,n){
    cin >> a[i];
  }
  lol ans = 0, nasu = 1;
  bool safe = true;
  while(safe){
    rep(i,n){
      if((a[i]/nasu) % 2 == 1){
	safe = false;
      }
      //  cout << a[i] / nasu << " ";
    }
    // cout << '\n';
    ans ++;
    nasu *= 2;
    }
  cout << ans - 1 << '\n';
  return 0;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	char c;
	cin >> c;
	string a = "aiueo";
	cout << (a.find(c) != string::npos ? "vowel" : "consonant") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<int> des[300010],mp;
bool erz[300010];
int main()
{
	//freopen("in.txt","r",stdin);
	int n;scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		des[u].insert(v);des[v].insert(u);
	}
	for (int i=1;i<=n;i++) if (des[i].size()==2) mp.insert(i);
	while (mp.size())
	{
		int s=*mp.begin();mp.erase(s);n-=2;
		
		int p1=*des[s].begin();des[s].erase(p1);int p2=*des[s].begin();des[s].erase(p2);
		if (des[p1].size()>des[p2].size()) swap(p1,p2);
		
		des[p1].erase(s);des[p2].erase(s);
		for (set<int>::iterator it=des[p1].begin();it!=des[p1].end();it++)
		{
			des[*it].erase(p1);
			des[*it].insert(p2);
			des[p2].insert(*it);
		}
		
		mp.erase(p1);
		if (des[p2].size()==2) mp.insert(p2);else mp.erase(p2);
	}
	//cout<<n<<endl;
	if (n==2) printf("Second\n");else printf("First\n");
}

Measured memory_bytes: 25728
import java.util.*;

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

		System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int n,a,min=1000000,max=-1000000;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<min)min=a;
        if(a>max)max=a;
        sum+=a;
    }cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(int argc, char const *argv[])
{
    string w, t;
    int count = 0;
    cin >> w;
    for (int i = 0; i < w.size() ; ++i)
    {
        w[i] = tolower(w[i]);
    }
    while(1) {
        cin >> t;
        if(t == "END_OF_TEXT") break;

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

        if(t == w)
        {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
int main() {
	ll L, R, d;
	cin >> L >> R >> d;
	cout << R / d - (L - 1) / d << endl;
}

Measured memory_bytes: 3588
from itertools import product
def main():
    h, w, k = map(int, input().split())
    dp = [[0 for j in range(w)] for i in range(h+1)]
    dp[0][0] = 1
    p = []
    for q in product(("-", " "), repeat=w-1):
        f = True
        for j in range(len(q)-1):
            if q[j] == "-" and q[j+1] == "-":
                f = False
        if f:
            p.append(q)
    MOD = 10**9 + 7
    for i in range(1, h+1):
        for q in p:
            for j in range(w):
                if 0 < j and q[j-1] == "-":
                    dp[i][j] += dp[i-1][j-1]
                    dp[i][j] %= MOD
                if j < w-1 and q[j] == "-":
                    dp[i][j] += dp[i-1][j+1]
                    dp[i][j] %= MOD
                if w == 1 or  (0 < j < w-1 and q[j-1] == " " and q[j] == " "):
                    dp[i][j] += dp[i-1][j]
                    dp[i][j] %= MOD
                elif j == 0 and 1 < w and q[j] == " ":
                    dp[i][j] += dp[i-1][j]
                    dp[i][j] %= MOD
                elif j == w-1 and 1 < w and q[j-1] == " ":
                    dp[i][j] += dp[i-1][j]
                    dp[i][j] %= MOD
    print(dp[h][k-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<n;i++)
    {
        cout<<s1[i]<<s2[i];
    }
}

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

const int INF = 10000000;

int main() {
  int N;
  vector<int> A(210);
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  int res = INF;
  for(int i = 0; i < N; i++){
    int count = 0;
    while(A[i] % 2 == 0){
      A[i] /= 2;
      count++;
    }
    if(res > count){
      res = count;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
	int n,k;
	cin >> n >> k;
	double ans = 0;
	for(int i=1; i<=n; i++){
		double sub = 1.0/n;
		int num = i;
		while(num < k){
			num *= 2;
			sub /= 2;
		}
		ans += sub;
	}
	cout << fixed << setprecision(10);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

vector<int> parser(const string& s) {
	const int N = s.size();
	vector<int> res(N + 1, 0);
	rep(i, N)res[i + 1] = s[i] == 'A' ? 1 : 2;
	rep(i, N)res[i + 1] += res[i];
	return res;
}

int main()
{
	string s, t;
	int q;
	cin >> s >> t >> q;

	auto imoss = parser(s);
	auto imost = parser(t);

	rep(i, q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; c--;

		int ps = (imoss[b] - imoss[a]) % 3;
		int pt = (imost[d] - imost[c]) % 3;
		cout << (ps == pt ? "YES" : "NO") << endl;
	}

	return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long x;
  cin >> x;
  long long t = 100;
  for (int i = 0; ; ++i) {
    t += t / 100;
    if (t >= x) {
      cout << i + 1 << '\n';
      exit(0);
    }
  }
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string s; cin >> s;
    int len = s.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len-1); msk++) {
        ll num = s[0] -'0';
        for (int i = 0; i < len-1; i++) {
            if (msk & 1<<i) {
                ans += num;
                num = 0;
            }
            num = num * 10 + (s[i+1] - '0');
        }
        ans += num;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {

    int N, K;
    scanf("%d %d", &N, &K);

    int A[N];
    REP(0, i, N) {
        scanf("%d", &A[i]);
    }

    int cnt = 0;
    int idx = 0;
    while (true) {
        if (idx >= N - 1) {
            break;
        }
        cnt++;
        idx += K - 1;
    }

    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 512
N = int(input())
H = [int(x) for x in input().split()]

ans = "Yes"
for i in range(1, N):
  if H[-(i + 1)] <= H[-i]:
    continue
  elif H[-(i + 1)] - 1 <= H[-i]:
    H[-(i + 1)] -= 1
  else:
    ans = "No"
    break
print(ans)

Measured memory_bytes: 14252
def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    a = [0,0]
    for key,i in d.items():
        if i>=4:
            if a[1]<key:
                a = [key,key]
            elif a[0]<key:
                a = [key,a[1]]
        elif i>=2:
            if a[1]<key:
                a = [a[1],key]
            elif a[0]<key:
                a = [key,a[1]]
    ans = a[0]*a[1]
    print(ans)
    return

def examD():

    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 18756
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		long c = 0;
		for (int i = 0; i < N; ++i) {
			sc.next();
			int s = sc.next().charAt(0) == '(' ? 1 : -1;
			c += sc.nextInt() * s;
			System.out.println(c == 0 ? "Yes" : "No");
		}
	}

}

Measured memory_bytes: 42556
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[900001];
ll invf[900001];
ll comb(int x, int y){
	if(x<y) return 0;
	return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	int n, m, k; cin>>n>>m>>k;
	f[0]=1;
	for(ll i=1; i<=n+m+k; i++) f[i]=f[i-1]*i%MOD;
	invf[n+m+k]=inv(f[n+m+k]);
	for(ll i=n+m+k-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
	ll p3[600001]; p3[0]=1;
	ll p2[600001]; p2[0]=1;
	for(int i=1; i<=m+k; i++){
		p3[i]=p3[i-1]*3%MOD;
		p2[i]=p2[i-1]*2%MOD;
	}
	ll sm[600001], sk[600001];
	sm[m+1]=1; sk[k+1]=1;
	for(int i=m+2; i<=m+k; i++){
		sm[i]=2*sm[i-1]+comb(i-1, m);
		sm[i]%=MOD;
	}
	for(int i=k+2; i<=m+k; i++){
		sk[i]=2*sk[i-1]+comb(i-1, k);
		sk[i]%=MOD;
	}
	ll ans=0;
	for(int i=0; i<=m+k; i++){
		ans+=comb(n-1+i, i)*p2[i]%MOD*p3[m+k-i]%MOD;
		ans%=MOD;
	}
	for(int i=m+1; i<=m+k; i++){
		ans+=(MOD-sm[i]*comb(n-1+i, i)%MOD*p3[m+k-i]%MOD);
		ans%=MOD;
	}
	for(int i=k+1; i<=m+k; i++){
		ans+=(MOD-sk[i]*comb(n-1+i, i)%MOD*p3[m+k-i]%MOD);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 33024
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int d,e;
    d=a;
    if(b>d)d=b;
    if(c>d)d=c;
    e=a+b+c-d;
    printf("%d\n",d*10+e);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <memory.h>
int main(void){
  long long d[4001];
  int n,i,j,f,e,p,q,a[4000];
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    memset(a,0,sizeof(a));
    memset(d,0,sizeof(d));
    f=1;
    for(i=0,j=0;i<n;i++){
      scanf("%d %d %d",&e,&p,&q);
      if(d[e]!=-1)
	d[e]+=p*q;
      if(d[e]>999999){
	f=0;
	a[j++]=e;
	d[e]=-1;
      }
    }
    if(f)
      puts("NA");
    else{
      for(i=0;i<j;i++)
	printf("%d\n",a[i]);
    }
  }
  return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

void greedy(string::iterator itr, int k, int c, string &s, bool isForward, vector<int> &vec)
{
    auto endItr = s.end();
    if (!isForward)
    {
        endItr = s.begin();
        endItr--;
    }
    while ((k > 0) && (itr != endItr))
    {
        if (*itr == 'x')
            isForward ? itr++ : itr--;
        else
        {
            vec.push_back(distance(s.begin(), itr));
            k--;
            for (int i = 0; (itr != endItr) && (i < c + 1); i++)
            {
                isForward ? itr++ : itr--;
            }
        }
    }
}

int main()
{
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> l, r;
    auto itr = s.begin();
    greedy(itr, k, c, s, true, l);
    itr = s.end();
    itr--;
    greedy(itr, k, c, s, false, r);
    reverse(r.begin(), r.end());

    vector<int> ans;
    for (int i = 0; i < k; i++)
    {
        if (l[i] == r[i])
            ans.push_back(l[i]);
    }

    for (auto &&item : ans)
        cout << item + 1 << endl;

    return 0;
}

Measured memory_bytes: 4216
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2*(int)1e5 + 3;

int n, a[N], b[N];
VI ve;

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    ve.PB(a[i]);
  }
  sort(ve.begin(), ve.end());
  int m1, m2;
  if (n&1)
    m1 = ve[(n-1)/2];
  else
    m1 = ve[n/2-1]+ve[n/2];
  ve.clear();
  for (int i = 1; i <= n; ++i)
    ve.PB(b[i]);
  sort(ve.begin(), ve.end());
  if (n&1)
    m2 = ve[(n-1)/2];
  else
    m2 = ve[n/2-1]+ve[n/2];
  cout<<m2-m1+1<<"\n";
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    int C[9][9] = {};
    int ans = 0;
    rep(i,N) {
        string s = to_string(i+1);
        rep(a,9) {
            string A;
            A = to_string(a+1);
            if (s[0]!=A[0]) continue;

            rep(b,9) {
                
                string B;
                B = to_string(b+1);
                if (s[0]==A[0] && s[s.size()-1]==B[0]) {
                    C[a][b]++;
                }
            }
        }
    }
    rep(a,9) {
        rep(b,9) {
            ans += C[a][b]*C[b][a];
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3684
import sys
sys.setrecursionlimit(10**7)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n = map(int, input().split())
    s9 = sum(n)
    if s9 % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define fi first
#define se second
#define forn(i,n) for(int i = 0; i < (n); ++i)
#define for1(i,n) for(int i = 1; i <= (n); ++i)
#define forr(i,n) for(int i = (n)-1; i >= 0; --i)
#define forab(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{forn(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;forn(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX = 100001;

int dp[MAX] = {};

int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr); 
	int n, k ; 
	cin >> n>> k;
	vi h(n);
	cin >> h;
	forn(i,n) dp[i] = INF;
	dp[0] = 0;
	forn(i,n){
		for1(j,k){
			if(i-j >= 0) mins(dp[i], abs(h[i]-h[i-j]) + dp[i-j]);
		}
	}
	cout << dp[n-1];
	return 0;
}




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

h = []
B = [0]*N

for i in range(N):
    h.append(A[i])
    h = [min(h)]
    B[i] = h[0]

j = []
C = [0]*N

for i in range(N-1,-1,-1):
    j.append(A[i])
    j = [max(j)]
    C[i] = j[0]

B = B[:-1]
C = C[1:]
D = list(map(lambda x:C[x]-B[x],range(N-1)))
t = max(D)

s = 0
D.append(0)
for i in range(N-1):
    if D[i] == t and D[i] > D[i+1]:
        s += 1

print(s)


Measured memory_bytes: 14484
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int mod = 1e9 + 7;


int modpower(int a, int n, int mod){
	if(n == 0){
		return 1;
	}
	int result = modpower(a,n/2,mod);	// modpower(2,2,31)
	if(n % 2 == 1){
		result = ((result * result % mod) * a) % mod;
	}
	else{
		result = (result * result) % mod;
	}
	return result;
}

int ncr(int n, int a){
	if(a > n-a)
		a = n-a;
	int num = 1;
	for(int i = n; i >= n-a+1; i--){
		num = (num*i) % mod; 
	}
	int den = 1;
	for(int i = 1; i <= a; i++){
		den = (den*i) % mod;
	}
	int d = modpower(den,mod-2,mod);
	if(d < 0)
		d += mod;
	int ans = (num * d) % mod;
	if(ans < 0)
		ans += mod;
	return ans;
}


int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;
	
	int answer = (modpower(2,n,mod) - 1 + mod) % mod;
	int result1 = ncr(n,a);
	int result2 = ncr(n,b);

	int ans = (answer - result1 - result2 + mod) % mod;
	if(ans < 0)
		ans += mod;
	
	cout << ans;


	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int i, sum = 0;
    for (i = 1; i < 999; i++) {
        sum += i;
        if (b-a == i+1) {
            cout << sum - a << endl;
            return 0;
        }
    }

}

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

signed main(){
	int n,m,ans=0;
	cin>>n>>m;

	for(int i=m/n;i>=1;i--){
		if(m%i==0){ans=i;break;}
	}
	cout<<ans<<endl;
}


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

int c[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    cout << c[--k] << "\n";
    return 0;
}

Measured memory_bytes: 256
import numpy as np
from collections import Counter
n = int(input())
i = np.arange(n)
a = np.array(list(map(int, input().split())))
p = i + a
m = i - a
pc = Counter(p)
mc = Counter(m)
ans = sum([cnt * mc[x] for x, cnt in pc.items()])
print(ans)


Measured memory_bytes: 75556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class C_Bugged {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            if (sum % 10 != 0) {
                out.printLine(sum);
                return;
            }
            Arrays.sort(a);

            for (int i = 0; i < n; i++) {
                if (sum % 10 == 0) {
                    if (a[i] % 10 != 0) sum -= a[i];
                    if (i == n - 1) {
                        sum = -1;
                    }
                }

            }
            out.printLine(Math.max(0, sum));
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

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

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printLine(long i) {
            writer.println(i);
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21460
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-15 19:53:54

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a, b, k;
	cin >> a >> b >> k;
	a = __gcd(a, b);
	int cnt = 0;
	for(int i = a; i >= 1; --i){
		if(a%i != 0)	continue;
		cnt++;
		if(cnt == k){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    int N = 0; cin >> N;
    int l = 0, r = N-1;
    string z;
    cout << 0 << endl;
    cout.clear();
    cin >> z;
    REP(i, 19)
    {
        int m = (l+r)/2;
        string s;
        cout << m << endl;
        cout.clear();
        cin >> s;
        if(s == "Vacant") return 0;
        if(m % 2 == 0)
        {
            if(s == z)
            {
                l = m+1;
            }
            else
            {
                r = m-1;
            }
        }
        else
        {
            if(s != z)
            {
                l = m+1;
            }
            else
            {
                r = m-1;
            }
        }
    }
}

Measured memory_bytes: 852
#include<iostream>
#include<map>
using namespace std;
map<int,bool> a;
int n,tq;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>tq;
        if(a[tq]==false)
			a[tq]=true;
        else
        {
        	cout<<"NO";
        	return 0;
		}
    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 9600
n = int(input())
a = list(map(int, input().split()))
a_ = [i for i in a if i % 2 == 0]

for i in a_:
    bool_3 = i % 3 != 0
    bool_5 = i % 5 != 0
    if bool_3 and bool_5:
        print('DENIED')
        break
else:
    print('APPROVED')


Measured memory_bytes: 9040
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll x, y, ans;

int main(){
	cin >> x >> y;
	if(abs(x) == abs(y)){
		ans = (x*y >= 0)? 0 : 1;
	}
	if(abs(x) > abs(y)){
		ans = abs(x)-abs(y);
		if(x > 0){ans++;}
		if(y > 0){ans++;}
	}
	if(abs(x) < abs(y)){
		ans = abs(y)-abs(x);
		if(x < 0){ans++;}
		if(y < 0){ans++;}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int r,t,T;
	complex<double> ans(0.0,0.0);

	T=90;

	while(scanf("%d,%d",&r,&t)>0){
		ans+=polar((double)r,(double)T*PI/180.0);
		T-=t;
	}
	
	cout<<(int)ans.real()<<endl<<(int)ans.imag()<<endl;

	return 0;

}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  int city[n] = {0};
  
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    for(int j = 0; j < n; j++) {
      if(j+1 == a || j+1 == b) city[j]++;
    }
  }
  
  for(int k = 0; k < n; k++) {
    cout << city[k] << endl;
  }
}

Measured memory_bytes: 256
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
char a,b;
int main(){
	cin>>a>>b;
	if(a==b)cout<<'H'<<endl;
	else cout<<'D'<<endl;


	return 0;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	cookie := make(I64, 3)

	var sum int64
	for i := 0; i < 3; i++ {
		cookie[i] = getNextInt64(scanner)
		sum += cookie[i]
	}

	ans := 0
	for sum > 0 {
		sort.Sort(cookie)
		for i := 2; i >= 0; i-- {
			if cookie[i]%2 != 0 {
				fmt.Println(ans)
				return
			}
			cookie[i] -= cookie[0]
		}
		cookie[0], cookie[1], cookie[2] = (cookie[1]+cookie[2])/2, (cookie[0]+cookie[2])/2, (cookie[0]+cookie[1])/2
		sum = 0
		for i := 0; i < 3; i++ {
			sum += cookie[i]
		}
		ans++
	}
	fmt.Println(-1)
	writer.Flush()
}

type I64 []int64

func (a I64) Len() int           { return len(a) }
func (a I64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a I64) Less(i, j int) bool { return a[i] < a[j] }


Measured memory_bytes: 640
import java.util.*;

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

		while(n-- > 0){
			int x = 0, y = 0;
			double max = Double.MIN_VALUE;
			int maxX = -1, maxY = -1;

			while(true){
				int tx = sc.nextInt(), ty = sc.nextInt();
				if(tx == 0 && ty == 0) break;

				x += tx;
				y += ty;

				double dist = Math.sqrt(x*x + y*y);
				if(dist > max || dist == max && x > maxX){
					max = dist;
					maxX = x;
					maxY = y;
				}
			}

			System.out.println(maxX + " " + maxY);
		}
	}
}

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

typedef long long ll;
#define endl "\n"

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

    int n, m;
    cin>>n>>m;
    vector<int> h(n);
    for (int i=0; i<n; ++i){
    	cin>>h[i];
    }
    vector<set<int>> adj(n);
    for (int i=0; i<m; ++i){
    	int u,v;
    	cin>>u>>v; u--; v--;
    	adj[u].insert(h[v]);
    	adj[v].insert(h[u]);
    }
    int ans=0;
    for (int i=0; i<n; ++i){
    	if (adj[i].empty()){
    		ans++;
    		continue;
    	}
    	auto it = adj[i].end(); it--; //largest element
    	ans+=(h[i]>*it);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 17700
mod = 10**9 + 7

n = int(raw_input())
s = raw_input()

q = []

for a in "abcdefghijklmnopqrstuvwxyz":
  q.append( s.count(a) )

ans = 1

for a in q:
  ans *= (a+1)
  ans %= mod

print ans-1

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int d, t, s;
  cin >>d >> t >>s;

  if(d/s>t)cout << "No" << endl;
  else if(d/s==t&&d%s!=0)cout << "No" << endl;
  else if(d/s<=t)cout << "Yes" << endl;

  return 0;
}

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

i64 gcd(i64 a,i64 b){
    if(a<b) swap(a,b);
    int tmp;
    while(a%b!=0){
        tmp = a%b;
        a = b;
        b = tmp;
    }
    return b;
}

int main(){
    i64 n,ans=0;
    cin>>n;
    for(i64 i=1;i<=n;i++){
        for(i64 j=1;j<=n;j++){
            for(i64 k=1;k<=n;k++)
                ans+=gcd(gcd(i,j),k);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    string s, t;   cin >> s;
    t = s;

    reverse(t.begin(), t.end());
    int left=0, right=0, cnt=0, n=s.size();
    while(left<n || right<n){
        if(s[left]==t[right]){
            left += 1; right += 1;
        }else if(s[left]=='x'){
            cnt += 1;   left += 1;
        }else if(t[right]=='x'){
            cnt += 1;   right += 1;
        }else{
            cnt = -1; break;
        }
    }
    if(0<cnt) cnt /= 2;
    cout <<cnt << endl;
}



Measured memory_bytes: 512
def main():
    n, k = map(int, input().split())
    cnt = [0]*101
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()

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

int main(void){
	int n, result = 0;
	cin >> n;
	map<int, int> o_map;
	map<int, int> e_map;
	for(int index = 0; index < n; index++){
		int v;
		cin >> v;
		if(index % 2 == 0)
			e_map[v]++;
		else
			o_map[v]++;
	}

	int o_value, o_max = 0;
	for(auto itr = o_map.begin(); itr != o_map.end(); itr++){
		if(o_max < itr->second){
			o_value = itr->first;
			o_max = itr->second;
		}
	}

	int e_value, e_max = 0;
	for(auto itr = e_map.begin(); itr != e_map.end(); itr++){
		if(e_max < itr->second){
			e_value = itr->first;
			e_max = itr->second;
		}
	}

	if(e_value == o_value){
		o_map[o_value] = 0;
		int o_value2, o_max2 = 0;
		for(auto itr = o_map.begin(); itr != o_map.end(); itr++){
			if(o_max2 < itr->second){
				o_value2 = itr->first;
				o_max2 = itr->second;
			}
		}

		e_map[e_value] = 0;
		int e_value2, e_max2 = 0;
		for(auto itr = e_map.begin(); itr != e_map.end(); itr++){
			if(e_max2 < itr->second){
				e_value2 = itr->first;
				e_max2 = itr->second;
			}
		}
		if(o_max2 < e_max2) e_max = e_max2;
		else o_max = o_max2;
	}
	
	result += n/2 - o_max;
	result += n/2 - e_max;

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <tuple>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b){return (b==0?a:gcd(b,a%b));}
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,n) for(int i=a;i<n;i++)

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

    Rep(i,1,10){
        if (n / i < 10){
            if (floor(n/i) != n/i){
                continue;
            }
            else cout << "Yes" << endl;
            return 0;
        }
        else continue;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 45

int A[N];

int fib(int n){
  if(A[n] == -1){
    if(n != 0 && n != 1) 
      A[n] = fib(n-1) + fib(n-2);
    return A[n];
  }
  else return A[n];
}

int main(){
  int n, x, i;
  A[0] = 1;
  A[1] = 1;
  scanf("%d",&n);
  for(i=2; i <= n; i++) A[i] = -1;
  x = fib(n);
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 596
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 1e5 + 5, mod = (int) 0;
int n, mark[N], h[N], sz[N], res;
int mn = 1e9 + 1;
vector<pair<int, int>> adj[N];
void dfs(int v, int p = -1) {
	if (p == -1) h[v] = 0;
	sz[v] = 1;
	for (auto e : adj[v]) if (e.x != p) {
		int u = e.first, w = e.second;
		h[u] = h[v] + w;
		dfs(u, v);
		sz[v] += sz[u];
	}
}
void dfs_mark(int v, int p = -1) {
	mark[v] = 1;
	for (auto e : adj[v]) if (e.x != p) {
		int u = e.first, w = e.second;
		dfs_mark(u, v);
	}
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int j = 0; j < n - 1; ++j) {
		int u, v, w;
		cin >> u >> v >> w;
		--u, --v;
		adj[u].pb(mp(v, w));
		adj[v].pb(mp(u, w));
	}
	dfs(0);
	int root = -1;
	for (int v = 0; v < n; ++v) {
		if (sz[v] >= (n / 2) + (n & 1)) {
			if (root == -1 || sz[v] <= sz[root]) {
				root = v;	
			}
		}
	}
	dfs(root);
	int flag = 1;
	for (auto e : adj[root]) {
		int u = e.first, w = e.second;
//		cerr << " hi " << u << ' ' << sz[u] << ' ' << (n / 2) + (n & 1) << endl;
		if (sz[u] != (n / 2) + (n & 1)) {
			dfs_mark(u, root);
		} else {
			flag = 0;
		}
	}
	if (flag) memset(mark, 0, sizeof mark);
	for (int v = 0; v < n; ++v) {
		if (v != root && !mark[v]) mn = min(mn, h[v]);
		res += 2 * h[v];
//		cerr << v << ' ' << h[v] << ' ' << sz[v] << ' ' << mark[v] << endl;
	}
	
	cout << res - mn << endl;
	
}






Measured memory_bytes: 14208
X, N = map(int, input().split())
p = list(map(int, input().split()))
pp = set(p)

ans = X
idx = 0
for i in range(-101, 102):
    if(abs(X-i) < ans):
        if(i not in pp):
            ans = abs(X-i)
            idx = i
print(idx)

Measured memory_bytes: 9188
#include<cstdio>

const int N=20000;

int n;
int a[N+5],b[N+5],p;

int main()
{
	scanf("%d",&n);
	
	a[1]=1;
	for(int i=2;i<=n;i++)
		a[i]=a[i-1]+2*n;
	b[n]=1;
	for(int i=n-1;i>=1;i--)
		b[i]=b[i+1]+2*n;
	
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p);
		a[p]+=i;
	}
	for(int i=1;i<=n;i++)
		printf("%d ",a[i]);
	putchar('\n');
	for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

int col[200005];
vector <int> graf[200005];
int posl[200005];
int last[200005];
vector <int> novi[200005];
ll res[200005];
ll sz[200005];
bool ima[200005];
ll sve[200005];
int par[200005];
int sad[200005];

void dfs_init(int v, int parent){
    par[v] = parent;
    last[v] = posl[col[v]];
    sz[v] = 1;
    posl[col[v]] = v;
    for(auto c : graf[v]){
        if(c == parent) continue;
        sad[v] = c;
        dfs_init(c, v);
        posl[col[v]] = v;
        sz[v] += sz[c];
    }
    posl[col[v]] = last[v];
    novi[sad[last[v]]].push_back(v);
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> col[i];
        ima[col[i]] = 1;
        sve[i] = n;
    }
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    dfs_init(1, 0);
    for(int i=1; i<=n; i++){
        if(last[i] == 0) sve[col[i]] -= sz[i];
    }
    for(int i=1; i<=n; i++){
        ll tr = sz[i];
        for(auto c : novi[i]){
            tr -= sz[c];
        }
        res[col[par[i]]] += tr*(tr+1)/2;
    }
    for(int i=1; i<=n; i++){
        res[i] += 1LL*sve[i]*(sve[i]+1)/2;
        cout << 1LL*n*(n+1)/2 - res[i] << "\n";
    }
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<pair<int,int>> P(N);
  rep(i,N) cin >> P[i].second >> P[i].first;
  sort(P.begin(), P.end());

  int time=0;
  rep(i, N)
  {
    time += P[i].second;
    if(P[i].first < time)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main(){
  ll a, b;
  cin >> a >> b;
  cout << a * b / gcd(a, b) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int f (int x) {
  int s = 0;
  while (x) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  int mi = 1e9;
  for (int a = 1; a < n; ++a) mi = min(mi, f(a) + f(n-a));
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 256
N = input()
s = input()

#累積和 前処理 Eの数を集計
count = s.count('E')

ans = count
#左端1番目からリーダーをずらしながらチェック。
for ch in s:
    if ch == 'E':
        count -= 1
        ans = min(count,ans)
    else:
        count += 1
    
print(ans)

Measured memory_bytes: 9604
{-# LANGUAGE OverloadedStrings #-}
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import           Data.Char             (isUpper)
import           Data.Word             (Word8)

main :: IO ()
main = do
  a <- B.head <$> B.getLine
  if isUpper a
    then B.putStrLn "A"
    else B.putStrLn "a"


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;

int main()
{
int h,w,m;
cin>>h>>w>>m;
vector<int>hs(h);
vector<int>ws(w);
set<P>s;
rep(i,m)
{
int r,c;
cin>>r>>c;
r--;c--;
hs[r]++;
ws[c]++;
s.emplace(r,c);

}
int hm=0,wm=0;
rep(i,h)
hm=max(hm,hs[i]);
rep(j,w)
wm=max(wm,ws[j]);
vector<int>hv;
vector<int>wv;
rep(i,h)
if(hs[i]==hm)hv.push_back(i);
rep(j,w)
if(ws[j]==wm)wv.push_back(j);
int ans=hm+wm;
for(int x:hv)
{
for(int y:wv)
{
if(s.count(P(x,y)))continue;
cout <<ans;
return 0;


}


}
ans--;
cout <<ans;
return 0;
}

Measured memory_bytes: 23784