akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] c = new int[n - 1];
        int[] s = new int[n - 1];
        int[] f = new int[n - 1];

        for (int i = 0; i < n - 1; i++) {
            c[i] = in.nextInt();
            s[i] = in.nextInt();
            f[i] = in.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            int time = s[i] + c[i];
            for (int j = i + 1; j < n - 1; j++) {
                if (time % f[j] != 0) {
                    time += f[j] - (time % f[j]);
                }

                if (time < s[j]) {
                    time = s[j];
                }

                time += c[j];
            }

            System.out.println(time);
        }
        System.out.println(0);
    }
}

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

int main()
{
    int n;
    cin>>n;
    int u[n],v[n];
    for(int i=0;i<n;i++)
    {
        cin>>u[i]>>v[i];
    }
    int flag=0;
    for(int i=0;i<n-2;i++)
    {
        if(u[i]==v[i]&&u[i+1]==v[i+1]&&u[i+2]==v[i+2])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<< "No"<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int m,n;
	cin>>m>>n;
if((n-1)%(m-1)==0)
{
	cout<<ceil(	(n-1)/(m-1) );
}
else
{
	cout<< ceil ( 	(n-1)/(m-1) ) +1;
}
	
	return 0;	
}

Measured memory_bytes: 256
program ABC103C
    implicit none
    integer(8)::i,N
    integer(8)::result=0
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        result=result+A(i)-1
    end do

    print'(i0)',result
    
end program ABC103C

Measured memory_bytes: 256
function bomb(y,x){
   var dx=[-1,1,0,0];
   var dy=[0,0,-1,1];
   for(var i=0;i<4;i++){
      for(var j=1;j<=3;j++){
         var yy=y+(dy[i]*j);
         var xx=x+(dx[i]*j);
         if(yy<0 || yy>=8 || xx<0 || xx>=8)continue;
         if(yx[yy][xx]==1){yx[yy][xx]=0;bomb(yy,xx);}
      }
   }
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var AL=Arr.shift();
for(var i=0;i<AL;i++){
   Arr.shift();
   var yx=[];
   for(var j=0;j<8;j++){
      var line=Arr.shift().split("").map(Number);
      yx.push(line);
   }
   var X=(Arr.shift()-0)-1;
   var Y=(Arr.shift()-0)-1;
   if(yx[Y][X]==1){yx[Y][X]=0;bomb(Y,X);}
   console.log("Data "+(i+1)+":");
   for(var j=0;j<8;j++)console.log(yx[j].join(""));
}

Measured memory_bytes: 8788
#include <stdio.h>
#include <string.h>
int main(){
	char weather[3][7]={"Sunny","Cloudy","Rainy"};
	char str[7]={};
	scanf("%s", str);
	for (int i = 0; i < 3; i++) {
		if(strcmp(str,weather[i])==0){
			printf("%s\n", weather[(i+1)%3]);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int main(){
    ll n;
    lsc(n);
    ll sq=0, sm=0;
    fr(i, 1, n){
        ll x;lsc(x);
        sq = fmod(sq + fmod(x*x));
        sm += x;
    }
    sm = fmod(sm);
    sm = fmod(sm*sm);
    ll ans = fmod(sm - sq + mod);
    ans = fmod(ans * inv(2));
    lpr(ans);n_l;
    return 0;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll l;
    cin >> l;
    ll a[n+2] = {};
    srep(i,1,n+1){
        scanf("%lld",&a[i]);
    }
    srep(i,1,n){
        if(a[i]+a[i+1]>=l){
            puts("Possible");
            srep(j,1,i){
                cout << j << endl;
            }
            for(int j=n-1;j>=i;j--){
                cout << j << endl;
            }
            return 0;
        }
    }


    puts("Impossible");
    return 0;
}
 
 


Measured memory_bytes: 1536
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
#
# N, K = [int(sys.stdin.readline()) for _ in range(2)]
# X = np.array(list(map(int, sys.stdin.readline().split())))
#
# print(np.minimum(X, abs(X - K)).sum() * 2)

N = int(sys.stdin.readline())
L, R = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
L = np.array(L)
R = np.array(R)
print(sum(R-L+1))


Measured memory_bytes: 13648
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T>
std::istream& operator >> (std::istream& is, std::vector<T>& vec){
  T tmp;
  is >> tmp;
  vec.push_back(tmp);
  return is;
}
template <class T>
auto mkVec(unsigned int x){
  return std::vector<T>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(x, std::vector<T>(y));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(x, std::vector<std::vector<T>>(y, std::vector<T>(z)));
}

int main(int const argc, char const** argv){
  ll D, G;
  cin >> D >> G;
  vector<ll> p, c;
  rep(i, D){
    ll a, b;
    cin >> a >> b;
    p.push_back(a);
    c.push_back(b);
  }
  ll res = imax;
  for(ll mask = 0; mask < (1 << D); ++mask){
    ll sum = 0, num = 0, rest_max = - 1;
    for(ll i = 0; i < D; ++i){
      if(mask & (1 << i)){// 逆試す
        sum += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      }else{
        rest_max = i;
      }
    }

    if(sum < G){
      for(ll i = 0; i < p[rest_max]; i++){
        sum += (rest_max + 1) * 100;
        num++;
        if(sum >= G){
          break;
        }
      }
    }
      // debug(mask);
      // debug(rest_max);
      // debug(sum);
      // debug(num);

    if(sum >= G){
      res = min(res, num);
    }
  }
  cout << res;
}


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

int main() {
  string n; cin >> n;
  int s=n.size()-1;
  if(n[s]=='2'||n[s]=='4'||n[s]=='5'||n[s]=='7'||n[s]=='9') cout << "hon" << endl;
  else if(n[s]=='0'||n[s]=='1'||n[s]=='6'||n[s]=='8') cout << "pon" << endl;
  else cout << "bon" << endl;
}

Measured memory_bytes: 3596
S=input()
K=int(input())

for i in range(len(S)):
    if S[i]!="1":
        x=i
        break
    else:
        x=0

if S[x]=="1":
    print(1)

elif K<x+1:
    print(1)

else:
    print(S[x])
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
   int a;
   while(cin>>a,a){
       int c[100];
       for(int b=0;b<a;b++)cin>>c[b];
       int s=0;
       while(1){
	  int d[100];
	  map<int,int>e;
	  for(int f=0;f<a;f++)e[c[f]]++;
	  for(int f=0;f<a;f++)d[f]=e[c[f]];
	  for(int f=0;f<a;f++){if(c[f]!=d[f])break;if(a-f==1)goto l;}
	  for(int f=0;f<a;f++)c[f]=d[f];
	  s++;
	   }
	l:; 
	cout<<s<<endl;
	for(int f=0;f<a-1;f++)cout<<c[f]<<" ";
	 cout<<c[a-1]<<endl;
       }
}

Measured memory_bytes: 3064
fn main() {
    let abck = read_vec::<i64>();
    let mut k = abck[3];
    let mut ret = 0;

    if k <= abck[0] {
        println!("{}", k);
        return;
    } else {
        ret += abck[0];
        k -= abck[0];
    }
    if k <= abck[1] {
        println!("{}", ret);
        return;
    } else {
        k -= abck[1];
    }
    if k <= abck[2] {
        println!("{}", ret - k);
    } else {
        println!("{}", ret - abck[2]);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int  n; 
  cin >> n;
  
  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  
  sort(data.begin(), data.end());
  
  long long int s = data[0], p = 0;
  for (int i = 1; i < n; i++) {
    if (s + s < data[i]) {
      p = i;
    }
    s += data[i];
  }
  
  cout << n - p << endl;
  return 0; 
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
#define icn cin
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    int isHonest[20];
    int A[20];
    int x[20][20];
    int y[20][20];
    rep(i,0,N){
        cin >> A[i];
        rep(j,0,A[i]){
            int a,b; cin >> a >> b;
            a--;
            x[i][j] = a;
            y[i][j] = b;
        }
    }

    int ans = 0;
    rep(i,0,1<<N){
        int cnt = 0;
        rep(j,0,N){
            if(i & (1 << j)){
                isHonest[j] = 1;
                cnt++;
            }else{
                isHonest[j] = 0;
            }
        }
        bool flag = true;
        rep(k,0,N){
            if(isHonest[k] == 0) continue;
            rep(l,0,A[k]){
                if(isHonest[x[k][l]] != y[k][l]) flag = false;
            }
        }
        if(flag){
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,T;
    cin >> N >> X >> T;
    cout << (N+X-1)/X*T << "\n";
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
int a,b,c,tmp;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
tmp=a;
a=b;
b=tmp;
}
if(a>c){
tmp=a;
a=c;
c=tmp;
}
if(b>c){
tmp=b;
b=c;
c=tmp;
}

printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    while(1) {
        int N;
        cin >> N;
        if(N<=0) break;

        vector<set<int> > list(N);

        for(int i=0;i<N;++i) {
            int M;
            cin >> M;
            for(int j=0;j<M;++j) {
                int p;
                cin >> p;
                list[i].insert(p);
            }
        }

        int K;
        vector<int> l;
        cin >> K;
        for(int i=0;i<K;++i) {
            int p;
            cin >> p;
            l.push_back(p);
        }

        vector<int> hannin;
        for(int i=0;i<N;++i) {
            int j;
            for(j=0;j<K;++j) {
                if(list[i].find(l[j])==list[i].end()) {
                    break;
                }
            }
            if(j==K) {
                hannin.push_back(i+1);
            }
        }
        if(hannin.size()==1) {
            cout << hannin[0] << endl;
        } else {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 1128
def main():
    mod = 998244353
    fact = [1, 1]
    for i in range(2, 400001):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    n, m, k = map(int, input().split())
    ans = 0
    for i in range(k+1):
        ans = (ans+m*pow(m-1, n-i-1, mod)*nCr(n-1, n-i-1)) % mod

    print(ans)


main()


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

using namespace std;

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

    int d;
    while (cin >> d && d) {
        int n, m;
        cin >> n >> m;

        vector<int> S(1, 0);
        int di;
        for (int i=0; i<n-1; ++i) {
            cin >> di;
            S.push_back(di);
        }
        sort(S.begin(), S.end());

        long long sum = 0;
        int ki;
        for (int i=0; i<m; ++i) {
            cin >> ki;
            int j = lower_bound(S.begin(), S.end(), ki) - S.begin();
            int add = 1000000000;
            add = min(add, abs(S[j % n] - ki));
            add = min(add, abs(S[j % n] + d - ki));
            add = min(add, abs(S[j % n] - d - ki));
            add = min(add, abs(S[(j + 1) % n] - ki));
            add = min(add, abs(S[(j + 1) % n] + d - ki));
            add = min(add, abs(S[(j + 1) % n] - d - ki));
            add = min(add, abs(S[(j + n - 1) % n] - ki));
            add = min(add, abs(S[(j + n - 1) % n] + d - ki));
            add = min(add, abs(S[(j + n - 1) % n] - d - ki));
            sum += add;
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1740
#include <stdio.h>

int main()
{
	int k = 10;
	char res;
	const long long pow[11] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000};
	long long tmp = 49999999999, ans = 0;
	
	printf("? %lld\n", tmp);
	fflush(stdout);
	scanf(" %c", &res);
	if (res == 'Y') {
		for (tmp -= pow[k]; tmp >= pow[k]; tmp -= pow[k]) {
			printf("? %lld\n", tmp);
			fflush(stdout);
			scanf(" %c", &res);
			if (res == 'N') break;
		}
		ans = tmp / pow[k] + 1;
		tmp += pow[k];
	} else {
		for (tmp += pow[k]; tmp <= pow[k] * 9; tmp += pow[k]) {
			printf("? %lld\n", tmp);
			fflush(stdout);
			scanf(" %c", &res);
			if (res == 'Y') break;
		}
		ans = tmp / pow[k];
	}
	printf("? %lld\n", (ans - 1) * 10 + 9);
	fflush(stdout);
	scanf(" %c", &res);
	
	if ((ans > pow[10-k] && res == 'Y') || (ans == pow[10-k] && res == 'N')) {
		for (k--; k >= 0; k--) {
			tmp -= pow[k] * 5;
			printf("? %lld\n", tmp);
			fflush(stdout);
			scanf(" %c", &res);
			if (res == 'Y') {
				for (tmp -= pow[k]; tmp >= ans * pow[k+1]; tmp -= pow[k]) {
					printf("? %lld\n", tmp);
					fflush(stdout);
					scanf(" %c", &res);
					if (res == 'N') break;
				}
				ans = ans * 10 + (tmp / pow[k] + 1) % 10;
				tmp += pow[k];
			} else {
				for (tmp += pow[k]; tmp < (ans + 1) * pow[k+1] - 1; tmp += pow[k]) {
					printf("? %lld\n", tmp);
					fflush(stdout);
					scanf(" %c", &res);
					if (res == 'Y') break;
				}
				ans = ans * 10 + tmp / pow[k] % 10;
			}
			printf("? %lld\n", (ans - 1) * 10 + 9);
			fflush(stdout);
			scanf(" %c", &res);
			if ((ans > pow[10-k] && res == 'N') || (ans == pow[10-k] && res == 'Y')) break;
		}
	}
	
	printf("! %lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef unsigned long long ll;


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

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

  ll monster_num = 1; ll attack = 0;
  while (h > 1)
  {
      /* code */
      attack += monster_num;
      monster_num *= 2;
      h = h/2;
  }
  ll ans = attack + monster_num;
  cout << ans << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
lists=list(map(int,input().split()))
#スタート地点がa_i(1<=i<=N)の場合で固定する
import itertools
seq=[i for i in range(1,N)]
D=list(itertools.combinations(seq,K-1))

answer=float("inf")

def cal(D):
    money=0
    now_height=lists[0]
    K=set(D)
    for i in range(1,N):
        if now_height>=lists[i]:
            if i in K:
                money+=(now_height+1-lists[i])
                now_height+=1
            else:
                #i not in K:
                pass
            
        elif now_height<lists[i]:
            if i in K:
                money+=0
                now_height=lists[i]
            else:
                #i not in K:
                money+=(lists[i]+1-now_height)
                now_height+=1
    return money
for que in D:
    answer=min(answer,cal(que))
print(answer)
            
    

Measured memory_bytes: 43500
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, b, r;
    cin >> n >> b >> r;

    cout << (n/(b+r) * b) + min(n%(b+r), b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

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

long long lcm(long long a,long long b){
	long long x=gcd(a,b);
return (a/x)*(b/x)*x;
}

int main(){
	int n;
	cin>>n;
	long long ans;
	cin>>ans;
	for(int i=2;i<=n;i++){
		long long t;
		cin>>t;
		ans=lcm(ans,t);
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A = vec![0usize; N];
    let mut B = vec![0usize; N];
    for i in 0..N {
        A[i] = sc.get();
        B[i] = sc.get();
    }
    A.sort();
    B.sort();
    if N % 2 != 0 {
        let medA = A[(N+1)/2-1];
        let medB = B[(N+1)/2-1];
        let ans = medB - medA + 1;
        println!("{}", ans);
    } else {
        let medA2 = A[N/2-1] + A[N/2];
        let medB2 = B[N/2-1] + B[N/2];
        let ans = medB2 - medA2 + 1;
        println!("{}", ans);
    }
}


Measured memory_bytes: 5716
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int N,W;

int main(){
	
	cin >> N >> W;
	
	vector<ll> w(N),v(N);
	REP(i,N) cin >> w[i] >> v[i];
	
	vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
	
	REP(i,N){
		for(ll sumw=0; sumw<=W; ++sumw){
			if(sumw-w[i] >= 0){
				chmax(dp[i+1][sumw], dp[i][sumw-w[i]] + v[i]);
			}
			chmax(dp[i+1][sumw], dp[i][sumw]);
		}
	}
	
	cout << dp[N][W] << endl;
	
	return 0;
}

Measured memory_bytes: 83024
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>()
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let x = get!(i32);
    println!("{}", if x == 0 { 1 } else { 0 });
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
int main(){
    const ll inf=1LL<<50;
    int N,M;
    ll L;
    cin>>N>>M>>L;
    vector<vector<P>> graph(N);
    REP(i,M){
        int a,b; 
        ll c;
        cin>>a>>b>>c;
        a--;b--;
        if(c>L) continue;
        graph[a].push_back(P(c,b));
        graph[b].push_back(P(c,a));
    }
    int Q;cin>>Q;
    vector<int> s(Q),t(Q);
    REP(i,Q){
        cin>>s[i]>>t[i];
        s[i]--;t[i]--;
    }
    vector<vector<P>> ans(N,vector<P>(N,P(inf,0)));
    REP(i,N) ans[i][i]=P(0,-L);
    priority_queue<PP,vector<PP>,greater<>> que;
    REP(k,N){
        ans[k][k]=P(0,-L);
        que.push(PP(P(0,-L),k));
        while(!que.empty()){
            PP p=que.top();que.pop();
            int u=p.second;
            if(ans[k][u]<p.first) continue;
            REP(j,graph[u].size()){
                int v=graph[u][j].second;
                ll a=ans[k][u].second+graph[u][j].first,b=0;
                if(a>0){
                    a=-L+graph[u][j].first;
                    b=1;
                }
                P alt=P(ans[k][u].first+b,a);
                if(alt<ans[k][v]){
                    ans[k][v]=alt;
                    que.push(PP(alt,v));
                }
            }
        }
    }
    REP(q,Q){
        if(ans[s[q]][t[q]].first==inf) cout<<-1<<endl;
        else cout<<ans[s[q]][t[q]].first<<endl;
    }
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b)
{
   ll res = 1;
   while(b>0)
   {
     if(b&1)
      res = (res*a)%mod;
     a = (a*a)%mod;
     b/=2;
   }
   return res;
}
#define rs resize
vector<vi> adj;
vector<vector<ll> > dp;
vector<ll> l,visit,sum;
ll n,a,b,c,i,q,k,st = 1,j,logx;
void dfs(ll v)
{
   visit[v] = st;
   for(auto &it: adj[v])
    if(visit[it.f] != st)
    {
      sum[it.f] = sum[v] + it.se;
      l[it.f] = l[v] + 1;
      dfs(it.f);
      dp[0][it.f] = v;
    }
}
ll lca(ll a,ll b)
{
   if(l[a] > l[b]) swap(a,b);
   ll i, d = l[b] - l[a];
   for(i = 0;i < logx;i++)
    if(d&(1<<i))
     b = dp[i][b];
   if(a == b) return a;
   for(i = logx - 1;i>=0;i--)
    if(dp[i][a] != dp[i][b])
     a = dp[i][a],b = dp[i][b];
   return dp[0][a];
}
ll dist(ll a,ll b)
{
  return sum[a] + sum[b] - 2*sum[lca(a,b)];
}
int main()
{
   std::ios::sync_with_stdio(false);
   cin>>n;
   logx = log(n)/log(2) + 1;
   dp.rs(logx,vector<ll>(n)),adj.rs(n),l.rs(n),visit.rs(n),sum.rs(n);
   rep(i,0,n-1){
      cin>>a>>b>>c;
      a--,b--;
      adj[a].pb({b,c}),adj[b].pb({a,c});
   }
   dfs(0);
   rep(i,1,logx) rep(j,0,n) dp[i][j] = dp[i-1][dp[i-1][j]];
   cin>>q>>k;
   while(q--){
      cin>>a>>b;
      cout<<dist(a - 1,k - 1) + dist(k - 1,b - 1)<<endl;
   }
   return 0;
}


Measured memory_bytes: 29168
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, x = i_map()

    print(b//x - a//x + (1 if a%x == 0 else 0))

if __name__ == '__main__':
    main()


Measured memory_bytes: 71984
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()

// DEBUG TEMPLATE
#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__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

void solve()
{ 
 int n;
 cin>>n;
 cout<< ((n+999)/1000)*1000-n<<endl;
}


/*
  
*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 3636
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 65112
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
int n, i, in;
bool pos = true;
int main ()
{
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> in;
        if(in % 2 == 0 and (in % 3 != 0 and in % 5 != 0))
        {
            pos = false;
            break;
        }
    }
    cout << ((pos) ? "APPROVED\n" : "DENIED\n");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int a, b, c;
	int i = 0;

	scanf("%d %d %d", &a, &b, &c);
	if (a < b) {
		for (int j = b; j >= a; j--){
			if(c%j == 0)
				i++;
		}
	}
	else {
		for (int j = b; j <=a; j++) {
			if(c%j == 0)
				i++;
		}
	}
	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 2136
while True:
    try:
        a, b, c, d, e, f = map(int, input().split())
    except EOFError:
        break
    else:
        y = (f - c * d / a) / (e - b * d / a)
        x = c/a - b*y/a
        print('{0:.3f} {1:.3f}'.format(x, y))

Measured memory_bytes: 7660
let s = read_line () in
let n = String.length s in
let checkC i e =
    let rec loop i k =
        if i = e then k = 1 else
            if s.[i] = 'C' then loop (i + 1) (k + 1)
                           else loop (i + 1) k
    in
    loop i 0
in
let checkS i e =
    let rec loop i =
        if i = e then true else
            if s.[i] = 'C' then (if i >= 2 && i < e - 1 then loop (i + 1) else false)
            else if s.[i] >= 'a' && s.[i] <= 'z' then loop (i + 1) else false
    in
    loop i 
in
print_endline @@ if s.[0] = 'A' && checkC 2 (n - 1) && checkS 1 n then "AC" else "WA"

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

int N, W, w[105], v[105], mem[105][100005];

int dp(int n, int cw) {
	if (cw < 0) return -1e9;
	if (n == 0) return 0;
	if (mem[n][cw] != -1) return mem[n][cw];
	return mem[n][cw] = max(dp(n - 1, cw - w[n]) + v[n], dp(n - 1, cw));
}

main() {
	ios::sync_with_stdio(0);
	memset(mem, -1, sizeof mem);
	cin.tie(0);
	cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	cout << dp(N, W) << '\n';
}


Measured memory_bytes: 82304
using System;
using System.Linq;
namespace A___Restricted
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = line[0];
            int b = line[1];
            if((a+b)>=10)
            {
                Console.WriteLine("error");
            }
            else
            {
                Console.WriteLine(a + b);
            }
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int n,q,mi;
int A[2000];

int solve(int j,int m);

int main(void){
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
		}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&mi);
		if(solve(0,mi)) printf("yes\n");
		else printf("no\n");
		}
	return 0;
}
		
int solve(int j,int m){
	if(m==0) return 1;
	if(j>=n) return 0;
	int judge=solve(j+1,m)||solve(j+1,m-A[j]);
	return judge;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...U>void _(const char*s,T h,U...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}//break continue pop_back
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...)
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=2e5+1;
int a[N];
int r[N];
int32_t main(){

    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    vector<int>w;
    for(int i=n;i>=1;--i){
        r[i]=a[i];
        for(int j=i+i;j<=n;j+=i)
            r[i]^=r[j];
        if(r[i])w.pb(i);
    }
    cout<<w.size()<<'\n';
    for(int i:w)cout<<i<<' ';
        cout<<'\n';
    return 0;
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%2==0){
		cout<<"No"<<endl;
	}
	else{
		if(b%2==0){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define M1 (ll)1000000007
#define M2 (ll)998244353
#define Pi 3.141592653
#define exp 2.71828
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define di deque<int>
#define dl deque<ll>
#define dii deque<pi>
#define dll deque<pl>
#define vvi vector<vi>
#define vvl vector<vl>
#define vii vector<pi>
#define vll vector<pl>
#define pb push_back
#define pp pop_back
#define pf push_front
#define pt pop_front
#define mp make_pair
#define in insert
#define er erase
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rpt(i,a,b,t) for(int i=a;i<b&&t<1;i++)
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define rept(i,n,t) for(int i = 0 ; i<n&&t<1 ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define reprt(i,n,t) for(int i=n-1;i>=0&&t<1;i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
int main() {                                                  
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<n+1;++i) cin>>p[i];
    double dp[n+1][n+1];
    for(int i=0;i<n+1;++i) for(int j=0;j<n+1;++j) dp[i][j]=0;
    dp[0][0]=1;
    for(int i=1;i<n+1;++i) dp[i][0] = dp[i-1][0]*(1-p[i]);
    for(int i=1;i<n+1;++i){
        for(int j=1;j<=i+1;++j){
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]); 
        }
    }
    double result = 0;
    for(int i=0;i<=n/2;++i){
        result += dp[n][n-i];
    }
    cout<<setprecision(10)<<result;
    // cout<<result;                               
}


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

int main(){
	int h[10];
	for (int i = 0; i < 10; i++){
		cin >> h[i];
	}
	int n = 0;
	int a = 0;
	while (n == 0){
		n++;
		for (int i = 0; i < 9; i++){
			
			if (h[i]<h[i + 1]){
				a = h[i];
				h[i] = h[i + 1];
				h[i + 1] = a;
				n = 0;
			}
		}
	}
	for (int i = 0; i < 3; i++){
		cout << h[i]<< '\n';
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> lw(n), re(n);
    for (int i=1; i<n; i++) {
        lw[i] = lw[i-1];
        if (s[i-1]=='W') lw[i]++;
    }
    for (int i=n-2; i>=0; i--) {
        re[i] = re[i+1];
        if (s[i+1]=='E') re[i]++;
    }
    int ans = 300000;
    for (int i=0; i<n; i++) {
        ans = min(ans, lw[i]+re[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

int N,M;
map<int,int> m;
int main(){
	cin>>N;
	string ans="YES";
	REP(i,0,N) {
		int a;
		scanf("%d",&a);
		m[a]++;
	}
	cin>>M;
	REP(i,0,M) {
		int a;
		scanf("%d",&a);
		if(m[a]>0){
			m[a]--;
		}else{
			ans="NO";
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 9600
#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, x, y;
    cin >> n >> x >> y;
    int ans[n-1];

    rep(i,n-1) ans[i] = 0;

    for (int first=0; first < n-1; first++) {
        for(int second=first+1; second < n; second++) {
            int dis = min(second-first, abs((y-1)-second)+abs((x-1)-first)+1);

            // int dis;
            // if (first <= x-1 && second >= y-1) {
            //     dis = second - first - (y-x-1);
            // }
            // else {
            //     dis = min(second-first, abs(y-second)+abs(x-first)+1);
            // }
            // cout << first << " " << second << " " <<dis << endl;
            ans[dis-1]++;
        }
    }

    // cout << "+++" << endl;
    rep(i,n-1) cout << ans[i] << endl;

    return 0;




}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>//cout << fixed からの cout << setprecision(n) << 小数　によって小数を整数部分含めてn桁表示できるようにする
#include<cctype>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int r,g,b,n,cnt;
  cin >> r >> g >> b >> n;

  for(int i = 0;i <= n / r ; i++){
    for(int j = 0;j <= (n - r*i)/g; j++){
      if ((n-(r * i + g * j)) % b == 0){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) { cin >> s[i]; }
    int temp[h + 2][w + 2] = {};
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                temp[i + 1][j + 1] = 1;
            }
        }
    }
    int ans[h][w] = {};
    rep(i, h) {
        rep(j, w) {
            repd(l0, -1, 2) {
                repd(l1, -1, 2) { ans[i][j] += temp[i + 1 + l0][j + 1 + l1]; }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                cout << "#";
            } else {
                cout << ans[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#define N 10000
#define INF 1000000000

int n;
std::vector<std::pair<int, int> > adj[N];  //

void dijkstra(){
  std::priority_queue<std::pair<int , int> > PQ;  //Container adapter
  std::vector<int> Set(N, 1); //create int number of N, all value initialization to 1
  std::vector<int> d(N, INF); //create int number of N, all value initialization to INF

  d[0] = 0;
  PQ.push(std::make_pair(0, 0)); //add elements of PQ
  Set[0] = 1;

  while( PQ.empty() != 1 ){
    std::pair<int, int> f = PQ.top(); //Extract elements in priority order
    PQ.pop();//Erase the next element

    int u = f.second;
    Set[u] = 2;

    if( d[u] < f.first*(-1) ) continue;

    //   std::cout << adj[u].size() << std::endl;
    for(int i=0; i<adj[u].size(); i++){
      int v = adj[u][i].first;
      if( Set[v] == 2 )continue;
      if( d[v] > d[u] + adj[u][i].second ){
        d[v] = d[u] +adj[u][i].second;
        PQ.push(std::make_pair(d[v]*(-1), v));
        Set[v] = 1;
      }
    }
  }
  for(int j=0; j<n; j++){
    std::cout << j << " " << (d[j] == INF ? -1 : d[j]) << std::endl;
  }
}

int main(){
  int u, k, v, c;
  //Input
  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> u >> k;
    for(int j=0; j<k; j++){
      std::cin >> v >> c;
      adj[u].push_back(std::make_pair(v, c));
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 8096