akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int main(){
    double r;
    cin >> r;
    cout << r * 2 * M_PI;

    return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main()
{
    int n, h[20], view = 1;
    bool flag;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &h[i]);
    for(int i = 1; i < n; i++)
    {
        flag = true;
        for(int j = 0; j < i; j++)
        {
            if((h[i] - h[j]) < 0) flag = false;
        }
        if(flag) view++;
    }
    printf("%d", view);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	string s[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
	int a,b;
	while(cin>>a>>b,a+b){
		int co=b;
		a--;
		while(a){a--;co+=d[a];}
		cout<<s[co%7]<<endl;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    int t = n, d = 0;
    while(t) d++, t /= 10;
    int c = 9, ans = 0;
    for(int i = 0; i < d-1; i += 2) {
        ans += c;
        c *= 100;
    }
    if(d % 2 == 1) ans += n - pow(10, d-1) + 1;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD=1000000007;
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/
  return MUL(x, POW(y, MOD - 2));
}
ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }

map<int, int> prime_factorization(ll M){
  map<int, int> table;
  for (int i=2;i*i<=M;++i){
    while(M%i==0){
      ++table[i];
      M/=i;
    }
  }
  if(M!=1) table[M]=1;
  return table;
}

int main(){
  int N;cin>>N;ll M;cin>>M;
  map<int, int> prime_table=prime_factorization(M);
  ll ans=1;
  for (auto p:prime_table){
    int x=p.second;
    (ans*=comb(N+x-1, x))%=MOD;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    unsigned long long a, b, c, d, ans, ans1;
    cin>>a>>b>>c>>d;
    ans =  a*b;
    ans1 =  c*d;
    if(ans>ans1)
        cout<<ans<<endl;
    else
        cout<<ans1<<endl;
}


Measured memory_bytes: 256
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = Array.init 10 @@ fun _ -> Array.init 10 @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let a_ss = Array.init h @@ fun _ -> Array.init w @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let ans = ref 0
let _ =
  for k = 0 to 9 do
    for i = 0 to 9 do
      for j = 0 to 9 do css.(i).(j) <- min css.(i).(j) @@ css.(i).(k) + css.(k).(j) done done done;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do if a_ss.(i).(j) <> -1 then ans := !ans + css.(a_ss.(i).(j)).(1) done done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll f[10005];
int g(int x, int y, int z) {
   return (x * x + y * y + z * z + x * y + y * z + z * x);
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;

   rep(x, 1, 1001) {
      rep(y, 1, 1001) {
         rep(z, 1, 1001) {
            int res = g(x, y, z);
            if (res > n) continue;
            f[res]++;
         }
      }
   }
   rep(i, 1, n + 1) cout << f[i] << endl;
   return 0;
}

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

using namespace std;

int main(){
    int N,K,ans =0;
    cin >> N >> K;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

    sort(h.begin(),h.end());

    for(int i=0;i<N;i++){
        if(K<=h[i]){
            ans = N-i;
            break;
        }
        if(i==N-1){
            ans = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll a[50];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	ll ans = 0;
	while(true){
		bool update = 0;
		rep(i,N) if(a[i]>=N){
			ll q = a[i]/N;
			a[i] -= q*N;
			rep(j,N) if(i!=j) a[j]+=q;
			ans += q;
			update = 1;
		}
		if(!update) break;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		char[] sa = new char[s.length()];
		char[] ta = new char[t.length()];

		sa = s.toCharArray();
		ta = t.toCharArray();

		Arrays.sort(sa);
		Arrays.sort(ta);

		s = String.valueOf(sa);
		t = new StringBuilder(String.valueOf(ta)).reverse().toString();

		if (t.compareTo(s) > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}

Measured memory_bytes: 35612
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,i,j,cou=0,cou2,cou3,v[1000000],w[1000000],min_i,en=0;
    char S[100],W[100],s[10],X,Y;
    scanf("%d",&A);
    B=A/2;
    if(A%2==0){
    printf("%d",B*B);
    }else{
        printf("%d",B*B+B);
    }
}

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

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

    static int ans[100000] = {0};
    pair<int,int> sep;
    int cur[2] = {1, 0};
    bool f = false;
    for(int i=1;i<s.size();i++){
        if(!f && s[i] == 'L'){
            sep = {i-1, i};
            f = true;
        }else if(f && s[i] == 'R'){
            f = false;
            ans[sep.first] = cur[sep.first % 2];
            ans[sep.second] = cur[sep.second % 2];
            cur[0] = cur[1] = 0;
        } 
        cur[i%2]++;
    }
    ans[sep.first] = cur[sep.first % 2];
    ans[sep.second] = cur[sep.second % 2];
    
    for(int i=0;i<s.size();i++) cout << ans[i] << " \n"[i+1==s.size()];
    
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=[0]*(N+1)
    
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                k=x**2+y**2+z**2+x*y+y*z+z*x
                if k<=N:
                    ans[k]+=1
                    
                    
    for i in range(1,N+1):
        print(ans[i])

main()


Measured memory_bytes: 68836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		final long K = sc.nextInt();
    		final long K2 = (K * (K-1) / 2) % 1000000007;
    		int[] A = new int[N];
    		for (int i=0; i<N; i++) {
    			A[i] = sc.nextInt();
    		}

    		int count1 = 0;
    		for (int i=0; i<N; i++) {
    			for (int j=i+1; j<N; j++) {
    				if (A[i] > A[j]) {
    					count1++;
    				}
    			}
    		}

    		final int MAX_A = 2001;
    		int[] numCount = new int[MAX_A+1];
    		for (int i=0; i<N; i++) {
    			numCount[A[i]]++;
    		}
    		long totalCount = 0;
    		for (int i=1; i<=MAX_A; i++) {
    			if (numCount[i] != 0) {
        			int lessThan = 0;
        			for (int j=0; j<i; j++) {
        				lessThan += numCount[j];
        			}
        			if (lessThan != 0) {
            			totalCount += lessThan * K2 * numCount[i] ;
            			totalCount %= 1000000007;
        			}
    			}
    		}

    		totalCount += count1 * K;
    		System.out.println(totalCount % 1000000007);

    	} finally {
    		sc.close();
    	}
    }
}



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

using Int = long long;
using ll = long long;

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;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

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

  ll s,t,p,q,m,y;
  cin>>s>>t>>p>>q>>m>>y;

  cout<<(t^s^y)<<endl;
  return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,P;cin>>N>>P;
  if(N>40){
    cout << 1 << endl;
    return 0;
  }
  if((1ll<<N)>P){
    cout << 1 << endl;
    return 0;
  }
  if(N==1){
    cout << P << endl;
    return 0;
  }
  ll ans = 1;
  for(ll i=2;i*i<=P;i++){
    ll x=pow(i,N);
    if(x>P)break;
    while(P%x==0){
      ans *= i;
      P/=x;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String color[] = new String[N];
		boolean or = false;
		for(int i = 0; i<N; i++) {
			color[i]= sc.next();
			if(color[i].equals("Y"))or = true;
		}
		if(!or)System.out.println("Three");
		else System.out.println("Four");
		sc.close();
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int a,b;
    cin >> a >> b;
    a--,b--;
    printf("100 100\n");
    for(int i=0;i<50;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(i%2&&j%2&&a)
            {
                a--;
                printf(".");
            }
            else printf("#");
        }
        printf("\n");
    }
    for(int i=50;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(i%2&&j%2&&b)
            {
                b--;
                printf("#");
            }
            else printf(".");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3640
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = (2 * i + 1)|0;
    right = (2 * i + 2)|0;
    if (left < n && Number(arr[left]) > Number(arr[largest])) largest = left|0;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right|0;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };
  for (let i = Math.floor(n / 2 - 1); i >= 0; i=(i-1)|0) maxHeapify(i);
}



Measured memory_bytes: 88316
import java.util.*;
import java.lang.*;
class MathLib{
    public static long divCeil(long a, long b){
        return (a+b-1)/b;
    }

    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

    public static LinkedList<Long> divisors(long N){
        LinkedList<Long> ans = new LinkedList<>();
        for(long n = (long)(Math.sqrt(N)+2); n>0; n--){
            if(n*n>N) continue;
            else if(n*n==N) ans.add(n);
            else if(N%n==0){
                ans.addFirst(n);
                ans.addLast(N/n);
            }
        }
        return ans;
    }
}
public class Main {
    static long check(long N, long K){
        while(N>=K){
            if(N%K==0) N = N/K;
            else N %= K;
        }
        return N;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        /*
        * in mod-K world...
        * if(N%K==0) N = N/K;
        * else N = N; => never change
        *
        * K must be the divisor of N or divisor of N-1.
        * */
        int ans = 0;

        for(long k:MathLib.divisors(N)) if(k>1 && check(N,k)==1) ans++;
        for(long k:MathLib.divisors(N-1)) if(k>1 && (N%k>0) && check(N,k)==1) ans++;
        System.out.println(ans);
    }
}


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

using namespace std;

int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
        c-=b;
        if(c>0)
            a-=d;
    }
    (a>0)?cout<<"Yes":cout<<"No";
}


Measured memory_bytes: 3512
#include <iostream>
#include <queue>
#include <algorithm>
#include <unordered_set>
#define DEBUG

using std::endl;
constexpr int32_t INF = 1000000000;

std::unordered_set<int32_t> graph[100000];
int32_t path[200000][2];
int32_t N,M,Q;
int32_t D[100000];
void dij(int32_t s)
{
	using P = std::pair<int32_t,int32_t>;
	std::queue<P> que;
	for(auto& i : D)i=INF;
	D[0] = 0;
	que.emplace(0,0);
	while(!que.empty())
	{
		auto n = que.front();que.pop();
		if(D[n.second] < n.first){continue;}
		
		for(auto& e : graph[n.second]){
			auto cost = n.first + 1;
			if(cost < D[e]){
				D[e] = cost;
				que.emplace(cost,e);
			}
		}
	}
}



int main()
{
	std::cin >> N >> M >> Q;
	for(int i = 0;i < M;++i){
		std::cin >> path[i][0]>>path[i][1];--path[i][0];--path[i][1];
		graph[path[i][0]].insert(path[i][1]);
		graph[path[i][1]].insert(path[i][0]);
	}
	
	dij(0);
	
	int32_t count = 0;
	for(int i = 0;i < Q; ++i)
	{
		int32_t R;
		std::cin >> R;--R;
		
		int32_t from = path[R][0];
		int32_t to = path[R][1];
		graph[from].erase(graph[from].find(to));
		graph[to].erase(graph[to].find(from));
		
		if(D[to] == D[from]){
			std::cout << count << endl;
			continue;
		}
		if(D[to] < D[from]){
			std::swap(from,to);
		}
		if(D[to] >= INF){
			std::cout << count << endl;
			continue;
		}
		
		//辺を逆にたどる
		bool used[100000] ={};//[1]:tmp
		std::queue<int32_t> que;
		que.emplace(to);
		used[to] = true;
		while(!que.empty())
		{
			auto n = que.front();que.pop();
			if(D[n] >= INF){continue;}
			
			bool path_is_exsists = false;
			for(auto& e : graph[n]){
				if(D[e] < D[n]){
					path_is_exsists = true;
					break;
				}
			}
			if(path_is_exsists){
				//OK
			}
			else{
				++count;
				D[n] = INF;
				for(auto& e : graph[n]){
					if(!used[e] && D[e] < INF){
						used[e] = true;
						que.push(e);
					}
				}
			}
		}
		
		std::cout << count << endl;
	}
	
}

Measured memory_bytes: 29568
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string s1,s2;
	while(cin>>s1>>s2)
	{
		int len1=s1.length();
		int len2=s2.length();
		if(len1>len2)
		{
			cout<<'>'<<endl;
		}
		else if(len1<len2)
		{
			cout<<'<'<<endl;
		}
		else
		{
			int flag=0;
			for(int i=0;i<len1;i++)
			{
				if(s1[i]>s2[i])
				{
					cout<<'>'<<endl;
					flag=1;
				}
				else if(s1[i]<s2[i])
				{
					cout<<'<'<<endl;
					flag=1;
				}
			}
			if(!flag)
			{
				cout<<'='<<endl;
			}
		}
	}
} 

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans = "U" * (ty - sy) + "R" * (tx - sx + 1) + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "UL" + "U" *  (ty - sy + 1) + "R" * (tx - sx + 1) + "D" * (ty - sy + 1) + "L" * (tx - sx)
print(ans)

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

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n);
  vector<int> b(m);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());
  for(int i=0; i<m; i++) cin >> b[i];
  sort(b.begin(), b.end());
  
  if(a[0] >= b[0]) {
    cout << "War" << endl;
    return 0;
  }
  
  else {
    for(int i=a[0]+1; i<=b[0]; i++) {
      if(x<i && i<=y) {
        cout << "No War" << endl;
        return 0;
      }
    }
    cout << "War" << endl;
    return 0;
  }
}

Measured memory_bytes: 3620
n, a, b, c, d = map(int, input().split())
li = list(input())

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(a-1,c):
    if li[i]=='.':
      count_sharp = 0
      if b-2 <= i and i <= d:
        count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
  # print(count_sharp,max_dot)
else:
  for i in range(a-1,d):
    if li[i]=='#':
      if not c<b:
        count_sharp += 1
        if count_sharp>1:
          break
    else:
      count_sharp = 0
  if(count_sharp<=1):
    print('Yes')
  else:
    print('No')
  # print(count_sharp)

Measured memory_bytes: 4924
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
vector<int> G;
int m;

bool check(int v)
{
  int cnt = 0;
  int sum = 0;
  rep(i,G.size())
    {
      if(G[i] > v)return false;
      sum += G[i];
      if(sum > v)
	{
	  sum = G[i];
	  cnt++;
	}
    }
  return cnt < m;
}

int main()
{
  int n;
  while(cin >> m >> n,m|n)
    {
      G.resize(n);
      rep(i,n)cin >> G[i];
      int L = 0;
      int R = 1500000;
      int M;
      rep(j,100)
	{
	  M = (L+R)/2;
	  if(!check(M))
	    L = M;
	  else
	    R = M;	      
	}
      cout << R << endl; 
    }
  return 0;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "=" << endl;
  } else if (a < b) {
    cout << "<" << endl;
  } else {
    cout << ">" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
ll f[N*4];
vector<ll> v;
void upd(ll pos, ll val)
{
	for(int i=pos; i<N*4; i += i&-i) f[i] += val;
}

ll query(ll pos)
{
	ll res = 0;
	for(int i=pos; i>0; i -= i&-i) res += f[i];
	return res;
} 

bool check(ll m, ll sz)
{
	memset(f, 0, sizeof(f));
	ll inv = 0;
	ll n = sz;
	vector<ll> tmp(n+1);
	tmp[0] = 0;
	for(int i=0; i<n; i++)
		tmp[i+1] = tmp[i]  + (v[i] >= m?1:-1);
	for(int i=0; i<=n; i++)
	{
		ll ind = tmp[i] + N + 1;
		inv += query(ind);
		upd(ind, 1);
	} 
	ll total = (n*(n+1)) /2;
	ll obj = (total+1) /2;
	if(inv>= obj) return true;
	else return false;
}

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
    int n;
	cin>>n;
	v.resize(n);
	for(int i=0; i<n; i++) cin>>v[i];
	ll l = 0, r = 1 << 30;
	ll ans = 0;
	while(l <= r)
	{
		ll mid = l + (r-l) / 2;
		if(check(mid, n)) {ans = mid, l = mid + 1;}
		else r = mid - 1;
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}


const int N = 2e5+ 10;
int rk[N], p[N];
 
int getP(int a){
	return (a == p[a] ? a : p[a] = getP(p[a]));
}
 
void unite(int a, int b){
	a = getP(a), b = getP(b);
	if (a == b) return;
	if (rk[a] < rk[b]) swap(a, b);
	p[b] = a;
	rk[a] += rk[b];
}





void solve()
{
    int n, m; cin>>n>>m;
    REP(i, 1, n) {
        p[i] = i;
        rk[i] = 1;
    }
    // map<int, set<int>> mp;
    int mx = 0;
    rep(i, m)
    {
        int x, y; cin>>x>>y;
        unite(x, y);
        // mp[x].insert(y);
        // mp[y].insert(x);
        // mx = max({mx, sz(mp[x]), sz(mp[y])});
    }
    REP(i, 1, n) {
        mx = max(mx, rk[getP(i)]);
    }
    cout<<mx<<endl;
    
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
int n, k;
ll a[120000];
ll pr[120000];
ll pr2[120000];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	for (int i = 0; i < n; ++i)
		pr[i + 1] = pr[i] + a[i];
	for (int i = 0; i < n; ++i)
		pr2[i + 1] = pr2[i] + max(0ll, a[i]);
	ll ans = 0;
	for (int i = 0; i + k <= n; ++i) {
		ans = max(ans, pr2[n] - pr2[i + k] + pr2[i]);
		ans = max(ans, pr2[n] - pr2[i + k] + pr2[i] + pr[i + k] - pr[i]);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int A[N];
    int total=0;
    for(int i=0;i<N;++i){
        cin >> A[i];
        total += A[i];
    }
    double popular = total*1.0/(4*M);
    int count=0;
    for(int i = 0;i<N;++i){
        if(A[i]>=popular) count+=1;
    }
    if(count>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

void five(int h, int a){  // h=height , a=number
  
  if(h==1){
    if(a<=4)
      printf("*");
    else
      printf(" ");
  }
  else{  // h==2
    if(a>=5)
      printf("*");
    else
      printf(" ");
  }
}

void ball(int h, int a){
  
  if(a==h-1||a==h+4)
    printf(" ");
  else
    printf("*");
}

int main(void){
  char num1[7];
  int num2[5];
  int i,j,f=0,len;
  
  while(scanf("%s",num1)!=EOF){  // scan
    len=strlen(num1);  // length

    for(i=0;i<5-len;i++)  // left zero
      num2[i]=0;
    j=0;
    for(i=5-len;i<5;i++)  // char->int copy
      num2[i]=num1[j++]-'0';

    if(f)
      puts("");

    for(j=1;j<=2;j++){  // j=1,2
      for(i=0;i<5;i++){
	five(j,num2[i]);
      }
      puts("");
    }
    
    puts("=====");
    
    for(j=1;j<=5;j++){  // j=1,2, ... ,5
      for(i=0;i<5;i++){
	ball(j,num2[i]);
      }
      puts("");
    }
    f=1;
  }
  return 0;
}

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

int main() {
	int n,m;
  cin>>n>>m;
  vector<long long> h(n);
  for(long long &x: h) cin>>x;
  vector<int> ans(n,1);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(h[a-1]>=h[b-1]) ans[b-1]=0;
    if(h[a-1]<=h[b-1]) ans[a-1]=0;
  }
  long long count=0;
  for(int i=0;i<n;i++){
    count+=ans[i];
  }
  cout<<count<<endl;
}


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

int main(){
    string s;
    cin >> s;
    F(s.size()){
        if(s[i]==','){
            s[i]=' ';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf=1e18;
const int N=2e5+10;



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

    printf("%d\n",(int)(k*pow(k-1,n-1)));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }


signed main() {
	int n;
	cin >> n;
	V<P<int>> ba(n);
	RBF(i, ba) {
		cin >> i.second >> i.first;
	}
	upsort(ba);

	int now = 0;
	RBF(i, ba) {
		now += i.second;
		if (now > i.first) {
			col("No");
			return 0;
		}
	}
	col("Yes");
	return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
string red,blue;
  cin >> red;
  cin >> blue;
  int  redn,bluen;

  cin >> redn >> bluen;
    string U;
    cin >> U;
  if(U == red){
  cout << redn - 1 << " " << bluen << endl;
  }
  else {
  cout << redn << " " << bluen - 1 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int R;

	cin >> R;

	string s;

	if(R < 1200){
		s = "ABC";
	}	else if ( R < 2800){
		s = "ARC";
	} else {
		s = "AGC";
	}

	cout << s << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

#define EPS 1e-14
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INFLL (ll)1e18 //Long long infinity
#define INF (int)1e9 //Int infinity
#define MX 100005

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<string> vstr;

#define us unordered_set
#define um unordered_map
#define bs bitset

#define RANGE(i,a,b,d) for (int i=min((int)a,(int)b); i<max((int)a,(int)b); i+=d)
#define RRANGE(i,a,b,d) for (int i=max((int)a,(int)b); i>min((int)a,(int)b); i+=d)
#define FOR(i,a,b) RANGE(i,a,b,1)
#define RFOR(i,a,b) RRANGE(i,a,b,-1)
#define REP(i,s) FOR(i,0,s)
#define RREP(i,s) RFOR(i,s-1,-1)
#define FORIT(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define EACH(x,v) for (auto &x : v)

#define sz(x) (int)(x).size()
#define len(x) (int)sizeof(x)/sizeof(*x)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define contains(m,x) (m.find(x) != m.end()) // check if an element in a map
#define isIn(S, s) (S.find(s) != string::npos) // check if substring

#define pv(v) EACH(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) EACH(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) EACH(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

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

namespace std{
  // Used for hashing pair
  template <> struct hash<pi>{
    size_t operator()(const pi&x)const{
      ll P=38923, Q=109797901;
      return (size_t)((x.F*P+x.S)%Q);
    }
  };
};

// This is min queue
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
void print(T t){
  cout << t << endl;
}

//Python style printing
template<typename T, typename... Args>
void print(T t, Args... args){
  cout << t << " ";
  print(args...);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());

        if(a+b==c || a+c==b ||b+c==a)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


Measured memory_bytes: 21204
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const int max_digit = 10;

int main() {
	int K; cin >> K;
	vector<vector<string>> lunlun(max_digit);
	// 1桁のlunlun
	for (int i = 1; i <= 9; ++i) {
		ostringstream oss; oss << i;
		lunlun[0].push_back(oss.str());
	}
	// 2桁以降のlunlun
	for (int i = 1; i < max_digit; ++i) {
		for (string tmp : lunlun[i - 1]) {
			int lst = tmp[tmp.length() - 1] - '0';
			if (lst > 0) {
				string new_lunlun = tmp + (char)('0' + lst - 1);
				lunlun[i].push_back(new_lunlun);
			}
			{
				string new_lunlun = tmp + (char)('0' + lst);
				lunlun[i].push_back(new_lunlun);
			}
			if (lst < 9) {
				string new_lunlun = tmp + (char)('0' + lst + 1);
				lunlun[i].push_back(new_lunlun);
			}
		}
	}
	vector<string> lunluns;
	for (int i = 0; i < max_digit; ++i) {
		for (string tmp : lunlun[i]) {
			lunluns.push_back(tmp);
		}
	}
	cout << lunluns[K - 1] << endl;
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll m,d;cin>>m>>d;
  rep(i,1,m+1)rep(j,20,d+1){
    if((j%10)>=2&&i==((j%10)*(j/10))){
      res++;
      //cout<<i spa j<<endl;
    }
  }
  cout<<res<<endl;
  return 0;
}

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

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


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

using namespace std;

class Position {
public:
	int tx, ty, kx, ky;
	int cnt;

	Position() {
		tx = ty = kx = ky = cnt = 0;
	}

	Position(int x1, int y1, int x2, int y2) : tx(x1), ty(y1), kx(x2), ky(y2) {
		cnt = 0;
	}
};

int W, H, Ans;
int MapData[50][50];
int Dx[4] = { 1,0,-1,0 };
int Dy[4] = { 0,1,0,-1 };
bool Visited[50][50][50][50];

bool solve(int x1, int y1, int x2, int y2) {
	int curTx, curTy, curKx, curKy, nextTx, nextTy, nextKx, nextKy;
	queue<Position> positionList;
	Position curPos, next;

	memset(Visited, false, sizeof(Visited));
	positionList.push(Position(x1, y1, x2, y2));
	while (!positionList.empty()) {
		curPos = positionList.front();
		positionList.pop();

		if (curPos.cnt == 100) {
			return false;
		}
		curTx = curPos.tx;
		curTy = curPos.ty;
		curKx = curPos.kx;
		curKy = curPos.ky;
		if (curTx == curKx && curTy == curKy) {
			Ans = curPos.cnt;
			return true;
		}
		if (Visited[curTx][curTy][curKx][curKy]) {
			continue;
		}
		Visited[curTx][curTy][curKx][curKy] = true;
		next.cnt = curPos.cnt + 1;

		for (int i = 0; i < 4; ++i) {
			nextTx = curTx + Dx[i];
			nextTy = curTy + Dy[i];
			nextKx = curKx - Dx[i];
			nextKy = curKy - Dy[i];
			if (nextTx < 0 || nextTx > W - 1 || nextTy < 0 || nextTy > H - 1 || MapData[nextTy][nextTx] == 1) {
				next.tx = curTx;
				next.ty = curTy;
			}
			else {
				next.tx = nextTx;
				next.ty = nextTy;
			}

			if (nextKx < 0 || nextKx > W - 1 || nextKy < 0 || nextKy > H - 1 || MapData[nextKy][nextKx] == 1) {
				next.kx = curKx;
				next.ky = curKy;
			}
			else {
				next.kx = nextKx;
				next.ky = nextKy;
			}
			positionList.push(next);
		}
	}

	return false;
}

int main() {
	int x1, y1, x2, y2;

	while (cin >> W >> H, W) {
		cin >> x1 >> y1 >> x2 >> y2;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> MapData[i][j];
			}
		}
		if (solve(--x1, --y1, --x2, --y2)) {
			cout << Ans << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 10304
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
int main()
{
    int s=0;
    char x[21],y[21]={"CODEFESTIVAL2016"};
    gets(x);
    for(int i=0;i<strlen(x);i++)
    if(x[i]!=y[i])
    s++;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 256
@n = gets.to_i
@s = gets.chomp.chars.map {|e| e == ?o ? 0 : 1}
@a = Array.new(@n)

xxx = ->(i) {@a[i] ^ @s[i] ^ @a[i-1]}
calc = ->(x, y) {
    @a[0] = x
    @a[-1] = y
    (@n-2).times {|i| @a[i+1] = xxx.(i)}
    if xxx.(-2) == @a[-1] && xxx.(-1) == @a[0]
        puts @a.map{|e| e == 0 ? ?S : ?W}.join
        exit
    end
}

calc.(0, 0)
calc.(0, 1)
calc.(1, 0)
calc.(1, 1)
p -1

Measured memory_bytes: 25800
#include <stdio.h>
int main(){
  int n, a[21]={0}, b[21]={0}, c[21]={0}, cnt=0;
  scanf("%d",&n);
  for(int i=0; i<n; i++){ scanf("%d",&a[i]); }
  for(int i=0; i<n; i++){ scanf("%d",&b[i]); }
  for(int i=0; i<n; i++){ scanf("%d",&c[i]); }
  for(int i=0; i<n; i++){
    cnt += b[a[i]-1];
    if( i!=0 && a[i-1]==a[i]-1 ){ cnt += c[a[i]-1-1]; }
  }
  printf("%d",cnt);
  return 0;
}

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

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

    int b,c;
    vector <ll> a(n);

    rep(i,n){
        cin >> a[i];
        
    }

    sort(a.begin(),a.end());
    priority_queue <ll> q;
    q.push(a[n-1]);

    b=a[n-2];
    c=a[n-2];
    //ans=a[n-1];
    ll p;
    ll qq;

    rep(i,n-1){
        p=a[n-2-i];
        qq=q.top();
        q.pop();
        ans+=qq;
        q.push(p);
        q.push(p);
        
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 6920
#include<stdio.h>

int main(void)
{
    int a[9],n,b[11],i,j;
    
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    scanf("%d %d %d",&a[3],&a[4],&a[5]);
    scanf("%d %d %d",&a[6],&a[7],&a[8]);
    scanf("%d",&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%d",&b[i]);
    }
    for(i = 0 ; i < 9 ; i++)
    {
        for(j = 1 ; j <= n ; j++)
        {
            if(a[i] == b[j])
            {
                a[i] = 0;
                
            }
            
        }
        
    }
    if(a[0] == a[1] && a[1] == a[2])
    {
        printf("Yes");
       
    }
    else if(a[3] == a[4] && a[4] == a[5])
    {
        printf("Yes");
      
    }
    else if(a[6] == a[7] && a[7] == a[8])
    {
        printf("Yes");
        
    }
    else if(a[0] == a[4] && a[4] == a[8])
    {
        printf("Yes");
       
    }
    else if(a[2] == a[4] && a[4] == a[6])
    {
        printf("Yes");
        
    }
    else if(a[0] == a[3] && a[3] == a[6])
    {
        printf("Yes");
       
    }
    else if(a[1] == a[4] && a[4] == a[7])
    {
        printf("Yes");
       
    }
    else if(a[2] == a[5] && a[5] == a[8])
    {
        printf("Yes");
        
    }
    else
    {
        printf("No");
    }
    
    
    return 0;
}

Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	int a=Integer.parseInt(str[0]);
            	int b=Integer.parseInt(str[2]);
            	if(str[1].equals("?"))break;
            	else if(str[1].equals("+"))System.out.println(a+b);
            	else if(str[1].equals("-"))System.out.println(a-b);
            	else if(str[1].equals("/"))System.out.println(a/b);
            	else if(str[1].equals("*"))System.out.println(a*b);
            	
            }
        }
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll k,n;
	cin >> k >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	ll ans=a[n-1]-a[0];
	ll tmp=0;
	rep(i,n-1) chmax(tmp,abs(a[i]-a[i+1]));
	cout << min(ans,ans-tmp+(a[0]-0)+(k-a[n-1])) << endl;
	return 0;
}

Measured memory_bytes: 1792
import itertools
A, B, C = map(int,input().split())
K = int(input())
ans = 'No'
ls = []
for i in range(K+1):
    for j in range(K+1-i):
        l = K-i-j
        ls.append([i,j,l])
for lis in ls:
    if A*2**lis[0] < B*2**lis[1] and B*2**lis[1] < C*2**lis[2]:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 9132
#include <iostream>
using namespace std;
long long dp[100005];
int main(int argc, char** argv) {
	int n,w;
	cin >> n >> w;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin >> x >> y;
		for(int j=w-x;j>=0;j--)
			dp[j+x]=max(dp[j+x],dp[j]+y);
	}
	cout << dp[w];
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#ifdef DEBUG
    #include <ctime>
#endif
using namespace std;

// template

// abbreviations
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define ii pair<int, int>
#define a first
#define b second
#define vii vector<ii>
#define mii map<ii>
#define vvi vector<vi>
#define vvl vector<vl>
#define que queue
#define pque priority_queue
#define stk stack
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define pu push
#define po pop
#define mp make_pair
#define sz(var) ((int) var.size())
#define rep(it, n) for(int it = 0; it < n; ++it)
#define dep(it, n) for(int it = n - 1; it >= 0; --it)
#define rep1(it, n) for(int it = 1; it <= n; ++it)
#define dep1(it, n) for(int it = n; it > 0; --it)
#define loop(it, from, to) for(int it = (from); it <= (to); ++it)
#define iter(it, cont) for(__typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it)
#define riter(it, cont) for(__typeof((cont).rbegin()) it = (cont).rbegin(); it != (cont).rend(); ++it)
#define all(cont) (cont).begin(), (cont).end()
#define rng(cont, n) cont, cont + n
#define memclr(var) memset(var, 0, sizeof(var))

typedef unsigned long long ull;
typedef long long ll;

const int INF = INT_MAX;
const int NINF = INT_MIN;
const ll INF_LL = LLONG_MAX;
const ll NINF_LL = LLONG_MIN;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;

#ifdef DEBUG
    #define debug(fmt, args...) printf("Line %d, in %s\t: " fmt, __LINE__, __FUNCTION__, ##args)
    #define rep_rt() printf("[Run time: %.3fs]\n", ((double) clock()) / CLOCKS_PER_SEC)
#else
    #define debug(...)
#endif

// end of template

#define MAXN (int) (1e5)

int arr[MAXN + 1];
int pos_val[MAXN + 1];

int main() {
#ifdef DEBUG
    freopen("agc003_c.in", "r", stdin);
#endif
    
    int n;
    scanf("%d", &n);
    rep(idx, n) scanf("%d", arr + idx);
    
    vi unq_arr(arr, arr + n);
    sort(all(unq_arr));
    unq_arr.resize(unique(all(unq_arr)) - unq_arr.begin());

    rep(idx, n) {
        arr[idx] = lower_bound(all(unq_arr), arr[idx]) - unq_arr.begin();
        pos_val[arr[idx]] = idx;
    }
    int ans = 0;
    dep(idx, n) {
        ans += abs(idx - pos_val[idx]) % 2;
    }
    printf("%d\n", ans >> 1);

#ifdef DEBUG
    rep_rt();
#endif
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    map<int, int> mp;
    for(int i=0; i<N; i++) mp[a[i]]++;

    int res = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        res += itr->second-1;
    }

    cout << ((res%2 == 0)? mp.size():mp.size()-1) << endl;
}

Measured memory_bytes: 5376
n, m = map(int, input().split())
H = list(map(int, input().split()))

g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans = 0
for i in range(n):
    flag = True
    if len(g[i]) == 0:
        ans += 1
    else:
        for v in g[i]:
            if H[v] >= H[i]:
                flag = False
                break
        if flag:
            ans += 1

print(ans)

Measured memory_bytes: 29372
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' ').map(Number))

  const N = input[0][0]
  const A = input[1]
  const B = input[2]
  const C = input[3]
  // console.log(A, B, C)

  let ans = 0
  let before = 0
  for (let i = 0; i < N; i++) {
    ans += B[A[i] - 1]
    if (A[i] === before + 1 && C[A[i] - 2]) ans += C[A[i] - 2]
    before = A[i]
  }

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064