akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let a:i32 = match buf.trim().to_string().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let b:i32 = match buf.trim().to_string().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	let mut v = vec![1, 2, 3];
	v[(a-1) as usize] = 0;
	v[(b-1) as usize] = 0;
	for num in v {
		if num != 0 {
			println!("{}", num);
		}
	}
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
char c[5];
int main(){
	int i, j, k;
	cin >> c;
	if(c[0] == 'S' && c[1] == 'A' && c[2] == 'T')cout << 1 << endl;
	else if(c[0] == 'S' && c[1] == 'U' && c[2] == 'N')cout << 7 << endl;
	else if(c[0] == 'M' && c[1] == 'O' && c[2] == 'N')cout << 6 << endl;
	else if(c[0] == 'T' && c[1] == 'U' && c[2] == 'E')cout << 5 << endl;
	else if(c[0] == 'W' && c[1] == 'E' && c[2] == 'D')cout << 4 << endl;
	else if(c[0] == 'T' && c[1] == 'H' && c[2] == 'U')cout << 3 << endl;
	else if(c[0] == 'F' && c[1] == 'R' && c[2] == 'I')cout << 2 << endl;
	return 0;
}


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

using namespace std;
using ll=long long;

int t;

void test_case(){
    int n;
    cin>>n;
    vector<double>dp(n+1);
    dp[0]=1; // P(having 0 heads outoff 0 coins) = 1
    for(int coin=1; coin<=n; coin++){
        double p_head;
        cin>>p_head;
        double p_tail=(1-p_head);
        for(int n_heads=coin; n_heads>=0; n_heads--){
            dp[n_heads]=((n_heads ? dp[n_heads-1] : 0)*p_head) + (dp[n_heads]*p_tail);
        }
    }
    double ans=0;
    for(int n_head=0; n_head<=n; n_head++){
        if(n_head>(n-n_head)){
            // cout<<dp[n_head]<<" "<<n_head<<endl;
            ans+=dp[n_head];
        }
    }
    cout<<setprecision(10)<<ans<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }

    return 0;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <algorithm>
int N, M, a[100001];
int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 1, u, v; i <= M; i++)
	{
		scanf("%d%d", &u, &v);
		a[u] ^= 1;
		a[v] ^= 1;
	}
	printf(int(std::count(a + 1, a + N + 1, 0)) == N ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
	int N, D, s,t;
	cin >> N >> D;
	s = (int)(N%(2*D+1));
	t = (int)(N/(2*D+1));
	if(s==0) cout << t << endl;
	else cout << t+1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        String X = sc.next();
        String Y = sc.next();
        String[] xy = {X,Y};
      
        int x = 0;
        int y = 0;
        for(int i = 0; i < 2; i++){
          switch(xy[i]){
            case "A": 
              if(x == 0){
                x = 10;
              }else{
                y = 10;
              }
              break;
            case "B":
              if(x == 0){
                x = 11;
              }else{
                y = 11;
              }
              break;
            case "C":
              if(x == 0){
                x = 12;
              }else{
                y = 12;
              }
              break;
            case "D":
              if(x == 0){
                x = 13;
              }else{
                y = 13;
              }
              break;
            case "E":
              if(x == 0){
                x = 14;
              }else{
                y = 14;
              }
              break;
            case "F":
              if(x == 0){
                x = 15;
              }else{
                y = 15;
              }
              break;
          }
        }
        
        if(x > y){
          System.out.println(">");
        }else if(x == y){
          System.out.println("=");
        }else{
          System.out.println("<");
        }
        
	}

}

Measured memory_bytes: 35664
#include<bits/stdc++.h>
using namespace std;
int f(string t,string s,int x,int y)
{
	int i;
	int ans=0;
	for(i=x;i<=y;i++)
		if(t[i-x]!=s[i])
			ans++;
	return ans;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int i;
	int ans=INT_MAX;
	ans=min(ans,f(t,s,0,t.length()-1));
	for(i=t.length();i<s.length();i++)
	{
		ans=min(ans,f(t,s,i-t.length()+1,i));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(a+b>=c) {
        printf("%d\n", b+c);
    } else {
        printf("%d\n", b+(a+b)+1);
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N, L;
  cin >> N >> L;
  vi a(N);
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }

  {
    bool f = false;
    for (ll i = 0; i < N - 1; i++) {
      if (a[i] + a[i + 1] >= L) {
        f = true;
      }
    }

    if (f == false) {
      cout << "Impossible" << endl;
      return 0;
    }

    cout << "Possible" << endl;
  }


  for (ll i = 1; i <= N - 1; i++) {
    if (a[i - 1] + a[i] >= L) {
      for (ll k = 1; k <= i - 1; k++) {
        cout << k << endl;
      }
      for (ll k = N - 1; k >= i + 1; k--) {
        cout << k << endl;
      }
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1664
using System;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int ans = 1;
        for(int i = 0;i < N;i++){
            if(ans*2 < ans+K){
                ans = ans*2;
            }else ans += K;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, p;
string s;
int f[10000];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> p >> s;
    s = " " + s;
    ll res = 0;
    if (p == 2) {
        FOR(i,1,n)
            if ((s[i] - '0') % 2 == 0) res += i;
    }
    else if (p == 5) {
        FOR(i,1,n)
            if ((s[i] - '0') % 5 == 0) res += i;
    }
    else {
        int now = 0;
        f[0] = 1;
        
        int mu = 1;
        FORE(i,n,1) {
            now = (now + mu * (s[i] - '0') % p) % p;
            res += f[now];
            f[now]++;
            mu = mu * 10 % p;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, a, b;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int in[13]={0};
int n;
int q[13];
int w[3]={0,1,-1};
bool f(int c){
	if(c==12){
		int sum=0;
		rep(i,12)sum+=q[i]*w[in[i]];
		if(n==sum){
			string s="";
			rep(i,12)if(in[i]==0)s="0"+s;
			else if(in[i]==1)s="+"+s;
			else s="-"+s;
			while(s[0]=='0')s=s.substr(1);
			cout<<s<<endl;
			return 1;
		}
		return 0;
	}
	rep(i,3){
		in[c]=i;
		if(f(c+1))return 1;
	}
	return 0;
}
int main(){
	int t=1;
	rep(i,13){
		q[i]=t;
		t*=3;
	}
	cin>>n;
	f(0);
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll N,M;
	cin >> N >> M;
	vector<ll> A(N);
	FOR(i,0,N)cin >> A[i];
	vector<P> BC(M);
	FOR(i,0,M){
		cin >> BC[i].second >> BC[i].first;
	}
	SORT(BC);
	REV(BC);
	SORT(A);
	int i = 0;
	FOR(j,0,M){
		FOR(c,0,BC[j].second){
			if(i==N||BC[j].first<=A[i])break;
			A[i++] = BC[j].first;
		}
		if(i==N||BC[j].first<=A[i])break;
	}
	ll ans = 0;
	for(auto a:A){
		ans += a;
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 50 + 5;

int n, m;
char mp[N][N];
bool st[N][N];
int xi[5] = {0, 1, 0, -1};
int yi[5] = {1, 0, -1, 0};

bool check(int x, int y) {
    return !(x < 0 || x >= n || y < 0 || y >= m);
}

int ways(int x, int y) {
    if (mp[x][y] != '.')
        return -1;
    queue<pair<PII, int>> que;
    que.push(make_pair(make_pair(x, y), 0));
    int ans = -1;
    st[x][y] = true;
    while (!que.empty()) {
        PII now = que.front().first;
        int step = que.front().second;
        ans = max(ans, step);
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nowx = now.first + xi[i];
            int nowy = now.second + yi[i];
            if (check(nowx, nowy) && !st[nowx][nowy] && mp[nowx][nowy] == '.') {
                que.push(make_pair(make_pair(nowx, nowy), step + 1));
                st[nowx][nowy] = true;
            }
        }
    }
    return ans;

}

int main() {
    int ans = -1;

    cin >> n >> m;
    for (int i = 0; i < n; i++)
        scanf("%s", mp[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            memset(st, false, sizeof st);
            int now = ways(i, j);
            if (now > ans)
                ans = now;
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,A,B;

int main(){
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i,N){
        cin >> X[i];
    }

    ll ans = 0;
    for(int i=0;i<N-1;i++){
        ans += min(A*(X[i+1]-X[i]),B);
    }
    cout << ans << endl;
}


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

const int MAX = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int N;
int M[MAX][MAX];

int d[MAX];

queue<int> Q;

void bfs() {
    for (int i = 0; i < N; i++) {
        d[i] = -1;
    }
    
    Q.push(0);
    d[0] = 0;

    while (!Q.empty()) {
        int u = Q.front(); Q.pop();

        for (int i = 0; i < N; i++) {
            if (M[u][i] == 1 && d[i] == -1) {
                Q.push(i);
                d[i] = d[u] + 1;
            }
        }
    }
}

int main() {
    int u, k;
    
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs();
    
    for (int i = 0; i < N; i++) {
        printf("%d %d\n", i + 1, d[i]);
    }

    return 0;
}



Measured memory_bytes: 3264
#include<iostream>
using namespace std;
int minnum(int x,int y);
int main(){
    int data[5] = {0};
    int ansX = 0;
    int Yover = 0;
    int ansY = 0;
    for(int i = 0;i < 5;i++){
        cin >> data[i];
    }
    ansX = data[0] * data[4];
    Yover = data[4] - data[2];
    if(Yover < 0){
        Yover = 0;
    }
    ansY = data[1] + (Yover * data[3]);
    int ans = minnum(ansX,ansY);
    cout << ans << endl;
    return 0;
}

int minnum(int x,int y){
    if(x <= y){
        return x;
    }
    else{
        return y;
    }
}

Measured memory_bytes: 3060
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

double a, b, c, d, e, f, ans1, ans2;
double percent;

int main()
{
	cin >> a >> b >> c >> d >> e >> f;
	percent=0;
	for(ll i = 0; i < 300; i++){
		for(ll j = 0; j < 300; j++){
			for(ll k = 0; k < 31; k++){
				for(ll l = 0; l < 31; l++){
					if((i*c+j*d) <= (k*a+l*b)*e && i*c+j*d+k*a*100+l*b*100<=f){
						if(100*(i*c+j*d)*1.0/(i*c+j*d+k*a*100+l*b*100)>percent){
							percent=100*(i*c+j*d)*1.0/(i*c+j*d+k*a*100+l*b*100);
							ans1=i*c+j*d+k*a*100+l*b*100;
							ans2=i*c+j*d;
						}
					}
				}
			}
		}
	}
	if(ans1!=0||ans2!=0){
		cout << ans1 << " " << ans2;
	}
	else{
		cout << 100*a << " " << 0;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int r, c;
    cin >> r >> c;
    vector<int> cc(c);
    int s= 0;
    
    rep(i, r) {
        int su = 0;
        rep(i, c) {
            int a;
            cin >> a;
            su += a;
            cc[i] += a;
            cout << a << ' ';
        }
        cout << su << endl;
        s += su;
    }
    rep(i, c) {
        cout << cc[i] << ' ';
    }
    cout << s << endl;

    return 0;
}


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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define vii vector<pair<int, int> >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false); cin.tie(0)

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 1e5 + 10;

int a[N];
int main(){
	boost;
	int n; 
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	int ans = 0;
	
	int i = 0;
	while(i < n){
		int j = i + 1, k = i + 1;
		int c1 = 0, c2 = 0;
		while(j < n && a[j - 1] <= a[j]){
			++c1;
			++j;
		}
		while(k < n && a[k - 1] >= a[k]){
			++c2;
			++k;
		}
		if(c1 > c2){
			i = j;
		}else{
			i = k;
		}
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long a[n];
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	long long p1=sum/n;
	long long rem=sum%n;
	long long p2=(sum+rem)/n;
	long long ans1=0;
	long long ans2=0;
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=(a[i]*a[i]);
	}
	long long min=0;
	long long  minans=1e9+7;
	
	for(int j=p1;j<=p2;j++){
		min=ans;
		min+=n*(j*j);
		min-=2*j*sum;
		if(min<minans){
			minans=min;
		}
	}

	cout<<minans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int maxn = 500005;
 
inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}
 
int n, k;
int p[maxn], q[maxn], r[maxn], cnt;
int Min[maxn << 2];
 
#define mid ((l + r) >> 1)
#define lch (s << 1)
#define rch (s << 1 | 1)
 
void build(int s, int l, int r)
{
	Min[s] = n + 1;
	if (l == r) return ;
	build(lch, l, mid);
	build(rch, mid + 1, r);
}
 
void modify(int s, int l, int r, int p, int v)
{
	if (l == r) return Min[s] = v, void();
	if (p <= mid) modify(lch, l, mid, p, v);
	else modify(rch, mid + 1, r, p, v);
	Min[s] = min(Min[lch], Min[rch]);
}
 
int query(int s, int l, int r, int ql, int qr)
{
	if (ql <= l && r <= qr) return Min[s];
	int res = n + 1;
	if (ql <= mid) res = min(res, query(lch, l, mid, ql, qr));
	if (qr >= mid + 1) res = min(res, query(rch, mid + 1, r, ql, qr));
	return res;
}
 
struct edge
{
	int to, next;
} e[maxn << 1];
int h[maxn], deg[maxn], tot;
 
priority_queue<int> que;
 
void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	++deg[v];
}
 
int main(){
	n = gi(); k = gi();
	for (int i = 1; i <= n; ++i) q[p[i] = gi()] = i;
	build(1, 1, n);
	for (int i = n, x; i >= 1; --i) {
		x = query(1, 1, n, max(1, q[i] - k + 1), q[i]);
		if (x <= n) add(q[x], q[i]);
		x = query(1, 1, n, q[i], min(n, q[i] + k - 1));
		if (x <= n) add(q[x], q[i]);
		modify(1, 1, n, q[i], i);
	}
 
	for (int i = 1; i <= n; ++i)
		if (!deg[i]) que.push(i);
	int u;
	while (!que.empty()) {
		r[++cnt] = u = que.top(); que.pop();
		for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
			if (!(--deg[v])) que.push(v);
	}
	reverse(r + 1, r + n + 1);
	for (int i = 1; i <= n; ++i) p[r[i]] = i;
	for (int i = 1; i <= n; ++i) printf("%d\n", p[i]);
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
//| #######################|
//|  ADARSH SINGH KUSHWAHA |
//| ###################### |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Bahut_tej_gand_faad ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frb(i, a, b) for(ll i = a - 1; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define mp map<ll,ll>
#define mps map<char,ll>
#define v vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define mod 1000000007
#define max 1000001
void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    ll x = t * s;
    if (x >= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
int main() {
    Bahut_tej_gand_faad;
    //int t;
    // cin >> t;
    // while (t--) {
    solve();
    // }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

//using integer = unsigned long long;
using integer = signed long long;

int main(void) {
  integer n;
  std::cin >> n;

  std::vector<std::vector<integer>> a(2, std::vector<integer>(n));
  for (integer i = 0; i < n; i++) {
    std::cin >> a[0][i];
  }
  for (integer i = 0; i < n; i++) {
    std::cin >> a[1][i];
  }

  integer max = 0;
  for (integer i = 0; i < n; i++) {
    integer sum = 0;
    sum += std::accumulate(a[0].begin(), a[0].begin() + (i + 1), 0);
    sum += std::accumulate(a[1].begin() + i, a[1].end(), 0);
    if (max < sum) {
      max = sum;
    }
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(v) for v in input().split()]
mod = 1000000007
cusum = [0]
for i in range(N):
    cusum.append(cusum[i] + A[i])

totalSum = 0
for i in range(N - 1):
    sum = (cusum[N] - cusum[i + 1]) % mod
    totalSum += sum * A[i]
    totalSum %= mod
print(totalSum)

Measured memory_bytes: 31576
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    judge = [[False]*W for _ in range(H)]
    judge[i][j]=True
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          continue
        c = b+1
        if judge[h][w]:
          continue
        A[h][w]=c
        judge[h][w]=True
        q.append([h,w])
        
    A = [a for b in A for a in b if a!=inf]
    ans = max(ans,max(A))
    
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		int maxHeight = Integer.MIN_VALUE;
		int answer = 0;

		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
			if (maxHeight <= H[i]) {
				maxHeight = Math.max(maxHeight, H[i]);
				answer++;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int upb(int n)
{
  int ret=0;
  while(n>0) ret++, n/=2;
  return ret;
}

int main()
{
  vector<bool> close(1<<(5*5), false);

  for (int n; cin>>n, !(n==0); ){

    vector<vector<int> > pats(n*n+1);
    vector<vector<int> > tmp(n, vector<int>(n, 0));
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	for (int k=i; k<n; k++){
	  for (int l=j; l<n; l++){
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=1;
	    int bd=0;
	    for (int a=0; a<n; a++){
	      for (int b=0; b<n; b++){
		bd=(bd<<1)|tmp[a][b];
	      }
	    }
	    pats[upb(bd)].push_back(bd);
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=0;
	  }
	}
      }
    }

    int bd=0;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	int t; cin>>t;
	bd=(bd<<1)|t;
      }
    }

    queue<pair<int, int> > mm;
    vector<int> cls;
    cls.reserve(1<<16);
    mm.push(make_pair(0, bd));
    close[bd]=true;
    cls.push_back(bd);
    while(!mm.empty()){
      int dep=mm.front().first;
      int cbd=mm.front().second;
      mm.pop();
      //cout<<cbd<<endl;
      int ub=upb(cbd);
      for (int i=0; i<pats[ub].size(); i++){
	int nbd=cbd^pats[ub][i];
	if (nbd==0){
	  for (int i=0; i<=dep; i++)
	    cout<<"myon";
	  cout<<endl;
	  goto _exit;
	}
	//cout<<"*** "<<nbd<<endl;
	if (close[nbd]) continue;
	close[nbd]=true;
	cls.push_back(nbd);
	mm.push(make_pair(dep+1, nbd));
      }
    }
  _exit:;
    for (int i=0; i<cls.size(); i++)
      close[cls[i]]=false;
  }
  return 0;
}

Measured memory_bytes: 6616
import numpy as np
n = int(input())
A = np.array(input().split(), dtype=np.int64)
left = np.zeros(n, dtype=np.int64)
right = np.zeros(n, dtype=np.int64)
stack = []
for i in range(n):
  now = 1
  while stack and stack[-1][0] > A[i]:
    num, dis = stack.pop()
    now += dis
  left[i] = now
  stack.append((A[i], left[i]))
stack = []
for i in range(n-1, -1, -1):
  now = 1
  while stack and stack[-1][0] > A[i]:
    num, dis = stack.pop()
    now += dis
  right[i] = now
  stack.append((A[i], right[i]))
mul = A*left*right
print(mul.sum())

Measured memory_bytes: 50540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=1e6+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,a,b;
      cin>>n>>a>>b;
      cout<<min(n*a,b);
}     
// I never lose. I either win or I learn

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

using namespace std;

int main(){
  int n, a[100005], t=0;
  cin >> n;
  for(int i=0;i<n;i++){
	  cin >> a[i];
  }
  sort(a,a+n);
  long long sum = a[0];
  for(int i=1;i<n;i++){
	  if(sum*2<a[i]){
		  t = i;
	  }
	  sum += a[i];
  }
  cout << n-t << endl;
  return 0;

}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   if(s[0]==s[1]&&s[1]==s[2]) {
       cout << "No" << endl;
   } else {
       cout << "Yes" << endl;
   }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ans = "Good";
        char[] s = sc.next().toCharArray();
        for(int i = 0; i < s.length-1; i++) if(s[i] == s[i + 1]) ans = "Bad";
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int INFTY = 1001001001;

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

    sort(a.begin(), a.end(), greater<int>());
    int max_v = a[0];
    int ans, dif=INFTY, d=max_v / 2;
    for(int i=1;i<N;++i){
        if(dif > abs(d - a[i])){
            dif = abs(d - a[i]);
            ans = a[i];
        }
    }
    cout << max_v << " " << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    ans=1;
    n-=k;
    k--;
    ans+=(n%k==0?n/k:n/k+1);
    Cout(ans);
    return 0;
}


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

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int a[200];
  int s=0,t=0;
  for(int i=1;i<=m;i++){
    cin>>a[i];
	if(a[i]<x)
	  s++;
	else if(a[i]>x)
	  t++;
	  }
  cout<<(s<=t?s:t)<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, T, S[100001];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		for(int j = l; j <= r; j++) S[j] = 1;
	}
	for(int i = 1; i <= 100000; i++)
		if(S[i]) T++;
	printf("%d\n", T);
}

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

int keisan(int okane, int kaisuu) {
	
	if (okane < 6) return kaisuu + okane;

	int saishou6 = 100000;
	int jou6, jou9;
	rep(i, 7) {
		int kari = okane - pow(6, i);
		if (kari >= 0 && saishou6 > kari) {
			saishou6 = kari;
			jou6 = i;
		}
		else if (kari < 0) break;
	}
	int saishou9 = 100000;
	rep(i, 6) {
		int kari = okane - pow(9, i);
		if (kari >= 0 && saishou9 > kari) {
			saishou9 = kari;
			jou9 = i;
		}
		else if (kari < 0) break;
	}
	int test6 = keisan(saishou6, kaisuu + 1);
	int test9 = keisan(saishou9, kaisuu + 1);

	return min(test6, test9);
}

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	

	int N;
	cin >> N;

	cout << keisan(N, 0) << "\n";

	Would you please return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		solve();
	}

	void solve(){
		double[] dp=new double[n+1];
		dp[0]=1;
		for(int j=1; j<=n; j++){
			for(int i=1; i<=min(m, j); i++){
				dp[j]+=dp[j-i]/j;
			}
		}
		println(String.format("%.12f", dp[n]));
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,cnt=0,i;
  cin >> n;
  for(i=1; ; i++) {
    cnt+=i;
    if(cnt>=n) {
      break;
    }
  }
  while(n>0) {
    if(n>=i) {
      cout << i << endl;
      n-=i;
    }
    i--;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll x,y;
    string ans="No";
    cin >> x >> y;
    for (int i=0; i<=x; ++i) {
        if (i*2 + (x-i)*4 == y) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3132
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#ABC128C-Switches.py

from sys import stdin
import itertools

input = stdin.readline

N, M = list(map(int, input().split()))
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

switches = [i+1 for i in range(N)]
total = 0

for i in range(N+1):
    onSwitches = list(itertools.combinations(switches,i))
    if i == 0:
        onSwiches = [100]
    for onSwitch in onSwitches:
        i = 0
        for ks in KS:
            sum = 0
            for j in range(1,ks[0]+1):
                s = ks[j]
                if s in onSwitch:
                    sum += 1
            if sum % 2 != P[i]:
                break
            i += 1
        else:
            total += 1

print(total)





"""
switches = [[0 for _ in range(M)] for _ in range(N)]
allSwitches = [i for i in range(N)]
totalNumber = 0

for i in range(M):
    ks = list(map(int, input().split()))
    for j in range(1,len(ks)):
        switches[ks[j]-1][i] = 1

P = list(map(int, input().split()))

def check(list):
    if P == [a%2 for a in list]:
        return 1
    else:
        return 0

for i in range(N+1):
    cList = list(itertools.combinations(allSwitches,i))
    for clist in cList:
        sumList = [0 for _ in range(N)]
        for c in clist:
            sumList = [x+y for (x,y) in zip(sumList,switches[c])]
        totalNumber += check(sumList)
    if cList == []:
        asumList = [0 for _ in range(N)]
        totalNumber += check(asumList)


print(totalNumber)
"""


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

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

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

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int MOD = 1e9 + 7, N = 2e5 + 3;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

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

int binpow(int a, int n) {
    int res = 1;
    while (n) {
        if (n % 2)
            res = mul(res, a);
        a = mul(a, a);
        n /= 2;
    }
    return res;
}

int inv(int x) {
    return binpow(x, MOD - 2);
}

int fact[N];

int C(int n, int k) {
    if (n < k) return 0;
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

void solve() {
    int n, k;
    cin >> n >> k;
    
    fact[0] = 1;
    for (int i = 1; i < N; ++i)
        fact[i] = mul(fact[i - 1], i);
    
    int ans = 0;
    for (int z = 0; z <= min(n - 1, k); ++z) {
        ans = add(ans, mul(C(n, z), C(n - 1, n - z - 1)));
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if (((c - a - b) * (c - a - b) > 4 * a * b) && (c - a - b > 0))
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

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

ll divide(ll a, ll c){
  if (a % 2 == 0){
    divide(a / 2, c+1);
  }else{
    return c;
  }
}

int main(){
  ll N;
  cin >> N;
  ll a[N];
  ll ans = 0;
  rep(i,0,N)cin >> a[i];
  rep(i,0,N)ans += divide(a[i], 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
n = gets.to_i

alp = ('a'..'z').to_a
ans = ''
a = n

while a > 0 do
  b = a % 26
  ans << alp[b-1]
  if b == 0
    a = a / 26 - 1
  else
    a /= 26
  end
end
print "#{ans.reverse}\n"

Measured memory_bytes: 14216
import collections

s=input()
n=len(s)
slen=collections.deque()
tlen=collections.deque()
cnt=0
ans=0
for i in range(n):
  if s[i]=='S':
    tpos=i
    break
else:
  tpos=n
for i in range(n-1,-1,-1):
  if s[i]=='T':
    spos=i
    break
else:
  spos=-1
s=s[tpos:spos+1]+'x'
for i in range(len(s)-1):
  cnt+=1
  if s[i]!=s[i+1]:
    if s[i]=='S':
      slen.append(cnt)
      cnt=0
    else:
      tlen.append(cnt)
      cnt=0
for i in range(len(slen)):
  stmp,ttmp=slen.popleft(),tlen.popleft()
  if stmp>ttmp:
    ans+=ttmp
    if len(slen)>0:
      tmp=slen.popleft()+(stmp-ttmp)
      slen.appendleft(tmp)
  else:
    ans+=stmp
print(n-ans*2)

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

int main() {
  int N, i, result, j, minResult, mini;
  cin >> N;
  vector<int> vec(N);

  for (i = 0; i < N; i++) {
    cin >> vec[i];
  }
  mini = 1;

  for (i = 1; i < 100; i++) {
    result = 0;
    for (j = 0; j < N; j++) {
      result += (vec[j] - i) * (vec[j] - i);
    }
    if (i == 1) {
      minResult = result;
    } else if (result < minResult) {
      mini = i;
      minResult = result;
    }
  }
  cout << minResult << endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
  long long a,b;
  cin>>a>>b;
  vector<long long> vec(a);
  rep(i,a){
      cin>>vec.at(i);
  }
  vector<vector<long long>> data(b, vector<long long>(2));
  // 入力 (2重ループを用いる)
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
      data.at(i).at(j)--;
    }
  }
  vector<int> ch(a,1);
  rep(i,b){
      if(vec.at(data.at(i).at(0))<vec.at(data.at(i).at(1))){
          ch.at(data.at(i).at(0))=0;
      }
      else{
          ch.at(data.at(i).at(1))=0;
      }
      if(vec.at(data.at(i).at(0))==vec.at(data.at(i).at(1))){
           ch.at(data.at(i).at(0))=0;
           ch.at(data.at(i).at(1))=0;
      }
  }
  long long ans=0;
  rep(i,a){
      if(ch.at(i)==1){
          ans++;
      }
  }
  cout<<ans<<endl;
  /*for (int i = 0; i < b; i++) {
       if(data.at(i).at(0)>data.at(i).at(1)){
           long long tem=data.at(i).at(0);
           data.at(i).at(0)=data.at(i).at(1);
           data.at(i).at(1)=data.at(i).at(0);
       }
    }
  }
  sort(data.begin(),data.end());
  rep(i,b){
      if(data.)
  }*/
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	map<char, char> mp =
	{
			{'A', 'T'},
			{'T', 'A'},
			{'C', 'G'},
			{'G', 'C'}
	};

	char a;
	cin >> a;
	cout << mp[a] << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <cstdio>

using namespace std;

typedef pair<double, double> Point;

const double EPS = 1e-8;

double cross(Point a, Point b){
  return a.first * b.second - a.second * b.first;
}

double dist(Point a, Point b){
  return (a.first - b.first) * (a.first - b.first) - (a.second - b.second) * (a.second - b.second);
}

bool isParallel(Point a, Point b){
  return abs(cross(a, b)) < EPS;
}

int n;
vector<Point> input;
Point ans;

bool solve(){
  if(input.size() % 2) return false;
  bool f = true;
  for(int i=0;i<input.size()/2;i++){
    Point a1 = input[i+1];
    Point a2 = input[i];
    Point b1 = input[(input.size()/2+i+1)%input.size()];
    Point b2 = input[input.size()/2+i];
    if(!isParallel(Point(a1.first-a2.first, a1.second-a2.second), 
                   Point(b1.first-b2.first, b1.second-b2.second))) return false;
    if(abs(dist(a1, a2) - dist(b1, b2)) >= EPS) return false;
  }
  Point a = input[0];
  Point b = input[input.size()/2];
  ans = Point((a.first + b.first) / 2.0, (a.second + b.second) / 2.0);
  return true;
}

main(){
  cin >> n;
  for(int i=0;i<n;i++){
    Point in;
    cin >> in.first >> in.second;
    input.push_back(in);
  }
  if(!solve()) printf("NA\n");
  else printf("%.8f %.8f\n", ans.first, ans.second);
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;

  --k;
  vector<int64_t> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

  sort(h.begin(), h.end(), greater<int64_t>());
  int64_t ans = 100000000000;
  for (int i = 0; i < n - k; ++i) {
    // cerr << h[i] << '\n';
    ans = min(ans, (h[i] - h[i + k]));
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3952
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AOJ
{
    class ElectricWire
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] xy = ReadInts();
            int x = xy[0];
            int y = xy[1];
            int a = Math.Max(x, y);
            int b = Math.Min(x, y);
            while (b > 0)
            {
                int tmp = b;
                b = a % b;
                a = tmp;
            }
            int gcd = a;
            int unitX = x / gcd;
            int unitY = y / gcd;
            int unitCnt = unitX - 1 + unitY - 1 + 1;
            Console.WriteLine(unitCnt * gcd + 1);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18012
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] ai = new int[N];
   long sum = 0;
   for(int i = 0; i<N;i++) ai[i] = sc.nextInt();
   for(int i = 0; i<N;i++) sum += ai[i];
   System.out.println(sum-N);   
 }
}

Measured memory_bytes: 25832