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

int main(void){

    int a,b,aa,bb;
    scanf("%d %d",&a,&b);
    int flag=0;
    for(int c=0;c<=1000000000;c++){
        aa=a-c;
        bb=b-c;
        if(abs(aa)==abs(bb)){
            printf("%d",c);
            flag=1;
        }
    }
    if(flag==0){
        printf("IMPOSSIBLE");
    }
    return 0;
}

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

int s[205];

int main() {
  while (true) {
    int m, nmin, nmax;
    cin >> m >> nmin >> nmax;

    if ((m | nmin | nmax) == 0)
      break;

    for (int i = 1; i <= m; i++)
      cin >> s[i];

    int mv = nmin;
    for (int i = nmin; i <= nmax; i++)
      if (s[i] - s[i + 1] >= s[mv] - s[mv + 1])
        mv = i;
    cout << mv << endl;
  }
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    double pi = 3.141592653589793238;
    int a, b, h, m; cin >> a >> b >> h >> m;
    double ax = a * cos(2.0*pi*(h+m/60.0)/12.0);
    double ay = a * sin(2.0*pi*(h+m/60.0)/12.0);
    double bx = b * cos(2.0*pi*m/60.0);
    double by = b * sin(2.0*pi*m/60.0);
    double ans = sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 4144
#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),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

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);
const ll mod=1000000007;
const ll mod2=998244353;

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll n,m,q,ans=0;
vll a,b,c,d;

void dfs(vll A){
	if((ll)A.size()==n+1){
		ll now=0;
		rep(i,q){
			if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
		}
		chmax(ans,now);
		return;
	}
	A.pb(A.back());
	while(A.back()<=m){
		dfs(A);
		A.back()++;
	}
}

int main()
{
	cin >> n >> m >> q;
	a=b=c=d=vll(q);
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vll(1,1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define maxx 1000001
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main() {
    FASTIO
    string a,b,c,d;
    cin>>a>>b>>c;
    d[0]=a[0];d[1]=b[1];d[2]=c[2];
    cout<<d[0]<<d[1]<<d[2]<<endl;
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int N, P;
ll A[51];
ll dp[51][100*50+1];

ll solve(int idx, int sum) {
    if (idx >= N) {
        return sum%2 == P;
    }
    ll& res = dp[idx][sum];
    if (res != -1) return res;
    res = 0;
    res += solve(idx+1, sum);
    res += solve(idx+1, sum+A[idx]);
    return res;
}

int main() {
    cin >> N >> P;
    rep(i, N) cin >> A[i];
    fill(dp[0], dp[N], -1);
    cout << solve(0, 0) << endl;
    return 0;
}


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int i, int j, int h, int w, char tmp[][21])
{
    int ans[21][21] = {0};
    char c[21][21] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i<=h; i++){
        for(int j=0; j<=w; j++){
            c[i][j] = tmp[i][j];
        }
    }

        s.push(make_pair(i, j));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int a = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            a = max(a, ans[i][j]);
        }
    }

    return a;
}


int main()
{
    double N, K;
    cin >> N >> K;

    double ans = 0.0;
    for (ll i = 1; i <= N; i++)
    {
        float tmp = ceil(log2(K * 1.0) - log2(i * 1.0));
        if(tmp > 0.0){
            ans += (1.0 / N) * pow(0.5, tmp);
        }
        else{
            ans += (1.0 / N);
        }
    }

    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = [[] for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        B[i].append((x-1, y))
ans = 0
for s in range(1<<N):
    flag1 = True
    cnt = 0
    for i in range(N):
        if s&(1<<i):
            cnt+=1
            flag2 = True
            for x, y in B[i]:
                if ((s>>x)&1) != y:
                    flag2 = False
                    break
            if not flag2:
                flag1 = False
    if flag1:
        ans = max(ans, cnt)
print(ans)

                



Measured memory_bytes: 43628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	char s[101];
	char t[101];
	scanf("%s %s", s, t);

	bool ans = false;

	for(int i=0;i<strlen(s);i++){
		char s2[101];
      memset(s2,0,sizeof(s2));
		for(int j=i;j<strlen(s);j++){
			s2[j] = s[j-i];
		}
		for(int j=0;j<i;j++){
			s2[j] = s[strlen(s)-i+j];
		}
      
		//printf("%s\n",s2);
      
		if(strcmp(s2,t)==0){
			ans = true;
			printf("Yes\n");
			return 0;
		}
	}

	if(ans){
		printf("Yes\n");
	}else{
		printf("No\n" );
	}

	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double ans = 0;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        double b = 1.0 / n;
        int a = 0;
        int j = i;
        while (j < k) {
            j <<= 1;
            a++;
        }
        ans += b * pow(0.5, a);
    }
    printf("%.20f\n", ans);
}

Measured memory_bytes: 512
import heapq
from collections import defaultdict
n,m = map(int,input().split())
day = []
d = defaultdict(list)
for i in range(n):
    a,b = map(int,input().split())
    d[a].append(b)
task = []
cost = 0
heapq.heapify(task)
for i in range(1,m+1):
    for j in d[i]:
        heapq.heappush(task,-j)
        #print(task,j)
    if task != []:
        c = heapq.heappop(task)
        cost += (-1)*c  
print(cost)


Measured memory_bytes: 27772
#include <iostream>
#include<algorithm>
using namespace std;
int main(void)
{
  int i,n,k,h[100000],ans=1000000001;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    cin>>h[i];
  
  }
  sort(h,h+n);
  for(i=0;i<n-k+1;i++)
  {
    if(h[i+k-1]-h[i]<ans){ans=h[i+k-1]-h[i];}
  
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 4036
#include <stdio.h>


int temp[100]; 

void MergeSort(int x[ ], int left, int right);
int main(void);

  /* 配列 x[ ] の left から right の要素のマージソートを行う */
void MergeSort(int x[ ], int left, int right)
{
    int mid, i, j, k;
	
    if (left >= right)              /* 配列の要素がひとつなら */
        return;                     /* 何もしないで戻る */

                                    /* ここでは分割しているだけ */
    mid = (left + right) / 2;       /* 中央の値より */
    MergeSort(x, left, mid);        /* 左を再帰呼び出し */
    MergeSort(x, mid + 1, right);   /* 右を再帰呼び出し */

      /* x[left] から x[mid] を作業領域にコピー */
    for (i = left; i <= mid; i++)
        temp[i] = x[i];

      /* x[mid + 1] から x[right] は逆順にコピー */
    for (i = mid + 1, j = right; i <= right; i++, j--)
        temp[i] = x[j];

    i = left;         /* i とj は作業領域のデーターを */
    j = right;        /* k は配列の要素を指している */

    for (k = left; k <= right; k++)    /* 小さい方から配列に戻す */
        if (temp[i] <= temp[j])        /* ここでソートされる */
            x[k] = temp[i++];
        else
            x[k] = temp[j--];
}

int main(void)
{
    int N,i,sum=0,sum2=0;
      /* ソートされるデータ */
    int a[100] = {};
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{scanf("%d",&a[i]);}

    MergeSort(a, 0, N - 1);
if(N%2==0)
{for (i = N-1; i > 0; i=i-2)
	{
    sum += a[i];
	sum2 += a[i-1];
	}}
else
{for (i = N-1; i > 1; i=i-2)
	{
    sum += a[i];
	sum2 += a[i-1];
	}
	sum += a[0];
}
	printf("%d\n",sum-sum2);
        
		return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int duzina[101][10001],prethodni[1001][1001];

int main()
{
    int N, M,W[101],P[101],optimalni[1000];
    int i,j;

    scanf("%d",&N);
    scanf("%d",&M);

    for(i=0; i<N; ++i)
    {    
        scanf("%d",&P[i]);
         scanf("%d",&W[i]);
    }

    for(i=0; i<=M; ++i)
    {
        duzina[0][i]=0;
        prethodni[0][i]=0;
    }

    for(i=1; i<=N;++i)
    {
        for(j=0; j<=M;++j)
        {

            if(W[i-1]>j){duzina[i][j]=duzina[i-1][j]; continue;}

            int k;

            k=((j-W[i-1])>0)?duzina[i-1][j-W[i-1]]:0;


            if(duzina[i-1][j]>(k+P[i-1]))
            {
                duzina[i][j]=duzina[i-1][j];
                prethodni[i][j]=0;
            }
            else
            {
                duzina[i][j]=k+P[i-1];
                prethodni[i][j]=1;
            }

        }
    }


    printf("%d\n",duzina[N][M]);



    return 0;
}

Measured memory_bytes: 6844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=0;
    if(a+b>2*c){
        if(x>y){
            ans+=y*c*2;
            if(a>c*2){
                ans+=c*2*(x-y);
            }else{
                ans+=a*(x-y);
            }
        }else{
            ans+=x*c*2;
            if(b>c*2){
                ans+=c*2*(y-x);
            }else{
                ans+=b*(y-x);
            }
        }
    }else{
        ans=x*a+y*b;
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
import numpy as np

def main():
    x = int(input())
    money = 100
    ans = 0
    while x > money:
        money += money * 0.01
        ans += 1
        money = np.floor(money)
        #print(money)
        #print(ans)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26988
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  int ans = 0;
  vector<int> s(N); REP(i, N) {
    cin >> s[i];
    ans += s[i];
  }
  sort(ALL(s));
  if (ans % 10 == 0) {
    REP(i, N) {
      if (s[i] % 10 != 0) {
        ans -= s[i];
        break;
      }
    }
  }
  if (ans % 10 == 0) cout << 0 << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S, R = "yuiophjklnm";
  while (cin >> S, S != "#") {
    int ans = -1, s = 0, t, l;
    size_t m = -1;
    l = S.size();
    for (int i = 0; i < l; ++i) {
      if (R.find(S[i]) != m) t = 1;
      else t = -1;
      if (t != s) ++ans;
      s = t;
    }
    cout << ans << endl;
  }
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int T = sc.nextInt();
		int A = sc.nextInt()*T, B = sc.nextInt();
		if(A > B) System.out.println(B);
		else System.out.println(A);
	}

}


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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll h,s=0;

    cin>>h;

    for(ll i=1;h;i*=2)
    {
        s+=i;
        h/=2;
    }

    cout<<s<<endl;

    return 0;
}


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

partial class Solver {
    public void Run() {
        var A = ni();
        var B = ni();
        var AB = ni();
        var X = ni();
        var Y = ni();

        var ABcands = new[] { 0, X, Y };

        int ans = int.MaxValue;

        foreach (var abNum in ABcands) {
            var cost = abNum * AB * 2;
            cost += A * Math.Max(0, X - abNum);
            cost += B * Math.Max(0, Y - abNum);

            ans = Math.Min(ans, cost);
        }

        cout.WriteLine(ans);
    }
}

// PREWRITEN CODE BEGINS FROM HERE
partial class Solver : Scanner {
    public static void Main(string[] args) {
        new Solver(Console.In, Console.Out).Run();
    }

    TextReader cin;
    TextWriter cout;

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        this.cin = reader;
        this.cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

    public int ni() { return NextInt(); }
    public int[] ni(int n) { return NextIntArray(n); }
    public long nl() { return NextLong(); }
    public long[] nl(int n) { return NextLongArray(n); }
    public double nd() { return NextDouble(); }
    public string ns() { return Next(); }
}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private CultureInfo ci = CultureInfo.InvariantCulture;

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public int NextInt() { return Int32.Parse(Next(), ci); }
    public long NextLong() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt();
        return array;
    }

    public long[] NextLongArray(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextLong();
        return array;
    }

    public String Next() {
        if (TokenQueue.Count == 0) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N;
	scanf("%d", &N);
	int *A = (int*)malloc(sizeof(int) * N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int cnt = 0;
	int tmp;
	int pos = 1;
	int ok = 0;
	tmp = pos;
	int ans;
	while (cnt<=N+1) {
		tmp = A[tmp-1];
		cnt++;
		if(tmp==2){
			ok=1;
			break;
		}
	}
	if (ok) {
		ans = cnt;
		printf("%d\n", ans);
	}
	else {
		printf("%d\n", -1);
	}





#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i < N; ++i) {
        cin >> S.at(i);
        if(S.at(i) == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(M, vector<int>(2));
    for(int i=0; i<M; ++i){
        for(int j=0; j<2; ++j){
            cin >> A.at(i).at(j);
        }
    }

    vector<int> B(N+1, 0);

    for(int k=1; k<=N; ++k){
        for(int i=0; i<M; ++i){
            for(int j=0; j<2; ++j){
                if(A.at(i).at(j) == k) B.at(k)++;
            }
        }
    }
    for(int k=1; k<=N; ++k){
        cout << B.at(k) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt(),g = scanner.nextInt(),b = scanner.nextInt();
		int n = r * 100 + g * 10 + b;
		if(n % 4 == 0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 20692
/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("Ofast,no-stack-protector")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef long long  ll;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
#endif
const int N = 100001;
int a[N];
bool dp[N][2];
int main()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	int n; cin >> n;
	fr(i, n) cin >> a[i];
	dp[0][0] = 1;
	dp[0][1] = 1;
	for (int i = 1; i < n; ++i)
	{
		dp[i][0] = (dp[i - 1][0] && a[i - 1] <= a[i]) || (dp[i - 1][1] && a[i - 1] - 1 <= a[i]);
		dp[i][1] = (dp[i - 1][0] && a[i - 1] <= a[i]-1) || (dp[i - 1][1] && a[i - 1] - 1 <= a[i]-1);
	}
	if (dp[n - 1][0] || dp[n - 1][1])
	{
		cout << "Yes";
	}
	else cout << "No";
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <fstream>

using namespace std;

int main(){
    int n, t;
    cin >> n >> t;
    int minC = 100000;

    for (int i = 0; i < n; i++){
        int c, ti;
        cin >> c >> ti;
        if (ti > t) continue;
        if (c < minC) minC = c;
    }
    
    if (minC != 100000) cout << minC << "\n";
    else cout << "TLE\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

vvi G;
vi even, odd;
void dfs(int v, int pre, int d){
    if(d & 1)odd.push_back(v);
    else even.push_back(v);
    for(auto nv: G[v]){
        if(pre == nv)continue;
        dfs(nv, v, d + 1);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    G.resize(N);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,-1,0);
    vi nums[3];
    rep1(i,N+1){
        nums[i % 3].push_back(i);
    }
    //色塗りをする
    vi ans(N, -1);
    //evenのほうが小さい保証
    if(even.size() > odd.size()){
        swap(even, odd);
    }
    //両方入る場合
    if(even.size() >= max(nums[1].size(),  nums[2].size())){
        rep(i,nums[1].size()){
            ans[even[i]] = nums[1][i];
        }
        rep(i, nums[2].size()){
            ans[odd[i]] = nums[2][i];
        }
        int idx = 0;
        for(int i = 0; i < N; i++){
            if(ans[i] == -1){
                ans[i] = nums[0][idx];
                idx++;
            }
        }
    }
    else{
        //このとき、even.size() <= num[0].size()
        //evenを0埋めする
        rep(i, even.size()){
            ans[even[i]] = nums[0][i];
        }
        //残りの0をoddへ
        int idx = 0;
        for(int i = even.size(); i < (int)nums[0].size();i++){
            ans[odd[idx]] = nums[0][i];
            idx++;
        }
        rep(i, nums[1].size()){
            ans[odd[idx]] = nums[1][i];
            idx++;
        }
        rep(i,nums[2].size()){
            ans[odd[idx]] = nums[2][i];
            idx++;
        }
    }
    rep(i,N){
        cout<<ans[i];
        if(i == N-1)cout<<endl;
        else cout<<" ";
    }
}

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> d(k);
    map<int,int> mp;
    
    rep(i,k){
        cin >> d[i];
        int a[k][d[i]];
        rep(j,d[i]){
            cin >> a[i][j];
            mp[a[i][j]]++;
        }

    }
    
    put(n-mp.size());
}

Measured memory_bytes: 3632
s = input()

i=1
tmp1 = s[0]
ans1 = 1

while i<len(s):
    if len(tmp1) == 2:
        tmp1 = s[i]
        i+=1
        ans1+=1
    elif tmp1 == s[i]:
        if i<len(s)-1:
            tmp1 = s[i] + s[i+1]
            i += 2
            ans1 +=1
        else:
            break
    else:
        tmp1 = s[i]
        i+=1
        ans1+=1

tmp2 = s[0] + s[1]
ans2 = 1
i=2
while i<len(s):
    if len(tmp2) == 2:
        tmp2 = s[i]
        i+=1
        ans2+=1
    elif tmp2 == s[i]:
        if i<len(s)-1:
            tmp2 = s[i] + s[i+1]
            i += 2
            ans2 +=1
        else:
            break
    else:
        tmp2 = s[i]
        i+=1
        ans2+=1

print(max(ans1,ans2))

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int N = n[0], X = n[1];
        int[] D = new int[N];
        for (int i = 0; i < N; i++) D[i] = intRead();
        Array.Sort(D);
        Console.WriteLine(N + (X - D.Sum()) / D[0]);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
ll a[10];
int main(){
	for(int i=1;i<=5;i++){
		a[i]=read();
		if(a[i]==0) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 3696
N,M = (int(X) for X in input().split())
if N>=M:
    print(0)
else:
    P   = sorted(int(X) for X in input().split())
    Mov = sorted([P[X+1]-P[X] for X in range(0,M-1)],reverse=True)
    print(sum(Mov[(N-1):]))

Measured memory_bytes: 20464
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#ifdef _MSC_VER
int getchar_unlocked() { return getchar(); }
#endif
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
#define qp(f) [](auto i){return f;}
using LL=long long;
using VI=vector<int>;
using VL=vector<LL>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL MOD = 1000000007;
const double pi = acos(-1.0);
const string Snum = "0123456789";
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
template<class T>T Sort(T& a) { sort(a.begin(), a.end()); return a; }
template<class T>T ReSort(T& a) { sort(a.rbegin(), a.rend()); return a; }
template<class T>T Reverse(T& a) { reverse(a.begin(), a.end()); return a; }
template<class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template<class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template<class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template<class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template<class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }
template<class T>T Age(T a, T b) { return (a + b - 1) / b; }
template<class T>T gcd(T n, T m) { return m == 0 ? n : gcd(m, n % m); }
template<class T>T lcm(T n, T m) { return n / gcd(n, m) * m; }


struct edge {
	LL to, cost;
};

int n;
vector<vector<edge>> g;

void dfs(LL v, LL p, LL deep, VL& dist) {
	dist[v] = deep;
	for (auto e : g[v]) {
		if (e.to == p)continue;
		dfs(e.to, v, deep + e.cost, dist);
	}
}


int main() {
	cin >> n;
	g.resize(n);

	rep(i, n - 1) {
		LL s, t, w;
		cin >> s >> t >> w;
		g[s].pb({ t,w });
		g[t].pb({ s,w });
	}

	VL d1(n);
	dfs(0, -1, 0, d1);

	LL pos = max_element(all(d1)) - d1.begin();
	VL d2(n);
	dfs(pos, -1, 0, d2);

	cout << Max(d2) << endl;
}


Measured memory_bytes: 18284
#include <stdio.h>

int main(void){
	char s[1000000], t[1000000];
	scanf("%s", s);
	scanf("%s", t);
	int count = 0;
	for(int i = 0; s[i]; i++)
		if(s[i] != t[i])count++;
	printf("%d\n", count);
	return 0;
}



Measured memory_bytes: 2492
//Binary Search Tree 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


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

void Insert(int);
void Inorder(Node*);
void Preorder(Node*);


Node *Root;


int main(){
	int m,i,k;
	char order[8];


	//input
	scanf("%d",&m);

	for(i=0;i<m;i++){
		scanf("%s",order);


		if(!strcmp("insert",order)){
			scanf("%d",&k);
			Insert(k);
		}
		else if(!strcmp("print",order)){
			Inorder(Root);
			printf("\n");
			Preorder(Root);
			printf("\n");
		}
	}
	return 0;
}


void Insert(int k){
	Node *y=NULL;
	Node *x=Root;
	Node *new;

	new=(Node *)malloc(sizeof(Node));
	new->key=k;
	new->left=NULL;
	new->right=NULL;

	while(x != NULL){
		y=x;
		if(new->key < x->key){
			x=x->left;
		}
		else{
			x=x->right;
		}
	}
	new->parent=y;
	if(y==NULL){
		Root=new;
	}
	else if(new->key < y->key){
		y->left=new;
	}
	else{
		y->right=new;
	}
}


//Torigake-zyun (root-> L -> R)
void Inorder(Node *u){
	if(u==NULL){
		return;//todo
	}
	Inorder(u->left);
	printf(" %d",u->key);
	Inorder(u->right);
}


//Ikigake-zyun(L -> root -> R)
void Preorder(Node *u){
	if(u==NULL){
		return;//todo
	}
	
	printf(" %d",u->key);
	Preorder(u->left);
	Preorder(u->right);
}



Measured memory_bytes: 25136
#include <iostream>

using namespace std;

int main(){
    int i = 1;
    while(true){
        int a;
        cin >> a;
        if(a ==0){
            break;
        }
        else{
            cout << "Case " << i << ": " << a << endl;
            i = i + 1;
        }
    }
    return 0;
}


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

int main(){
  int n;
  cin >>n;
  int ans = 0;
  for(int i = n;;i++){
    bool prime = true;
    for(int j = 2; j<n/2; j++){
      if(i%j==0) prime = false;
    }
    if(prime) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef pair<int, pair<string, int>> vp;


bool compare_with_restaurant_name(vp left, vp right) {
    return left.second.first < right.second.first;
}

bool compare_with_score(vp left, vp right) {
    return left.second.second > right.second.second;
}


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

    vector<pair<string, int>> restaurants(n);
    vector<vp> restaurants_with_idxs(n);

    for (int i=0; i<n; ++i) {
        cin >> s >> p;
        restaurants[i] = make_pair(s, p);
        restaurants_with_idxs[i] = make_pair(i+1, restaurants[i]);
    }

    sort(restaurants_with_idxs.begin(), restaurants_with_idxs.end(), compare_with_restaurant_name);

    vector<pair<int, int>> partisions;
    int left  = 0;
    int right = 0;
    string prev_city_name = restaurants_with_idxs[0].second.first;

    for (int i=1; i<n; ++i) {
        if (restaurants_with_idxs[i].second.first == prev_city_name) {
            right++;
        }
        else {
            partisions.push_back(make_pair(left, right));
            left  = i+1;
            right = i+1;
        }
        
        prev_city_name = restaurants_with_idxs[i].second.first;
    }

    if (left != right) {
        partisions.push_back(make_pair(left, right));
    }

    int left_part, right_part;
    int cursor = 0;
    int partision_length = partisions.size();

    for (pair<int, int> partision: partisions) {
        left_part  = partision.first;
        right_part = partision.second;

        if (cursor == 0) right_part++;
        if (cursor != 0)  left_part--;

        sort(restaurants_with_idxs.begin()+left_part,
             restaurants_with_idxs.begin()+right_part,
             compare_with_score);

        cursor++;
    }

    for (vp restaurants_with_idx: restaurants_with_idxs) {
        cout << restaurants_with_idx.first << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b){
  if(a % b == 0) return b;
  return gcd(b, a % b);
}

int main(){
  int k;
  std::cin >> k;

  long long ans = 0;
  for(int a = 1; a <= k; a++){
    for(int b = 1; b <= k; b++){
      for(int c = 1; c <= k; c++){
        ans += gcd(a, gcd(b, c));
      }
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

object Main{
  def main(args: Array[String]){
    val sc = new Scanner(System.in);
    val a,b,c,d = sc.nextInt;

    if(math.abs(a-c) <= d || (math.abs(a-b) <= d && math.abs(b-c) <= d))
      println("Yes");
    else
      println("No");
  }
}


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

typedef long long ll;

const int maxn = 1e5 + 5;

ll get(ll x) {
  if (x < 0) {
    return 0;
  }
  ll c = x & 3;
  if (c == 0) {
    return x;
  } else if (c == 1) {
    return 1;
  } else if (c == 2) {
    return x + 1;
  } else {
    return 0;
  }
}

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

  ll A, B;
  while (cin >> A >> B) {
    cout << (get(B) ^ get(A - 1)) << "\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
const int maxn=1e5+10;
int n,YZ,a[maxn],tree[maxn<<1],aa[maxn],l,r,mid;
int lowbit(int x){
    return x&(-x);
}
void add(int x){
    while(x<(maxn<<1)){
        ++tree[x];
        x+=lowbit(x);
    }
}
int query(int x){
    int ans=0;
    while(x){
        ans+=tree[x];
        x-=lowbit(x);
    }
    return ans;
}
bool check(int m){
    int cnt=0;
    memset(tree,0,sizeof(tree));
    for(re int i=1;i<=n;++i){
        if(a[i]<=m){
            aa[i]=1;
        }
        else{
            aa[i]=-1;
        }
    }
    aa[0]=0;
    for(re int i=1;i<=n;++i){
        aa[i]+=aa[i-1];
    }
    for(re int i=0;i<=n;++i){
        aa[i]+=maxn;
    }
    add(aa[0]);
    for(re int i=1;i<=n;++i){
        cnt+=query(aa[i]-1);
        add(aa[i]);
    }
    return cnt>=YZ;
}
signed main(){
    scanf("%lld",&n);
    YZ=n*(n+1)/4+1;
    for(re int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    l=0,r=1e9;
    while(l<r){
        mid=(l+r)>>1;
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 6876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
    double a,b,x;
    cin>>a>>b>>x;
    double s=x/a;
    double rad;
    if(s>=a*b/2){
      double h=(a*b-s)*2/a;
      rad = atan2(h,a);
    }else{
      double w =s*2/b;
      rad = atan2(b,w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    printf("%.10f\n",deg);
}

Measured memory_bytes: 4172
#include<cstdio>
int main(){
	long long K,A[100000];
	scanf("%lld",&K);
	for(int i=0;i<K;i++)scanf("%lld",A+i);
	long long min=2,max=2;
	for(int i=K-1;i>=0;i--){
		if(min%A[i])min+=A[i]-min%A[i];
		if(max%A[i])max+=-max%A[i];
		if(min>max){
			printf("-1");
			return 0;
		}
		else max+=A[i]-1;
	}
	printf("%lld %lld",min,max);
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
//#pragma warning(disable : 4996)
#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
using namespace std;
typedef long long ll;

const int maxn = (int)1e5 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 9;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101;
const long double pi = 3.1415926535897932;
ll a, b, n;
ll f(ll x) {
	return (int)(a * x / b) - (int)a * (x / b);
}

int main() {
	drobucs;
	cin >> a >> b >> n;
	cout << max(f(min(b - 1, n)), f(n));
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, H, W, ans = 0;
  cin >> N >> H >> W;
  vector<int> A(N), B(N);
  for (int i=0; i<N; i++) cin >> A[i] >> B[i];
  for (int i=0; i<N; i++) {
    if (A[i]>=H&&B[i]>=W) ans++;
  }
  cout << ans << endl;
}

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

int main(){
    int n,t,a;
    cin>>n>>t>>a;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    double ans = 1e9;
    int res = 0;
    rep(i,n){
        double tmp = abs(t-h[i]*0.006-a);
        if(ans>tmp){
            res = i;
            ans = tmp;
        }
    }
    cout << res+1 << endl;
}


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

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

    int n, m;
    cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, 0, n) {
        ll a;
        cin >> a;
        pq.push(a);
    }
    rep(i, 0, m) {
        ll a = pq.top();
        pq.pop();
        pq.push(a / 2);
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
# ABC 132 D

N=10**4
p=10**9+7
f,finv,inv=[0]*(N+5),[0]*(N+5),[0]*(N+5)

def nCr_init(L,p):
    for i in range(L+1):
        if i<=1:
            f[i],finv[i],inv[i]=1,1,1
        else:
            f[i]=(f[i-1]*i)%p
            inv[i]=(p-inv[p%i]*(p//i))%p
            finv[i]=(finv[i-1]*inv[i])%p

def nCr(n,r,p):
    if 0<=r<=n and 0<=n:
        return (f[n]*finv[n-r]*finv[r])%p
    else:
        return 0
    
nCr_init(N,p)

N,K=map(int,input().split())
for i in range(1,K+1):
    NR=N-K
    NB=K
    print((nCr(NB-1,i-1,p)*nCr(NR+1,i,p))%p)

Measured memory_bytes: 74016
s = str(input())

if (s[0] == 'A'
    and len([i for i in s[2:-1] if i == 'C']) == 1
    and str([i for i in s[2:-1] if i != 'C']).islower
    and str.islower(s[1]+s[-1])):
    print('AC')
else:
    print('WA')


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

int main()
{
  int N;
  map< pair< int, int >, int > p1, p2;
  
  cin >> N;
  while(N--) {
    int x, y, w;
    cin >> x >> y >> w;
    p1[{x, y}] = p2[{x, y}] = w;
  }
  int ret = 0;
  for(const auto& p : p1) {
    for(int k = -1; k <= 0; k++) {
      for(int l = -1; l <= 0; l++) {
        int weight = 0;
        for(int i = 0; i <= 1; i++) {
          for(int j = 0; j <= 1; j++) {
            weight += p2[{p.first.first + k + i, p.first.second + l + j}];
          }
        }
        ret = max(ret, weight);
      }
    }
  }
  cout << ret << " / 1" << endl;
}

Measured memory_bytes: 65536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        int ans = 0;
        for (int i = a; i <= b; i++) {
            if(h % i == 0) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26404
n, p = map(int,input().split())
s = input()

mod = p
l = 100

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

T = [1]
for i in range(n-1):
    T.append((T[-1]*10) % p)

P = [0] * p
P[0] = 1

ans = 0
v = 0
S = [int(s[i]) for i in range(n-1,-1,-1)]

if p==2 or p==5:
    for i in range(n):
        ans += (int(s[i]) % p == 0) * (i+1)
else:
    for i in range(n):
        v = (v + T[i]*S[i]) % p
        ans += P[v]
        P[v] += 1
        # print(P)

print(ans)


Measured memory_bytes: 53472