akhauriyash/Code-Regression huggingface dataset:
def solution(h, t, a):
    n = len(h)
    foo, goo = -1, 0
    for i in range(n):
        cur = abs(t * 1000- h[i] * 6 - a * 1000)
        if foo == -1 or goo > cur:
            goo = cur
            foo = i
    return foo

def main():
    n = int(input().strip())
    t, a = [int(i) for i in input().strip().split()]
    h = [int(i) for i in input().strip().split()]
    print(solution(h, t, a) + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(A);
    READV(B);
    FORI(i,1,4)
    {
        if (A!=i && B!=i)
        {
            cout<<i<<endl;
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
    int a, b, c;
    scanf("%d%d", &a, &b);
    if(b == 100) c = a*1000+b;
    else if(b >= 10 && b <= 99) c = a*100+b;
    else c = a*10+b;
    double x = sqrt((double)c);
    if(ceil(x) == floor(x)) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
    var N int
    fmt.Scan(&N)

    mod := N % 10

    if mod == 3 {
        fmt.Println("bon")
    } else if mod == 0 || mod == 1 || mod == 6 || mod == 8 {
        fmt.Println("pon")
    } else {
        fmt.Println("hon")
    }
}


Measured memory_bytes: 1756
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i <= n; ++i)
        if (i + i * 8 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    cout << ":(" << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> X(N);
    vector<ll> Y(N);
    vector<ll> Z(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> Z[i];
    }

    ll ans = 0;

    for (int i = 0; i < (1 << 3); ++i) {
        ll sx = (i >> 0) & 1 == 1 ? -1 : 1;
        ll sy = (i >> 1) & 1 == 1 ? -1 : 1;
        ll sz = (i >> 2) & 1 == 1 ? -1 : 1;

        vector<ll> S(N);
        for (int j = 0; j < N; ++j) {
            S[j] = sx * X[j] + sy * Y[j] + sz * Z[j];
        }
        sort(S.begin(), S.end());
        ll _ans = 0;

        for (int j = N - M; j <= N - 1; ++j) {
            _ans += S[j];
        }

        ans = max(ans, _ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, x, t;
	int cnt;
	scanf("%d%d%d", &n, &x, &t);
	if (n % x != 0)
	{
		cnt = n / x;
		cnt += 1;
		printf("%d", cnt * t);
	}
	else
	{
		cnt = n / x;
		printf("%d", cnt * t);
	}
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int x, ans = 0;
	cin >> x;
	ans = x / 500;
	ans = ans * 1000;
	x = x % 500;
	x = x / 5;
	ans = ans + x * 5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main () {
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  
  int ans1 = 0, ans2 = 0, now = 0, count = 0;
  
  rep(i,0,n){
    now += a[i];
    if(count % 2==0){
      
      if(now <= 0){
        ans1 += 1-now;
        now = 1;
      }
      
    }
    
    if(count % 2==1){
      
      if(now >= 0){
        ans1 += 1+now;
        now = -1;
      }
      
    }
    count++;
  }
  
  
  
  now = 0;
  count = 0;
  
  rep(i,0,n){
    now += a[i];
    if(count % 2==1){
      
      if(now <= 0){
        ans2 += 1-now;
        now = 1;
      }
      
    }
    
    if(count % 2==0){
      
      if(now >= 0){
        ans2 += 1+now;
        now = -1;
      }
      
    }
    count++;
  }
  
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int juglid(int x,int y){
int c=1,t;
	if(y>x){
	t=x;
		x=y;
		y=t;
	}
	while(c>0){
	c=x%y;
		x=y;
		y=c;
	
	}
	return x;
}

main(){
	int x,y;
	scanf("%d %d",&x,&y);
	int ans=juglid(x,y);
	printf("%d\n",ans);
	return 0;
}



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


long long n,a,m,k,q,b,c,a1,a2,b1,b2;
float qq,ww,ff=2,qs;
string ss,s1,s2;
int main(){
    cin>>s1>>s2;
    cin>>a1>>a2;
    cin>>ss;
    if (ss==s1){
        cout<<a1-1<<' '<<a2;
    }
    else{
        cout<<a1<<' '<<a2-1;
    }
}


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

struct UnionFind {
  vector<int> par, rank;

  UnionFind(int n = 1) : par(n), rank(n, 0) {
    iota(begin(par), end(par), 0);
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool isSame(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank[x] < rank[y]) swap(x, y);
    rank[x] += rank[y];
    par[y] = x;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n + m);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int l;
      cin >> l, l--;
      uf.unite(i, n + l);
    }
  }
  int r = uf.root(0);
  for (int i = 1; i < n; i++) {
    if (uf.root(i) != r) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  pair<pair<string,int>, int> pair[N];

  for(int i=0; i<N; i++){
    string name;
    int point;
    cin >> name >> point;
    pair[i] = make_pair(make_pair(name, -point), i);
  }

  sort(pair, pair+N);

  for(int i=0; i<N; i++){
    cout << pair[i].second+1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int M1[101][101];
    int M2[101];
    int M3[101];
    int n,m;

    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++)scanf("%d", &M1[i][j]);
    }

    for(int i=0; i<m; i++)scanf("%d", &M2[i]);

    for(int i=0; i<n; i++){
        M3[i]=0;
        for(int j=0; j<m; j++)M3[i] += M1[i][j] * M2[j];
    }

    for(int i=0; i<n; i++)printf("%d\n", M3[i]);

    return 0;

}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();


        int largest = (b / k) * k;

        if (largest >= a) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }

    }
}


Measured memory_bytes: 35648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, D; cin >> N >> D;
  vector<vector<int>> pos(N, vector<int>(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> pos[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N - 1; ++i){
    for (int j = i + 1; j < N; ++j) {
      int tmp = 0;
      for (int k = 0; k < D; ++k) {
        int diff = pos[i][k] - pos[j][k];
        tmp += diff * diff;
      }
      int r = (int)sqrt(tmp);
      if (tmp == r * r) ++ans;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d, d + n, greater<int>());
    int cur = 101, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (cur > d[i])
        {
            ans++;
            cur = d[i];
        }
    }
    cout << ans << endl;
}


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

int main(){
	int n,a,b,c;

	cin >> n;

	for(int i=0; i<n; i++){
		cin >> a >> b >> c;

		int max=a, k=b, l=c;
		if(max < b){
			max = b;
			k=a;
		}
		if(max < c){
			max = c;
			k=b;
			l=a;
		}

		if(max*max == k*k + l*l)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <quadmath.h>
using namespace std;

int main(){
    long double a,b,c;
    cin >> a >> b >>c;
    if (a+b<c-2.0*sqrtl(a*b)){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
}

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

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

  vector<int> dp(2005);
  for (int i = 3; i <= 2000; i++)
  {
    int cnt = 0;
    for (int j = 3; j <= i; j++)
    {
      cnt+=dp[i-j];
      cnt%=1000000007;
    }
    dp[i] = cnt+1;
  }
  cout << dp[s] << endl;
}

Measured memory_bytes: 3640
S = input()
T = input()
C = []
if len(S) == len(T):
  c = 0
  for j in range(len(T)):
      if S[j] == T[j]:
        c += 1
  C.append(c)
else:
  for i in range(len(S) - len(T)+1):
    s = S[i:len(T)+i]
    c = 0
    for j in range(len(T)):
      if s[j] == T[j]:
        c += 1
    C.append(c)
print(len(T)-max(C))

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

int main() {
  string s,t;
  cin >> s >> t;
  
  int ans=0;
  
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      ans++;
    }
  }
  
  cout << ans << endl;
}


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


int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int ans = 0;
  int num = 0;
  int min_AB = min(A, B);
  for(int ii=min_AB; ii>0; ii--){
    if((A%ii==0) && (B%ii==0)){
      num++;
    }
    if(num == K){
      cout << ii << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Mod 1000000007;
const int N = 1000;
int f[N][N], mat[N][N];

int ways(int n, int m){
    
    f[0][0] = 1;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(i == 0 && j == 0) continue;
            if(mat[i][j] == 1){
                f[i][j] = 0;
            }
            else{
                int r = 0, d = 0;
                if(i-1 >= 0)
                    r = f[i-1][j];
                if(j-1 >= 0)
                    d = f[i][j-1];
                f[i][j] = (r+d)%Mod;
            }
        }
    }
    return f[n-1][m-1];
}

int main(){
	int n, m;
	cin >> n >> m;
	
	char ch;
	for(int i = 0; i < n; i++){
	    for(int j = 0; j < m; j++){
	        cin >> ch;
	        if(ch == '.') mat[i][j] = 0;
	        else mat[i][j] = 1;
	    }
	}
	
	cout << ways(n,m);
}

Measured memory_bytes: 11340
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

bool test_case() {
	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	if(b > d) return false;
	if(b > a) return false;
	if(a > c) {
		ll diff = a - c;
		ll times = diff / b;
		times = max(0LL, times - 2);
		a -= times * b;
	}
	while(a - b > c) a -= b;
	if(b > a) return false;
	if(d >= 2 * b) d = b + d % b;
	assert(b <= d && d < 2 * b);
	ll up = d - b;
	if(up == 0) return true; // b == d
	if(a < c) {
		ll times = (c - a) / up;
		times = max(0LL, times - 2);
		a += times * up;
	}
	while(a <= c) a += up;
	assert(a < c + b);
	assert(a > c);
	ll g = __gcd(b, d);
	if(a - g > c) {
		ll times = (a - c) / g;
		times = max(0LL, times - 3);
		a -= times * g;
	}
	while(a - g > c) a -= g;
	if(b > a) return false;
	return true;
}

int main() {
	int T;
	scanf("%d", &T);
	while(T--) puts(test_case() ? "Yes" : "No");
}


Measured memory_bytes: 256
import sys
def input():return sys.stdin.readline().strip()
from collections import Counter

def main():
    N, M = map(int, input().split())
    A = []
    B = []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    ca = Counter(A)
    cb = Counter(B)
    c = ca + cb
    
    if all(count%2 == 0 for count in c.values()):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 27232
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef int64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;
const int MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll power(ll x, int p) {
    x %= MOD;
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }

    return res;
}

map<ll, int> factorize(ll n, const vector<int> &pr) {
    map<ll, int> res;

    while(n > 1) {
        ++res[pr[n]];
        n /= pr[n];
    }

    return res;
}

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

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

    // soe
    vector<int> pr(1000005);
    REP(i, pr.size()) pr[i] = i;

    for (int i=2; i * i < pr.size(); ++i) {
        if(pr[i] != i) continue;
        for (int j=i*i; j < pr.size(); j+=i) {
            if (pr[j] == j) pr[j] = i;
        }
    }

    // get lcm as prior
    map<ll, int> lcm;
    int a[N];
    REP(i, N) {
        cin >> a[i];

        map<ll, int> fa;
        fa = factorize(a[i], pr);

        for(auto p: fa) {
            lcm[p.fi] = max(lcm[p.fi], p.se);
        }
    }

    // get remainder of lcm
    ll LCM = 1;
    for(auto p: lcm) {
        LCM = (LCM * power(p.fi, p.se)) % MOD;
    }
    ll res = 0;
    REP(i, N) {
        ll val = LCM * power(a[i], MOD-2);
        res = (res + val) % MOD;
    }

    cout << fixed << setprecision(20);
    cout << res << endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  int a, b, c, d, ans;
  cin >> a >> b >> c;
  if(b>=a&&b>=c){
     d = a;
     a = b;
     b = d;
  }
   if(c>=a&&c>=b){
     d = a;
     a = c;
     c = d;
  }
  if(c>=b){
    d = b;
    b = c;
    c = d;
  }
  ans = abs(a - b) + abs(b - c);
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int a, b, c; cin >> a >> b >> c;
  int x; cin >> x;
  int ans{};
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        auto sum = i * 500 + j * 100 + k * 50;
        if (x == sum) {
          ++ans;
        }
      }
    }
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <int> F(100,-1);
int fib(int n){
    if(n==0 || n==1){
        return F[n]=1;
    }
    if(F[n]!=-1){
        return F[n];
    }
    return F[n]=fib(n-2)+fib(n-1);
}
int main() {
	int n;
	cin>>n;
	int ans;
	ans=fib(n);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S;
  cin >> S;
  
  int ans = 999;
  
  for (int i=0;i<S.size()-2;i++) {
    int num = (S.at(i)-'0')*100 + (S.at(i+1)-'0') * 10 + (S.at(i+2)-'0');

    ans = min(ans,abs(num-753));
  }
  
  cout << ans << endl;
  
  
}
  

Measured memory_bytes: 256
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def query(self,top_num,front_num):
 
        self.save_data = [i for i in range(6)]
        #元の値の保存
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]
 
        ret = -1;
 
        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break
 
        #元の値の復元
        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]
 
        return ret;
 
 
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
num_query = int(input())
for loop in range(num_query):
    top_num,front_num = map(int,input().split())
    print("%d"%(dice.query(top_num, front_num)))


Measured memory_bytes: 6404
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	/* --------------------------------------------------------------------
	   main
	 * -------------------------------------------------------------------- */
	public static void main(String args[]) throws Exception {

		// ----- input -----
		Input input = new Input();
		final Data l = input.readLine();
		final int D = l.col[0];
		final int N = l.col[1];

		// ----- main -----
		System.out.print((int)Math.pow(100, D)*(N==100?N+1:N));
	}

	/* --------------------------------------------------------------------
	 * inupt class
	 * -------------------------------------------------------------------- */
	static class Input {

		public BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		public void close() throws Exception {
			input.close();
		}

		public Data readLine() throws Exception {
			return new Data(input.readLine().split(" "));
		}
	}
	/* --------------------------------------------------------------------
	 * data class
	 * -------------------------------------------------------------------- */
	static class Data{
		public int[] col;
		public Data(String[] values) {
			col = new int[values.length];
			for(int i=0; i < values.length; i++) {
				col[i] = Integer.parseInt(values[i]);
			}
		}
	}
}

Measured memory_bytes: 22356
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, int>;

void Main() {
	int n, k;
	cin >> n >> k;
	vi a(n);
    
    int g;
    rep(i, n) {
        cin >> a[i];
        if(i == 0) g = a[i];
        else g = __gcd(g, a[i]);
    }
    
    rep(i, n){
        if(a[i] < k) continue;
        if((a[i] - k) % g == 0) {
            cout << "POSSIBLE" << endl;
            return;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

vector<int> s[10];
int p[10];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j)
        {
            int x;
            cin >> x; x--;
            s[i].push_back(x);
        }
    }
    for (int i = 0; i < m; ++i)
        cin >> p[i];

    int sol = 0;
    for (int b = 0; b < (1 << n); ++b)
    {
        int l = 0;
        for (int i = 0; i < m; ++i)
        {
            int k = 0;
            for (int j = 0; j < s[i].size(); ++j)
                if (b & (1 << s[i][j]))
                    k++;
            if (k % 2 == p[i])
                l++;
        }
        if (l == m)
            sol++;
    }
    cout << sol;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int T = in.nextInt();
		int A = in.nextInt();
		int h[] =new int[N];
		double t[] =new double[N];
		for (int i = 0; i < N; i++) {
			h[i]= in.nextInt();
			t[i]=Math.abs((T-h[i]*0.006)-A);
		}
		int minn=10000;
		double min=10000000;
		for (int i = 0; i < N; i++) {
			if(min>t[i]) {
				min=t[i];
				minn=i;
			}
		}
		System.out.println(minn+1);
	}
}


Measured memory_bytes: 23648
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string s[3]; cin >> s[0] >> s[1] >> s[2];

    cout << (char)('A'+s[0][0]-'a') << (char)('A'+s[1][0]-'a') << (char)('A'+s[2][0]-'a') << endl;
    return 0;
}


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

struct edge {
    int dst;
    long long cost;
};

vector<edge> graph[100010];
bool visited[100010];
map<int, long long> dist;

void dfs(int node, long long cost) {
    visited[node] = true;

    for (auto e: graph[node]) {
        if (!visited[e.dst]) {
            dfs(e.dst, cost + e.cost);
        }
    }

    dist[node] = cost;
}

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

    for (int i=0; i<N-1; i++) {
        int a,b;
        long long c;
        cin >> a >> b >> c;
        graph[a].push_back( edge{b,c} );
        graph[b].push_back( edge{a,c} );
    }

    int Q,K;
    cin >> Q >> K;

    dfs(K, 0LL);

    for (int i=0; i<Q; i++) {
        int x,y;
        cin >> x >> y;

        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 23040
#include<iostream>
using namespace std;
int N,M;
int pa[1<<17],pb[1<<17];
main()
{
	cin>>N>>M;
	for(int i=1;i<=M;i++)
	{
		pa[i-1]=i;
		if(N%2==1)pb[i-1]=N+1-i;
		else
		{
			if((N/2-1+1)/2<i)pb[i-1]=N-i;
			else pb[i-1]=N+1-i;
		}
	}
	for(int i=0;i<M;i++)cout<<pa[i]<<" "<<pb[i]<<endl;
}

Measured memory_bytes: 4288
#include<iostream>
main(){for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M)){for(i=s=0;i<n;i++<k&&(M=s+=a[i-1]))std::cin>>a[i];for(i=k;i<n;M<s&&(M=s))s+=a[i]-a[i++-k];}}

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

int main(void)
{
	int hara, kigen, niti;

	cin >> hara >> kigen >> niti;

	if (niti - kigen <= 0) {
		cout << "delicious" << endl;
	}
	else if (niti - kigen <= hara) {
		cout << "safe" << endl;
	}
	else if (niti - kigen > hara) {
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x, n; cin >> x >> n;

    if(n == 0){
        cout << x << endl;
        return 0;
    }

    map<ll,ll> mp;
    for(long long i = 0; i < n; i ++){
        ll p; cin >> p;
        mp[p]++;
    }
    ll ans = INF;
    ll res = 0;
    for(ll i = -110; i <= 210; i++){
        if(mp.count(i) == 0){
            if(abs(x-i) < ans){
                ans = abs(x-i);
                res = i;
            }
        }
    }

    cout << res << endl;


}

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

vector<ll> sumst[100100]; //sumst[C][k]にはスタートから間隔Cでk個の和を取った値を入れておく
vector<ll> sumla[100100]; //sumla[C][k]にはゴール....

int main(){
    int N; cin >> N;
    ll s[100100];
    for(int i=0; i<N; i++){
        cin >> s[i];
    }

    for(int C=1; C<N; C++){
        int k=(N-1)/C;
        sumst[C].push_back(0LL);
        for(int i=0; i<k; i++){
            ll a =sumst[C].at(i)+s[(i+1)*C];
            sumst[C].push_back(a);
        }
    }

    for(int C=1; C<N; C++){
        int k=(N-1)/C;
        sumla[C].push_back(0LL);
        for(int i=0; i<k; i++){
            ll a =sumla[C].at(i)+s[N-1 - (i+1)*C];
            sumla[C].push_back(a);
        }
    }

    ll ans=0;
    for(int C=1; C<N; C++){
        int k=(N-1)/C;
        for(int i=1; i<=k; i++){
            int A=N-1-i*C;
            if(A<=C) continue;
            if(A%C==0 && A/C <=i ) continue;
            ans = max(ans,sumst[C].at(i)+sumla[C].at(i));
//            cout << C << " " << i << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 33396
using System;
public class B {
  public static void Main() {
    var input = System.Console.ReadLine().Split(' ');
    var h = long.Parse(input[0]);
    var w = long.Parse(input[1]);
    // これぜったい1行にまとまるよね
    if (h == 1 || w == 1) {
      Console.WriteLine(1);
      return;
    }
    if (w % 2 == 0) {
      Console.WriteLine(h * (w / 2));
    } else if (h % 2 == 0) {
        Console.WriteLine(h * (w / 2) + h / 2);
    } else {
        Console.WriteLine(h * (w / 2) + h / 2 + 1);
    }
  }
}


Measured memory_bytes: 11092
n, m = map(int, input().split())
H = list(map(int,input().split()))
H2 = [1]*n
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        H2[b-1] = 0
    elif H[a-1] == H[b-1]:
        H2[b-1] = 0
        H2[a-1] = 0
    else:
        H2[a-1] = 0

print(H2.count(1))

Measured memory_bytes: 20144
#include<iostream>
#include<math.h>
#include<climits>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<unordered_set>
#include<unordered_map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack> 
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define ull             unsigned long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define si              set<int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1e9+7
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(t)            int t; cin>>t; while(t--)
#define asc(i,a,n)      for (int i=a;i<n;i++)
#define dsc(i,a,n)      for (int i=n-1;i>=a;i--)
#define sz(x)           ((int)(x).size())
#define flg             if(flag==0)cout<<"Yes"<<endl;else{cout<<"No"<<endl;}
#define FLG             if(flag==0)cout<<"YES"<<endl;else{cout<<"NO"<<endl;}
#define input(arr,n)    for(int i=0; i<n ; i++) cin>>arr[i];
#define output(arr,n)   for(int i=0; i<n ; i++) cout<<arr[i]<<" ";
#define fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 


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

  set<string> s;

  for(int i=0; i <n ; i++)
  {
    string a;
    cin>>a;

    s.insert(a);
  }

  cout<<s.size()<<endl;
}





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

int main()
{
    long long sum = 0;
    int n, t, i, x;
    cin >> n >> t;
    for(i=0;i<t;i++)
    {
        cin >> x;
        sum = sum + x;
    }
    if(sum>n)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << n-sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

ans = 0
hands = []
for i in range(N):
    if i < K:
        # グー
        if T[i] == 'r':
            ans += P
            hands.append('p')
        # チョキ
        elif T[i] == 's':
            ans += R
            hands.append('r')
        # パー
        else:
            ans += S
            hands.append('s')
    else:
        if T[i] == 'r':
            if hands[i-K] != 'p':
                ans += P
                hands.append('p')
            else:
                hands.append('-')
        # チョキ
        elif T[i] == 's':
            if hands[i-K] != 'r':
                ans += R
                hands.append('r')
            else:
                hands.append('-')
        # パー
        else:
            if hands[i-K] != 's':
                ans += S
                hands.append('s')
            else:
                hands.append('-')
print(ans)


Measured memory_bytes: 4792
#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 n;
    cin >> n;
    vector<ll> as(n);
    rep(i, 0, n) cin >> as[i];
    sort(as.begin(), as.end());
    
    ll ans = 0;
    rep(i, 0, n) {
        if (i == 0) ans -= as[i];
        else if (i == n-1) ans += as[i];
        else if (as[i]  >= 0) ans += as[i];
        else ans -= as[i];
    }
    cout << ans << endl;

    if (as[n-1] < 0) {
        ll x = as[n-1];
        rep(i, 0, n-1) {
            cout << x << " " << as[i] << endl;
            x -= as[i];
        }
        assert(x == ans);
        return 0;
    }
    if (as[0] > 0) {
        ll x = as[0];
        rep(i, 1, n-1) {
            cout << x << " " << as[i] << endl;
            x -= as[i];
        }
        cout << as[n-1] << " " << x << endl;
        x = as[n-1] - x;
        assert(x == ans);
        return 0;
    }

    ll p = as[n-1], q = as[0];
    rep(i, 1, n-1) {
        if (as[i] <= 0) {
            cout << p << " " << as[i] << endl;
            p -= as[i];
        }
        else {
            cout << q << " " << as[i] << endl;
            q -= as[i];
        }
    }
    cout << p << " " << q << endl;
    p -= q;
    assert(p == ans);
    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
//#include <string.h>

int main(void){
  
  char s[4];
  
  scanf("%s", s);

  for(int i=0;i<3;i++){
  	if(s[i]=='1'){
      s[i]='9';
    }
    else if(s[i]=='9'){
      s[i]='1';
    }
  }
  
  printf("%s", s);
    
    
  return 0;
}

  

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<char>> ch = {{}, {'.', ',', '!', '?', ' '}, {'a', 'b', 'c'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}, {'j', 'k', 'l'}, {'m', 'n', 'o'}, {'p', 'q', 'r', 's'}, {'t', 'u', 'v'}, {'w', 'x', 'y', 'z'}};
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    string S;
    cin >> S;
    int N = S.size();
    int cnt = 0;
    int c = 0;
    for (int j = 0; j < N; j++){
      if (S[j] == '0'){
        if (cnt != 0){
          cout << ch[c][(cnt - 1) % ch[c].size()];
          cnt = 0;
        }
      } else {
        cnt++;
        c = S[j] - '0';
      }
    }
    cout << endl;
  }
}


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

const ll INF=0x3f3f3f3f3f3f3f3f;

int n,K;
ll dp[310][310][310];
int h[400];

int main(){
	cin>>n>>K;
	rep(i,n)scanf("%d",&h[i]);
	vector<int>xs{0};
	rep(i,n)xs.push_back(h[i]);
	sort(xs.begin(),xs.end());
	memset(dp,0x3f,sizeof(dp));
	dp[0][0][0]=0;
	rep(i,n){
		int id=lower_bound(xs.begin(),xs.end(),h[i])-xs.begin();
		rep(j,K+1)rep(k,xs.size()){
			dp[i+1][j][id]=min(dp[i+1][j][id],dp[i][j][k]+max(0,h[i]-xs[k]));
			dp[i+1][j+1][k]=min(dp[i+1][j+1][k],dp[i][j][k]);
		}
	}
	ll ans=INF;
	rep(i,K+1)rep(j,xs.size())ans=min(ans,dp[n][i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 232960
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
//#include <functional>
//#include <cmath>


int main(){
    int32_t N, M, L;
    std::cin >> N >> M >> L;
    constexpr int64_t INF = 1LL << 60;

    std::vector< std::vector<int64_t>> Path(N, std::vector<int64_t>(N, INF));
    for(int32_t i = 0; i< M; i++){
        int32_t A,B;
        int64_t C;
        std::cin >> A >> B >> C;
        Path[A-1][B-1] = C;
        Path[B-1][A-1] = C;
    }

    for(int32_t i = 0; i < N; i++){
        for(int32_t j = 0; j < N; j++){
            for(int32_t k = 0; k < N; k++){
                Path[j][k] = std::min(Path[j][k], Path[j][i] + Path[i][k]);

            }
        }
    }

    std::vector< std::vector<int64_t>> recharge(N, std::vector<int64_t>(N, INF));
    for(int32_t j = 0; j < N; j++){
        for(int32_t k = 0; k < N; k++){
            if(Path[j][k] <= L){
                recharge[j][k] = 1;
            }
        }
    }
    for(int32_t i = 0; i < N; i++){
        for(int32_t j = 0; j < N; j++){
            for(int32_t k = 0; k < N; k++){
                recharge[j][k] = std::min(recharge[j][k], recharge[j][i] + recharge[i][k]);

            }
        }
    }

    int32_t Q;
    std::cin >> Q;
    for(int32_t i = 0; i < Q; i++){
        int32_t s,t;
        std::cin >> s >> t;
        if(recharge[s-1][t-1] >= N){
            std::cout << -1 << std::endl;
        }
        else{
            std::cout << recharge[s-1][t-1] - 1 << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(long long 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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
 
int main() {
  double n , k;
  long double ans = 0;
  cin >> n >> k;
  for(double i = 1; i <= n ;i++) { //調べる数字
    int kaisuu = 0;
    if(i >= k) {
      ans+=(1.0/n);
    } else {
      for(double j = i; j < k;j*=2) {
      kaisuu++;
        if (j*2 >= k) {
          ans +=(1.0/n)*pow(0.5,kaisuu);
        }
      }
    }
    
  }
  cout << std::setprecision(15) << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(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; }

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 () {
  int A, B, C; cin >> A >> B >> C;

  int M = max({A,B,C});
  int X;
  if (M%2==(A+B+C)%2) {
    X = M;
  }
  else {
    X = M+1;
  }

  cout << (3*X-(A+B+C))/2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  while (cin >> n, n)
  {
    int w, h;
    cin >> w >> h;
    bool field[110][110] = {};
    for (int i = 0; i < n; ++i)
    {
      int x, y;
      cin >> x >> y;
      field[y][x] = true;
    }
    int s, t;
    cin >> s >> t;
    int ans = 0;
    for (int y = 1; y <= h - t + 1; ++y)
    {
      for (int x = 1; x <= w - s + 1; ++x)
      {
        int sum = 0;
        for (int i = 0; i < t; ++i)
        {
          for (int j = 0; j < s; ++j)
          {
            if (field[y + i][x + j])
              sum++;
          }
        }
        ans = max(ans, sum);
      }
    }
    cout << ans << endl;
  }

  return 0;
}



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

int main() {
  int N;
  cin>>N;
  //cout<<N;
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  int a=0,ans=0;
  for(int i=0;i<N;i++){
    if(i==N-1||h.at(i)<h.at(i+1)){
      ans=max(a,ans);
      a=0;
    }
    else{
      a++;
    }
    //cout<<i<<endl;
  }
  cout<<ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  int sum = 0;
  rep(i, n) sum += l[i];
  int max = *max_element(l.begin(), l.end());
  sum -= max;

  if (max < sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()

m=0
a=0
r=0
c=0
h=0

for i in range(n):
  k=input()[0]
  if k=='M':
    m+=1
  if k=='A':
    a+=1
  if k=='R':
    r+=1
  if k=='C':
    c+=1
  if k=='H':
    h+=1

cnts = [m,a,r,c,h]

ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      cs = [cnts[i],cnts[j],cnts[k]]
      ans += cs[0]*cs[1]*cs[2]
print(ans)



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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(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++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    pi a[n + 1];
    FOR(i, 1, n)
    {
        int x;
        cin >> x;
        a[i].fi = x;
        a[i].se = i;
    }
    sort(a + 1, a + 1 + n);
    FOR(i, 1, n)
    {
        cout << a[i].se << " ";
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll a) {
  cout << a + a*a + a*a*a << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll a;
  cin >> a;

  solve(a);

  return 0;
}


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

using namespace std;

int main()
{
	int N,M;
	cin >> N>>M;
	int a[M+1][N+1];
	long long ans=0;
	//memset(a,0,sizeof(a));
	for(int i=1;i<=M;i++)
	{
		int n;
		cin >> n;
		for(int j=1;j<=n;j++)
		{
			cin >> a[i][j];
		}
		for(int j=n+1;j<=N;j++)
		{
			a[i][j]=0;
		}
	}
	for(int i=1;i<=M;i++)
	{
		cin >> a[i][0];
	}
	for(int i=0;i<=(pow(2,N)-1);i++)//
	{
		for(int j=1;j<=M;j++)
		{
			int sum=0;
			for(int z=1;a[j][z]>0 && z<=N;z++)
			{
				sum+=pow(2,a[j][z]-1);
			}
			//cout << "*" << sum <<' ';
			
			int q=sum&i,bitsum=0; 
			for(int z=1;z<=10;z++)
			{
				if((1<<(z-1))&q)
				bitsum++;
			 } 
			 if(bitsum%2!=a[j][0]) break;
			 if(j==M) ans++; 
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256