akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a,const void *b){
  if(*(int*)a-*(int*)b > 0) return 1;
  return -1;
}

long long gcd(long long x,long long y){
    if(y == 0) return x;
    return gcd(y,x%y);
}

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

  N++;
  int x[N];
  for(int i = 0;i < N;i++) scanf("%d",&x[i]);

  qsort(x,N,sizeof(int),compare_int);

  int ans = x[1]-x[0];
  for(int i = 0;i < N-1;i++){
    ans = gcd(ans,x[i+1]-x[i]);
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
 
int main(){
    ll n,k,a,b;
    set<ll> set;
    map<ll,ll> map;
    cin>>n>>k;
    rep(l,n){
        cin>>a>>b;
        if(set.count(a)){
            map[a]+=b;
        }else{
            set.insert(a);
            map[a]=b;
        }
    }
    ll hikaku=0,ans;
    for(auto value:set){
        hikaku+=map[value];
        if(k<=hikaku){
            ans=value;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10464
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<int> vll;
typedef pair<ll, ll> pll;
const int INF = 1e9 + 7;
void init() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
}

int main() {
    init();
    int N;
    cin >> N;
    vector<int> cost(N), h(N);
    for(int i = 0; i<N; i++){
        cin >> h[i];
    }
    cost[1] = abs(h[0]-h[1]);
    for(int i = 2; i<N; i++){
        cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]- h[i-2]));
    }
    cout << cost[N-1] << '\n';
}


Measured memory_bytes: 1024
package main

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

func dummy() {
	math.Abs(1.0)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	res, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return res
}
func nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextStrSlice(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = nextStr()
	}
	return res
}

func mod(val int, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func minInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res > val[i] {
			res = val[i]
		}
	}
	return res
}

const MOD = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	h := nextIntSlice(n)
	dp := make([]int, n)
	dp[0] = 0
	dp[1] = absInt(h[0] - h[1])
	for i := 1; i < n-1; i++ {
		dp[i+1] = minInt(dp[i-1]+absInt(h[i-1]-h[i+1]), dp[i]+absInt(h[i]-h[i+1]))
	}
	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b){
        cout << "Zero" << endl;
    }else if(b < 0){
        if((b - a) % 2 == 0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }else{
        cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1000005;
const int INF=1061109567;
int n;
char s[N];
int a[N];
int sum[N];
int suf[N];
int calc(int Min)
{
	static int b[N];
	int add=0; 
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='?'&&suf[i]-add-2>=Min) add+=2;
		b[i]=sum[i]-add;
	}
	int Max=max(*max_element(b+1,b+n+1),0);
	return Max-Min;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='1'||s[i]=='?') a[i]=1;
		else if(s[i]=='0') a[i]=-1;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	suf[n+1]=INF;
	for(int i=n;i>=1;i--)
		suf[i]=min(suf[i+1],sum[i]);
	int m=min(*min_element(sum+1,sum+n+1),0);
	printf("%d",min(calc(m),calc(m-1)));
	return 0;
}

Measured memory_bytes: 20396
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def can_make(num, a, b):
    while num >= 0:
        if num % a == 0 or num % b == 0:
            return True
        num -= a
    return False

def main():
    A, B, C, D, E, F = LI()
    if A > B:
        A, B = B, A
    if C > D:
        C, D = D, C
    max_perc = -1
    max_sugar = -1
    max_water = -1
    for unit in range(A, 31):
        water = unit * 100
        for sugar in range(min(F - water, unit*E)+1):
            # if water + sugar == 2634 and sugar == 934:
            #     import pdb
            #     pdb.set_trace()
            if water + sugar > F:
                continue
            if 100*sugar/(water+sugar) > E:
                continue
            if can_make(sugar, C, D) and can_make(water, 100*A, 100*B):
                perc = sugar/(sugar + water)
                if perc >= max_perc:
                    max_perc = perc
                    max_sugar = sugar
                    max_water = water
    print(max_water + max_sugar, max_sugar)

main()



Measured memory_bytes: 69336
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
using namespace std;

#define M 60

typedef long long ll;

int main(){
    int n;
    ll x = 0;
    cin >> n;
    vector<int> x0(M, 0);
    vector<int> x1(M, 0);
    for (int i = 0; i < n; i++) {
        cin >> x;
        bitset<M> a(x);
        for (int j = 0; j < M; j++) {
            if (a[j] == 0) x0[j] += 1;
            else x1[j] += 1;
        }
    }

    ll ans = 0, k = 1, MOD = 1e9 + 7;
    for (int j = 0; j < M; j++) {
        ans += (k * (x0[j] % MOD) % MOD) * (x1[j] % MOD) % MOD;
        ans %= MOD;
        k *= 2;
        k %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int D[4];
int N[4];

int main() {
    for (int i = 0; i < 3; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        D[a]++;
        D[b]++;
    }
    for (int i = 0; i < 4; i++) {
        N[D[i]]++;
    }
    puts(N[1] == 2 && N[2] == 2 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 128
#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()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	//std::set<char> se;

	std::vector<char> s(4);
	rep(i,4)std::cin >> s[i];
	sort(all(s));
	if(s[1]!=s[2]&&s[3]==s[2]&&s[0]==s[1])std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dx = [-1, 0, 1]
dy = [-1, 0, 1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            flag = 0
            for d_x in dx:
                for d_y in dy:
                    if (d_x == 0 and d_y == 0) or (d_x == -1 and d_y == -1) or (d_x == 1 and d_y == 1)\
                            or (d_x == 1 and d_y == -1) or (d_x == -1 and d_y == 1):
                        continue
                    if not (d_x == 0 and d_y == 0) and 0 <= i + d_x < h and 0 <= j + d_y < w \
                            and s[i + d_x][j + d_y] == '#':
                        flag = 1

            if flag == 0:
                print('No')
                exit(0)

print('Yes')


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

using namespace std;

typedef long long llint;

int main() {
  llint x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<llint> p(a), q(b), r(c);
  for (int i = 0; i < a; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> q[i];
  }
  for (int i = 0; i < c; i++) {
    cin >> r[i];
  }

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());

  vector<llint> v, w, u;
  for (int i = 0; i < x; i++) {
    v.emplace_back(p[i]);
  }
  for (int i = 0; i < y; i++) {
    w.emplace_back(q[i]);
  }

  for (int i = 0; i < c; i++) {
    if (v.empty()) {
      if (!w.empty()) {
        if (w.back() < r[i]) {
          w.pop_back();
          u.emplace_back(r[i]);
        }
      }
    } else if (w.empty()) {
      if (!v.empty()) {
        if (v.back() < r[i]) {
          v.pop_back();
          u.emplace_back(r[i]);
        }
      }
    } else {
      if (v.back() < w.back()) {
        if (v.back() < r[i]) {
          v.pop_back();
          u.emplace_back(r[i]);
        }
      } else {
        if (w.back() < r[i]) {
          w.pop_back();
          u.emplace_back(r[i]);
        }
      }
    }
  }

  llint ans = 0;
  for (auto &t : v) {
    ans += t;
  }
  for (auto &t : w) {
    ans += t;
  }
  for (auto &t : u) {
    ans += t;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5492
A,B=list(map(int,input().split()))
l_a=list(input())
l_b=list(input())
import fractions
gcd=fractions.gcd(A,B)
total=A*B//gcd
A_n=total//A
B_n=total//B
S=A_n*B_n//fractions.gcd(A_n,B_n)
for i in range(total//S):
   if l_a[i*B_n] != l_b[i*A_n]:
      print(-1)
      exit()
print(total)

Measured memory_bytes: 6428
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    string s,t;
    cin>>s>>t;
    int n1 = s.size(),n2 = t.size();
    int a[n1+1][n2+1];
    for(int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
            if(i==0 || j==0)
                a[i][j] = 0;
            else if(s[i-1]==t[j-1])
            {
                a[i][j] = a[i-1][j-1]+1;
            }
            else
            {
                if(a[i-1][j]>a[i][j-1])
                    a[i][j] = a[i-1][j];
                else
                    a[i][j] = a[i][j-1];
            }
            // cout<<a[i][j]<<" ";
        }
        // cout<<endl;

    }

    int index = a[n1][n2];
    char ans[index+1];
    ans[index] = '\0';
    int i = n1,j=n2;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans[index-1] = s[i-1];
            i--,j--,index--;
        }
        else if(a[i-1][j]>a[i][j-1])
            i--;
        else
            j--;
    }
    cout<<ans<<endl;
    
    

}
int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    solve();
    
        
    
    
    return 0; 
} 

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  vl A(N);
  rep(i,N) {
cin >>A.at(i);
  }
  
 map<ll,ll> mp;
  rep(i,N) {
mp[A.at(i)]++;
  }
  
  
  ll x=mp.size();
  if(x%2==0) {
    cout<<x-1<<endl;
  }
  else {
    cout<<x<<endl;
  }
  
  
  
}
  
  
 
    
    
   

Measured memory_bytes: 7296
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    mod = 998244353
    a, b, c, d = nm()
    n, m = c-a, d-b
    dp = [[0]*(m+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        dp[i+1][0] = dp[i][0] * b % mod
    for i in range(m):
        dp[0][i+1] = dp[0][i] * a % mod
    for i in range(1, n+1):
        for j in range(1, m+1):
            dp[i][j] = (dp[i][j-1] * (a + i) + dp[i-1][j] * (b + j) - dp[i-1][j-1] * (a + i - 1) * (b + j - 1)) % mod
    # if a < 10:
    #     prn(dp)
    print(dp[n][m])

    return

solve()


Measured memory_bytes: 133608
def main():
    N = int(input())
    *A, = map(int, input().split())

    n_neg = 0
    near_zero = 10 ** 10
    for a in A:
        if a < 0:
            n_neg += 1
        near_zero = min(near_zero, abs(a))

    s = sum([abs(a) for a in A])
    if n_neg % 2 == 0:
        print(s)
    else:
        print(s - near_zero * 2)


main()


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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {

	COMinit();

	long x, y;
	cin >> x >> y;

	if((x+y)%3 != 0){
		cout << 0;
	}else{
		long row = (x+y)/3;
		long column = x - row;
		cout << COM(row, column) << endl;
	}

	return 0;
}


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

int main()
{
	int a, b, k, x;
	int count = 0;
	cin >> a >> b >> k;
	for (int i = a; i > 0; i--) {
		if (a%i == 0 && b % i == 0) {
			count++;
		}
		if (count == k) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
<?php

fscanf(STDIN, '%d %d', $a, $b);

if ($a === 1) {
    $a = 14;
}

if ($b === 1) {
    $b = 14;
}

if ($a > $b) {
    echo 'Alice';
} elseif ($a<$b) {
    echo 'Bob';
} else {
    echo 'Draw';
}

echo PHP_EOL;


Measured memory_bytes: 16244
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 char c;
  cin >> c;
  
  if('A'<=c&&c<='Z') cout << "A" << endl;
  else cout << 'a' << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n, m, x;
   cin>>n>>m>>x;
   int c[12];
   int a[12][12];
   rep(i, n){
      cin>>c[i];
      rep(j, m){
         cin>>a[i][j];
      }
   }

   int mn=INT_MAX;
   rep(code, (1<<12)){
      int csum=0;
      int asum[12]={0};
      rep(i, n) if((code>>i)&1){
         csum+=c[i];
         rep(j, m) asum[j]+=a[i][j];
      }
      bool satis=true;
      rep(j, m) if(asum[j]<x){
         satis=false;
         break;
      }
      if(satis) mn=min(mn, csum);
   }

   if(mn==INT_MAX) cout<<-1<<endl;
   else cout<<mn<<endl;
   return 0;
}


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

using i64 = long long int;

int main(){
    i64 n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }

    bool can_create = true;
    for(i64 i=n-1;i>=0;--i){
        if(v[i] > i || (i > 0 && v[i] > v[i-1] + 1)){
            can_create = false;
            break;
        }
    }

    if(can_create){
        i64 ans = 0;
        for(i64 i=n-1;i>0;--i){
            if(v[i-1] == v[i] - 1){
                ans++;
            }else{
                ans += v[i];
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>

#define MN 100000

int N;
long A[MN];

void input(){
	std::cin >> N;
	for( int i = 0; i < N; i++ ){
		std::cin >> A[i];
	}
	std::sort(&A[0], &A[N]);
	return;
}

int func(int i){
	long s = A[i];
	for( int j = 0; j < N; j++ ){
		if( i == j ){ continue; }
		if( A[j] > 2 * s ){ return 0; }
		s += A[j];
		if( A[N-1] <= 2 * s ){ return 1; }
	}
	return 1;
}

void run(){
	int num = 0;
	//2分探索で、成功する大きさと失敗する大きさの境目を探す?
	int m, re;
	int l = -1, r = N;
	while( l+1 < r ){
		m = (l+r) / 2;
		if( func(m) ){
			r = m;
		}else{
			l = m;
		}
	}
	/*
	for( int i = 0; i < N; i++ ){
		num += func(i);
	}
	*/
	//std::cout << l << "," << r << std::endl;
	std::cout << N-r << std::endl;
	return;
}

int main(){
	input();
	run();
	return 0;
}


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

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

    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> A(n, vector<int>(m));
    vector<vector<int>> B(m, vector<int>(l));

    // input
    rep(i, n) rep(j, m) cin >> A[i][j];
    rep(i, m) rep(j, l) cin >> B[i][j];

    // n, m, l
    rep(i, n) {
        rep(j, l) {
            long row_sum = 0;
            rep(k, m) row_sum += A.at(i).at(k) * B.at(k).at(j);
            std::cout << row_sum;
            if (j != l - 1)
                cout << " ";
            else
                cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3236
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))

minus = []
plus = []
for i in range(len(A)):
    minus.append(A[i]-(i+1))
    plus.append(-A[i]-(i+1))
minus.sort()
plus.sort()
#print (minus)
#print (plus)
minus.append(INF)
plus.append(INF)
i=0
j=0
ans=0
while(i!=N and j!=N):
    
    if minus[i] < plus[j]:
        i+=1
    elif minus[i] > plus[j]:
        j+=1
    else:
        ci = 1
        cj = 1
        #print (minus[i],plus[j],ans,i,j)
        while(minus[i+1] == minus[i]):
            i+=1
            ci += 1
        while(plus[j+1] == plus[j]):
            j+=1
            cj += 1
        i+=1
        j+=1
        ans += ci*cj
    
print (ans)



Measured memory_bytes: 109864
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
//�N�C�b�N�\�[�gqsort�֐�
int compare_int(const void *a, const void *b)
{
    return *(lli*)a - *(lli*)b;
}
/*qsort(data, 10, sizeof(int), compare_int);*/

int main(void)
{
	lli i, n, ans;
	scanf("%lld", &n);
	lli d[n];
	rep(i,n) scanf("%lld", &d[i]);
	qsort(d, n, sizeof(lli), compare_int);
	ans = d[n/2] - d[n/2-1];
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

const int MN=20;
const int M=(1<<18)+5;

int cnt[M];

int n,m;

struct SegT
{
	int sum[M*2];
	void pull(int o,int ls,int rs)
	{
		sum[o]=sum[ls]+sum[rs];
	}
	void build(int o,int l,int r)
	{
		if(l==r)
		{
			sum[o]=cnt[l];
			return;
		}
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		build(ls,l,mid);
		build(rs,mid+1,r);
		pull(o,ls,rs);
	}
	int R;
	int query(int o,int l,int r)
	{
		if(r<=R) return sum[o];
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		int ans=query(ls,l,mid);
		if(mid<R)
			ans+=query(rs,mid+1,r);
		return ans;
	}
	int sub(int o,int l,int r,int kth)
	{
		if(l==r)
		{
			sum[o]--;
			return l;
		}
		int mid=(l+r)>>1;
		int ls=o+1,rs=o+((mid-l+1)<<1);
		int ans=-1;
		if(sum[ls]>=kth)
			ans=sub(ls,l,mid,kth);
		else
			ans=sub(rs,mid+1,r,kth-sum[ls]);
		pull(o,ls,rs);
		return ans;
	}
}segt;

int mx;
vector<int> vec;
bool solve()
{
	vec.push_back(m-1);
	segt.build(0,0,m-1);
	for(int i=0;i<n;i++)
	{
		int l=1<<i;
		//cout<<l<<endl;
		for(int j=0;j<l;j++)
		{
			int u=vec[j];
			segt.R=u-1;
			int sum=segt.query(0,0,m-1);
			//cout<<sum<<endl;
			if(!sum) return false;
			int v=segt.sub(0,0,m-1,sum);
			vec.push_back(v);
		}
	}
	return true;
}

map<int,int> ma;

int main()
{
	scanf("%d",&n);
	m=1<<n;
	int s,mx=-1;
	for(int i=0;i<m;i++)
	{
		scanf("%d",&s);
		mx=max(mx,s);
		ma[s]++;
	}
	ma[mx]--;
	m=1;
	for(auto p:ma)
		cnt[m++]=p.second;
	printf("%s\n",solve()?"Yes":"No");
}

Measured memory_bytes: 16764
def adj_matrix(array)
	result = Array.new(array.length) {Array.new(array.length, 0)};
	
	for i in 0..(array.length-1)
		if(array[i][1] != 0)
			for j in 2..(array[i].length-1)
				result[(array[i][0])-1][(array[i][j])-1] = 1
			end
		end
	end

	for k in 0..(result.length-1)
		puts result[k].join(" ")
	end
end

n = gets.chomp.to_i
a = []
for i in 0..(n-1)
	a << gets.chomp.split().map(&:to_i)
end

adj_matrix(a);

Measured memory_bytes: 8892
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

#define MAX_V 100001
#define INF (1e9 + 1)

struct edge{
  int to,cost;
};

int V,E,r,a,b,c;

vector< edge > G[MAX_V];


int d[MAX_V];
void dijkstra(){
  int i;
  for(i=0;i<MAX_V;i++)d[i]=INF;
  d[r]=0;
  priority_queue< pair<int,int> > Q;
  Q.push( make_pair(0,r) );
  while(!Q.empty()){
    pair<int,int> p=Q.top();
    Q.pop();
    int pos=p.second,cost=-p.first;
    if( cost > d[pos] )continue;
    for(i=0;i<G[pos].size();i++){
      edge e=G[pos][i];
      int to=e.to;
      int newcost=cost+e.cost;
      if( newcost < d[to]){
        d[to]=newcost;
        Q.push( make_pair(-d[to],to) );
      }
    }
  }

  for(i=0;i<V;i++){
    if(d[i]==INF)printf("INF\n");
    else printf("%d\n",d[i]);
  }
}

int main(){
  int i;
  scanf("%d %d %d",&V,&E,&r);
  for(i=0;i<E;i++){
    scanf("%d %d %d",&a,&b,&c);
    G[a].push_back((edge){b,c});
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 11192
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,m,a[101010],b[101010];
long long ct(long long x)
{
	long long cnt=0;
	for(int i=1;i<=n;i++)
	{
		cnt+=n-(lower_bound(a+1,a+n+1,x-a[i])-a)+1ll;
	}
	return cnt;
}
long long js(long long x)
{
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int p=lower_bound(a+1,a+n+1,x-a[i])-a;
		ans+=b[n]-b[p-1]+(n-p+1ll)*a[i];
	}
	return ans;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		b[i]=b[i-1]+a[i];
	}
	long long l=2*a[1],r=2*a[n];
	while(l<r)
	{
		long long mid=(l+r+1)/2;
		if(ct(mid)>=m)
		{
			l=mid;
		}
		else
		{
			r=mid-1;
		}
	}
	long long cnt=ct(l);
	cout<<js(l)-(cnt-m)*l<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a + b == 15) {
			System.out.println("+");
		}else if(a * b == 15) {
			System.out.println("*");
		}else {
			System.out.println("x");
		}
		sc.close();
	}

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>
int main(void){
  long int p,c,t,z,n;
  p = c = t = z = n = 0;
  while(0<scanf("%ld,%ld\n",&p,&c)){
    t+=p*c;z+=c;n++;
  }
  printf("%ld\n%ld\n",t,lround((double)z/n));
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int n;
string s;
map<string,long long> m;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    long long ans=0;
    for(auto it: m){
        ans = ans + (it.second*(it.second-1))/2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll H,N;
	cin >> H >> N;
	ll A;
	ll tmp=0;
	for(ll i=0;i<N;i++){
		cin >> A;
		tmp+=A;
	}
	if(tmp>=H)cout << "Yes";else cout <<"No";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int num[200];

int main(void)
{
	int i;
	long long int a1, a2, a3, a4;
	long long int n, m, x, sum=0, sum2=0;
	string s;
	cin >> n >> m >> x;
	for (i = 0; i < m; i++)
	{
		cin >> a1;
		num[a1] = 1;
	}
	for (i = x; i < n; i++)
		sum += num[i];
	for (i = 0; i < x; i++)
		sum2 += num[i];
	cout << min(sum, sum2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M;
    cin >> N>>M;
    vector<int> good(N,1);
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    for(int j=0;j<M;j++){
        int a, b;
        cin >>a >>b;
        if(H[a-1]>H[b-1]){
            good[b-1]=0;
        }else if(H[a-1]==H[b-1]){
            good[a-1]=0;
            good[b-1]=0;
        }else{
            good[a-1]=0;
        }
    }
    int sum=0;
    for(int k=0;k<N;k++){
        sum+=good[k];
    }
    cout << sum <<endl;
}

Measured memory_bytes: 4056
number = input()
number_list = number.split(' ')
a = 0
b = 0
c = 0
for i in number_list:
    a = number_list[0]
    b = number_list[1]
    c = number_list[2]

if int(a) < int(b) and int(b) < int(c):
    print("Yes")
else:
    print("No")






Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
#define hash hashh
using namespace std;
 
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 3e3;

ll A, B, P[70], BB, AA, ans;
int a[100], b[100], n;

int main() {
	P[0] = 1;
	for (int i = 1; i < 70; i++) P[i] = P[i - 1] * 2;
	cin >> A >> B;
	BB = B; AA = A;
	if (A == B) {
		cout << "1";
		return 0;
	}
	while (A) {
		a[++n] = A % 2;
		A /= 2;
	}
	n = 0;
	while (B) {
		b[++n] = B % 2;
		B /= 2;
	}
	int p1, p2, p3;
	for (int i = n; i >= 1; i--) {
		if (a[i] != b[i]) {
			p1 = i;
			break;
		}
	}
	ll tmp = 0;
	for (int i = p1; i >= 1; i--) tmp *= 2, tmp += a[i];
	ans = P[p1 - 1] - tmp; // cout << ans << "/"; 
	for (int i = p1 - 1; i >= 0; i--) {
		p2 = i;
		if (a[i] == 1) break;
	}
	for (int i = p1 - 1; i >= 0; i--) {
		p3 = i;
		if (b[i] == 1) break;
	}  //cout << p2 << "?" << p3 << endl;
	if (p3 >= p2) {
		ans += P[p1 - 1];
		cout << ans;
		return 0;
	}  //cout << "?";  
	ans = BB - AA + 1;  
	ans += (P[p1 - p2 - 1] - 1) * P[p2];  //cout << ans << endl;
	tmp = 0;
	for (int i = p2; i >= 1; i--) tmp *= 2, tmp += a[i];  //cout << tmp << endl;
	ans += P[p2] - tmp;
	tmp = 0;
	for (int i = p3; i >= 1; i--) tmp *= 2, tmp += b[i];
	ans += P[p3] - tmp - 1;
	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int X = int.Parse(input[1]);
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(Console.ReadLine());
    }
    int count = (X - arr.Sum()) / arr.Min();
    Console.WriteLine(arr.Count() + count);
  }
}

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    bool allneg = true;
    int negind = -1;
    ll negmax = -inf;
    rep(i, N){
        if(A[i] >= 0) {
            allneg = false;
            break;
        }
        if(negmax < A[i]){
            negmax = max(negmax, A[i]);
            negind = i;
        }
    }
    if(allneg){
        output(negmax);
        output(N - 1);
        for(int i = N - 1; i > negind; i--){
            output(i + 1);
        }
        rep(i, negind){
            output(1);
        }
        return 0;
    }
    
    vector<vector<int>> B(2, vector<int>(N)); // 偶数番目をとるか、奇数番目をとるか
    rep(i, N){
        if(A[i] >= 0){
            B[i % 2][i] = 1;
        }
    }
    vector<ll> S(2); // 和
    rep(i, 2){
        rep(j, N){
            if(B[i][j]){
                S[i] += A[j];
            }
        }
    }
    ll sum = max(S[0], S[1]);
    vector<int> C = S[0] > S[1] ? B[0] : B[1]; // 和に含める数字(1: 含める, 0: 含めない)
    vector<int> ret;
    int left = -1, right = N; // 和に含める左端のindex、右端のindex
    rep(i, N){
        if(C[i]) {
            left = i;
            break;
        }
    }
    for(int i = N - 1; i >= 0; i--){
        if(C[i]) {
            right = i;
            break;
        }
    }
    if(left == -1 && right == N) {
        output(0);
        output(N);
        rep(i, N) output(1);
        return 0;
    }
    
    for(int i = N - 1; i > left; i--){
        if(i > right){
            ret.pb(i + 1);
        }
        else {
            if(C[i - 1] && i >= 1){
                ret.pb(i + 1);
            }
            else if(C[i - 1] == 0 && C[i] == 0 && C[i + 1] == 0 && i >= 1 && i < N - 1 && (i - left) % 2 == 0){
                ret.pb(i + 1);
            }
        }
    }
    rep(i, left){
        ret.pb(1);
    }
    output(sum);
    output(ret.size());
    for(auto i: ret){
        output(i);
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<string> S(N);
        vector<Int> T(N);
        for (int i = 0; i < N; ++i) {
            cin >> S[i] >> T[i];
        }
        string X;
        cin >> X;

        Int ans = 0;
        bool f = false;
        for (int i = 0; i < N; ++i) {
            if (f) {
                ans += T[i];
            }
            if (S[i] == X) {
                f = true;
            }
        }
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#define forn(i, s, f) for (int i = (s); i <= (f); ++i)
#define for1(i, s, f) for (int i = (s); i >= (f); --i)
#define pb push_back

using namespace std;

typedef long long ll;

ll a, b, r, k = -1, ans;

#define int long long

int bit(ll x, int i)
{
    return ((x >> i) & 1);
}

main()
{
    cin >> a >> b;
    if (a == b)
    {
        cout << 1;
        return 0;
    }
    forn (i, 1, 61)
    {
        if (bit(a, i) != bit(b, i))
            r = i;
    }
    forn (i, r + 1, 61)
    {
        a = (bit(a, i) ? (a ^ (1ll << i)) : a),
        b = (bit(b, i) ? (b ^ (1ll << i)) : b);
    }
    ans = (1ll << r) - a;
    forn (i, 0, 61)
    {
        if ((1ll << r) + (1ll << i) <= b)
            k = i;
        else
            break;
    }
    pair < int, int > X, Y;
    X = {(1ll << r), (1ll << r) + (1ll << (k + 1ll)) - 1ll};
    Y = {(1ll << r) + a, 2ll * (1ll << r) - 1};
    if (X.second < Y.first) ans += (X.second - X.first + 1) + (Y.second - Y.first + 1);
    else ans += max(X.second, Y.second) - X.first + 1;
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,m;
	cin>>n>>m;
	if(n>m){
		for(int i=0;i<n;i++){
			cout<<m;
		}
	}
	else{
		for(int i=0;i<m;i++){
			cout<<n;
		}
	}
}



Measured memory_bytes: 256
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    dp = [[0] * (M+1) for _ in range(N+1)]
    
    for i in range(1, N+1):
        for j in range(1, M+1):
            p = (S[i-1] == T[j-1])
            dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-1] + p)
            
    ans = []
    x, y = N, M
    while x and y:
        if dp[x][y] == dp[x-1][y]:
            x -= 1
        elif dp[x][y] == dp[x][y-1]:
            y -= 1
        else:
            x -= 1
            y -= 1
            ans.append(S[x])
        
    print(''.join(ans[::-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 112732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  int a,b;
  int now=500000,ans=0;
  int mp[100001];
  for(int i=0;i<100001;i++){
    mp[i]=500000;
  }
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>a>>b;
    mp[a]=min(mp[a],b);
  }
  for(int i=1;i<=N;i++){
    if(now==i){
      ans++;
      now=500000;
    }
     now=min(now,mp[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
A , V = map(int, input().split())
B , W = map(int, input().split())
T = int(input())
if A < B:
    if A+T*V < B+T*W:
        print("NO")
    else:
        print("YES")
else:
    if A-T*V > B - T*W:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;
    rep(i,n){
        if(a[i] == i+1){
            a[i] = i+1; 
            a[i+1] = i;
            ans++;
        }       
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
N, K = map(int, input().split())
S = input()
Nums = []
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
# 累積和を作る
# 0 1 2 3 4 5 6
#  0 1 2 3 4 5
sum = [0] * (len(Nums) + 1)
for i in range(len(Nums)):
    sum[i + 1] = sum[i] + Nums[i]
ans = 0
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    # 次のleft, rightを計算する [left, right)
    left = i
    right = min(i + Add, len(Nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 7884
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)

for a in A:
    d[a] += 1

E = [(k, v) for k, v in d.items() if v >= 2]
E.sort(key=lambda x: -x[0])

if len(E) == 0:
    print(0)
    exit()
if len(E) == 1 and E[0][1] < 4:
    print(0)
    exit()

if E[0][1] >= 4:
    print(E[0][0] ** 2)
else:
    print(E[0][0] * E[1][0])


Measured memory_bytes: 18600
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int n,i,pt=1,mx;
int main(void){
    cin>>n;
    int a[n];
    for(i=-1;++i-n;){
        cin>>a[i];
    }
    sort(a,a+n);
    mx=a[n-1];
    a[n-1]=-1;
    cout<<mx<<' ';
    double harf=mx/2.0;
    while(a[pt]<harf&&(pt<n-2))++pt;
    if(abs(a[pt-1]-harf)<abs(a[pt]-harf))cout<<(a[pt-1])<<endl;
    else cout<<(a[pt])<<endl;
    return 0;
}

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

function main()
	n, m = readline() |> split |> parseMap
	ab = Array{Int}(2,n)
	for i in 1:n
		ab[:,i] = readline() |> split |> parseMap
	end
	cd = Array{Int}(2,m)
	for i in 1:m
		cd[:,i] = readline() |> split |> parseMap
	end
	for i in 1:n
		minim = 1
		for j in 2:m
      		if abs(ab[1,i]-cd[1,minim])+abs(ab[2,i]-cd[2,minim])>abs(ab[1,i]-cd[1,j])+abs(ab[2,i]-cd[2,j])
				minim = j
     		end
		end
		println(minim)
	end
end

main()

Measured memory_bytes: 112660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H,W,K;
    cin >> H >> W >> K;
    vector < vector <char> > grid(H, vector <char>(W));
    loop(i,0,H)
    {
        loop(j,0,W) cin >> grid[i][j];
    }
    ll ans=0;
    for (int i=0; i<(1<<H); ++i)
    {
        for (int j=0; j<(1<<W); ++j)
        {
            vector < vector <char> > grid2=grid;
            for (int k=0; k<H; ++k)
            {
                if ((1<<k) & i)
                {
                    for (int p=0; p<W; ++p) grid2[k][p]='.';
                }
            }
            for (int k=0; k<W; ++k)
            {
                if ((1<<k) & j)
                {
                    for (int p=0; p<H; ++p) grid2[p][k]='.';
                }
            }
            int sum=0;
            for (int k=0; k<H; ++k)
            {
                for (int p=0; p<W; ++p) if (grid2[k][p]=='#') sum++;
            }
            if (sum==K) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<ll,int> m;
    REP(i,n) {
        ll x;
        cin >> x;
        m[x]++;
    }
    ll x = 0, y = 0;
    for(auto item:m) {
        if (item.second >=4) {
            x = item.first; y = item.first;
        } else if (item.second >=2) {
            swap(y,x); x = item.first;
        }
    }
    cerr << x << y << endl;
    cout << x * y << endl;

    return 0;
}

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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    int N, X;
    cin >> N >> X;
    v<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    ll d = 0;
    int cnt = 1;
    for (int i = 0; i < N; i++)
    {
        d += L[i];
        if(d>X)break;
        cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;long x=0;
  vector<long>A(N);
  for(long i=0;i<N;i++)cin>>A[i];
  long ans=0;
  while(x!=1&&ans<=N){x=A[x]-1;ans++;}
  cout<<(ans<=N?ans:-1)<<endl;
}

Measured memory_bytes: 4036
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N, H, W, a, b;
    cin >> N >> H >> W;

    int ans = 0;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        if(H <= a && W <= b){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int main() {
	int x, y, s; 
	while (cin >> x >> y >> s && x&&y&&s) {
		int maxv = 0;
		for (int i = 1; i < s; ++i) {
			int a1 = i * (x+100)/100, a2 = i * (y+100)/100;
			for (int j = s - 1; j > 0; --j) {
				int b1 = j * (x+100)/100, b2 = j * (y+100)/100;
				if (a1 + b1 == s && maxv < a2 + b2) maxv = a2 + b2;
			}
		}
		cout << maxv << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
# ABC080
# C. Shopping Street

n = gets.chomp.to_i

f_ = []
n.times do 
  f_ << gets.chomp.split(" ").map(&:to_i)
end

p_ = []
n.times do 
  p_ << gets.chomp.split(" ").map(&:to_i)
end

res = -(1 << 30)
1.upto((1<<10) - 1) do |b|
  prft = 0
  n.times do |i|
    # Store
    c = 0
    10.times do |j|
      # Time
      if (((b >> j) & 1) & f_[i][j]) == 1 then
        c += 1
      end
    end
    prft += p_[i][c]
  end
  res = [res, prft].max
end

puts res

Measured memory_bytes: 1788
input_tap = input()
flag = 'No'
input_tap1 = input_tap[0::2]
input_tap2 = input_tap[1::2]

if 'L' in input_tap1:
    flag = 'No'
elif 'R' in input_tap2:
    flag = 'No'
else:
    flag = 'Yes'
print(flag)


Measured memory_bytes: 2940
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  tmp = C
  for j in range(M):
    tmp += A[j]*B[j]
  if tmp > 0:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int first[100001], second[100001];
int n;
struct P {
    int i, cnt;
};
P firstC[100001], secondC[100001];

bool cmp (P a, P b) {
    return a.cnt > b.cnt;
}

int main() {
    //freopen("input.txt", "r", stdin);
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n/2; i++) {
        int a, b;
        cin >> a >> b;
        first[a]++;
        second[b]++;
    } 
    for (int i = 1; i <= 100000; i++) {
        firstC[i].i = i;
        firstC[i].cnt = first[i];
        secondC[i].i = i;
        secondC[i].cnt = second[i];
    }
    sort(firstC, firstC+100001, cmp);
    sort(secondC, secondC+100001, cmp);
    //cout << firstC[0].i << " : " << firstC[0].cnt << endl;
    //cout << secondC[0].i << " : " << secondC[0].cnt << endl;
    
    if (firstC[0].i != secondC[0].i) {
        int ans = 0;
        for (int i = 1; i <= 100000; i++) {
            ans += (firstC[i].cnt+secondC[i].cnt);
        }
        cout << ans << endl;
    } else {
        int a = firstC[0].cnt;
        for (int i = 2; i <= 100000; i++) {
            a += firstC[i].cnt;
        }
        for (int i = 1; i <= 100000; i++) {
            a += secondC[i].cnt;
        }
        int b = secondC[0].cnt;
        for (int i = 2; i <= 100000; i++) {
            b += secondC[i].cnt;
        }
        for (int i = 1; i <= 100000; i++) {
            b += firstC[i].cnt;
        }
        cout << min(a, b) << endl;
     
    }
    return 0;
}



Measured memory_bytes: 2560