akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int m[11],i,j,work;
for(i=0;i<10;i++){
 scanf("%d",&m[i]);
}
for(i=0;i<10;i++){
 for(j=0;j<10;j++){
  if(m[i]>m[j]){
   work=m[i]; m[i]=m[j]; m[j]=work;
   }
  }
 }
for(i=0;i<3;i++){
 printf("%d\n",m[i]);
}
return 0; }

Measured memory_bytes: 2712
from sys import stdin
# import numpy as np
N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip().split()[0]

s = [1 if s=="R" else -1 for s in S]

if sum(s)>0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
package main

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

// 0 0 10 10 10 23
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	b := nextInts(n - 1)

	a := make([]int, n)
	a[n-1] = b[n-2]
	for i := n - 2; i > 0; i-- {
		a[i] = min(b[i], b[i-1])
	}
	a[0] = b[0]
	// puts(a)
	puts(sum(a))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	long long a[20000], b[20000];
	long long n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		a[i] = (i + 1) * n;
		b[n - 1 - i] = (i + 1) * n;
	}
	for (int i = 0; i < n; i++) {
		int cur;
		cin >> cur;
		b[cur - 1] -= (n - i - 1);
	}
	for (int i = 0; i < n; i++) 
		cout << a[i] << " ";
	cout << endl;
	for (int j = 0; j < n; j++)
		cout << b[j] << " ";
	cout << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  ll ans = 0;
  ll count = 1;

  ans += a.at(0);
  count++;

  for (long long i = 1; i < n; i++) {
    if (count == n) {
      break;
    }
    ans += a.at(i);
    count++;
    if (count == n) {
      break;
    }
    ans += a.at(i);
    count++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int d;
  cin>>d;
  cout << "Christmas";
  while(d<25){
    cout << " Eve";
    d++;
  }
  cout << endl;
  return 0;
}


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

L = 0
R = 0
l = 0
r = N - 1
for i in range(N):
    if L < R:
        L += A[l]
        l += 1
    else:
        R += A[r]
        r -= 1

print(abs(L-R))

Measured memory_bytes: 88016
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *left, *right, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k)
{
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(int argc, char const *argv[])
{
    int n, i, x;
    string com;    

    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}




Measured memory_bytes: 22084
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>
 
typedef vector<int> vec;
typedef long long int ll;
typedef unsigned long long ull;



int main(){
    fast_cin();
    ll n, x;cin>>n>>x;
    ll ans=0;
    rep(i, 0, x){
      int y;cin>>y;
      ans+=y;
    }
    cout<<(n-ans>=0?n-ans:-1);
}

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

int main(){
  string s;
  cin>>s;
  cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
  
  return 0;
}

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

using namespace std;


int main() {
	int type, mass;
	cin >> type >> mass;

	int temp;
	int min_mass;
	int sum_mass;
	for (int i = 0; i < type; i++) {
		cin >> temp;
		sum_mass += temp;

		if ( i == 0) {
			min_mass = temp;
			continue;
		}
		if (min_mass > temp) {
			min_mass = temp;
		}
	}

	cout << type + (mass - sum_mass) / min_mass << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

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

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

	for (int i = 0; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int c = 0; c < n; c++) {
			if (c > 0) {
				cout << ' ';
			}
			cout << a[c];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair


ll primeFactors(ll n)  
{  
    // Prll the number of 2s that divide n  
    ll cnt=0;
    if(n%2==0)
    	cnt++;
    while (n % 2 == 0)  
    {  
        n = n/2;  
    }  
  
    // n must be odd at this poll. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, prll i and divide n  
        if(n%i==0)
        	cnt++;
        while (n % i == 0)  
        {  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cnt++;
    // cout<<cnt<<endl;
    return cnt; 
}  
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll a,b;
	cin>>a>>b;
	// cout<<__gcd(a,b)<<endl;
	cout<<primeFactors(__gcd(a,b))+1<<endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
a = [int(input()) for _ in range(M)]
mod = pow(10,9) + 7

dp = [0]*(N+1)
dp[0] = 1

ok = [True]*(N+1)
for i in a:
  ok[i] = False

for i in range(N):
  for j in range(i+1,min(N+1,i+3)):
    if ok[j]:
      dp[j] += dp[i]
      dp[j] %= mod
      
print(dp[N])

Measured memory_bytes: 8592
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
X = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    X[a].append(b)
    X[b].append(a)

def col(n, E):
    C = [-1] * n
    c = 0
    for i in range(N):
        if C[i] >= 0: continue
        Q = [i]
        C[i] = c
        while Q:
            x = Q.pop()
            for y in E[x]:
                if C[y] == -1:
                    C[y] = C[x]
                    Q.append(y)
        c += 1
    return C

C = col(N, X)
K = max(C) + 1

if N < 2*K-2:
    print("Impossible")
elif K == 1:
    print(0)
else:
    B = [-1] * K
    BB = []
    for i in range(N):
        if B[C[i]] < 0:
            B[C[i]] = A[i]
        else:
            if A[i] >= B[C[i]]:
                BB.append(A[i])
            else:
                BB.append(B[C[i]])
                B[C[i]] = A[i]
    BB = sorted(BB)
    
    print(sum(B + BB[:K-2]))

Measured memory_bytes: 27988
N,Q=map(int,input().split())
S=input()
L=[]
R=[]
C=[0]*N
c=0
for i in range(Q):
    A=list(map(int,input().split()))
    L.append(A[0])
    R.append(A[1])
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        c+=1
        C[i]=c
    else:
        C[i]=c
C[N-1]=c
S+="X"
for i in range(Q):
    p=0
    if S[R[i]-1]=="A" and S[R[i]]=="C":
        p=C[R[i]-1]-C[L[i]-1]-1
    else:
        p=C[R[i]-1]-C[L[i]-1]
    if S[L[i]-1]=="A" and S[L[i]]=="C":
        p+=1
    print(p)

Measured memory_bytes: 19496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++)ans += i;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
	int N;
	cin >> N;
	vector<int64_t> R(N+1);
	R.at(0) = 2;
	R.at(1) = 1;
	for (int i=2; i<N+1; i++){
		R.at(i) = R.at(i-2) + R.at(i-1);
	}
	cout << R.at(N) << endl;
	
}

Measured memory_bytes: 256
n=int(input())
li=map(int,input().split())
li=sorted(li)[::-1]
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(A-B)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
#define max(a, b) (a < b ? b : a) 
#define min(a, b) ((a > b) ? b : a) 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--) 
#define INF 1000000000000000003 
typedef long long int ll; 
typedef vector<int> vi; 
typedef vector<long long int> vl; 
typedef pair<int, int> pi; 
typedef pair<long long int, long long int> pl; 
#define F first 
#define S second 
#define pb push_back 
#define POB pop_back 
#define MP make_pair 
int main()
 {
	ll t;
	//cin>>t;
	//while(t--)
	//{
		ll n;
		vl a;
		cin>>n;
		ll x,c=0;
		FOR(i,n)
		{cin>>x;
		a.pb(x);
		}
		FOR(i,n)
		{if(i%2==0 && a[i]%2!=0)
		c++;
		}
		cout<<c<<endl;
		
	//}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N, M;
	cin >> N >> M;
	vector<int> S(N);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		int A;
		cin >> A;
		sum += A;
		S[i] = A;
	}
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if(S[i] >= (double)sum / (4*M))
			cnt++;
	}
	if (cnt >= M)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<'\n';
    return(0);
}

Measured memory_bytes: 256
#define SuC_VaT              Doc_code_ban_khac
#define Nhan_cach_bang_0     Doc_code_ban_khac

//

#include <iostream>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <list>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<int,int> ii;
typedef pair<ll, pair<ll,ll> > iii;

const int kn = 2e6 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, mod2 = 1e9+9;
const ll base = 31, base1 = 37;

//#define x first
//#define y second
#define lwb lower_bound
#define upb upper_bound
#define _it iterator

#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front

#define log2(X) (31-__builtin_clz(X))
#define log2ll(X) (63-__builtin_clzll(X))
#define numbit(X) __builtin_popcount(X)
#define numbitll(X) __builtin_popcountll(X)

#define ms(val,a) memset(a,val,sizeof(a))

#define ff(i,n) for(int i=1;i<=n;i++)
#define _ff(i,n) for(int i=n;i>=1;i--)
#define f(i,a,b) for(int i = a; i <=b; i++)
#define _f(i,a,b) for(int i = b; i>=a;i--)

#define In(X) freopen(X,"r",stdin)
#define Out(X) freopen(X,"w",stdout)

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll p[3];

int main() {
	cin >> p[0] >> p[1] >> p[2];
	sort(p,p+3);
	cout << p[0] + p[1];
}
//hahahahahahahahahhahahahahahaahahahahhahahahahahahah


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, L, R, a[100001], cnt;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> L >> R;
		++a[L - 1];
		--a[R];
	}
	for (int i = 1; i < N; ++i) {
		a[i] += a[i - 1];
	}
	for (int i = 0; i < N; ++i) {
		if (a[i] == M)++cnt;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int h,w,n;
vector<string> cake,tmpcake;
vector<vector<bool> >delb;
void fall(void)
{
  REP(j,w)
    for(int i=h-2;i>=0;--i){
      if(tmpcake[i][j]=='.') continue;
      for(int k=i;k<h-1;++k)
	if(tmpcake[k+1][j]=='.')
	  swap(tmpcake[k][j],tmpcake[k+1][j]);
    }
}
bool del(void)
{
  fall();
  delb.assign(h,vector<bool>(w,false));
  bool flag=false;
  REP(i,h){
    int l=0;
    REP(j,w+1){
      if(j<w && tmpcake[i][j]==tmpcake[i][l]) continue;
      else{
	if(tmpcake[i][l]!='.') if(j-l>=n) FOR(k,l,j) delb[i][k]=true;
	l=j;
      }
    }
  }
  REP(j,w){
    int u=0;
    REP(i,h+1){
      if(i<h && tmpcake[i][j]==tmpcake[u][j]) continue;
      else{
	if(tmpcake[u][j]!='.') if(i-u>=n) FOR(k,u,i) delb[k][j]=true;
	u=i;
      }
    }
  }
  REP(i,h) REP(j,w) if(delb[i][j]){
    tmpcake[i][j]='.';
    flag=true;
  }
  if(flag) return del();
  flag=true;
  for(auto s:tmpcake) for(auto c:s) if(c!='.') flag=false;
  if(flag) return true;
}
int main(void)
{
  cin >> h >> w >> n;
  cake.resize(h);
  REP(i,h) cin >> cake[i];
  tmpcake.resize(h);
  bool flag=false;
  REP(i,h) REP(j,w-1){
    REP(k,h) tmpcake[k]=cake[k];
    swap(tmpcake[i][j],tmpcake[i][j+1]);
    if(del()) flag=true;
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

string S,T;
ll N,M,H,W,K,L;
void solve() {
    cin >> N >> K;
    vll A(N+1),res;
    rng(i,1,N+1){
        cin >> A[i];
    }
    rng(i,K+1,N+1){
        // DEBUG(A[i]);
        // DEBUG(A[i-K]);
        if(A[i]>A[i-K]) print("Yes");
        else print("No");
    }
    // ll p = 1;
    // rng(i,1,K){
    //     p *= A[i];
    // }
    // // DEBUG(p);
    // rng(i,K,N+1){
    //     p *= A[i];
    //     // DEBUG(i); 
    //     // DEBUG(p); 
    //     res.pb(p);
    //     if(A[i-K+1]!=0) p /= A[i-K+1];
    //     // DEBUG(A[i-K]);
    //     // DEBUG(p);
    // }
    // // DEBUG_VEC(res);
    // ll before = res[0];
    // rng(i,1,N-K+1){
    //     if(res[i]>before) print("Yes");
    //     else print("No");
    //     before = res[i];
    // }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4780
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_pattern = list(itertools.permutations([i for i in range(1,N+1)]))
#print(all_pattern)

for i, node in enumerate(all_pattern):
  #print(node)
  if node == P:
    p = i
  if node ==  Q:
    q = i
    
    
print(abs(p-q))


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

struct zahyou{
	double x;
	double y;
};

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int a,b,h,m;
	cin >> a >> b >> h >> m;

	zahyou l, s;
	double lth, sth;
	const double pi = 3.14159265358979;
	int sum_min = h * 60 + m;
	// cout << sum_min << endl;
	if(!sum_min){
		lth = 0;
	}
	else{
		lth = 2.0 * pi * sum_min / 720;
	}
	if(!m){
		sth = 0;
	}
	else{
		sth = 2.0 * pi * m / 60;
	}

	l.x = a * sin(lth);
	l.y = a * cos(lth);
	s.x = b * sin(sth);
	s.y = b * cos(sth);

	//cout << l.x << "/" << l.y << endl;
	//cout << s.x << "/" << s.y << endl;

	double ans = sqrt( (l.x - s.x)*(l.x - s.x) + (l.y - s.y)*(l.y - s.y));

	cout << ans << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 4116
#define _GLIBCXX_DEBUG
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  map<int,int> A;
  for(int i=0; i<N; i++){
    cin >> A[i+1];
  }
  int B[N];


  for(auto& i:A){
    B[i.second-1] = i.first;
  }
  
  for(int i=0; i<N; i++){
    cout << B[i] << " ";
  }

  
  return 0;
}

Measured memory_bytes: 8608
import java.util.Scanner;

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

Measured memory_bytes: 35708
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    "math"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    N := nextInt()
    T, A := nextFloat(), nextFloat()
    
    best := 0
    bestval := 0.0
    for i := 1; i <= N; i += 1 {
        h := nextFloat()
        t := T - h*0.006
        if best == 0 || math.Abs(A-t) < bestval {
            bestval = math.Abs(A-t)
            best = i
        }
    }
    fmt.Println(best)
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    char s[200000];
    char t[200000];
    gets(s);
    gets(t);
    int i=0,j=0;
    while(1){
        if(s[i]=='\0' || t[i]=='\0')break;
        if(s[i]!=t[i]){
            j++;
        }
        i++;
    }
    printf("%d",j);
}

Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(3);
  for (int i; i < 3; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  if (vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    cin>>v;
    ll naibu = 0;
    rep(i, n-1){
        fr(j,i+1,n){
            if(v[i] > v[j]) naibu ++;
        }
    }
    if (k == 1 ){
        pr(naibu);
        return 0;
    }
    ll naibu2 = 0;
    auto v2 = v;
    for(const auto& it:v) v2.push_back(it);
    rep(i, 2*n-1){
        fr(j,i+1,2*n){
            if(v2[i] > v2[j]) naibu2 ++;
        }
    }

    // pr(naibu);
    // pr(naibu2);
    const ll div = 1000000007;
    auto diff = (naibu2 - naibu * 2) % div;
    // pr(diff);

    ll ans = (naibu * k) % div;
    ll x = (diff %div) * (((k * (k-1) ) / 2) % div) % div;
    ans = (ans +x)%div;
    pr(ans);
    return 0;
}


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

int main(){
  int N,H,W; cin>>N>>H>>W;
  int ans=0;
  rep(i,N) rep(j,N){
    if(i+H<=N&&j+W<=N) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  	for (int i = 1; i < n-1; i++) {
      if (vec.at(i-1) < vec.at(i) && vec.at(i) < vec.at(i+1)) {
        ans++;
      }
      if (vec.at(i-1) > vec.at(i) && vec.at(i) > vec.at(i+1)) {
        ans++;
      }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define C                  31
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=1,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    string s;
    cin >> s; 
    if(s[2]==s[3] and s[4]==s[5]) cout << "Yes\n";
    else cout << "No";
    
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            int ac=0, wa=0, tle=0, re=0;
            int n = int.Parse(Console.ReadLine());

            for(int i=0;i<n;i++)
            {
                string str = Console.ReadLine();
                switch(str)
                {
                    case "AC":ac++;break;
                    case "WA":wa++;break;
                    case "TLE":tle++;break;
                    case "RE":re++;break;
                }
            }
            Console.Write("AC x " + ac + "\r\nWA x " + wa + "\r\nTLE x " + tle + "\r\nRE x " + re);
        }
    }
}


Measured memory_bytes: 30628
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  v(string) S(N);
  cin >> S;

  map<string, i64> mp;
  rep(i,N){
    mp[S[i]] = 1;
  }

  cout << mp.size() << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int a , b , c , d ;

int main ()
{
    string s , t ;
    vector < int > v ;
    cin >> s ;
    for ( int i = 0 ; i < s . size () ; ++ i ){
        if ( s [ i ] == '0' ){
            v . push_back ( 0 ) ;
        }
        if ( s [ i ] == '1' ){
            v . push_back ( 1 ) ;
        }
        if ( s [ i ] == 'B' ){
            if ( v . size ( ) != 0 ){
                v . pop_back ( ) ;
            }
        }
    }
    for ( int i = 0 ; i < v . size ( ) ; ++ i ){
        cout << v [ i ] ;
    }
}

Measured memory_bytes: 256
import java.util.*;

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {
    int INF = 1 << 28;
    void run() {
        Scanner sc = new Scanner(System.in);
        dfs(sc.nextInt(), sc.nextInt(), "");
    }
    
    void dfs(int j, int y, String ans) {
//        debug(j, y, ans);
        if ((j|y) == 0) {
            if (ok(ans)) {
                System.out.println(ans);
            }
        }
        if (j > 0) dfs(j-1, y, ans + 'A');
        if (y > 0) dfs(j, y-1, ans + 'B');
    }
    
    boolean ok(String ans) {
        int jc = 0, yc = 0;
        for (int i = 0, l = ans.length(); i < l; i++) {
            if (ans.charAt(i) == 'A') jc++;
            else yc++;
//            debug(jc, yc);
            if ((3 >= jc && yc == 5) || (3 >= yc && jc == 5)) {
                return jc + yc == l;
            }
            if (jc == yc && jc == 5) {
                return jc + yc == l;
            }
            if ((jc == 4 && yc == 6) || (yc == 4 && jc == 6)) {
                return jc + yc == l;
            }
        }
        return true;
    }
    
    void debug(Object...os) {
        System.out.println(deepToString(os));
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 17332
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
set<int> primeFactor(int x) {
    set<int> factor;
    int tmp = x;
    if (x < 2) {
        factor.insert(x);
        return factor;
    }
    for (int i = 2; i*i <= x; i++) {
        if (tmp % i == 0) {
            factor.insert(i);
            while (tmp % i == 0)
                tmp /= i;
        }
    }
    if (tmp != 1)
        factor.insert(tmp);
    return factor;
}

int eulersPhiFunction(int x) {
    /*
    ex) x = (p^k) * (q^l) * (r^m)
    phi(x) = x * {(1 - 1/p) * (1 - 1/q) * (1 - 1/r)}
    */
    int ret = x;
    set<int> factor = primeFactor(x);
    for (auto f : factor) {
        // n(1 - 1/p) = n - n/p
        ret -= ret / f;
    }
    return ret;
}

/* main */
int main() {
    /*
    A "Totative" is a positive integer less than or equal to a number n
    which is also relatively prime to n.
    */
    int n;
    cin >> n;

    cout << eulersPhiFunction(n) << '\n';
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, k, a[5055], ps[5055][5055], ans, to;
bool dpl[5055][5055], dpr[5055][5055];

int sum(int ind, int lb, int ub) {
	if (ub < 0) return 0;
	if (lb <= 0) return ps[ind][ub];
	
	return ps[ind][ub] - ps[ind][lb - 1];
}

int main () {
	
	scanf("%d%d", &n, &k);
	
	FOE(i, 1, n) scanf("%d", a + i);
	
	FOE(i, 1, n) if (a[i] > k) a[i] = k;
	
	FOE(i, 0, n + 1) dpl[i][0] = dpr[i][0] = 1;
	
	FOE(i, 1, n) {
		FOE(j, 0, k) {
			if (dpl[i - 1][j]) {
				dpl[i][j] = 1;			
				to = j + a[i];
				if (to > k) to = k;
				
				dpl[i][to] = 1;
			}
		}
	}
	
	FOD(i, n, 1) {
		FOE(j, 0, k) {
			if (dpr[i + 1][j]) {
				dpr[i][j] = 1;				
				
				to = j + a[i];
				if (to > k) to = k;
				
				dpr[i][to] = 1;
			}
		}
	}
	
	FOE(i, 1, n + 1) {
		ps[i][0] = dpr[i][0];
		FOE(j, 1, k) ps[i][j] = ps[i][j - 1] + dpr[i][j];
	}
	
	FOE(i, 1, n) {
		bool flag = 0;
		
		FOR(j, 0, k) if (dpl[i - 1][j]) {
			if (sum(i + 1, k - j - a[i], k - 1 - j) > 0)
				flag = 1;
		}
		
		if (flag) ans++;
	}
	
	printf("%d\n", n - ans);
	
	return 0;
	
}

Measured memory_bytes: 149760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n ,x;
    cin>>n>>x;
    int a,sum=0,k=0;
    while(n--)
    {
        cin>>a;
        sum=sum+a;
        if(sum<=x)
        {
            k++;
        }
    }
    cout<<k+1<<endl;
}


Measured memory_bytes: 256
abcd = input()


for i in range(2**3):
    t = ""
    for j in range(3):
        if((i>>j)&1):
            t += abcd[j]+"+"
        else:
            t += abcd[j]+"-"

    t += abcd[3]

    if eval(t) == 7:
        print(t+"=7")
        break



Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>

int main (void)
{
	char s[1000];
	int i;
	int sum;
	
	
	for(i = 0 ; i < 1000 ; i++)
	{
		s[i] = '\0';
	}
	
	while(1)
	{
		sum = 0;
		i = 0;
		scanf("%s",s);
		if(strcmp(s,"0")==0)
		{
			break;
		}
		while(s[i] != '\0')
		{
			sum = sum + s[i] - '0';
			i++;
		}
		printf("%d\n",sum);
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,t1y[200005],x1y[200005],y1y[200005];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>t1y[i]>>x1y[i]>>y1y[i];
	}
    for(int i=0;i<n;i++)
	{
        int t=t1y[i];
        int x=x1y[i];
        int y=y1y[i];
        if(x+y>t)
        {
        	cout<<"No"<<endl;
        	return 0;
		}
        if(!(x+y<=t && (t-x-y)%2==0))
		{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <string>

#include <vector>
#include <iostream>

using namespace std;

int main() {

	int N,M;

	cin >> N;
	M = N;
	int count=1;
	vector<int> digit;
	while (N / count > 0) {
		count *= 10;
	}
	count /= 10;
	while (N>0) {
		digit.push_back(N / count);
		N -= digit.back() * count;
		count /= 10;
	}
	int sum = 0;
	for (auto i : digit) {
		sum+= i ;
	}
	if (M % sum == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<cmath>
#include<map>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ull unsigned long long
#define ll long long
#define eps 1e-9
using namespace std;

inline int read() {
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 100005, M = N * 32, inf = 1e9;
ll sum[M], ql; int v[N], c[M][2], rt, tot = 0;
#define lc c[k][0]
#define rc c[k][1]
#define lpc c[pre][0]
#define rpc c[pre][1]
inline void upd(int l,int r,int &k,int pre) {
	sum[k = ++tot] = sum[pre] + ql;
	if( l == r ) return;
	int mid = (l + r) >> 1;
	if( ql <= mid ) upd(l,mid,lc,lpc), rc = rpc;
	else upd(mid+1,r,rc,rpc), lc = lpc;
}

inline ll query(int l,int r,int k) {
	if( r <= ql ) return sum[k];
	if( ql < l || !k ) return 0;
	int mid = (l + r) >> 1;
	if( ql <= mid ) return query(l,mid,lc);
	else return sum[lc] + query(mid+1,r,rc);
}

int main() {
	int n = read(); ll tot = 0, to;
	rep(i,1,n) v[i] = read();
	rep(i,1,n) ql = v[i], upd(1,inf,rt,rt), tot += v[i];
	int ans = 0;
	rep(i,1,n) {
		ql = v[i] * 2; 
		while( (to = query(1,inf,rt)) > (ql >> 1) ) ql = to << 1;
		if( to == tot ) ans++;
	}
	cout<<ans<<endl;
	return 0;   
}

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

int main()
{
  int N, M, A, B, count = 0;
  vector<int> H(100000);
  vector<bool> check_flag(100000, true);

  cin >> N >> M;
  for (int i = 0; i < N; i++)
    cin >> H[i];
  for (int i = 0; i < M; i++)
  {
    cin >> A >> B;
    if (H[A - 1] > H[B - 1])
      check_flag[B - 1] = false;
    else if (H[A - 1] < H[B - 1])
      check_flag[A - 1] = false;
    else
    {
      check_flag[B - 1] = false;
      check_flag[A - 1] = false;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (check_flag[i])
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

//ab|c できるならc=2
int max(int a,int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}

int main(void){
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int c,i,pre,counter = 0;
    int a[26],b[26];
    for(c = 1;c<=n-1;c++){
        pre = counter;
        counter = 0;
        for(i=0;i<26;i++){
            a[i] = 0;
            b[i] = 0;
        }
        for(i=0;i<c;i++){
            if(a[(int)s[i]-97] == 0){
                a[(int)s[i] - 97]++;
            }
        }
        for(i=c;i<=n-1;i++){
            if(b[(int)s[i] - 97] == 0){
                b[(int)s[i] - 97]++;
            }
        }
        for(i=0;i<26;i++){
            if(a[i] + b[i]== 2){
                counter ++;
            }
        }
        counter = max(pre,counter);
    }
    printf("%d\n",counter);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<map>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

long long mod_inv(long long x){
    return mod_pow(x, MOD - 2);
}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> p;
    vector<bool> np(1001);
    p.push_back(2);
    for(ll i = 3; i <= 1000; i += 2){
        if(np[i]){
            continue;
        }
        p.push_back(i);
        for(ll j = i * 2; j <= 1000; j += i){
            np[j] = true;
        }
    }
    map<ll, ll> mp;
    for(int i = 0; i < n; i++){
        ll x = a[i];
        for(auto&& j : p){
            if(x == 1){
                break;
            }
            ll cnt = 0;
            while(x % j == 0){
                cnt++;
                x /= j;
            }
            if(cnt == 0){
                continue;
            }
            mp[j] = max(mp[j], cnt);
        }
        if(x != 1){
            mp[x] = max(mp[x], 1LL);
        }
    }
    ll l = 1;
    for(auto&& i : mp){
        l *= mod_pow(i.first, i.second);
        l %= MOD;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += (l * mod_inv(a[i])) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
long long modExp(long long a,long long b,long long m)
{
    long long r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b/2;
        a=(a*a)%m;
    }
    return r%m;
}
int main(){
	string s;
	cin >> s;
	int n = s.length();
	reverse(s.begin(), s.end());
	vector<int> val(n);
	for(int i = 0; i < n; i++)
	{
		val[i] = ((s[i]-'0')*modExp(10, i, 2019))%2019;
	}
	vector<int> prefix(n);
	prefix[0] = val[0];
	for(int i = 1; i < n; i++)
		prefix[i] = (prefix[i-1] + val[i])%2019;
	map<long long, long long> count;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(prefix[i] == 0)
			ans++;
		ans += count[prefix[i]];
		count[prefix[i]]++;
	} 
	cout << ans << endl;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a % 2 == 0 || b % 2 == 0) puts("No");
	else puts("Yes");
	
	return 0;
}

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

using namespace std;

const int maxi=1e6+2;

int a[maxi];
string s;
vector<int> v[maxi];
map<int,int > mp;
int n;
int b[maxi];
int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            b[i]=a[i];
        }

   sort(b+1,b+n+1);

   printf("%d ",b[n]);

   int id=0;
   int dif=-1;
   for (int i=1;i<n;i++)
    {
        int dif1= min(b[n]-b[i],b[i]);
        if (dif<dif1)
        {
            dif=dif1;
            id=i;
        }
    }
    printf("%d",b[id]);
    printf("\n");
    return 0;
}
//sala mala


Measured memory_bytes: 27264
#include<stdio.h>

int main(){
	int n,a,b,c,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		a*=a;
		b*=b;
		c*=c;
		if(a==b+c || b==a+c || c==a+b){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	vector<int> P(N);
	REP(i,N){
		P[i] = in();
	}
	sort(ALL(P));
	
	cout << P[N/2]-P[N/2-1] << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ch_edge(CH,i) CH[i],CH[(i+1)%CH.size()]

typedef complex<double> Point;
typedef vector<Point> VP;

#define X real()
#define Y imag()

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int main(void){
	int n;
	cin>>n;
	VP p(n);
	rep(i,n){
		double x,y;
		cin>>x>>y;
		p[i] = {x,y};
	}

	/* s = 0.5*sigma(i,n){x[i]*y[i+1]-x[i+1]*y[i]} */
	double s=0;
	rep(i,n){
		s += cross(ch_edge(p,i));
	}
	s*=0.5;
	printf("%.1f\n",s );

    return 0;
}

Measured memory_bytes: 3292