akhauriyash/Code-Regression huggingface dataset:
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    vector<long long> t(5);
    for(auto &i : t) cin >> i;

    sort(t.begin(), t.end());
    long long ans = INF;

    do {
        long long curTime = 0;
        for(long long i = 0; i < 5; i++) {
            curTime += t[i];
            if(i == 4) break;
            if(curTime % 10 == 0) continue;
            else curTime += (10 - (curTime % 10));
        }
        ans = min(ans, curTime);
    } while(next_permutation(t.begin(), t.end()));

    cout << ans;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int N, a[200010], b[200010], par[200010], desc[200010];
ll dp[200010], divs[200010], ans[200010];
bool looked[200010]={};

ll mod=1000000007;
const int SIZE=210000;
ll fac[SIZE], finv[SIZE], inv[SIZE];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2; i<SIZE; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}
ll COM(int n, int k, ll m){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return (fac[n]*((finv[k]*finv[n-k])%m))%m;
}
ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a%m;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%m;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}


vector<vector<int>> G;

void dfs(int key){
    looked[key]=1;
    desc[key]=1;
    dp[key]=1;
    divs[key]=1;
    for(int i=0; i<G[key].size(); ++i){
        int v=a[G[key][i]]+b[G[key][i]]-key;
        if(!looked[v]){
            par[v]=key;
            dfs(v);
            desc[key] += desc[v];
            (dp[key] *= dp[v]) %= mod;
            (divs[key] *= finv[desc[v]]) %= mod;
        }
    }
    (dp[key] *= fac[desc[key]-1]) %= mod;
    (dp[key] *= divs[key]) %= mod;
}

void efs(int key){
    for(int i=0; i<G[key].size(); ++i){
        int v=a[G[key][i]]+b[G[key][i]]-key;
        if(v!=par[key]){
            ans[v]=fac[N-1];
            for(int j=0; j<G[v].size(); ++j){
                int w=a[G[v][j]]+b[G[v][j]]-v;
                if(w!=key){
                    (ans[v] *= dp[w]) %= mod;
                    (ans[v] *= finv[desc[w]]) %= mod;
                }
                else{
                    (ans[v] *= ans[w]) %= mod;
                    (ans[v] *= (finv[N-1]*fac[desc[v]])%mod) %= mod;
                    (ans[v] *= fac[N-1-desc[v]]) %= mod;
                    ans[v]=moddiv(ans[v], dp[v], mod);
                    (ans[v] *= finv[N-desc[v]]) %= mod;
                }
            }
            efs(v);
        }
    }
}

int main() {
	cin >> N;
	G.resize(N+1);
	for(int i=1; i<N; ++i){
	    cin >> a[i] >> b[i];
	    G[a[i]].emplace_back(i);
	    G[b[i]].emplace_back(i);
	}
	COMinit(mod);
	par[1]=0;
	dfs(1);
	ans[1]=dp[1];
	efs(1);
	for(int i=1; i<=N; ++i) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 26868
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].f>>v[i].s;
    for(int i=2;i<n;i++)
        if((v[i].f==v[i].s)&&(v[i-1].f==v[i-1].s)&&(v[i-2].f==v[i-2].s))
            return cout<<"Yes",0;
    cout<<"No";
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  string ss;cin>>ss;
  int w=0,e=0;
  rep(i,n)if(ss[i]=='E')e++;
  int tot=e;
  rep(i,n){
      if(ss[i]=='E')e--;
      tot=min(tot,w+e);
      if(ss[i]=='W')w++;
  }
  cout<<tot<<endl;
  return 0;
  }


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  
  vector<vector<int>> color(W, vector<int>(H, 0));
  
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      for (int k = 0; k < x; k++) {
        for (int l = 0; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else if (a == 2) {
      for (int k = x; k < W; k++) {
        for (int l = 0; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else if (a == 3) {
      for (int k = 0; k < W; k++) {
        for (int l = 0; l < y; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
    else {
      for (int k = 0; k < W; k++) {
        for (int l = y; l < H; l++) {
          color.at(k).at(l) = 1;
        }
      }
    }
  }
  
  int ans = 0;
  
  for (int k = 0; k < W; k++) {
    for (int l = 0; l < H; l++) {
      if (color.at(k).at(l) == 0) {
        ans++;
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define ll long long
#define pb push_back
using namespace std;
const ll INF=4e18,N=5e7;
ll a,b,c,d; map<ll,ll> mp;
ll solve(ll n,int T){
    if (!n) return 0; if (n==1) return d;
    if (mp.count(n)) return mp[n];
    ll ans=n<=INF/d?n*d:INF;
    if (n%2==0) ans=min(ans,solve(n/2,T)+a);
    else ans=min(ans,min(solve(n/2,T),solve(n/2+1,T))+a+d);
    if (n%3<3-n%3) ans=min(ans,solve(n/3,T)+b+n%3*d);
    else ans=min(ans,solve(n/3+1,T)+b+(3-n%3)*d);
    if (n%5<5-n%5) ans=min(ans,solve(n/5,T)+c+n%5*d);
    else ans=min(ans,solve(n/5+1,T)+c+(5-n%5)*d);
    return mp[n]=ans;
}
int main(){
    int T; cin>>T;
    while (T--){
        ll n; cin>>n>>a>>b>>c>>d; mp.clear();
        cout<<solve(n,T+1)<<endl;
    }
}


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

int main() {
  int x,y,z;
  
  cin >> x >> y >> z ;
  
  if (x+y <= y+z){
    if (x+y <= z+x){
      cout << x+y << endl;
    }
    else {
      cout << z+x << endl;
    }
  }
  
  else {
    if (y+z <= z+x) {
      cout << y+z << endl;
    }
    else {
      cout << z+x << endl;
    }
  }
      
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e9

int dp[41][401][401];

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ma,mb; cin>>n>>ma>>mb;
    vi a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(j,401)rep(k,401){
        dp[0][j][k] = INF;
    }
    dp[0][0][0] = 0;
    rep(i,n)rep(j,401)rep(k,401){
        if (j>=a[i] && k>=b[i]){
            dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]]+c[i]);
        }else{
            dp[i+1][j][k] = dp[i][j][k];
        }
    }
    int ans=INF;
    for(int i=1; ma*i<=400 && mb*i<=400; i++){
        chmin(ans, dp[n][ma*i][mb*i]);
    }
    ans = (ans==INF)?-1:ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 25984
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, M := getInt(), getInt()
	K := getInt()
	a := getInts(N)
	b := getInts(M)

	aa := make([]int, N+1)
	for i := 1; i <= N; i++ {
		aa[i] = aa[i-1] + a[i-1]
	}
	bb := make([]int, M+1)
	for i := 1; i <= M; i++ {
		bb[i] = bb[i-1] + b[i-1]
	}

	ans := 0
	for i := 0; i <= N; i++ {
		if aa[i] > K {
			continue
		}
		x := upperBound(bb, K-aa[i])
		ans = max(ans, i+x-1)
	}
	out(ans)
}


Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(){
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=22;i<=d;i++){
        for(int j=1;j<=m;j++){
            int dd=i;
            int d1=dd%10;
            if(d1==1) continue;
            dd/=10;
            int d10=dd%10;
            
            if(d1*d10==j){
                ans++;
                /*cout<<d10<<" "<<d1<<" "<<j<<endl;*/
            }
        }
    }
    cout<<ans<<endl;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

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

    int i, j;

    for(i=0; i<=25; i++){
        for(j=0; j<=15; j++){
            if(i*4+j*7==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>

#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;
    ll N,sum=0,ans,c;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    ll MAX=sqrt((double)N);
    EREP(i,MAX){
        if(N%i==0){
            ll temp=max(N/(ll)i,(ll)i);
            c=0;
            ans=log10(temp)+1;

        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<int> a;
  priority_queue<int> b;
  for(int i=0;i<m;i++){
    int L,R;
    cin>>L>>R;
    a.push(L);
    R=-R;
    b.push(R);
  }
  int l,r;
  l=a.top();
  r=b.top();
  r=-r;

  if(r-l+1<0)cout<<0;
  else{
    cout<<r-l+1;
  }
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

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

	// a : 10000円札の枚数
	// b :  5000円札の枚数
	// c :  1000円札の枚数
	int a, b, c;
	bool IsFound = false;
	for ( a = 0 ; a <= N; a++)
	{
		if ( (10000 * a) > Y ) break;
		for ( b = 0; (a+b) <= N; b++)
		{
			if ( (10000 * a + 5000 * b ) > Y ) break;
			// Confirm constraint
			c = N - a - b;
			int val = 10000 * a + 5000 * b + 1000 * c;
			if (val > Y) break;
			// Found
			if (val == Y)
			{
				IsFound = true;
				break;
			}
		}
		if (IsFound) break;
	}

	if (IsFound) cout << a << " " << b << " " << c << " " << endl;
	else cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    q=deque()
    l=[0]*(N+1)
    # for i in range(N,N//2,-1):
    #     if a[i-1]==1:
    #         l[i-1]=1

    #         q.appendleft(i)
    
    for i in range(N,0,-1):
        tot=0
        for j in range(2,N+1):
            if i*j>N:
                break
            tot^=l[(i*j)]
            
        if tot!=A[i-1]:
            l[i]+=1
            q.appendleft(i)
    print(len(q))
    if q:
        print(*q)




if __name__ == "__main__":
    main()

Measured memory_bytes: 104036
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
S = []
for i in range(N):
    S.append(input().rstrip('\n'))

if len(set(S)) != N:
    print("No")
    exit()
else:
    for i in range(1, N):
        if S[i - 1][-1] != S[i][0]:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 9112
n = int(input())
b = list(map(int, input().split()))
a = [-1] * n
num = [i for i in range(n - 1)]
d = {}
for i, j in zip(b, num):
    d[j] = i
d = sorted(d.items(), key=lambda x: x[1])
for k, v in d:
    if a[k] == -1:
        a[k] = v
    if a[k + 1] == -1:
        a[k + 1] = v
print(sum(a))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int k,x;
	cin>>k>>x;
	for (int i=x-k+1;i<=x+k-1;i++)
	{
		if (i>1000000) break;
		if (i<-1000000) continue;
		printf("%d ",i);
	 } 
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n;
	cin>>n;
	double p[n+1];
	for(i=1;i<=n;i++)
	cin>>p[i];
	double dp[n+1][n+1];
	for(i=0;i<=n;i++)
	for(j=0;j<=n;j++)
	dp[i][j]=0.0000;
	dp[0][0]=1.000;
	for(i=1;i<=n;i++)
	for(j=0;j<=i;j++)
	{
		if(j>=1)
		dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		else
		dp[i][j]=dp[i-1][j]*(1-p[i]);
	}
	double ans=0.000;
	for(j=n/2+1;j<=n;j++)
	ans+=dp[n][j];
	cout<<setprecision(15)<<ans;
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100000;

vector<vector<P>> G;
vl visited;  // visted[v] : 頂点vを訪問済みなら1
vl height;  // height[v] : 頂点vの高さ
bool ok = true;  // 条件が矛盾していないならtrue

void dfs(ll v, ll h = 0) {  // いまいる頂点v、vの高さ
    // 行きの処理はこのへんに書く
    if(visited[v]) {
        if(height[v] != h) {
            ok = false;
        }
        return;
    }
    visited[v] = 1;
    height[v] = h;
    for(auto p : G[v]) { 
        ll u = p.first;
        ll cost = p.second;
        dfs(u, h + cost);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, m;
    cin >> n >> m;    
    
    G.resize(n);
    rep(i, m) {
        ll a, b, cost;
        cin >> a >> b >> cost;
        a--;  b--;
        G[a].pb(make_pair(b, cost));
        G[b].pb(make_pair(a, -cost));
    }
    
    height.resize(n);
    visited.resize(n);
    rep(v, n) {
        if(visited[v]) {
            continue;
        }
        dfs(v);
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 16384
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

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

  int now = N;
  int sum = 0;
  while (now > 0) {
    sum += now%10;
    now/=10;
  }
  cout << ((N%sum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//#define DEBUG
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
const int inf = 0X3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int mod = 1000000007;
typedef long long ll;

int h, n;
int sum;

int main() {
    while(~scanf("%d", &h)) {
        scanf("%d", &n);
        sum  = 0;
        for (int i = 1; i <= n; i++) {
            int x;
            scanf("%d", &x);
            sum +=x;
        }
        if (sum >= h) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,N;
vvd in,dp;
double dfs(int a,int b){
	if(dp[a][b]+1)return dp[a][b];
	double out=0;
	rep(i,n)if((a&1<<i)==0){
		double sum=0;
		double p=1;
		loop(j,b,m){
			sum+=p*(1-in[i][j])*dfs(a|1<<i,j);
			p*=in[i][j];
		}
		out=max(out,sum+p);
	}
	
	return dp[a][b]=out;
}
int main(){
	cin>>n>>m;
	in=vvd(n,vd(m));
	rep(i,n)rep(j,m)cin>>in[i][j];
	N=1<<n;
	dp=vvd(N,vd(m,-1));
	cout<<shosu(11)<<dfs(0,0)<<endl;
}










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

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define endl '\n'
#define vll std::vector<ll>

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

        ll n,cnt = 0; cin >> n;
        vll a(n);
        rep(i,n){
                cin >> a[i];
                while(a[i] % 2 == 0) {
                        cnt++;
                        a[i] = a[i] / 2;
                }
        }
        cout << cnt << endl;

        return 0;
}


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

signed main(){
	cin.tie(0);
	cin.sync_with_stdio(0);

	int N, sum = 0;
	cin >> N;
	vector<long long> v(N);
	for(auto &i : v) cin >> i;
	for(auto &i : v) sum += i;

	vector<vector<long long>> dp(N, vector<long long>(N));

	for(int sz=0; sz<N; sz++){
		for(int i=0, j=sz; j<N; j++, i++){
			if(i == j) dp[i][j] = v[i];
			else if(i+1 == j) dp[i][j] = max(v[i], v[j]);
			else dp[i][j] = max(
			   	 v[j] + min(dp[i][j-2], dp[i+1][j-1]),
			    	 v[i] + min(dp[i+2][j], dp[i+1][j-1])
         		);
		}
	}
	long long a = dp[0][N-1];
	long long b = sum - a;
	cout << a - b;
}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#define MAXN 1200
using namespace std;
char s[MAXN];

int main() {
    cin>>s;
    int len = strlen(s);
    for(int i=0;i<len;i++)
    {
        if(s[i]==',')
            putchar(' ');
        else
            putchar(s[i]);
    }
    cout<<endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
template<class T>
struct FT{
    vector<T> d;
    FT(size_t n):d(n+1){}
    T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;}
    T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);}
    void add(size_t i,T x){for(++i;i<d.size();i+=i&-i)d[i]+=x;}
};
FT<int> ft(100001);
int main(){
  int n,m; cin >> n >> m;
  vt<tii> in;
  rep(i,m){
    int a,b; cin >> a >> b;
    in.pb(tii{b,a});
  }
  sort(ALL(in));
  int ans = 0;
  rep(i,m){
    int bb,aa; tie(bb,aa) = in[i];
    if(ft.sum(aa,bb) == 0){
      ft.add(bb - 1, 1 );
      ans++;
    }else{
      ;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1784
#include <iostream>

using namespace std;

int main()
{
  int t, n;
  int s, f;

  while (1) {
    cin >> t;
    if (t == 0) break;

    int time_to_study = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> s >> f;
      time_to_study += f - s;
    }
    if (time_to_study >= t) {
      cout << "OK" << endl;
    } else {
      cout << t - time_to_study << endl;
    }
  }
}



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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

const int MAX_V = 300;
using Cap = int;
using Cost = int;

const int inf = 1e9;

class BM {
public:
    int V;
    vector<vector<int>> g;
    vector<int> match;
    vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    BM(int v) : V(v), g(v), match(v), used(v) {}
    void ae(int u, int v) {
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    int mm() {
        int res = 0;
        fill(match.begin(), match.end(), -1);
        for (size_t v = 0; v < V; v++) {
            if (match[v] < 0) {
                fill(used.begin(), used.end(), 0);
                if (dfs(v)) res++;
            }
        }
        return res;
    }
};

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        int x1[110], y1[110], v[110];
        int x2[110], y2[110];

        for (size_t i = 0; i < n; i++) {
            cin >> x1[i] >> y1[i] >> v[i];
        }
        for (size_t i = 0; i < m; i++) {
            cin >> x2[i] >> y2[i];
        }

        double lb = 0, ub = 1e9;
        for (size_t i = 0; i < 70; i++) {
            double mid = (lb + ub) / 2;
            BM bm(n + m + 2);
            for (size_t i = 0; i < n; i++) {
                for (size_t j = 0; j < m; j++) {
                    double dx = x1[i] - x2[j];
                    double dy = y1[i] - y2[j];
                    double d = sqrt(dx*dx + dy*dy) / v[i];
                    if (d <= mid) {
                        bm.ae(i, j + n);
                    }
                }
            }

            if (bm.mm() == m) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        printf("%.10lf\n", ub);
    }

}

Measured memory_bytes: 3156
import itertools
A, B, C = map(int, input().split())
K = int(input())
targets = [A, B, C]
answer = 'No'

def check(targets):
    if targets[1] > targets[0] and targets[2] > targets[1]:
        return True
    else:
        return False

cases = itertools.product([0, 1, 2], repeat=K)
for case in cases:
    copy_targets = targets.copy()
    for i in case:
        copy_targets[i] = copy_targets[i] * 2
    if check(copy_targets):
        answer = 'Yes'
        break

print(answer)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  char C;
  cin >> C;
  C++;
  cout << C << '\n';
  return 0;
}

Measured memory_bytes: 3628
import math
if __name__ == "__main__":
    a, b, h, m = map(float, input().split())
    zi_deg = (60.0 * h + m) / 2
    hu_deg = 6.0 * m
    sa = abs(zi_deg - hu_deg)
    ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(sa))
    print(math.sqrt(ans))

Measured memory_bytes: 9440
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b, c, d = input_a

max = -1 * 10 ** 10
ans = []
ans.push(a * c)
ans.push(a * d)
ans.push(b * c)
ans.push(b * d)
puts ans.max
# (a..b).each do |i|
#   (c..d).each do |j|
#     if max < i * j
#       max = i * j
#     end
#   end
# end
# puts max


Measured memory_bytes: 14400
N = int(input())
list_A = []
for _ in range(N):
    A = int(input())
    list_A.append(A)
    
sorted_list = sorted(list_A, reverse=True)
A = sorted_list[0]
B = sorted_list[1]

for i in range(N):        
    if list_A[i] == A:
      print(B)
    else:
      print(A)

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[50];
  for (int i = 0; i < n; ++i) cin >> a[i];

  sort(a, a + n, greater<int>());

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

  cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    rep(i,0,n){
        if(a[i]==b[i]&&b[i]==c[i]) continue;
        if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]) ans+=2;
        else ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		char ball = 'A';
		while(sc.hasNextLine()) {
			String str = sc.nextLine();
			ball = whereIsBall(ball, str.charAt(0), str.charAt(2));
		}
		sc.close();
		System.out.println(ball);
	}
	
	static char whereIsBall(char ball, char swap1, char swap2) {
		if(ball == swap1) return swap2;
		else if(ball == swap2) return swap1;
		else return ball;
	}
}

Measured memory_bytes: 17308
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)
#define fill(x,t) memset(x,t,sizeof(x))
#define copy(x,t) memcpy(x,t,sizeof(x))

#define fi first
#define se second

typedef std:: pair <int,int> pair;
typedef long double ld;
typedef long long LL;

const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const int ny2=(MOD+1)/2;
const int N=2000005;
const ld pi=acos(-1);
const ld e=exp(1);
const ld eps=1e-8;

LL a[N],s[N],t[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	int n=read();
	rep(i,1,n) {
		a[i]=read();
		s[i]=s[i-1]+a[i];
		t[i]=t[i-1]^a[i];
	}
	LL ans=0;
	rep(i,1,n) {
		int l=1,r=i,pos=1;
		while (l<=r) {
			int mid=(l+r)>>1;
			if ((s[i]-s[mid-1])==(t[i]^t[mid-1])) {
				r=mid-1,pos=mid;
			} else l=mid+1;
		}
		ans+=(i-pos+1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9856
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut vec: Vec<usize> = vec![0; n + 1];
    for i in 1..=n {
        let mut tmp = 1;
        while i * tmp <= n {
            vec[i * tmp] += 1;
            tmp += 1;
        }
    }

    let mut ans: usize = 0;
    for (i, v) in vec.iter().enumerate() {
        ans += i * v;
    }
    println!("{}", ans)
}


Measured memory_bytes: 80184
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int W = 100005;


int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n, c;

    long long dp[W];
    SCD(n);
    SCD(c);
    int w[105], v[105];
    for (int i = 0; i < n; i++) {
    	SCD(w[i]);
    	SCD(v[i]);
    }
   	memset(dp, 0, sizeof(dp));
    long long ans = 0;
    for (int i = 0; i < n; i++) {
    	for (int j = c - w[i]; j >= 0; j--) {
    		dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
    	}
    }

    for (int i = 0; i <= c; i++)
    	ans = max(ans, dp[i]);
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1024
fun main(args : Array<String> ){
  val cs:MutableList<Char> = mutableListOf()
  readLine()!!.toList().map { x ->
    when(x) {
      '0' -> cs.add(x)
      '1' -> cs.add(x)
      else -> {
        if(cs.size != 0)
          cs.removeAt(cs.size - 1)
        else
          null
      }
    }
  }
  println( cs.joinToString("") )
}


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

int main(){
    int64_t N,M,x=0;
    cin >> N >> M;
    vector<int64_t> A(M);
    
    for(int i=0;i<M;i++){
        cin >> A.at(i);
        x+=A.at(i);
    }
    if(x>N){
        cout << -1 << endl;
    }else{
        cout << N-x <<endl;
    }

    
}

Measured memory_bytes: 3644
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  int Lj4PdHRW;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    wt_L("ACL");
  }
  wt_L("");
  wt_L('\n');
  return 0;
}
// cLay varsion 20200926-1

// --- original code ---
// {
//   REP(rd_int()) wtN("ACL");
//   wt("");
// }


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	sort(a.begin(), a.end());
	int b = a.size() / 2;
	for (int i = a[b-1]+1; i < a[b]+1; i++) {
		
		if (a[b - 1] == a[b]) break;
		ans++;
	}
	cout << ans<<endl;
	return 0; 
}









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

int main()
{
	ll n,k,i;
	cin >> n >> k;
	ll a[n],s=0LL;
	for(i=0;i<n;i++)cin >> a[i];
	sort(a,a+n);
	for(i=0;i<k;i++)s+=a[i];
	cout << s;
}

Measured memory_bytes: 3560
i = input()

prev = ""
res = 0
index = 0
while index < len(i):
    temp = i[index]
    if temp == prev:
        prev = i[index:index+2]
        if index == len(i)-1:
            res -= 1
        index += 2

    else:
        prev = temp
        index += 1

    res += 1

print(res)

Measured memory_bytes: 3500
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=b*d;
    x=max(x,a*c);
    x=max(x,a*d);
    x=max(x,b*c);
    cout<<x<<endl;


}

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

int main() {
  int N;
  cin >> N;
  vector<int> u(N), v(N);
  int x, y;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    u.at(i) = x - y;
    v.at(i) = x + y;
  }
  sort(u.begin(), u.end());
  sort(v.begin(), v.end());
  cout << max(u.at(N - 1) - u.at(0), v.at(N - 1) - v.at(0));
}


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n;
    string s;
    cin >> n >> s;
    if(n&1) 
        cout << "No\n";
    else {
        if(s.substr(0, n/2) == s.substr(n/2))
            cout << "Yes\n";
        else
            cout << "No\n";
    }
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
    string a;
    cin >> a;
    int p = 0;
    for (int i = 0;i < 3;i++){
        if (a[i] == '1'){
            p = p + 1;
        }
    }
    cout << p << endl;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> w(n);
	int wl = 0, wr = 0;
	for (int i = 0; i < n;++i) {
		cin >> w[i];
		wr += w[i];
	}
	int ans=100000000;
	for (int i = 0; i < n; ++i) {
		wl += w[i];
		wr -= w[i];
		ans = min(ans, (wl > wr) ? wl - wr : wr - wl);
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;++i){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());
  
  int count=0;
  for(int i=0;i<N;++i){
    for(int j=i+1;j<N;++j){
      int k=lower_bound(L.begin(),L.end(),L.at(i)+L.at(j))-L.begin();
      count=count+max(k-j-1,0);
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2019, Mod = 924844033;
int n, k, dp[N], dpt[N], C[N][N], F[N];
vector < int > A;
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= min(n, k + k); i++)
        A.push_back((n - ((i - 1) % k + 1)) / k);

    C[0][0] = C[0][1] = C[1][1] = 1;
    for (int i = 2; i < N; i++)
    {
        C[0][i] = 1;
        for (int j = 1; j < N; j++)
            C[j][i] = (C[j][i - 1] + C[j - 1][i - 2]) % Mod;
    }
    for (int i = F[0] = 1; i < N; i++)
        F[i] = 1LL * F[i - 1] * i % Mod;

    dp[0] = 1;
    int sum = 0;
    for (int i = 0; i < A.size(); i++)
    {
        memset(dpt, 0, sizeof(dpt));
        for (int j = 0; j <= (A[i] + 1 >> 1); j++)
            for (int h = 0; h <= sum && h + j <= n; h++)
                dpt[j + h] = (dpt[j + h] + 1LL * dp[h] * C[j][A[i]]) % Mod;
        sum = min(sum + A[i], n);
        for (int h = 0; h <= sum; h ++)
            dp[h] = dpt[h];
    }
    int tot = 0;
    for (int i = 0; i <= n; i++)
    {
        int add = 1LL * dp[i] * F[n - i] % Mod;
        if (i & 1)
            tot = (tot - add + Mod) % Mod;
        else
            tot = (tot + add) % Mod;
    }
    return !printf("%d", tot);
}

Measured memory_bytes: 16256
c = input()
al = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
      "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

print(al[al.index(c)+1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);} int dummmmmmmmy

using namespace std;

int main(){

    int n;
    cin >> n;

    int dp[100001] = {};

    vector<int> v;

    v.push_back(1);
    v.push_back(6);
    
    int tmp = 6;

    while(tmp <= 100000){
        tmp = tmp * 6;
        v.push_back(tmp);
    }

    v.push_back(9);

    tmp = 9;

    while(tmp <= 100000){
        tmp = tmp * 9;
        v.push_back(tmp);
    }

    for(int i = 1; i <= n; i++){
        tmp = INT_MAX;

        rep(j,v.size()){
            if(i - v[j] < 0) continue;
            tmp = min(tmp, dp[i - v[j]] + 1);
        }

        dp[i] = tmp;
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 5005;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

const int N = 100096;
int r[N], c[N], a[N];
int R, C, n;
bool vr[N], vc[N];
vector<int> er[N], ec[N];

bool ok = true;
int64_t low, up;

int64_t xr[N], yc[N];

void dfsr(int);
void dfsc(int);

void dfsr(int i) 
{
	low = max(low, -xr[i]);
	for (int j : er[i])
	{
		int c = ::c[j], a = ::a[j];
		up = min(up, a - xr[i]);
		if (!vc[c])
		{
			vc[c] = true;
			yc[c] = a - xr[i];
			dfsc(c);
		}
		else 
		{
			ok &= (yc[c] + xr[i] == a);

		}
	}
}

void dfsc(int j) 
{
	up = min(up, yc[j]);
	for (int i : ec[j])
	{
		int r = ::r[i], a = ::a[i];
		low = max(low, yc[j] - a);
		if (!vr[r]) 
		{
			vr[r] = true;
			xr[r] = a - yc[j];
			dfsr(r);
		}
		else 
		{
			ok &= (yc[j] + xr[r] == a);
		}
	}
}

int main()
{
	scanf("%d%d%d", &R, &C, &n);
	for (int i = 0; i < n; ++i) 
	{
		scanf("%d%d%d", r + i, c + i, a + i);
		er[r[i]].push_back(i);
		ec[c[i]].push_back(i);
	}
	for (int i = 1; i <= R && ok; ++i)
	{
		if (!vr[i])
		{
			low = -1e18;
			up = 1e18;
			dfsr(i);
			vr[i] = true;
			//ok &= (up >= 0 && low <= up);
			ok &= (low <= up);
		}
	}
	puts(ok ? "Yes" : "No");
	return 0;
}




Measured memory_bytes: 14080