akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b)    for (int i(a); i <= (b); ++i)
#define dec(i, a, b)    for (int i(a); i >= (b); --i)
#define MP        make_pair
#define fi        first
#define se        second
typedef long long LL;
typedef pair <int, int> PII;
int n;
int answer = 1e9;
map <int, int> map1, map2;
multiset <int> s1, s2;

int main(){
    
    scanf("%d", &n);
    
    rep(i, 1, n){
        int x;
        scanf("%d", &x);
        if (i & 1) map1[x]++;
        else map2[x]++;
    }
    
    for (auto u : map1) s1.insert(u.se);
    for (auto u : map2) s2.insert(u.se);
    
    for (auto u : map1){
        int x = u.se;
        if (map2.count(u.fi)){
            int ll = map2[u.fi];
            s2.erase(s2.find(ll));
            if (map2.size() > 1u){
                answer = min(answer, n - x - (*s2.rbegin()));
            }
            else answer = min(answer, n - x);
            s2.insert(ll);
        }
        else{
            answer = min(answer, n - x - (*s2.rbegin()));
        }   
    }
    printf("%d\n", answer);
    return 0;
}


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

// 関数定義
double absol(double x, double y) {
 
  if (x-y<0) {
    return y-x;
  }
  else {
    return x-y;
  }
 
}


int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> h(N);
  for(int i =0; i<N;i++){
    cin>> h.at(i) ;
  }
  double temp = T-0.006*h.at(0);
  int ans = 1;
  for(int i=1; i<N;i++){
    if(absol(temp,A) > absol(T -0.006*h.at(i),A)){
      temp = T-0.006*h.at(i);
      ans = i+1;
    }
  }
  cout<< ans <<endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e2 + 10;
const int mod = 1e9 + 7;

int gr[N][N];
bool vis[N][N];
int n , a , b , w , m;
pair<int,int> edge[N*10];
int wt[N*10];

int32_t main(){
	boost;

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	int x = 0;
	for(int i = 0 ; i < n ; ++i){
		(s[i] == 'I') ? x++ : x--;
		ans = max(ans, x);
	}
	cout << ans;
	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 pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/
const ll Div = 998244353;
ll dp[5000][5000] = {};
int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  dp[a][b] = 1;
  for(int i = a; i <= c; ++i)
  for(int j = b; j <= d; ++j){
    dp[i][j] += (dp[i-1][j] * j) % Div;
    dp[i][j] %= Div;
    dp[i][j] += (dp[i][j-1] * i) % Div;
    dp[i][j] %= Div;
    dp[i][j] -= ((dp[i-1][j-1]*(i-1)%Div)*(j-1))%Div;
    dp[i][j] += Div * Div;
    dp[i][j] %= Div;
  }
  cout << dp[c][d] << endl;
}


Measured memory_bytes: 85828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

/*
全部1になる


*/

int main(void){
    int N,K;
    scanf("%d %d",&N,&K);
    scanf("\n");
    int num = (N-1)/(K-1);
    if((N-1)%(K-1) != 0){
        num ++;
    }
    printf("%d\n",num);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    int C[12];
    int A[12][12];
    rep(i, n) {
        cin >> C[i];
        rep(j, m) {
            cin >> A[i][j];
        }
    }
    int ans = INF;
    rep(bit, 1 << n) {
        vector<int> X(m);
        int money = 0;
        rep(i, n) {
            if ((bit >> i) & 1) {
                money += C[i];
                rep(j, m) X[j] += A[i][j];
            }
        }
        bool flag = 0;
        rep(i, m) if(X[i] < x) {
            flag = 1;
        }
        if (flag) continue;
        chmin(ans, money);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

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

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

int main()
{
	int n,ct=0;
	cin >> n;
	int a[n];
	for(int i = 1;i <= n;i++){
		a[i] = i;
	}
	for(int i = 1;i <= n;i++){
		if(a[i] % 2 != 0)
			ct++;
	}
	float x;
	x = ct*1.0/n;
	printf("%.10lf",x);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// double dp[301][301][301];

int main() {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ai(0), aj(0), ak(0);
    for (int i = 0; i < n; ++i) {
        if (a[i] == 1)
            ak++;
        else if (a[i] == 2)
            aj++;
        else if (a[i] == 3)
            ai++;
    }
    vector<vector<vector<double>>> dp(
        n + 2, vector<vector<double>>(n + 3, vector<double>(n + 4, 0)));
    for (int i = 0; i <= n; ++i) {             // 3 left
        for (int j = 0; j <= n + 1; ++j) {     // 2 left
            for (int k = 0; k <= n + 2; ++k) { // 1 left
                if (i + j + k != 0) {
                    double tot = double(i + j + k);
                    dp[i][j][k] =
                        double(n) / tot +
                        ((i == 0 ? 0 : double(i) / tot * dp[i - 1][j + 1][k]) +
                         (j == 0 ? 0 : double(j) / tot * dp[i][j - 1][k + 1]) +
                         (k == 0 ? 0 : double(k) / tot * dp[i][j][k - 1]));
                }
            }
        }
    }

    cout << fixed << setprecision(10) << dp[ai][aj][ak] << endl;
    return 0;
}

Measured memory_bytes: 221952
import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p.append(i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2])
for e in sys.stdin:print(p[int(e)])


Measured memory_bytes: 50424
#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 A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    int res = 1;
    for(int i=min(A, B); i>=1; i--) {
        if(A%i == 0 && B%i == 0) {
            res = i;
            cnt++;
        }
        if(cnt == K) break;
    }

    cout << res << endl;
    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++)
typedef long long ll;

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

    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }

    int now = 0, c = 0;
    rep(i,n){
        if( now == 1 ){
            cout << c << endl;
            break;
        }
        if( c >= n-1 ){
            cout << "-1" << endl;
            break;
        }
        c++;
        now = a.at(now) - 1;
    }
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; cin >> n; int a[n];
    int ans = 100000; int total = 0;int total1 = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        total += a[i];
    }

    for(int i = 0;i < n;i++){
        ans = min(abs(total-total1),ans);
        total1 += a[i];
        total -= a[i];
    }
    cout << ans;
    
    
}




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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	int N,M;cin>>N>>M;
	int sum=0;
	for (int i = 0; i < M; ++i) {
		int a;cin>>a;sum+=a;

	}
	cout<<(sum-1)/(N+1)+1<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>
#include <tuple>

const int kN = 100000 + 5;
int n;
std::vector<int> edges[kN];

int dfs(int u, int fa)
{
    int best = 0, zeros = 0;
    for (int v : edges[u]) if (v != fa) {
        auto t = dfs(v, u);
        if (!t)
            ++ zeros;
        else
            best += t;
    }
    best += std::max(zeros - 1, 0);
    return best;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }
    int root = -1;
    for (int i = 0; i < n; ++ i)
        if (edges[i].size() > 2)
            root = i;

    if (root == -1) {
        return puts("1"), 0;
    }
    printf("%d\n", dfs(root, -1));
}


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

int main() {
  int H,W;
  cin >> H>>W;
  vector<int> vec(H,0);

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

    int a,c;
    cin>>a>>c;

    vec.at(a-1)++; 
    vec.at(c-1)++;

  }
  for (int i=0; i<H; i++){
    cout<<vec.at(i)<<endl;
  }

}
   


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

using ll = long long;

int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = 1e18;
    for(ll i = 1; i < h; i++) {
        ll rd = h - i;
        ll smx = max(i * w, max((rd/2) * w, (rd/2+rd%2) * w));
        ll smn = min(i * w, min((rd/2) * w, (rd/2+rd%2) * w));
        ans = min(ans, smx - smn);

        smx = max(i * w, max(rd * (w/2), rd * (w/2+w%2)));
        smn = min(i * w, min(rd * (w/2), rd * (w/2+w%2)));
        ans = min(ans, smx - smn);
    }

    for(ll i = 1; i < w; i++) {
        ll rd = w - i;
        ll smx = max(i * h, max((rd/2) * h, (rd/2+rd%2) * h));
        ll smn = min(i * h, min((rd/2) * h, (rd/2+rd%2) * h));
        ans = min(ans, smx - smn);

        smx = max(i * h, max(rd * (h/2), rd * (h/2+h%2)));
        smn = min(i * h, min(rd * (h/2), rd * (h/2+h%2)));
        ans = min(ans, smx - smn);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
nk=input().rstrip().split(" ")
n=int(nk[0])
k=int(nk[1])
numbers=input().rstrip().split(" ")
sigmas=[0]
sigma=0
for i in range(n):
    sigma=sigma+(int(numbers[i])+1)/2
    sigmas.append(sigma)
#print(sigmas)
deltas=[]
for i in range(n-k+1):
    delta=sigmas[k+i]-sigmas[i]
    deltas.append(delta)
#print(deltas)
answer=0
for delt in deltas:
    if delt>=answer:
        answer=delt
print(answer)

Measured memory_bytes: 29436
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() % 10;
        if (n == 3) {
            System.out.println("bon");
        }
        else if (n == 0 || n == 1 || n == 6 || n == 8) {
            System.out.println("pon");
        }
        else {
            System.out.println("hon");
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    array<ll, 3> T{};
    ll ans = 1;
    rep(i, N) {
        ll temp = 0;
        bool flag = true;
        iter(j, T) {
            if(j == A[i]) {
                if(flag) {
                    j++;
                    flag = false;
                }
                temp++;
            }
        }
        (ans *= temp) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;


int main() {
	string s;
	cin>>s;
	int ls=s.length();
	int p=0;
	for(int i=1;i<ls;++i){
		if(s[i]!=s[i-1])p++;
	}


	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int a[101]={0};
	int s[31]={0};
	int x,y;
	char comma;
	
	while(cin>>x>>comma>>y,x!=0||y!=0){
		a[x]=y;
		s[y]=1;
	}
	int f;
	while(cin>>f){
		int c=1;
		for(int i=a[f]+1;i<31;i++){
			if(s[i]==1)
				c++;
		}
		cout<<c<<endl;
	}
	
	
 	
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>

#define ll long long

using namespace std;

int main() {
    ll a, b = 100;
    ll ans = 0;
    cin >> a;
    while(a > b){
        ans++;
        b = static_cast<long long int>(b * 1.01);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int main() {

    ll R; cin >> R;

    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <utility>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


const int MAX = 1e3 + 5;
const int MOD = 1e9 + 7;
ll a[MAX];

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int n, x;
		in >> n;
		rep(i, 2, n+1, 1) {
			x = i;
			rep(j, 2, n+1, 1) {
				while (x % j == 0) x /= j, a[j]++;
			}
		}
		ll ans = 1;
		rep(i, 1, n+1, 1) ans = (ans * (a[i]+1)) % MOD;
		out << ans << endl;
    }
};

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


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

int main() {
  int A[10];
  string s;
  while(cin >> s) {
    for(int i = 0; i < s.size(); ++i) A[i] = s[i] - '0';
    for(int i = 10; i > 1; --i) {
      for(int j = 0; j+1 < i; ++j) {
        A[j] = (A[j] + A[j+1]) % 10;
      }
    }
    cout << A[0] << endl;
  }
  return 0;
}

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

int main(){
  int N, a, b, c, d;
  cin >> N;
  a = N/1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = (N - a * 1000 - b * 100 - c * 10);
  if (a == b && b == c || b == c && c == d){
    cout << "Yes" <<endl;
  }
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=[]
q=set()
for i in range(n):
	q.add(i)
for i in range(60):
	p=0
	l=[]
	for j in q:
		if a[j]%2==1:
			p+=1
		a[j]//=2
		if a[j]==0:
			l.append(j)
	for j in range(len(l)):
		q.remove(l[j])
	cnt.append(p)
ans=0
for i in range(60):
	ans+=(n-cnt[i])*cnt[i]*(2**i)
	ans%=mod
print(ans)


Measured memory_bytes: 123232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


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

    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end());
    vector<int> b(n);
    for (int i = 0; i<n; i++) b[i] = abs(n-i-1 - i);
    sort(b.begin(), b.end());
    if (a!=b) cout<<0;
    else cout<<po(2, n/2);


}




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

int main(){
	int a[100] = { 0 }, x, c = 0;
	for(int i = 0;i < 3;++i){
		cin >> x;
		a[--x]++;
	}
	for(int i = 0;i < 100;++i){
		if(a[i] > 0) ++c;
	}

	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int H, W, N, sum[605][605], ans; char str[305];
vector<int> r[605], c[605];

inline int calcr(int x, const int &l, const int &r){
	if(l > r || x < 1 || x > N) return 0;
	return sum[x][r] - sum[x - 1][r] - sum[x][l - 1] + sum[x - 1][l - 1];
}

inline int calcc(const int &d, const int &u, int y){
	if(d > u || y < 1 || y > N) return 0;
	return sum[u][y] - sum[u][y - 1] - sum[d - 1][y] + sum[d - 1][y - 1];
}

int main(){
	getint(H), getint(W), N = H + W;
	for(register int i = 1; i <= H; i++){
		scanf("%s", str + 1);
		for(register int j = 1; j <= W; j++) if(str[j] == '#'){
			sum[i + j][i - j + W]++;
			r[i + j].push_back(i - j + W);
			c[i - j + W].push_back(i + j);
		}
	}
	for(register int i = 1; i <= N; i++)
		for(register int j = 1; j <= N; j++)
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
	for(register int i = 1; i <= N; i++){
		sort(r[i].begin(), r[i].end());
		for(register int j = 0, siz = r[i].size(); j < siz; j++)
			for(register int k = j + 1; k < siz; k++){
				const int d = r[i][k] - r[i][j];
				ans += calcr(i - d, r[i][j], r[i][k]);
				ans += calcr(i + d, r[i][j], r[i][k]);
			}
		sort(c[i].begin(), c[i].end());
		for(register int j = 0, siz = c[i].size(); j < siz; j++)
			for(register int k = j + 1; k < siz; k++){
				const int d = c[i][k] - c[i][j];
				ans += calcc(c[i][j] + 1, c[i][k] - 1, i - d);
				ans += calcc(c[i][j] + 1, c[i][k] - 1, i + d);
			}
	}
	return printf("%d\n", ans), 0;
}

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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, a, b, c = 0;
  cin >> k >> a >> b;
  
  for (int i = a; i <= b; i++) {
    if (i%k == 0) {
      c = 1;
      break;
    }
  }
  
  if (c == 1)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}




Measured memory_bytes: 3620
def main():
    S = list(map(int, list(input().rstrip())))
    K = int(input())
    if sum(S[:K]) == K and len(set(S[:K])) == 1:
        print(1)
    else:
        for s in S:
            if s != 1:
                print(s)
                exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 61752
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int cnt = 0;

	while (A >= B) {
		B *= 2;
		cnt++;
	}

	while (B >= C) {
		C *= 2;
		cnt++;
	}

	string ans;
	if (cnt <= K) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    int ans = 0;
    if(n>=h && n>=w)
    {
        ans = (n-h+1)*(n-w+1);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int u = sc.nextInt();
        int v = sc.nextInt();

        // u(Mr. Takahashi) has already visited
        boolean[] alreadyVisitedU = new boolean[n + 1];
        // v(Mr. Aoki) has already visited
        boolean[] alreadyVisitedV = new boolean[n + 1];

        // edge map
        Map<Integer, Set<Integer>> edge = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            // add: a -> b
            if (!edge.keySet().contains(a)) {
                edge.put(a, new HashSet<>());
            }
            edge.get(a).add(b);
            // add: b -> a
            if (!edge.keySet().contains(b)) {
                edge.put(b, new HashSet<>());
            }
            edge.get(b).add(a);
        }

        // map: position -> depth
        Map<Integer, Integer> position2DepthMapU = new HashMap<>();
        Map<Integer, Integer> position2DepthMapV = new HashMap<>();
        dfs(alreadyVisitedU, edge, 0, u, position2DepthMapU);
        dfs(alreadyVisitedV, edge, 0, v, position2DepthMapV);
//        System.out.println("u: " + position2DepthMapU);
//        System.out.println("v: " + position2DepthMapV);

        // u < v のうち、maxのdepthを探す
        int ans = -1;
        for (int i : position2DepthMapU.keySet()) {
            int depthU = position2DepthMapU.get(i);
            int depthV = position2DepthMapV.get(i);
            if (depthU < depthV) {
                ans = Math.max(ans, depthV);
            }
        }
        ans--;
        System.out.println(ans);

        sc.close();
    }

    // return value: depth
    static void dfs(boolean[] alreadyVisited, Map<Integer, Set<Integer>> edge, int currentDepth, int currentPosition,
            Map<Integer, Integer> position2DepthMap) {
        if (alreadyVisited[currentPosition]) {
            return;
        }
        alreadyVisited[currentPosition] = true;
        position2DepthMap.put(currentPosition, currentDepth);
        for (int nextPosition : edge.get(currentPosition)) {
//            position2DepthMap.put(nextPosition, currentDepth + 1);
            dfs(alreadyVisited, edge, currentDepth + 1, nextPosition, position2DepthMap);
        }
        return;
    }

}


Measured memory_bytes: 147452
n=gets.to_i
a=[]
n.times do
  a<< gets.chomp
end
s=gets.chomp
r=[0,0]
n.times do |i|
  ([a[i].length,s.length].min).times do |j|
    if a[i][j]==??
      if s[j]!=?z && s[j]!=?a
        r[1]+=1
        break
      else
        if [a[i].length,s.length].min==j+1
          if s.length>a[i].length
            r[0]+=1
          elsif s.length==a[i].length
            r[1]+=1
          end
        end
      end
    elsif a[i][j]>s[j]
      break
    elsif a[i][j]<s[j]
      r[0]+=1
      break
    elsif a[i][j]==s[j]
      if [a[i].length,s.length].min==j+1
        if s.length>a[i].length
          r[0]+=1
        elsif s.length==a[i].length
          r[1]+=1
        end
      end
    end
  end
end
puts [*r[0]+1..r[0]+r[1]+1].* " "

Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int w,h;
  vector<vector<int>> mp;
  while(cin >> w >> h){
    if(!w)break;
    mp.resize(2*h-1,vector<int>(2*w-1,0));
    int W = 2*w-1;
    int H = 2*h-1;
    for(int i=0;i<H-2;i+=2){
	for(int j=0;j<W-2;j+=2){
	cin >> mp[i][j+1];
      }
      for(int j=0;j<W;j+=2){
	cin >> mp[i+1][j];
      }
    }
    for(int j=0;j<W-2;j+=2){
      cin >> mp[H-1][j+1];
    }
    /*   REP(i,H){
      REP(j,W)cout << mp[i][j] << " ";
      cout << endl;
      }*/
    queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    mp[0][0] = 1;
    while(que.size()){
      pair<int,int> p = que.front();
      que.pop();
      for(int k=0;k<4;k++){
	int y = p.first+2*dy[k];
	int x = p.second+2*dx[k];
	if(x>=0 && x<W && y>=0 && y<H){
	  if(mp[p.first+dy[k]][p.second+dx[k]])continue;
	  if(mp[p.first][p.second]+1 >= mp[y][x] && mp[y][x]>0)//????
	    {continue;
	    }
	  else{
	    mp[y][x] = mp[p.first][p.second]+1;
	    que.push(make_pair(y,x));
	  }
	}
      }
    }
    cout << mp[H-1][W-1] << endl;
    mp.clear();
  }
    return 0;
}
  

Measured memory_bytes: 3036
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int c[5],s[5];
    for (int i = 0; i < m; i++)
    {
        cin>>s[i]>>c[i];
    }
    for (int i = 0; i < 1000; i++)
    {
        string a=to_string(i);
        if(a.size()!=n)continue;
        bool f=true;
        for (int j = 0; j < m; j++)
        {
            if (a[s[j]-1]!=c[j]+'0')
            {
                f=false;
                break;
            }
        }
        if(f) {
          cout<<i<<endl;
       	  return 0;
        }
    }
    cout<<"-1"<<endl;
}

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

#define chalne_de continue
int mod = 1000000007;
const int N = 1000005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
ll lcm(ll a, ll b)
{
    ll x = gcd(a,b);
    a /= x;
    return a * b;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	ll a[n+1];
	rep(i,0,n)
	cin >> a[i];
	ll g = a[0];
	for ( int i = 1; i < n; i++)
        g = gcd(g,a[i]);
    ll lc = a[0];
    for ( int i = 1; i < n; i++)
        lc = lcm(lc,a[i]);
    cout << lc ;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    string S;
    vector<set<int>> idx(26);
    REP(i, 26) idx[i].insert(INF);
    cin >> N >> S >> Q;
    REP(i,N) idx[S[i]-'a'].insert(i);
    while(Q--){
        int q, l, r;
        char c;
        cin >> q;
        if(q == 1){
            cin >> l >> c;
            l--;
            idx[S[l]-'a'].erase(l);
            S[l] = c;
            idx[c-'a'].insert(l);
        }
        else{
            cin >> l >> r;
            l--, r--;
            int cnt = 0;
            REP(i,26){
                auto itr = idx[i].lower_bound(l);
                if(*itr <= r) cnt++;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 24220
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0&&W==0) break;
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll A, B, H, M;
    cin >> A >> B >> H >> M;

    double ra = (double)H/12*2*M_PI + (double)M/12/60*2*M_PI;
    double rb = (double)M/60*2*M_PI;

    double dx = A*cos(ra) - B*cos(rb);
    double dy = A*sin(ra) - B*sin(rb);
    double d = sqrt(dx*dx+dy*dy);

    cout << d << endl;
}


Measured memory_bytes: 4116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("at_A.in","r",stdin);
    //freopen("at_A.out","w",stdout);
#endif

	int a,b,c;
	cin>>a>>b>>c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    final static int MAX = 1_000_000+10;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next().toString();
        System.out.println(s.charAt(s.length() - 1) == 's'? s+"es":s+"s");

        }

    static int gcd(int a, int b) { return b==0 ? a : gcd(b, a%b);}
    static final Random random = new Random();

    static void ruffleSort(int[] a) {
        int n = a.length;//shuffle, then sort
        for (int i = 0; i < n; i++) {
            int oi = random.nextInt(n), temp = a[oi];
            a[oi] = a[i];
            a[i] = temp;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 36784
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    char str[1024];
    int N,i,j,tmp;
    float v[1024];
    
    fgets(str,sizeof(int),stdin);
    sscanf(str,"%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%f ",&v[i]);
    }
    
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            if(v[i]>v[j]){
                tmp = v[i];
                v[i] = v[j];
                v[j] = tmp;
            }
        }
    }
    
    for(i=0;i<N-1;i++){
        v[i+1] = (v[i]+v[i+1])*0.5;
    }
    
    printf("%f\n",v[N-1]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, h, N);
  int ans = 0;
  int cnt = INF;
  while (cnt > 0) {
    cnt = 0;
    bool f = true;
    rep(i, 0, N) {
      if (h[i] > 0) {
        h[i]--;
        if (f) {
          cnt++;
          f = false;
        }
      } else {
        f = true;
      }
    }
    ans += cnt;
  }
  print(ans);
}


Measured memory_bytes: 256
mat = [[] for i in range(10)]
vis  = [False for i in range(10)]
def dfs(a, n):
	all_vis= True
	for i in range(0, n):
		if vis[i]==False:
			all_vis=False
	if all_vis==True:
		return 1
	ans =0
	for i in mat[a]:
		if vis[i]==True:
			continue
		vis[i]=True
		ans = ans+dfs(i,n)
		vis[i]=False
	return ans
n , m = map(int , input().split())
for i in range(m):
	a, b= map(int ,input().split())
	a =a-1
	b=b-1
	mat[a].append(b)
	mat[b].append(a)
vis[0]=True
print(dfs(0, n))

Measured memory_bytes: 73808
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;


int main()
{
	//freopen("main.inp", "r", stdin);
	//freopen("main.out", "w", stdout);
	int n; cin >> n;
	float x = 1.0 * n / 3;
	x *= (x * x);
	cout << setprecision(12) << fixed << x;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
ll num(ll n, ll x){
    if(n==-1){return 0;}
    return n/x+1;
}
int main(){
    ll a,b,x,ans;
    cin >> a >> b >> x;
    ans = num(b,x) - num(a-1,x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,x;
	scan(N>>x);
	if(2<=x&&x<=2*N-2){
		prin("Yes");
		if(N==2){
			printf("%d\n%d\n%d\n",3,2,1);
			return 0;
		}
		int ans[200001];
		ans[N-1]=x;
		if(x>2){
			ans[N]=2*N-1;
			ans[N-2]=1;
			ans[N+1]=2;
			int v=3;
			rep(i,2*N-1){
				if(N-2<=i&&i<=N+1) continue;
				while(v==x||v==2*N-1) v++;
				ans[i]=v;
				v++;
			}
		}
		else{
			ans[N]=1;
			int v=3;
			rep(i,2*N-1){
				if(i==N-1||i==N) continue;
				ans[i]=v;
				v++;
			}
		}
		rep(i,2*N-1) prin(ans[i]);
	}
	else{
		prin("No");
	}
	return 0;
}


Measured memory_bytes: 2304
import math

a, b, h, m = map(int, input().split())

# if h != 0:
kaku_a = (360 * h / 12) + (m / 2)
# else:
#     kaku_a = 0

# if m != 0:
kaku_b = 360 * m / 60
# else:
#     kaku_b = 0

if kaku_a > kaku_b:
    kaku = kaku_a - kaku_b
else:
    kaku = kaku_b - kaku_a


cos = math.cos(math.radians(kaku))
lengs = a**2 + b**2 - (2 * a * b * cos)
lengs = math.sqrt(lengs)

print(lengs)


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
const int MAXN=60;
int n;
double v[MAXN];
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%lf",&v[i]);}
	sort(v+1,v+n+1);
	for (int i=1;i<=n-1;i++) {
		v[i+1]=(v[i]+v[i+1])/2;
	}
	printf("%lf\n",v[n]);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	/**
	 * ???????????¢??°
	 * @param args ?????°
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = null;
		try {
			//???????????????????????????????????????
			in = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(in.readLine());
			
			//?????¨???????????????????????????
			System.out.println(interest(100000, 5, n));
		} finally {
			//???????????????????????????
			if(in != null) in.close();
			in = null;
		}
	}
	/**
	 * ?????¨?????????????¨?????????????
	 * @param debit ??????????????????
	 * @param rate ?????????(??????:%)
	 * @param n ?????°
	 * @return ?????¨?????????
	 */
	public static int interest(int debit, int rate, int n) {
		int ret = debit;
		
		//??????????¨??????????
		for(int i = 0; i < n; i++) {
			//??????????????????
			ret += ret * rate / 100;
			//???3??????????????????
			ret = cutOut(ret, 3);
		}
		
		//?????¨?????????????????????
		return ret;
	}

	/**
	 * ?????????????????°???????¨?????????????
	 * @param num ????????????????????°???
	 * @param n ??????????????????n???
	 * @return ???n?????????????????????
	 */
	public static int cutOut(int num, int n) {
		int ret = num;
		//???????????????????¶??????°???????????????
		String kiri = "1";
		for(int i = 0; i < n; i++) {
			kiri = kiri + "0";
		}
		
		//???n??????????????????
		String str = String.valueOf(ret);
		str = str.substring(str.length()-n, str.length());
		if(Integer.parseInt(str) > 0) {
			ret  = ret - Integer.parseInt(str) + Integer.parseInt(kiri);
		}
		
		//?????????????????°????????????
		return ret;
	}
}

Measured memory_bytes: 24180
h, w, k = list(map(int, input().split()))

choco = [list(map(int, list(input()) )) for i in range(h)]

choco_cumsum = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    choco_cumsum[i][0] = choco[i][0]
    for j in range(1, w):
        choco_cumsum[i][j] = choco_cumsum[i][j-1] + choco[i][j]

ans = h + w + 1

for h_cut in range(2**(h-1)):
    # 上位ビットが上側。1が切る、0が切らない
    num_cut_init = bin(h_cut).count("1") # 立っているビットの個数
    num_cut = num_cut_init
    w_last_cot_pos = -1
    valid = True

    temp_list = [0] * (num_cut_init + 1)
    temp_dict = {}
    idx = 0
    temp_dict[0] = idx
    for i in range(1, h):
        # print('idx', 2 ** (-i+h-1) )
        if h_cut & (2 ** (-i+h-1) ):
            idx += 1
        # idx += h_cut & (2 ** (h-1) - i)
        temp_dict[i] = idx
    # print(temp_dict)

    iw = 0
    while iw < w:

        for ih in range(h):
            temp_list[temp_dict[ih]] += choco[ih][iw]
        # print(iw, temp_list)

        condition = max(temp_list) > k
        if condition:
            if w_last_cot_pos < iw-1:
                # もしそこで切ってkを超えるなら、その手前で切る
                num_cut += 1
                w_last_cot_pos = iw - 1
                temp_list = [0] * (num_cut_init + 1)
                # print('iw: ', iw, 'last: ', w_last_cot_pos)

            else:
                # 1つしか動かしてない場合は土台無理なので次のh_cutに
                valid = False
                break
        
        else:
            iw += 1
    
    if valid:
        ans = min(ans, num_cut)
    # print(num_cut)

print(ans)


Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;

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

  vector<P> A(N);
  REP(i,N) cin >> A[i].first >> A[i].second;
  
  ll ans = 0;
  REPR(i,N-1){
    if((A[i].first+ans)%A[i].second!=0){
      ans+=(((A[i].first+ans)/A[i].second)+1)*A[i].second-(A[i].first+ans);
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }

    int minx = -1e9 - 2, maxx = 1e9 + 2;
    bool none = false;
    for (int i = 0; i < n; i++) {
      if (a[i] == "x") {
        if ((i > 0 && a[i - 1] == "x") || (i < n - 1 && a[i + 1] == "x")) {
          none = true;
          break;
        } else if (i & 1) {
          if (i > 0) minx = max(minx, atoi(a[i - 1].c_str()) + 1);
          if (i < n - 1) minx = max(minx, atoi(a[i + 1].c_str()) + 1);
        } else {
          if (i > 0) maxx = min(maxx, atoi(a[i - 1].c_str()) - 1);
          if (i < n - 1) maxx = min(maxx, atoi(a[i + 1].c_str()) - 1);
        }
      } else if (i & 1) {
        if (i > 0 && a[i - 1] != "x" && atoi(a[i - 1].c_str()) >= atoi(a[i].c_str())) {
          none = true;
        } else if (i < n - 1 && a[i + 1] != "x" && atoi(a[i].c_str()) <= atoi(a[i + 1].c_str())) {
          none = true;
        }
        if (none) break;
      } else {
        if (i > 0 && a[i - 1] != "x" && atoi(a[i - 1].c_str()) <= atoi(a[i].c_str())) {
          none = true;
        } else if (i < n - 1 && a[i + 1] != "x" && atoi(a[i].c_str()) >= atoi(a[i + 1].c_str())) {
          none = true;
        }
        if (none) break;
      }
    }

    if (none || minx - maxx > 0) {
      cout << "none\n";
    } else if (minx == maxx) {
      cout << minx << endl;
    } else {
      cout << "ambiguous\n";
    }
  }

  return 0;
}


Measured memory_bytes: 3236
S = input()
sumi = 0
sumii = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == "1":
      sumi += 1
  if (i % 2) == 1:
    if S[i:i+1] == "0":
      sumi += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == "0":
      sumii += 1
  if (i % 2) == 1:
    if S[i:i+1] == "1":
      sumii += 1
        
if sumi > sumii:
  print(sumii)
else:
  print(sumi)

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

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "["<< *it << " = " << a << "]"<< endl;
    err(++it, args...);
}
using ll = long long;


int main() {
    int N, W;
    scanf("%d%d", &N, &W);
    int w, v ;
    
    vector<ll> dp(W+1);
    for (int i = 1; i<= N; i++) {
        scanf("%d %d", &w, &v);
        for (int j = W; j>=w; j--) {
            dp[j] = max(dp[j], dp[j-w] + v);
        }
    }

    printf("%lld\n", dp[W]);
}


Measured memory_bytes: 1024