akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  int N;
  cin >> N;
  vector<int> A(N, 0);
  rep(i, N){
    int a;
    cin >> a;
    if(N % 2){
      A[N/2-a/2]++;
      A[N/2+a/2]++;
    }else{
      A[N/2-a/2-1]++;
      A[N/2+a/2]++;
    }
  }
  ll ans = 1;
  rep(i, N){
    if(i >= (N+1)/2) continue;
    if(A[i] != 2) ans = 0;
    if(N % 2 && i == N/2){
      ans *= 1;
    }else{
      ans *= 2;
      ans %= MOD;
    }
  }
  printf("%llu\n", ans);
}


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

using namespace std;

int n,k;
int main()
{
    int rez=0;
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>k;
    while(n/k!=0){
        n/=k;
        rez+=1;
    }

    cout<<rez+1;





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
using namespace std;
 
int main(){
    
    double N,K,A[100000]={},B[100000]={},score,tmp=0,Am=0,deno=1,nume=0;


    cin >> N>>K;

    for(int i=1;i<=N;i++){
        score = i;
        tmp = 0;

            while(score<=(K-1)){
                score = score * 2;
                tmp += 1;
            }
        
        A[i] = tmp;
        if(Am<tmp){
            Am = tmp;
        }

    }

    for(int i=1;i<=N;i++){
        B[i] = Am - A[i];
        if(B[i]==0){
            nume +=1;
        }else{
            tmp =1;
            while(B[i]!=0){
                tmp = tmp * 2;
                B[i]-=1;
            }
            nume += tmp;
        }
    }

    deno = 1;

    for(int i=1;i<=Am;i++){
        deno = deno * 2;
    }

    deno = deno * N;
    
    cout << setprecision(13) << nume/deno <<endl;

    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
	int a, b, c;
	int n;
	int sum = 0;
	
	cin >> a >> b >> c;
	
	for(n=a; n<=b; n++)
		if(c%n == 0)
			sum++;
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    int x;
    cin >> x;
    x -= 400;
    x /= 200;
    x = 8 - x;
    cout << x<< endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int a, b;
  	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible";
	else cout <<"Impossible";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>A[i];
  }
  long long ans=0;
  for(int i=1;i<=N-1;i++){
  
    if(A[i]<A[i-1]){
          
      ans+=A[i-1]-A[i];
      A[i]=A[i-1];
    }
  }
  cout<<ans;
  return 0;
}

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

int main(){
    long long a,b,c,k; cin >> a >> b >> c >> k;
    long long ans;
    if(k%2==1) ans=(a-b)*(-1);
    else ans = a-b;
    if(abs(ans)>pow(10,18)) cout << "Unfair" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

int main(int argc, const char * argv[]) {
    int A,B,K;
    int k=0;
    cin>>A>>B>>K;
    for(int i=100;i>0;i--){
        if(A%i==0&&B%i==0){
            k++;
            if(k==K){cout<<i;return 0;}
        }
    }
    return 0;
}

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

using namespace std;

int main(){
	char str[3];
  	cin >> str;
    int flag = 0;
  	for(int i=0; i<3; i++){
      if(str[i] == '7'){
      		flag = flag+1;
      }
    }
  if(flag>0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <=b;++i)
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    cout << "NG";

    return 0;
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
#include <numeric>
#include <set>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


int main()
{
	Int n;
	while (cin >> n){
		vector<int> base(10);
		for (auto i = base.rbegin(); i != base.rend(); ++i){
			*i = n % 10;
			n /= 10;
		}

		REP(i, 9){
			vector<int> tmp(base.begin(), base.end());
			base.clear();
			REP(i, tmp.size() - 1){
				base.push_back((tmp[i] + tmp[i + 1]) % 10);
			}
		}
		cout << base[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int r = sc.nextInt();

      if (r < 1200) {
         System.out.println("ABC");
      }
      else if (r < 2800) {
         System.out.println("ARC");
      }
      else {
         System.out.println("AGC");
      }

   }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
    int i,N,A[100000],no[100001];
    scanf("%d",&N);
    for(i=0 ; i < N ; i++){
        scanf("%d",&A[i]);
        no[A[i]] = i+1;
    }
    for(i = 1 ; i <= N ; i++){
        printf("%d ",no[i]);
    }
    
    return 0;
}

Measured memory_bytes: 1536
import sys
import numpy as np

#n=int(sys.stdin.readline())
n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

a=n%k
print(min(a,abs(k-a)))


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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6;

void solve() {
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) {
		w << "Yes" << e;
	} else w << "No";
}


signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	
	//~ cin >> t;
	while(t--) {
		solve();
	}
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] arr = new long[n+1];
		for(int i = 0; i <= n; i++) {
			arr[i] = sc.nextInt();
		}
		if(n == 0) {
			if(arr[0] == 1) {
				System.out.println(1);
			}
			else {
				System.out.println(-1);
			}
			return;
		}
//		if(arr[0] > 0) {
//			System.out.println(-1); return;
//		}
		long[] nl = new long[n+1]; //not leaves
		for(int i = n-1; i >= 0; i--) {
			nl[i] = nl[i+1] + arr[i+1];
		}
		long max = 1;
		long res = 0;
		for(int i = 0; i <= n; i++) {
			if(nl[i] + arr[i] > max) {
				nl[i] = max - arr[i];
				if(nl[i] < 0) {
					System.out.println(-1); return;
				}
				max = 2 * nl[i];
			}
			res += nl[i] + arr[i];
		}
		System.out.println(res);
	}
	
	static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
	

}

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

int main() 
{
  int N;
  long long W,ans;
  ans=0;
  cin>>N>>W;
  long long int v[N],w[N];
  long long int sv=0;
  long long int sw=0;
  for(int i=0;i<N;i++)
  {
    cin>>w[i]>>v[i];
    sw+=w[i];
    sv+=v[i];
  }
  
  if(sw<=W)
  {
    cout<<sv;
    return 0;
  }
  
  long long int dp[N+1][sv+1];  
  for(long long int i=1;i<=sv;i++)
    dp[0][i]=sw+1;//means not possible
  
  for(int i=0; i<=N; i++)
    dp[i][0] = 0;
  
  for(int i=1; i<=N;i++)
    for(long long int j=1;j<=sv;j++)
      dp[i][j]= sw + 1;
  
  for(int i=1;i<=N;i++)
  {
    for(long long int j=0;j<=sv;j++)
    {
          if(j-v[i-1]>=0 && dp[i-1][j-v[i-1]]!=sw+1)
            dp[i][j]=min(dp[i][j],w[i-1]+dp[i-1][j-v[i-1]]);
            
          if(dp[i-1][j]!=sw+1)    
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }  
  }
  
  for(long long int j=sv;j>=0;j--)
  {
    if(dp[N][j]<=W)
    {
      ans = j;
      break;
    }
  }
  
  cout<<ans;
  
  return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI()

    return len([c for c in a if c >= k])


print(main())





Measured memory_bytes: 14960
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>

typedef long long int64;

int main(void) {
  std::string s;
  std::cin >> s;

  for (int i = 0; i < s.size(); i++) {
    s.at(i) = 'x';
  }

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int n,m,s,t,i,j,res=0;
  vector<int> v;
  cin >> n;
  cin >> s;
  for(i=1;i<n;i++){
    cin >> t;
    if(t==s+1) v.push_back(s);
    s=t;
  }
  sort(v.begin(),v.end());
  m=v.size();
  for(i=0;i<n;i++){
    cin >> t;
    res+=t;
  }
  j=0;
  for(i=1;i<n;i++){
    cin >> t;
    if(j<m&&i==v[j]){
      res+=t;
      j++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(){
    val n = readLine()!!.split(" ")[0].toLong()
    var x = 1L
    var y = 2L
    var z = 1L
    for (i in 0 until n){
        x *= 10
        x %= 1000000007
        y *= 9
        y %= 1000000007
        z *= 8
        z %= 1000000007
    }

    println((x + z - y + 2 * 1000000007) % 1000000007)
}


Measured memory_bytes: 36416
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x=read();
    int mx=0;
    for(ri int i=1;i*i<=x;i++)
    {
        mx=max(mx,i*i);
    }
    printf("%lld\n",mx);
    return 0;
}

Measured memory_bytes: 3728
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a;
        cin>>a;
        mp[a]++;
    }
    for(auto x:mp)if(x.second>1){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
signed main(){
	int n,h;cin>>n>>h;
	vector<int> a(n),b(n);
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	vector<int> orda(n),ordb(n);
	iota(All(orda),0);iota(All(ordb),0);
	sort(All(orda),[&](int x,int y){return a[x]>a[y];});
	sort(All(ordb),[&](int x,int y){return b[x]>b[y];});
	int ans=0,H=h;
	rep(i,n){
		if(0<h&&h<=b[orda[0]]) h-=b[orda[0]],ans++;
		if(h<=0) break;
		int at=b[ordb[i]];
		if(at>=a[orda[0]]&&ordb[i]!=orda[0]){ 
			h-=at;
			ans++;
		}
		
	}
	if(h>0){
		if(h<=b[orda[0]]) ans++;
		else{
			ans+=roundup(h-b[orda[0]],a[orda[0]])+1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
use proconio::{fastout, input};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: i64,
        k: usize,
    }
    let mut hs = HashSet::new();
    for _ in 0..k {
        input! {
            hate: i64,
        }
        hs.insert(hate);
    }

    let mut res = n;
    loop {
        let mut f = true;
        let mut check = res.clone();

        while check > 0 {
            // 全て含んでいない必要がある
            f &= !hs.contains(&(check % 10i64));
            check /= 10;
        }

        if f {
            break;
        }
        res += 1;
    }

    println!("{}", res);
}


Measured memory_bytes: 2192
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {

	static class State { // →bの辺の重さw
		int b, w;
		public State(int b, int w) {
			this.b = b;
			this.w = w;
		}
	}
	static class PQ implements Comparable<PQ>{
		int now;
		int d;
		public PQ(int now, int d) {
			this.now = now;
			this.d = d;
		}
		public int compareTo(PQ p) {
			return this.d - p.d;
		}
	}
	
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int V = sc.nextInt(); // 頂点数
			int E = sc.nextInt(); // 辺数
			int r = sc.nextInt(); // 初めの頂点
			int INF = Integer.MAX_VALUE;
			
			@SuppressWarnings("unchecked")
			List<State>[] edge = new ArrayList[V];
			for(int i=0; i<V; i++) {
				edge[i] = new ArrayList<State>();
			}
			PriorityQueue<PQ> pq = new PriorityQueue<>();
			for(int i=0; i<E; i++) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				int d = sc.nextInt();
				edge[s].add(new State(t, d));
			}
			int[] dis = new int[V];
			boolean[] processed = new boolean[V];
			for(int i=0; i<V; i++) {
				dis[i] = INF;
				processed[i] = false;
			}
			
			dis[r] = 0;
			pq.add(new PQ(r, 0));
			while(! pq.isEmpty()) {
				PQ p = pq.poll();
				if(processed[p.now]) {
					continue;
				}
				processed[p.now] = true;
				for(State s : edge[p.now]) {
					if(p.d+s.w < dis[s.b]) {
						dis[s.b] = p.d + s.w;
						pq.add(new PQ(s.b, dis[s.b]));
					}
				}
			}
			for(long cost : dis) {
				if(cost >= INF)	System.out.println("INF");
				else	System.out.println(cost);
			}
		}
	}

}





Measured memory_bytes: 324364
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    double a, b, n;
    cin >>a >> b >> n;

    double x = min(b-1.0, n);
    cout << floor(a*x/b) - a*floor(x/b) << endl;

    return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder out = new StringBuilder();
		while (true) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if (n == 0 && x == 0)
				break;
			int cnt = 0;
			for (int fi = 1; fi <= n - 2; ++fi) {
				for (int si = fi + 1; si <= n - 1; ++si) {
					for (int ti = si + 1; ti <= n; ++ti) {
						if (fi + si + ti == x)
							++cnt;
					}
				}
			}
			out.append(cnt + "\n");
		}
		System.out.print(out);
	}
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, m, x, y;
    cin>> n>> m>> x>> y;

    int x1[n+1], y1[m+1];

    for(int i= 0; i<n; i++)
        cin>> x1[i];
    x1[n]= x;


    for(int i= 0; i<m; i++)
        cin>> y1[i];
    y1[m]= y;

    sort (x1, x1+n+1);
    sort (y1, y1+m+1);


    cout << (y1[0] -x1[n] > 0 ? "No War\n" :"War\n" );

    return 0;
}




Measured memory_bytes: 3620
#include <stdio.h>
int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a >= b) {
        printf("1\n");
    } else {
        if (b % a == 0) {
            printf("%d\n", b / a);
        } else {
            printf("%d\n", b / a + 1);
        }
    }
    return 0;
}


Measured memory_bytes: 2036
S=input()

count_even=0
count_odd=0

odd=['R','U','D']
even=['L','U','D']

for i in range(len(S)):
    if (i+1)%2==0:
        if(S[i] in even):
            count_even+=1
    else:
        if(S[i] in odd):
            count_odd+=1

if(count_odd + count_even == len(S)):
    print('Yes')
else:
    print('No')

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

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		string s;
		cin >> s;
		if (s == "AC") c[0]++;
		else if (s == "WA") c[1]++;
		else if (s == "TLE") c[2]++;
		else c[3]++;
	}
	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

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

priority_queue<double,vector<double>,greater<double>> que;

int main(){
  ll N;
  cin>>N;
  REP(i,N){
    double v;
    cin>>v;
    que.push(v);
  }
  REP(i,N-1){
    double u,v,m;
    u=que.top(),que.pop();
    v=que.top(),que.pop();
    m=(u+v)/2;
    que.push(m);
  }
  printf("%.6f\n",que.top());

}


Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args){
    		 Scanner sc = new Scanner(System.in);
    		 int R = sc.nextInt();
     
    		 int G = sc.nextInt();
     
    		 int B = sc.nextInt();
     
    		 if(((R * 100) + (G * 10) + B) % 4 ==0) {
    			 System.out.println("YES");
    		 }else {
    			 System.out.println("NO");
    		 }
     
    	}
    }

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl "\n"
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin >> s;
    fr(i, s.length())
    {
        if (s[i] == '?')
            s[i] = 'D';
    }
    cout << s;
}

Measured memory_bytes: 3720
use std::io::*;
use std::str::FromStr;
use std::f64;

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

fn kock(n: u8, p1: (f64, f64), p2: (f64, f64)) {
    if n == 0 {
        return;
    }
    let s: (f64, f64) = ((2.0*p1.0+1.0*p2.0)/3.0,(2.0*p1.1+1.0*p2.1)/3.0);
    let t: (f64, f64) = ((1.0*p1.0+2.0*p2.0)/3.0,(1.0*p1.1+2.0*p2.1)/3.0);
    let u: (f64, f64) = ((t.0 -s.0)*((1.0/3.0) * f64::consts::PI).cos() - (t.1 -s.1)*((1.0/3.0) * f64::consts::PI).sin() + s.0, (t.0 -s.0)*((1.0/3.0) * f64::consts::PI).sin() + (t.1 - s.1)*((1.0/3.0) * f64::consts::PI).cos() + s.1);
    kock(n-1, p1, s);
    println!("{} {}", s.0, s.1);
    kock(n-1, s, u);
    println!("{} {}", u.0, u.1);
    kock(n-1, u, t);
    println!("{} {}", t.0, t.1);
    kock(n-1, t, p2);
}

fn main() {
    let n: u8 = read();
    println!("0.0 0.0");
    kock(n, (0.0,0.0), (100.0,0.0));
    println!("100.0 0.0");
}



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

typedef long long ll;

int check(int c){
  if(c<400) return 0;
  else if(c<800) return 1;
  else if(c<1200) return 2;
  else if(c<1600) return 3;
  else if(c<2000) return 4;
  else if(c<2400) return 5;
  else if(c<2800) return 6;
  else if(c<3200) return 7;
  else return 8;
}

 
int main(){
  vector<int> m(8, 0);
  int n;
  cin >> n;
  int free = 0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    int c = check(a);
    if(c==8) free++;
    else m[c] += 1;
  }
  int ans = 0;
  for(int i=0; i<8; i++){
    if(m[i]>0) ans++;
  }
  int mans = ans;
  if(ans==0) mans+=1;
  cout << mans << " ";
  ans += free;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 3e5 + 7;
 
int main()
{      
	speed;
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	for ( int i = 0; a[i]; i++ ) {
		cout << a[i] << b[i];
	}
	time; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

// 2 <= N <= 80, 100 <= Ai <= 200から、動的計画法だなとわかる。
// あり得る状態として、i日目の取引を始める前の時点で
// (持っている所持金)と(持っている株の枚数)の二通り
// いや、(買った株の枚数)と(売った株の枚数)と(持っている所持金)の三つか?
// 最もお金を増やせるパターンとして、100円の株をありったけ買って、翌日200円になった株をすべて売るパターン
// とすると、二日おきに所持金が高々二倍になる
// だから、持てる所持金の合計は1000×2^40 =... となり、10^{10}は超えそう
// だから、
// DP[n][i][j] := n日目の取引を始める直前の時点でi枚買い、j枚売った時の所持金の最大値
// として、max_{i, j}DP[N][i][j]を答えればOK
// 持てる株の最大数は、10×2^40 = ... いや、無理じゃん

// どうやら、
// ・株を買うときは、必ず全財産をつぎ込む
// ・株を売るときは、必ず持っている株をすべて売る
// の二通りの方法が一番最適となる。

// なので、
// DP[x] := x日目に、株の売却が終了した時点の所持金の最大値
// として、
// DP[i] := max(DP[i-1], DP[j-1]/A_j*A_i + DP[j-1]%A_j ) (1 <= j <= N-1)
// となる

int main() {
    int N;
    cin >> N;
    V<int> A(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    V<long long> dp(N + 1, 0LL);
    dp[0] = 1000;
    for (int i = 1; i <= N; ++i) {
        dp[i] = dp[i - 1];
        for (int j = 0; j <= i - 1; ++j) {
            dp[i] = max(dp[i], dp[j] % A[j] + dp[j] / A[j] * A[i - 1]);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    ll a=0,b=0,d=0,n=0;
    //VI a(N);
    string s,s1,s2;
    cin >> n;
    VI x(n);
    VI y(n);
    rep(i,n){
        cin >> x[i];
        y[i]=x[i];
    }
    sort(ALL(y));
    rep(i,n-1){
        if((x[i] != y[i]))
            d++;
    }
    if(d <= 2) cout << "YES" <<endl; 
    else cout << "NO" <<endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int m, f, h;
    while(1){
        cin >> m >> f >> h;
        if(m==-1&&f==-1&&h==-1){
            break;
        } else if(m==-1||f==-1){
            cout << "F" << endl;
            continue;
        }else if(m+f>=80) {
            cout << "A" << endl; 
            continue;
        } else if(m+f>=65&&m+f<80) {
             cout << "B" << endl;
             continue;
        } else if(m+f>=50&&m+f<65) {
            cout << "C" << endl;
            continue;
        } else if(m+f<30) {
            cout << "F" << endl;
            continue;
        } else if(m+f<50&&m+f>=30&&h>=50) {
            cout << "C" << endl;
            continue;
        } else if(m+f<50&&m+f>=30&&h<50) {
            cout << "D" << endl;
            continue;
        }
    }
    return 0;
}


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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  
  if (A + B != 0){
  
    if (N % (A + B) == 0){
      cout << A * (N / (A + B)) << endl;
    }
    else{
    
      if (N % (A + B) < A){
        cout << A * (N / (A + B)) + N % (A + B) << endl;
      }
      else{
        cout << A * (N / (A + B)) + A << endl;
      }
    }
  }
  else{
    cout << 0 << endl;
  }
}
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<long long> a;
    long long tmp;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        a.push(tmp);
    }
    for (int i = 0; i < m; i++){
        tmp = a.top();
        a.pop();
        tmp /= 2;
        a.push(tmp);
    }
    long long sum_a = 0;
    for (int i = 0; i < n; i++){
        sum_a += a.top();
        a.pop();
    }
    cout << sum_a << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;

int main()
{
	int i, j, k;
	ll n, s;
	scanf("%lld%lld", &n, &s);
	ll tmp;
	if (n == s) {
		printf("%lld", n + 1);
		return 0;
	}
	vector<ll> candidates;
	for (ll d = 2; d *d <= n; ++d) {
		tmp = n;
		ll sum = 0;
		while (tmp > 0) {
			sum += tmp % d;
			tmp /= d;
		}
		if (sum == s) {
			printf("%lld", d);
			return 0;
		}
	}


	tmp = abs(n - s);
	vector<ll> factors;
	ll check = sqrt(tmp);
	for (ll d = 1; d*d <= tmp; ++d) {
		if (tmp %d == 0) {
			factors.push_back(d);
			if (tmp / d != d) factors.push_back(tmp / d);
		}
	}
	for (i = 0; i < factors.size(); ++i) {
		ll d = factors[i];
		if (d > check) continue;
		if (tmp % d == 0) {
			ll b = tmp / d + 1;
			if (n / b + n % b == s) {		
				candidates.push_back(b);
			}
			
		}
	}
	sort(candidates.begin(), candidates.end());
	if (candidates.empty()) printf("-1");
	else printf("%lld", candidates[0]);
}

Measured memory_bytes: 256
n=int(input())
x1=[[int(0) for i in range(10)]for j in range(3)]
x2=[[int(0) for i in range(10)]for j in range(3)]
x3=[[int(0) for i in range(10)]for j in range(3)]
x4=[[int(0) for i in range(10)]for j in range(3)]

for i in range(n):
    b,f,r,v=[int(s) for s in input().split()]
    if b==1:
        x1[f-1][r-1]=x1[f-1][r-1]+v
    elif b==2:
        x2[f-1][r-1]=x2[f-1][r-1]+v
    elif b==3:
        x3[f-1][r-1]=x3[f-1][r-1]+v
    else:
        x4[f-1][r-1]=x4[f-1][r-1]+v
for j in range(3):
    for k in range(10):
        print("",x1[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x2[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x3[j][k],end="")
    print("")
for n in range(20):
    print('#',end="")
print("")
for j in range(3):
    for k in range(10):
        print("",x4[j][k],end="")
    print("")

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

int main(){
  int n,x;
  cin >> n >> x;
  
  vector<int> okashi(n);
  for(int i=0; i<n; i++){
    cin >> okashi.at(i);
  }
  
   sort(okashi.begin(), okashi.end());
  
  int count = 0;
  
  for (int i=0; i<n; i++){
    if (x >= okashi.at(i)){
      if(i == n-1 && x != okashi.at(i)){
        break;
      }
      else{
        x -= okashi.at(i);
        count++;
      }
    }
    else{
      break;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
7
500 600
*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	boolean flag = false;
	for(int i = a;i<= b;i++){
	    if(i%k  == 0){
	        flag  = true;
	        break;
	    }
	    
	    }
	    
	    if(!flag){
	        System.out.println("NG");
	    }else
	     System.out.println("OK");
	}
	
	}



Measured memory_bytes: 35808
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n,m;
  while(1){
    cin>>n;
    if(n==0)break;

    pair<int,int>p[22];
    for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;

    cin>>m;
    int x=10,y=10;
    int cnt=0;
    for(int i=0;i<m;i++){
      char a;int b;
      cin>>a>>b;
      
      if(a=='N'){

	for(int j=0;j<n;j++){
	  if(x==p[j].first&&y<=p[j].second&&p[j].second<=y+b){
	    cnt++;
	    p[j].first=INF;p[j].second=INF;
	  }
	}
	y+=b;
	
      }else if(a=='S'){

	for(int j=0;j<n;j++){
	  if(x==p[j].first&&y-b<=p[j].second&&p[j].second<=y){
	    cnt++;
	    p[j].first=INF;p[j].second=INF;
	  }
	  
	}

	y-=b;
	
      }else if(a=='W'){

	for(int j=0;j<n;j++){
	  if(y==p[j].second&&x-b<=p[j].first&&p[j].first<=x){
	    cnt++;
	    p[j].first=INF;p[j].second=INF;
	  }
	  
	}
	x-=b;
	
      }else if(a=='E'){

	for(int j=0;j<n;j++){
	  if(y==p[j].second&&x<=p[j].first&&p[j].first<=x+b){
	    cnt++;
	    p[j].first=INF;p[j].second=INF;
	  }
      
	}
	x+=b;
	
      }
      if(debug)cout<<"("<<x<<","<<y<<")"<<endl;
    }
    if(cnt==n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> x;
    for(int i=0; i<N; i++)
    {
    	int a;
    	cin >> a;
    	x.push_back(a);
    }
    int dist = 0;
    for(int i=0; i<N; i++)
    {
    	int A = x[i];
    	int B = abs(K-x[i]);
    	dist += min(A,B)*2;
    }
    cout << dist << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define N 100005
int n,ans,a[N],bit[N*4],s[N];
void add(int x){for(;x<N*4;x+=x&-x)bit[x]++;}
int qry(int x){int res=0;for(;x;x-=x&-x)res+=bit[x];return res;}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int l=0,r=1e9;l<=r;)
	{
		memset(bit,0,sizeof(bit));
		int mid=l+r>>1;long long res=0;
		add(n+1);
		for(int i=0;i<n;i++)
		{
			s[i]=(i?s[i-1]:0)+(a[i]>=mid?1:-1);
			res+=qry(s[i]+n+1);add(s[i]+n+1);
		}
		if(res>=1ll*n*(n+1)/2-res)ans=mid,l=mid+1;else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int a,b,n;
    vector<vector<int> > p;
    vector<int> temp;

    int x,y;
    cin >> a >> b;
    while(a!=0 && b!=0) {
        cin >> n;
        for(int i=0; i<=a; ++i) {
            for(int j=0; j<=b; ++j) {
                temp.push_back(0);
            }
            p.push_back(temp);
            temp.clear();
        }

        for(int i=0; i<n; ++i) {
            cin >> x >> y;
            p[x][y]=-1;
        }

        p[0][1]=1;
        for(int i=1; i<=a; ++i) {
            for(int j=1; j<=b; ++j) {
                if(p[i][j]!=-1) {
                    p[i][j]+=p[i][j-1]+p[i-1][j];
                } else {
                    p[i][j]=0;
                }
            }
        }
        cout << p[a][b] << endl;
        cin >> a >> b;
        p.clear();
    }

    return 0;
}

Measured memory_bytes: 3056
import numpy as np
N = int(input())
a_list = list(map(int, input().split()))
class_list = []
free_list = []
for a in a_list:  
  if a < 3200:
    amod = a // 400
    class_list.append(amod)
  
  else:
    free_list.append(a)

set_list = list(set(class_list))
min_list = len(set_list)
max_list = len(set_list) + len(free_list)

if min_list == 0:
  min_list = 1
print(min_list, max_list)
    

  



Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
int saihin(vector<int> v,int n){//一番多く出てくる数と2番目に多く出てくる数を調べる
  int max1=0,max2=0,index1=-10,index2=-20;
  /*vector<int> vec(200000);
  max1 = 0;
  max2 = 0;
  index1 = -10;
  index2 = -20;
  for(int i=0; i<200000; i++){
    vec.at(i) = 0;
  }
  for(int i=0; i<v.size(); i++){
    vec.at(v.at(i)-1)++;
  }
  
  for(int i=0; i<6; i++){
    cout << vec.at(i) << " ";
  }
  cout << endl;
  
  for(int i=0; i<200000; i++){
    if(max1 <= vec.at(i)){
      max1 = vec.at(i);
      index2 = index1;
      max2 = max1;
      index1 = i+1;
      }
    if(max1 >= vec.at(i) && max2 <= vec.at(i) && index1 != i+1){
      max2 = vec.at(i);
      index2 = i+1;
      }
    }*/
  vector<int> m(100000);
  for(int i=0; i<100001; i++){
    m[i] = 0;
  }
  for(int i=0; i<v.size(); i++){
    m[v.at(i)]++;
  }
  for(int i=1; i<100001; i++){
    if(max1 < m[i]){
      max2 = max1;
      index2 = index1;
      max1 = m[i];
      index1 = i;
    }else{
      if(max2 < m[i]){
        max2 = m[i];
        index2 = i;
      }
    }
  }
  if(n==1){return index1;}
  if(n==2){return index2;}
}

int igai(vector<int> v,int n){
  int cntigai = 0;
  for(int i=0; i<v.size(); i++){
    if(v.at(i) != n){
      cntigai++;
    }
  }
  return cntigai;
}

int main(){
  int n;
  cin >> n;
  vector<int> e(n/2);
  vector<int> o(n/2);
  for(int i=0; i<n/2; i++){
    cin >> e.at(i) >> o.at(i);
  }
  int e1 = saihin(e,1);
  int e2 = saihin(e,2);
  int o1 = saihin(o,1);
  int o2 = saihin(o,2);
  
 
/*  cout << e1 << e2 << o1 << o2 <<endl;
  for(int i=0; i<n/2; i++){
    cout << e.at(i) << " ";
  }  
  cout << endl;
  for(int i=0; i<n/2; i++){
    cout << o.at(i) << " ";
  }
  cout << endl;*/
  
  
  if(e1 != o1){
    cout << igai(e,e1)+igai(o,o1) << endl;
  }else{
    cout << min(igai(e,e1)+igai(o,o2),igai(e,e2)+igai(o,o1)) << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(b>c&&d>a)
    {
    printf("%d",abs(min(b,d)-max(a,c)));
    }
    else
    {
        printf("0");
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<int> dp(3);
    	for(int day=0; day<n;day++) {
            vector<int> new_dp(3, 0);
            vector<int> c(3);
    		for(int i=0; i<3; i++) {
                in >> c[i];
    		}
    		for(int i=0; i<3;i++) {
    			for(int j=0; j<3; j++) {
    				if(i!=j) {
                        new_dp[j] = max(new_dp[j], dp[i] + c[j]);
    				}
    			}
    		}
            dp = new_dp;
    	}
        out << max({ dp[0],dp[1],dp[2] });
    	
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

int main()
{
    int x; cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}
/*
Ctrl+@
g++ a.cpp
./a.out
*/

Measured memory_bytes: 3632
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextLong();


        long ans = 0;
        long count =0;
        long life = H;
        while(life != 0){
            life = life / 2;
            ans += Math.pow(2,count);
            count++;
        }

        System.out.println(ans);


    }

}






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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (auto &e : a) {
		cin >> e;
	}
	vector<vector<int>> b(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		b[0][i] = a[i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			b[i][j] = min(b[i - 1][j], a[(n + j - i) % n]);
		}
	}
	vector<ll> s(n);
	for (int i = 0; i < n; i++) {
		s[i] = (ll)i * x;
		for (int j = 0; j < n; j++) {
			s[i] += b[i][j];
		}
	}
	ll m = s.front();
	for (auto e : s) {
		if (e < m) {
			m = e;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 16000
N=int(input())
s=input()
tmp = 0
for i in s[1:]:
    if i == "E":
        tmp += 1
ans = tmp
for i in range(1,N):
    if s[i] =="W" and s[i-1]=="W":
        tmp += 1
    elif s[i]=="E" and s[i-1]=="E":
        tmp -=1
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 43736
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long H = scan.nextInt();
        long W = scan.nextInt();
        if (H == 1 || W == 1) {
            System.out.println(1);
            return;
        }
        long ans = H * (W / 2);
        if (W % 2 == 1) {
            ans += H / 2;
            if (H % 2 == 1) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22608
#pragma GCC optimize("Ofast") 

////////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define print(...) for(auto xas:{__VA_ARGS__})cerr<<xas<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)
#define coutd(x,y) printf("%0.y lf",x);

////////////////////////////////////////////////////////////////////////////////

typedef vector<int> vec; 
typedef pair<int, int> pa; 
typedef vector<pa> vecp; 
typedef set<int> se;
typedef map<int,int> ma;

////////////////////////////////////////////////////////////////////////////////


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

int expo(int a,int n)
{
    if(n==0)
        return 1;
    if(n==1)
        return a;
    int tmp=expo(a,n/2);
    tmp=(tmp*tmp)%mod;
    if(n&1)
        tmp=(tmp*a)%mod;
    return tmp;
}


////////////////////////////////////////////////////////////////////////////////



signed main() {
bew;
    tar(n);
    tar(m);
    vec ar(m);
    ip(ar,m);
    
    int x=accumulate(all(ar),0);
    if(n-x<0)
    cout<<-1;
    else
    cout<<n-x;



return 0;
}

Measured memory_bytes: 3700