akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int N, M;
vector<int> A[100000];

int p[100000];

void Init() {
  for(int i = 0; i < N; ++i) {
    p[i] = i;
  }
}

int Root(int i) {
  if(p[i] == i) return i;
  return p[i] = Root(p[i]);
}

void Unite(int i, int j) {
  int a = Root(i);
  int b = Root(j);
  if (a == b) return;
  p[b] = a;
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < N; ++i) {
    int K;
    cin >> K;
    for(int j = 0; j < K; ++j) {
      int a;
      cin >> a;
      --a;
      A[a].push_back(i);
    }
  }
  
  Init();
  for(int i = 0; i < M; ++i) {
    for(int j = 1; j < A[i].size(); ++j) {
      Unite(A[i][j - 1], A[i][j]);
    }
  }
  
  bool ok = true;
  int r = Root(0);
  for(int i = 1; i < N; ++i) {
    if(r != Root(i)) ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4608
n = int(input())
t_l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
t_t = [[abs(t_l[i][0]-t_l[i-1][0]), abs(t_l[i][1]-t_l[i-1][1]), abs(t_l[i][2]-t_l[i-1][2])] for i in range(1,n+1)]
ans = "Yes"

for j in t_t:
    t, x, y = j
    if t < x + y:
        ans = "No"
        break
    elif t % 2 != (x + y) % 2:
        ans = "No"
        break
print(ans)


Measured memory_bytes: 38708
/*1803115*/
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};

    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }

    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2044
n = int(input())
a = [int(input())-1 for _ in range(n)]

x = 0
cnt = 0
for i in a:
    if a[x] == -1:
        print(-1)
        exit()
    else:
        t = x
        x,a[t] = a[x],-1
        cnt += 1
        if x == 1:
            print(cnt)
            exit()



Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x){return x*x;}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;      
     x = x % p;    
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
            y = y>>1;  
            x = (x*x) % p;   
    } 
    return res; 
} 

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    vl v(n);
    f(n)cin>>v[i];
    map<ll,int> al;
    f(n){
        map<ll,int> m = prime(v[i]);
        for(auto it : m){
            if(al[it.ff] == 0 || al[it.ff] < it.ss){
                al[it.ff] = it.ss;
            }
        }
    }
    ll up = 1;
    for(auto it : al){
        ll val  = it.ff;
        int x= it.ss;
        while(x--){
            up = mul(up,val);
        }
    }
    ll ans = 0;
    for(int i = 0;i<n;++i){
        ll mo = power(v[i],MOD-2,MOD);
        ll contri = mul(up,mo);
        ans = add(ans,contri);
    }
    cout << ans;

    
    return 0;
}

    


Measured memory_bytes: 1024
n = int(input())
AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(n)]
sortAB = sorted(AB, reverse=True)
sortCD = sorted(CD, key=lambda x: x[1])

for i in range(n):
    for j in range(len(sortCD)):
        if sortAB[i][0] < sortCD[j][0] and sortAB[i][1] < sortCD[j][1]:
            sortCD.pop(j)
            break
            
print(n - len(sortCD))

Measured memory_bytes: 3064
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
A = [Q, min(2 * Q, H), min(4 * Q, 2 * H, S), min(8 * Q, 4 * H, 2 * S, D)]
ans = (N // 8) * A[3] + ((N % 8) // 4) * A[2] + ((N % 4) // 2) * A[1] + (N % 2) * A[0]
print(ans)

Measured memory_bytes: 61820
def head(x):
    r, q = divmod(x, 10)
    if r == 0:
        return q
    return head(r)
    

def tail(x):
    return x % 10


def submit():
    n = int(input())
    head_tail_count = {(i, j):0 for i in range(10) for j in range(10)}

    for x in range(n + 1):
        h = head(x)
        t = tail(x)
        head_tail_count[(h, t)] += 1

    ans = 0
    for x in range(1, 10):
        for y in range(1, 10):
            ans += head_tail_count[(x, y)] * head_tail_count[(y, x)]
    print(ans)


if __name__ == "__main__":
    submit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long unsigned int;
typedef pair<int,int> P;
typedef priority_queue<int> Pr;
Int const MOD=1000000007;

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

    int n; cin>>n; Int t[n],ans; cin>>ans; 
    for (int i = 0; i < n-1; i++){
        Int p; cin>>p; ans=ans/__gcd(ans,p)*p;
    }
    cout<<ans<<'\n';
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int n, m, q; cin>>n>>m>>q;
    vector<vector<int>> train(510, vector<int>(510, 0));

    for(int i=0; i<m; i++){
        int l, r; cin>>l>>r;
        l--, r--;
        train[l][r]++;
    }

    vector<vector<int>> sum(510, vector<int>(510, 0));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j == 0) {
                sum[i][j] = train[i][j];
            }
            else {
                sum[i][j] = sum[i][j-1] + train[i][j];
            }
        }
    }

    for(int i=0; i<q; i++){
        int p, q; cin>>p>>q;
        p--, q--;

        int ans=0;
        for(int j=p; j<=q; j++){
            if(p == 0){
                ans += sum[j][q];
            }
            else {
                ans += sum[j][q] - sum[j][p-1];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
#!/usr/bin/env python
# coding: utf-8

# In[35]:


import collections


# In[31]:


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


# In[36]:


count = collections.Counter(A)
numsum = 0
for i in count.values():
    numsum += i*(i-1)//2

for i in A:
    print(numsum - (count[i]-1))


# In[ ]:






Measured memory_bytes: 33940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int i, N, d, c = 0;



	cin >> N;
	vector<int> a(N);
	// vector<int> b(M);
	for (i = 1; i <= N; i++){
		cin >> a[i];

		if (a[i] % 2 == 1 && i % 2 == 1){
			c++;
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3624
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define M 1000000007
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
lli h,w;
char arr[1005][1005];
lli dp[10005][10005];
lli rec(lli i,lli j)
         {  if(dp[i][j]!=-1)
              return dp[i][j];
            if(i==w&&j==h)
              {
               dp[i][j]=1;
               return 1;
              }
        else
            {lli sum=0;
             if(arr[i+1][j]=='.')
                sum+=(rec(i+1,j)%M);
             if(arr[i][j+1]=='.')
                sum+=(rec(i,j+1)%M);
             dp[i][j]=sum%M;
             return sum%M;
            }
         }
int main()
   {harry

    cin>>w>>h;

    for(lli i=1;i<=w;i++)
       {for(lli j=1;j<=h;j++)
         cin>>arr[i][j];}
    memset(dp,-1,sizeof(dp));
    cout<<rec(1,1);

    }

















Measured memory_bytes: 783360
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

struct Data{
    int a, b, c, d;
};


int saiki(vector<int> vec, int n, int m, vector<Data> &dat){
    if(vec.size() == n){
        int sum = 0;
        REP(i, dat.size()){
            if(vec[dat[i].b] - vec[dat[i].a] == dat[i].c)
                sum += dat[i].d;
        }
        return sum;
    }
    else{
        int maxx = 0;
        auto vec2 = vec;
        int lb = (vec2.empty() ? 1 : vec2.back());
        vec2.push_back(0);
        IFOR(i, lb, m){
            vec2.back() = i;
            maxx = max(maxx, saiki(vec2, n, m, dat));
        }
        return maxx;
    }
}
int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<Data> dat(q);
    REP(i, q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        dat[i] = {a, b, c, d};
    }

    int ans = saiki({}, n, m, dat);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        long ans = 0;
              
        
        for(long M = N+1; M >= K; M--){
        long plus = (M * (N-M+1) + 1) % 1000000007;
        ans = ans + plus;
        ans = ans % 1000000007;
        }
        
        System.out.print(ans);
	}
}

Measured memory_bytes: 35812
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

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


		return b;
}

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

ll N, K;
vector<ll> A, B;
ll b[50];


ll is_one(ll a, ll k) {


	return ((a & ((ll)1 << k)) != 0);
}



ll calc(ll a, ll k) {
	ll  ans = 0;

	for (int i = 0; i < 50; i++) {


		if (i == k) {
			ans += ((ll)1 << i) * (b[i]);
		}
		else if(i > k) {
			if (is_one(a, i) == 1)
				ans += ((ll)1 << i) * (N - b[i]);
			else
				ans += ((ll)1 << i) * (b[i]);
		}

		else {

			ans += ((ll)1 << i) * max(b[i], N - b[i]);
			

		}


	}

	return ans;
}

 

int main() {

	
	cin >> N >> K;

	
	A.resize(N);

	rep(i, N) {
		cin >> A[i];

		rep(j, 50) {
			b[j] += is_one(A[i], j);
			
		}
		
	}


	ll ans = 0;
	
	rep(i, 50) {

		if (is_one(K, i) == 1) {
			
			ans = max(ans, calc(K, i));
		}



	}

	ll ans2 = 0;


	rep(i, 50) {
		if (is_one(K, i) == 1) {
			ans2 += ((ll)1 << i) * (N - b[i]);
		}
		else {

			ans2 += ((ll)1 << i) * (b[i]);
		}

	}


	ans = max(ans, ans2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    int n; scanf("%d", &n);
    vector<vector<int> > g(n);
    repeat (i, n - 1) {
        int x, y; scanf("%d%d", &x, &y); -- x; -- y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> grundy(n);
    function<int (int, int)> go = [&](int i, int parent) {
        int acc = 0;
        for (int j : g[i]) if (j != parent) {
            acc ^= go(j, i) + 1;
        }
        return acc;
    };
    int result = go(0, -1);
    printf("%s\n", result ? "Alice" : "Bob");
    return 0;
}


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

int main(){

  int N, i, j;
  int mn=10000000;
  cin>>N;
  vector<int> a(N);
  
  for(i=0; i<N; i++) cin>>a[i];
  
  for(i=-100; i<=100; i++){
    int Sum=0;
    for(j=0; j<N; j++){
      Sum+=pow(i-a[j], 2);
    }
    mn=min(Sum, mn);
  }
  cout<<mn<<endl;
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int n,l;
    cin>>n>>l;
    VI a(n+1);
    for(int i=1;i<n+1;i++){
        cin>>a[i];
    }
    int p=0;
    for(int i=1;i<n;i++){
        if(a[i]+a[i+1]>=l){
            p=i;
            break;
        }
    }
    if(!p){
        cout<<"Impossible"<<endl;
        return 0;
    }
    else{
        cout<<"Possible"<<endl;
        for(int i=1;i<p;i++){
            cout<<i<<endl;
        }
        for(int i=n-1;i>=p;i--){
            cout<<i<<endl;
        }
    }

    return 0;
}


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

using namespace std;

int n, x;
const int N = 1e6 + 2;
vector < int > dp[N];

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector < int > vt(n);
    for(int i = 0; i < n; ++i) {
        cin >> vt[i];
        //f[vt[]]
    }
    sort(vt.begin(),vt.end());
    for(int i = 1 ; i < N ; ++i) {
        for(int j = i ; j < N ; j += i) {
            dp[j].push_back(i);
        }
    }
    //for(auto i : dp[31]) cout << i << ' ';
    int ans = 0;
    for(int i = 0 ; i < n ; ++i) {
        int curr = vt[i];
        /// find currents divisors
        bool can = true;
        for(int div : dp[curr]) {
            if(div == curr) break;
            if(binary_search(vt.begin(),vt.end(),div)){
                can = false;
                break;
            }
        }
        if(can) {
            if(upper_bound(vt.begin(),vt.end(), curr) - lower_bound(vt.begin(),vt.end(),curr) == 1) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std; 

int main(){
	
	int N ; 
	
	vector<int> M(25);
	
	cin >> N; 
	
	for(int i=0; i<N;i++)  cin >> M[i];
	
	int ans = 1;
	int max = M[0];
	
	for(int i = 1 ; i< N ; i++ ){
		if(M[i] >= max){
			ans++;
			max = M[i];
		}
	}
	
	cout << ans << endl;
	
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
signed main()
{
    speed
    int n;cin>>n;
    std::vector<int> inp(n);
    int ix=0;
    for(int i=0;i<n;++i)
    {
        cin>>inp[i];
        if(inp[i]>inp[ix]){ix=i;}
    }
    sort(inp.begin(),inp.end());
    for(int i=0;i<n;++i)
    {
        if(i==ix){cout<<inp[n-2]<<"\n";}
        else
        {
            cout<<inp[n-1]<<"\n";
        }
    }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define loop(n) for(int i=0;i<n;i++)
using namespace std;
long long int gcd(long long int a,long long int b){
    if(a==0) return b;
    return gcd(b%a,a);
}
long long int lcm(long long int p,long long int s){
    if(p>s)
        return (p*s)/gcd(s,p);
    else
        return (p*s)/gcd(p,s);
}
int main()
{
    long long int n,t,m;cin>>n>>m;
    t=lcm(n,m);
    cout<<t;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, i;
    cin>>n>>m;
    double a[n], sum = 0, req;
    for(i = 0; i < n; i++) {
    	cin>>a[i];
    	sum += a[i];
    }
    req = sum / (4 * m);
    ll ans = 0;
    for(i = 0; i < n; i++) {
    	if(a[i] >= req) {
    		ans++;
    	}
    }
    if(ans >= m) {
    	cout<<"Yes\n";
    } else {
    	cout<<"No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<queue>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;
const int MAX = 100005;

long long fac[MAX], facinv[MAX], inv[MAX];
void facinit(){
    fac[0] = fac[1] = 1;
    facinv[0] = facinv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        facinv[i] = facinv[i - 1] * inv[i] % MOD;
    }   
}

long long Combi(long long a, long long b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (facinv[b] * facinv[a - b] % MOD) % MOD;
}

int main(){
    facinit();
    int n, k; cin >> n >> k;
    vector<lint> v;
    rep(i, n){
        lint a; cin >> a; v.push_back(a);
    }
    sort(all(v));
    lint ans = 0;
    repn(i, n){
        lint coef = (Combi(i-1, k-1)-Combi(n-i, k-1)+MOD)%MOD;
        ans += (coef * (v[i-1] + MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3704
n = int(input())
eigo = 'abcdefghijklmnopqrstuvwxyz'

keta = 1
while n > 26**keta:
    n -= 26**keta
    keta += 1

ans =''
n = n-1
for i in range(keta):
    a =n // 26**(keta-1-i)
    ans += eigo[a]
    n = n % (26**(keta-1-i))
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 300005
#define MAXM 1005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define re(i, n) FOR(i, 1, n)
#define rep(i, n) for(int i = 0;i <(n); ++i)
#define fore(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

const ll MOD = 1e9+7;
int N;
int ar[MAXN];
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) cin >> ar[i];
	if((N%2) == 0) {
		for(int i=N; i>=2; i-=2) printf("%d ", ar[i]);
		for(int i=1; i<=N; i+=2) printf("%d ", ar[i]);
		printf("\n");
	}
	else {
		for(int i=N; i>=1; i-=2) printf("%d ", ar[i]);
		for(int j=2; j<=N; j+=2) printf("%d ", ar[j]);
		printf("\n");
	}
	
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<long> q;
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    q.push(a);
  }

  for (int i=0; i<m; i++) {
    int a = q.top();
    q.pop();
    // cerr << a << " " << (int)((double)a/2.0) << endl;
    q.push((int)((double)a/2.0));
  }

  long ans = 0;
  while(! q.empty()) {
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;
}

Measured memory_bytes: 1400
S = input()
count = 0

if S.count(S[0]) == 2:
    count = count + 1
if S.count(S[1]) == 2:
    count = count + 1
if S.count(S[2]) == 2:
    count = count + 1
if S.count(S[3]) == 2:
    count = count + 1

if count==4:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

	int N, t = 0, x = 0, y = 0;

	scanf("%d", &N);

	rep(i, N) {
		int tn, xn, yn;
		scanf("%d%d%d", &tn, &xn, &yn);
		if ((abs(x - xn) + abs(y - yn)) > (tn - t)) {
			printf("No\n");
			return 0;
		}
		if (((abs(x - xn) + abs(y - yn)) - (tn - t)) % 2) {
			printf("No\n");
			return 0;
		}
		t = tn;
		x = xn;
		y = yn;
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 256
sub u1{my$i=pop;
	$p[$i]=$p[$i]&&$p[$i]!=$i?u1($p[$i]):$i+0
}
sub u2{my$i=pop;
	$q[$i]=$q[$i]&&$q[$i]!=$i?u2($q[$i]):$i+0
}
($N,$K,$L)=split$",<>;
for(1..$K){
	($a,$b)=split$",<>;
	$a=u1($a+0);
	$b=u1($b+0);
	if($a!=$b){
		$p[$a]=$b
	}
}
for(1..$L){
	($a,$b)=split$",<>;
	$a=u2($a+0);
	$b=u2($b+0);
	if($a!=$b){
		$q[$a]=$b
	}
}
@s=map u1($_)._.u2($_).$".$_,1..$N;
@s=sort@s;
for($i=0;$i<$N;){
	$j=$i+1,$t=1;
	($a,$b)=split$",$s[$i];
	for(;($c,$d)=split($",$s[$j]),$j<$N&&$a eq$c;++$j){
		++$t
	}
	for(;$i<$j;++$i){
		($a,$b)=split$",$s[$i];
		$ans[$b]=$t
	}
}
print$_,$"for@ans


Measured memory_bytes: 62456
#include<cstdio>
#include<algorithm>
using namespace std;
int n, T = 100001;
struct point {
	int b, e;
}w[201000];
int S1[201000], S2[201000], S[201000], R1, R2;
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &w[i].b, &w[i].e);
		S[w[i].b]++, S[w[i].e]--;
		S1[w[i].b]++;
		S2[w[i].e]++;
	}
	for (i = 1; i <= T; i++) {
		S[i] += S[i - 1];
		S1[i] += S1[i - 1];
		S2[i] += S2[i - 1];
		R2 = max(R2, S[i]);
	}
	for (i = 1; i <= n; i++) {
		R1 = max(R1, n - (n - S1[w[i].e - 1]) - S2[w[i].b]);
	}
	printf("%d %d\n", R1, R2);
}

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

using namespace std;

const int NMAX = 1e2;
const int VMAX = 1e3;

typedef long long LL;

int N, W, K;
LL dp[NMAX * VMAX + 5];

int main()
{
    cin >> N >> W;
    for(int i = 1; i <= NMAX * VMAX; i++)
        dp[i] = 1LL << 60;
    K = N * VMAX;
    for(int i = 1; i <= N; i++)
    {
        int w, v;
        cin >> w >> v;
        for(int j = K; j >= v; j--)
            dp[j] = min(dp[j], dp[j - v] + w);
    }

    for(int i = K; i >= 0; i--)
        if(dp[i] <= W)
        {
            cout << i;
            exit(0);   
        }

    exit(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,x[N],ans[N];
int main()
{
	cin>>n;
	for(int i=	1;i<n;i++)cin>>x[i],ans[x[i]]++;
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}

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

int a,b,flag=1;
char s[100005];

int main()
{
	cin>>a>>b;
	for (int i=1;i<=a+b+1;i++)  cin>>s[i];
	for (int i=1;i<=a+b+1;i++)
	{
		if (i==a+1)  continue;
		if (s[i]<'0'||s[i]>'9')
		{
			flag=0;
			break;
		}
	}	
	if (s[a+1]>='0'&&s[a+1]<='9')  flag=0;
	
	if (flag==0)  cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

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

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  string n; cin >> n;
  cout << "ABC"+n << endl;
  //if (s[0]==s[2]){cout << "Yes";}
  //else {cout << "No";}

  return 0;
}


Measured memory_bytes: 256
from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%4==0:
    ans4+=1
  elif a[i]%2==0:
    ans2+=1
  else:
    ans0+=1
if ans2>0:
  if ans0<=ans4:
    print('Yes')
  else:
    print('No')
else:
  if ceil((ans0+ans4)/2)>=ans0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 15020
while True :
    q = int(input())

    if q == -1 :
        break

    else :
        x = q / 2

        while abs(x ** 3 - q) >= 0.00001 * q :
            x -= ((x ** 3 - q) / (3 * x ** 2))

        print(f"{x:.6f}")


Measured memory_bytes: 5676
/**
 * @author: shashankchdhry
 * @made:   2020-03-30 21:53:38 
**/
#include <bits/stdc++.h>

using namespace std;

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

    string s;
    cin >> s;

    unordered_map<char, int> uomp;
    for (int i = 0; i < s.length(); i++)
    {
        uomp[s[i]]++;
    }

    for (auto i:uomp)
    {
        if (i.second%2)
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AEoui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();

            out.println(a / 3);
        }

    }
}



Measured memory_bytes: 20948
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"wait\n"
typedef long long ll;
typedef unsigned long long ull;


class solution{
public:
	void solve(){
		ll n,w;
		cin>>n>>w;
		vector<pair<ll,ll>> v(n);
		for(int i=0;i<n;i++){
			cin>>v[i].f>>v[i].s;
		}
		//cerr<<"wait\n";
		vector<ll> dp(w+1,0);
		vector<ll> newdp(w+1,0);
		for(int i=0;i<n;i++){
			for(int weight_already=0;weight_already<=w;weight_already++){
				if(weight_already+v[i].f<=w){
					ll val = dp[weight_already]+v[i].s;
					ll a = newdp[weight_already+v[i].f];
					newdp[weight_already+v[i].f] = max(a,val); 
				}
			}
			dp = newdp;
		}
		cout<<*max_element(dp.begin(),dp.end())<<"\n";
				
	}
};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cerr<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cerr<<#v<<":";REP(debugidx,v.size())cerr<<" "<<v[debugidx];cerr<<endl
#define DEBUG_ARR(v,n) cerr<<#v<<":";REP(debugidx,n)cerr<<" "<<v[debugidx];cerr<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    long double a,b,c;
    cin>>a>>b>>c;
    long double x = sqrt(a);
    long double y = sqrt(b);
    //long double z = sqrt(c);
    
    if(a+b + 2*(x*y) < c) yn;
    return 0;
}

Measured memory_bytes: 3772
N,M = map(int,input().split())
AB = []
for i in range(M):
    a,b = map(int,input().split())
    AB.append([a,b])
AB.sort()
cnt = 1
r_min = float('inf')
for l,r in AB:
    if l>=r_min:
        cnt += 1
        r_min = r
    else:
        r_min = min(r_min,r)
print(cnt)


Measured memory_bytes: 20076
// 0157 最長増加部分列
#include <iostream>
#include <algorithm>
#include <map>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
bool compare_h(pair<int, int> a, pair<int, int> b){
	return a.first < b.first;
}
bool compare_r(pair<int, int> a, pair<int, int> b){
	return a.second < b.second;
}


int main(){
	int n, m;
	while(cin >> n && n){
		int dp[256];
		// high, r
		pair<int, int> dolls[256];
		rep(i, n){
			cin >> dolls[i].first >> dolls[i].second;
		}
		cin >> m;
		rep(i, m){
			cin >> dolls[i+n].first >> dolls[i+n].second;
		}


		// hの最長増加部分列
		// hについてソートしrの最長増加部分列を求める
		int hlis = 0;
		sort(dolls, dolls+n+m, compare_h);
		dp[0] = 1;
		for(int i = 1; i < n+m; i++){
			dp[i] = 1;
			for(int j = 0; j < i; j++){
				if(dolls[j].second < dolls[i].second && dolls[j].first != dolls[i].first){
					dp[i] = max(dp[i], dp[j] + 1);
				}
			}
			hlis = max(hlis, dp[i]);
		}					
		
		// rの最長増加部分列
		// rについてソートしhの最長増加部分列を求める
		int rlis = 0;
		sort(dolls, dolls+n+m, compare_r);
		dp[0] = 1;
		for(int i = 1; i < n+m; i++){
			dp[i] = 1;
			for(int j = 0; j < i; j++){
				if(dolls[j].first < dolls[i].first && dolls[j].second != dolls[i].second){
					dp[i] = max(dp[i], dp[j] + 1);
				}
			}
			rlis = max(rlis, dp[i]);
		}

		cout << max(rlis, hlis) << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
s = raw_input()
k = int(raw_input())
l = len(s)
ls = []
for a in range(l):
    for b in range(a+1,min(a+k+1,l+1)):
        if ls.count(s[a:b]) == 0:
            ls.append(s[a:b])
ls.sort()
print ls[k-1]

Measured memory_bytes: 3576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i< n ; i++) {
            sb.append(s.charAt(i));
            sb.append(t.charAt(i));
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

ll n;
set<string> st;

void rec(string s, ll step, ll maxn){
    if(step == n) { st.insert(s); return; }
    for(ll i=0; i<=maxn; i++){
        s[step] = (char)('a'+i);
        rec(s, step+1, max(i+1, maxn));
    }
}

int main(){
    Init();
    cin >> n;
    rec(string(n, ' '), 0, 0), 0;
    for(auto &s: st) cout << s << endl;
}

Measured memory_bytes: 12516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var input = Console.ReadLine();
            switch (input) {
                case "A": Console.WriteLine("T"); break;
                case "C": Console.WriteLine("G"); break;
                case "G": Console.WriteLine("C"); break;
                case "T": Console.WriteLine("A"); break;
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
       try {
			Scanner sc=new Scanner(System.in);
			int d=sc.nextInt();
			int t=sc.nextInt();
			int s=sc.nextInt();
			int k=t*s;
			if(k>=d) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}catch(Exception e) {
			
		}

    }
}

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

struct UnionFind{
    vector<int> data;
    int __size;
    UnionFind(int sz) {
    data.assign(sz, -1);
    __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
      return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int unum() {
    return (__size);
  }
};

int main(){ 
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  UnionFind uf(h*w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j + 1 < w && s[i][j] != s[i][j+1]) uf.unite(i*w+j, i*w+(j+1)); 
      if (i + 1 < h && s[i][j] != s[i+1][j]) uf.unite(i*w+j, (i+1)*w+j); 
    }
  }
  ll res = 0;
  vector<vector<ll>> cnt(h*w,vector<ll>(2,0));
  rep(i,h) rep(j,w) {
    if (s[i][j] == '#') cnt[uf.find(i*w+j)][0]++;
    else cnt[uf.find(i*w+j)][1]++;
  }
  
  rep(i,h*w) res += cnt[i][0]*cnt[i][1];
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int limit = a + b, count = 0;
    rep(i, n) {
        if(s[i] == 'a') {
            if(limit > 0){
                cout << "Yes" << endl;
                limit--;
            }else{
                cout << "No" << endl;
            }
        }
        if(s[i] == 'b'){
            if(limit > 0 && count < b){
                cout << "Yes" << endl;
                limit--;
                count++;
            }else{
                cout << "No" << endl;
            }
        }
        if(s[i] == 'c')
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int X, A, B;
  cin >> X >> A >> B;
  if(abs(X-A) < abs(X-B)) cout << 'A' << endl;
  else cout << 'B' << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var even = K / 2;
            var odd = K - even;

            Console.WriteLine(even * odd);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    
    vector<long long> dp(H+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[min(j+A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define INF 2000000000

int compare_int(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

int main(){
	int n,k,i;
	long long h[100000];
	for(i=0;i<100000;i++)h[i]=INF;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%lld",&h[i]);
	qsort(h,n,sizeof(long long),compare_int);
	long long ans=INF;
//	long sa[100000];
/*	for(i=0;i<n-k;i++){
		sa[i]=h[i+k-1]-h[i];
//		printf("%ld\n",sa[i]);
	}*/
//	for(i=0;i<n;i++)printf("%lld\n",h[i]);
	for(i=0;i<=n-k;i++){
		ans=min(h[i+k-1]-h[i],ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, N;
    cin >> X >> N;
    int p[110];
    rep(i, N) cin >> p[i];
    int ans = -200;
    REP(i, -200, 200) {
        bool ok = true;
        rep(j, N) {
            if(i == p[j]) ok = false;
        }
        int k1 = abs(X - ans);
        int k2 = abs(i - X);
        if(ok) {
            if(k2 < k1) {
                ans = i;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    swap(x, y);
    swap(x, z);
    printf("%d %d %d\n", x, y, z);
    return 0;
}


Measured memory_bytes: 256
N=int(input())

wlist = []
for i in range(N):
  a,b=map(int,input().split())
  wlist.append((b,a))
  
wlist.sort()
#print(wlist)

ok = True
time = 0
for i in range(N):
  b,a=wlist[i]
  time += a
  if time > b:
    ok = False
    break
    
if ok:
  print("Yes")
else:
  print("No")

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

using namespace std;


const int maxn = 200005;
int a[maxn];


int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
    {
        scanf("%d", a + i);
    }
    if(a[0]){
        printf("-1\n");
        return 0;
    }
    long long ans = 0;
    for(int i = n - 1; i; i--)
    {
        if(a[i] - 1 > a[i - 1] ){
            ans = -1;
            break;
        }
        else if(a[i] - 1 < a[i - 1]){
            ans += a[i];
        }
        else ans++;
    }
    printf("%lld\n", ans);
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  string S;
  IN(S);

  vll left(30, 0);
  vll right(30, 0);
  REP(i,N){
    right[S[i]-'a']++;
  }

  ll ans = 0;
  REP(i,30){
    if(left[i]>0 && right[i]>0) ans++;
  }

  REP(i,N){
    ll ans_tmp = 0;
    left[S[i]-'a']++;
    right[S[i]-'a']--;
    REP(j,30){
      if(left[j]>0 && right[j]>0) ans_tmp++;
    }
    chmax(ans, ans_tmp);
  }

  OUT(ans);

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(ll &i:A)cin >> i;
    ll money=1000;
    ll beat=0;
    vector<bool> B(N);//BY(0),SE(0);
    for(ll i=0;i<N-1;i++){
        if((long double)A[i+1]/A[i]>1)B[i]=true;//BY.push_back(i);
        else B[i]=false;//SE.push_back(i);
        
    }
    for(ll i=0;i<N;i++){
        
        if(B[i]){
           /* while(money-A[i]>=0){
                beat++;
                money-=A[i];
            }*/
            beat+=money/A[i];
            money=money % A[i];
            
        }else{
            money+=beat*A[i];
            beat=0;
        }
        
    }
    
    cout << money << endl;
    
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


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


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int k, a, b;
    cin >> k >> a >> b;
    int cur = k;
    while (cur <= b) {
    	if (cur >= a) {
    		cout << "OK\n";
    		return 0;
    	}
    	cur += k;
    }
    cout << "NG\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;

    double odd = 0;
    double num = 0;
    for(int i = 1; i <= N; i++){
        num++; 
        if(i%2) odd++;
    }

    printf("%.14lf\n", odd / num);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string>s(n);
  map<string,int>m;
  int mx = 1;
  for(int i = 0;i < n;i++){
    cin >> s[i];
    m.insert(make_pair(s[i],0)); 
  }
  for(int i = 0;i < n;i++){
    m[s[i]]+=1;
    mx = max(m[s[i]],mx);
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  for(int i = 0;i < s.size();i++){
    if(m[s[i]] == mx){
      cout << s[i] << endl;
    }
  }
}
    

Measured memory_bytes: 26752