akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <chrono>
using namespace std;

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 a, b, c; cin >> a >> b >> c;
        cout << (a < b && b < c ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
long long sum(long long n){ return n*(n+1)/2; }
int main(){
	long long N;
	cin>>N;
	cout<<sum(N)-sum(N/3)*3-sum(N/5)*5+sum(N/15)*15<<endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


int n, m;
vector<int>G[100005];
int dp[100005][15];
struct info {
	int v, d, c;
};
vector<info>qu;
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int q; cin >> q;
	while (q--) {
		int v, d, c; cin >> v >> d >> c; v--;
		qu.push_back({ v,d,c });
	}
	reverse(all(qu));
	rep(i, n)rep(j, 11)dp[i][j] = inf;
	rep(i, qu.size()) {
		chmin(dp[qu[i].v][qu[i].d], i);
	}
	for (int i = 10; i > 0; i--) {
		rep(j, n) {
			chmin(dp[j][i - 1], dp[j][i]);
			for (int k : G[j]) {
				chmin(dp[k][i - 1], dp[j][i]);
			}
		}
	}
	rep(i, n) {
		if (dp[i][0] != inf) {
			cout << qu[dp[i][0]].c << endl;
		}
		else cout << 0 << endl;
	}
}


Measured memory_bytes: 21740
import copy

s = input()
target_x, target_y = map(int, input().split())

fl = s.split('T')
f_cnts = [ len(v) for v in fl ]

target_x -= f_cnts[0]
f_cnts = f_cnts[1:]

last_xs = set()
last_ys = set()
last_xs.add(0)
last_ys.add(0)
for i, f_cnt in enumerate(f_cnts):
    if i%2 == 0:
        next_y = f_cnts[i]
        next_last_ys = set()
        for y in list(last_ys):
            next_last_ys.add(y+next_y)
            next_last_ys.add(abs(y-next_y))
        last_ys = copy.deepcopy(next_last_ys)
    else:
        next_x = f_cnts[i]
        next_last_xs = set()
        for x in list(last_xs):
            next_last_xs.add(x+next_x)
            next_last_xs.add(abs(x-next_x))
        last_xs = copy.deepcopy(next_last_xs)


if (target_x in last_xs or -1*target_x in last_xs) and (target_y in last_ys or -1*target_y in last_ys):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 88168
#include <stdio.h>

typedef struct node{
    int key;
    int parent;
    int left;
    int right;
}Tree;

int main(){
    int i,j,n;
    int data;
    int parent;
    
    scanf("%d",&n);
    Tree T[n+1];
    for(i=0;i<n+1;i++){
        T[i].key=0;
        T[i].parent=0;
        T[i].left=0;
        T[i].right=0;
    }
    
    parent=-1;
    for(i=1;i<n+1;i++){
        scanf("%d",&data);
        T[i].key=data;
        T[i].parent=T[i/2].key;
        if(T[i/2].left==0)T[i/2].left=data;
        else T[i/2].right=data;
    }
    
    for(i=1;i<n+1;i++){
        printf("node %d: key = %d, ",i,T[i].key);
        if(T[i].parent!=0)printf("parent key = %d, ",T[i].parent);
        if(T[i].left!=0)printf("left key = %d, ",T[i].left);
        if(T[i].right!=0)printf("right key = %d, ",T[i].right);
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    char c[3] = {'a','b','c'};
    F0R(i,3){
      bool nice = false;
      F0R(j,3){
        if(s[j] == c[i]) nice = true;
      }
      if(!nice) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
X=int(input())
if 400<=X and X<=599: print('8')
elif 600<=X and X<=799: print('7')
elif 800<=X and X<=999: print('6')
elif 1000<=X and X<=1199: print('5')
elif 1200<=X and X<=1399: print('4')
elif 1400<=X and X<=1599: print('3')
elif 1600<=X and X<=1799: print('2')
elif 1800<=X and X<=1999: print('1')


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=4e5+10,size=1<<20,mod=998244353;
const ll inf=1e18;

template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

int n,dic[150],f[N*2][2],g[N*2][2];
ll ans=inf;
vector<pi> x[N],y[N];

int main() {
	qr(n);
	dic['U']=0;
	dic['D']=1;
	dic['R']=2;
	dic['L']=3;
	for(int i=1;i<=n;i++) {
		int a,b,c;qr(a); qr(b);
		char str[6]; scanf("%s",str);
		a++; b++; c=dic[str[0]];
		x[a].pb(mk(b,c));
		y[b].pb(mk(a,c));
	}
	for(int i=1;i<N;i++) {
		sort(all(x[i]));
		sort(all(y[i]));
		ll a,b;
		a=b=inf;
		for(auto j:x[i]) {
			if(j.se==0) a=j.fi;
			else if(j.se==1) b=j.fi;
			if(a<b) ans=min(ans,(b-a)*5);
		}
		a=b=inf;
		for(auto j:y[i]) {
			if(j.se==2) a=j.fi;
			else if(j.se==3) b=j.fi;
			if(a<b) ans=min(ans,(b-a)*5);
		}
	}
	for(int i=1;i<N;i++) 
		for(auto j:x[i]) {
			int t=j.fi;
			if(j.se==2) {
				f[j.fi-i+N][0]=i;
				f[j.fi+i][1]=i;
			}
			else if(j.se==3) {
				int k=g[j.fi+i][1];
				if(k) ans=min(ans,(i-k)*10LL);
				k=g[j.fi-i+N][0];
				if(k) ans=min(ans,(i-k)*10LL);
			}
			else if(j.se==1) {
				int k=f[j.fi-i+N][0];
				if(k) ans=min(ans,(i-k)*10LL);
				g[j.fi+i][1]=i;
			}
			else if(j.se==0) {
				int k=f[j.fi+i][1];
				if(k) ans=min(ans,(i-k)*10LL);
				g[j.fi-i+N][0]=i;
			}
		}
	if(ans>inf/2) puts("SAFE");
	else pr2(ans);
	return 0;
}


Measured memory_bytes: 40180
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define PI 3.1415926535897932384626433832795
#define inf 0x3f3f3f3f
#define MAXN 100005
using namespace std;
typedef long long ll;
const double EPS=1e-6;

map <int,int>ma;
bool check(ll x)
{
	if(x==0)
	{
		if(ma[x]==1)
			return 1;
		else
			return 0;
	}
	
	while(x)
	{
		if(ma[x%10])
			return 1;
		x/=10;
	}
	return 0;
}

int main()
{
	//ios::sync_with_stdio(false);
	ll n,k;
	int i,a;
	scanf("%lld%lld",&n,&k);
	for(i=0;i<k;i++)
	{
		scanf("%d",&a);
		ma[a]=1;
	}
	while(check(n))
		n++;
	printf("%lld",n);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int number;
	int human,fish;
	int i;
	int max = -1;
	int x = 0;
	scanf("%d",&number);
	for(i = 0;i < number;i++){
		scanf("%d %d",&human,&fish);
		if(fish > max){
			max = fish;
			x = human;
		}
		if((max == fish) && (x > human)){
			x = human;
		}
	}
	printf("%d %d\n",x,max);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  string s;cin>>s;
  char c='?';
  rep(i,n) {
    if(c!=s[i]) {
      ans++;
      c=s[i];
    }
  }
  print(ans);
  return 0;
}

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

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

int N;
ll X;

ll func(ll N, ll X, vector<ll> dpp, vector<ll> f){
    if(N == 0){
        return 1;
    }
    if(X == 1)  return 0;
    if(X <= 1 + f[N-1]){
        return func(N-1, X-1, dpp, f);
    } else if(X == 2 + f[N-1]){
        return 1 + func(N-1, X-2, dpp, f);
    } else {
        return dpp[N-1] + 1 + func(N-1, X-2-f[N-1], dpp, f);
    }
}

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

    vector<ll> dpp(N+1);
    vector<ll> f(N+1);
    dpp[0] = 1;
    f[0] = 1;
    for(int i=0;i<N;i++){
        dpp[i+1] = dpp[i] * 2 + 1;
        f[i+1] = f[i] * 2 + 3;
    }

    ll ans = func(N, X, dpp, f);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,p,ans=1;
    cin>>n>>p;
    map<ll,ll> mp;
    for(ll i=1;i*i<=p;i++){
        if(p%i==0){
            mp[i]++;
            mp[p/i]++;
        }
    }
    for(auto i:mp){
        ll b=p,cnt=0,a=i.fi;
        if(a==1) continue;
        while(b%a==0){
            cnt++;
            b/=a;
        }
        if(cnt>=n) ans=max(a,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

void add(ll& a, ll b){a = (a+b) % MOD;}

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) cout<<0;
    else{
        cout<<min({a*b,b*c,c*a});
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0;i < N;++i){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    if(N % 2 == 1) cout << 0 << endl;
    else{
        if(d[N/2] == d[N/2-1]) cout << 0 << endl;
        else cout << d[N/2]-d[N/2-1] << endl;
    }
}

Measured memory_bytes: 640
n = int(input())
A = [int(input()) for a in range(n)]
count = 0
for i in A:
    if i == 2:
        count += 1
        continue
    if i <= 1 or i%2 == 0:
        continue
    
    j = 3
    while(j*j < i):
        if i%j == 0:
            break
        j += 2
    
    if j*j > i:
        count += 1
        
print(count)


Measured memory_bytes: 5984
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
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()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:i64, a:i64, b:i64};
    if (b-a)%2==0 {
        println!("{}", (b-a)/2);
        return ();
    }
    let d = vec![b-1,n-a,a+(b-a)/2,(n-b+1)+(n-(a+n-b+1))/2];
    //debug!(b-1, n-a, a+(b-a)/2, (n-b+1)+(n-(a+n-b+1))/2);
    println!("{}", d.iter().min().unwrap());
}


Measured memory_bytes: 4352
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(N),[1,2]):
    if i+j<=N-1:
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Measured memory_bytes: 53704
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    string s;
    cin >> s;
    ll N = stoi(s);
    int p = 0;
    FOR(i,0,s.size())p += ctoi(s[i]);
    Yes(N%p == 0);
}


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

using namespace std;

int main()
{
    int answer = 0;
    string S;
    cin >> S;
    if (S.size() < 2)
    {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i < S.size(); i++)
    {

        if (S[i - 1] == S[i])
        {
            if (S[i - 1] == '0')
            {
                S[i] = '1';
            }
            else if (S[i - 1] == '1')
            {
                S[i] = '0';
            }
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
n, k, q = gets.to_s.split.map(&:to_i)
array = []
score = []
n.times do
  score << k - q
end
q.times do
  score[gets.to_i - 1] += 1
end
score.each do |s|
  puts s > 0 ? "Yes" : "No"
end

Measured memory_bytes: 3196
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int d,e;
  int i,j;
  while(1){
    double ans=INF;
    cin>>d>>e;
    if(d==0 && e==0)break;
    rep(i,d+1){
      j=d-i;
      double rail=sqrt(i*i+j*j);
      rail=max(rail-e,e-rail);//diff
      ans=min(ans,rail);
    }
    printf("%.10f\n",ans);
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()


int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> m;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }

    ll ans = 0;

    for (auto t : m)
    {
        ans += t.second * (t.second - 1) / 2;
    }
    for (auto t : a)
    {
        if (m[t] >= 2)
        {
            ans -= (m[t] - 1);
        }
        cout << ans << endl;
        if (m[t] >= 2)
        {
            ans += (m[t] - 1);
        }
    }
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, t[105], m;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	vector<int> ans(m);
	FOR(i, m) {
		int p, x;
		cin >> p >> x;
		ans[i] = sum - t[p] + x;
	}
	FOR(i, m) cout << ans[i] << endl;
	return 0;
}

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

main(){
	string s; cin>>s;
	
	int cnt=0, ans=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='R') cnt++;
		else{
			ans = max(ans, cnt);
			cnt=0;
		}
	}
	ans = max(ans,cnt);
	cout<<ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
//解説配信の解答写し
const int m=2019;
int main() {
  string s;
  cin >> s;
  int n=s.size();
  reverse(s.begin(),s.end());
  int x=1,tot=0;
  vector<int> cnt(m);
  long long ans=0;
  rep(i,n){
    cnt[tot]++;
    tot+=(s[i]-'0')*x;
    tot%=m;
    ans+=cnt[tot];
    x=x*10%m;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    char b;
    cin >> b;

    switch (b)
    {
    case 'A':
        cout << 'T';
        break;
    case 'T':
        cout << 'A';
        break;
    case 'C':
        cout << 'G';
        break;
    case 'G':
        cout << 'C';
        break;
    }
    return 0;
}


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

using namespace std;
#define N 100010
ll n,m,p,a[N];
ll dist(ll x,ll y){
 if(x<=y)return (y-x)*100;
 return (n-(x-y))*100;
}
int main(){
    cin>>n>>m>>p;
    for(int i=0;i<m;i++)cin>>a[i];
    if(m==1){
     cout<<min(dist(p,a[0]),dist(a[0],p))<<endl;
     return 0;
    }a[m]=p;
    sort(a,a+m+1);
    ll ans=1e17;
    for(int i=0;i<=m;i++){
        int j=(i+1)%(m+1);
        ans=min(ans,dist(p,a[i])*2+dist(a[j],p));
        ans=min(ans,dist(p,a[i])+2*dist(a[j],p));
    }
    cout<<ans<<endl;
 return 0;   
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
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; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
int main(){
int n;
ll k,cnt=0ll;
cin>>n>>k;
vector<ll> pos,neg;
rep(i,n){ll o;cin>>o;
if(o==0)cnt++;
else{if (o>0)pos.emplace_back(o);
     else neg.emplace_back(-o);}
}
sort(all(pos));sort(all(neg));
ll po=(ll)pos.size(),ne=(ll)neg.size();
ll ok=1e18+1,ng=-1e18-1;
while (ok-ng>1){
  ll mid=(ok+ng)/2;
  if (mid==0){
    if (cnt*(cnt-1)/2+cnt*(ne+po)+po*ne>=k)ok=mid;
    else ng=mid;
  }
  else{
  if (mid>0){
    ll ret=0ll;
    vep(i,pos){
      
      ret+=(upper_bound(i+1,pos.end(),mid/(*i))-i)-1;
    }
    vep(i,neg){
      ret+=(upper_bound(i+1,neg.end(),mid/(*i))-i)-1;
    }
    if (ret+cnt*(cnt-1)/2+cnt*(po+ne)+po*ne>=k)ok=mid;
    else ng=mid;
  }
  else{
    ll ret=0ll;
    vep(i,pos){
      ret+=neg.end()-lower_bound(all(neg),ceildiv(-mid,*i));
    }
    if (ret>=k) ok=mid;else ng=mid;
  }
  }
}
print(ok);
}


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

class Card {
 public:
  int id;
  int number;
  char suit;

  bool operator<(const Card& B) const { return number < B.number; }
  bool operator>(const Card& B) const { return number > B.number; }
  bool operator<=(const Card& B) const { return number <= B.number; }
  bool operator>=(const Card& B) const { return number >= B.number; }
};

template <class T>
void Swap(T* a, T* b) {
  T t = *a;
  *a = *b;
  *b = t;
}

template <class T>
int partition(T* array, int p, int r) {
  T x = array[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (array[j] <= x) {
      i = i + 1;
      Swap(&array[i], &array[j]);
    }
  }
  Swap(&array[i + 1], &array[r]);
  return i + 1;
}

template <class T>
void quickSort(T* array, int p, int r) {
  if (p < r) {
    int q = partition(array, p, r);
    quickSort(array, p, q - 1);
    quickSort(array, q + 1, r);
  }
}

int main() {
  int n;
  cin >> n;
  Card cards[n];
  for (int i = 0; i < n; i++) {
    cards[i].id = i;
    cin >> cards[i].suit >> cards[i].number;
  }
  quickSort(cards, 0, n - 1);

  bool is_stable = true;
  int compare_number = 0;
  int compare_id = 0;
  for (int i = 0; i < n; i++) {
    if (cards[i].number != compare_number) {
      compare_id = cards[i].id;
      compare_number = cards[i].number;
      continue;
    }
    if (compare_id > cards[i].id) {
      is_stable = false;
      break;
    }
  }
  if (is_stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  for (int i = 0; i < n; i++) {
    cout << cards[i].suit << " " << cards[i].number << endl;
  }
  return 0;
}


Measured memory_bytes: 4248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main(void) {
  ll n, m;
  cin >> n >> m;
  //sが余る場合
  if(n*2 > m) {
    cout << m/2 << endl;
  } else {
     m += n*2;
  n=0;
  cout << m/4 << endl;
}
  }
 

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

int N;
vector<vector<int>> G;
int ans;

void dfs(int v, vector<int> V) {
  V.at(v) = 1;
  if (accumulate(V.begin(), V.end(), 0) == N) {
    ans++;
    return;
  }
  for (auto g : G.at(v)) if (!V.at(g)) dfs(g, V);
  V.at(v) = 0;
}

int main() {
  int M;
  cin >> N >> M;
  G.resize(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b), G.at(b).push_back(a);
  }
  vector<int> V(N);
  dfs(0, V);
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 1e6+5;
const ll INF = 1e18;
const ll MOD = 998244353;

int main()
{
    ll n,k,i,j,p,q,x,y;
    cin >> n >> k;
    vector<ll> dp(n+1,0),cum(n+1,0);
    dp[1]=1;cum[1]=1;
    vector<pair<ll,ll>> vec;
    for(i=0;i<k;i++)
    {
        cin >> x >> y;
        vec.pb({x,y});
    }
    for(i=2;i<=n;i++)
    {
        for(j=0;j<k;j++)
        {
            if(i-vec[j].first<1)
                continue;
            p = i-vec[j].first;
            q = max((ll)1,i-vec[j].second);
            dp[i] = (dp[i]+cum[p]-cum[q-1]+MOD)%MOD;
        }
        cum[i] = (cum[i-1]+dp[i])%MOD;
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 6372
#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;

int mod = 1000000007;

int main() {
    int N, M; cin >> N >> M;
    int sa = abs(N-M);
    if(sa > 1){
        cout << 0 << endl;
    } else {
        ll ans = 1;
        if(N == M){
            for (int i = 2; i <= N; i++){
                ans *= i;
                ans %= mod;
                ans *= i;
                ans %= mod;
            }
            ans *= 2;
            ans %= mod;
        } else {
            for (int i = 2; i <= N; i++){
                ans *= i;
                ans %= mod;
            }
            for (int i = 2; i <= M; i++){
                ans *= i;
                ans %= mod;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int a, b;
	cin >> a >> b;

	println(((a * b) % 2 == 0 ? "No" : "Yes"));
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t long long
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int A, B;
  cin >> A >> B;
  int N;
  for (N = 0; ; N++) {
    if (B < pow(2, N)) {
      break;
    }
  }
  int M;
  for (M = 0; ; M++) {
    if (A < pow(2, M)) {
      break;
    }
  }
  debug(M);
  debug(N);
  vector<bool> v(N, 0);
  int ans = 0;
  if (A % 4 == 2 || A % 4 == 3) {
    ans ^= 1;
  }
  if (B % 4 == 1 || B % 4 == 2) {
    ans ^= 1;
  }
  if (N == 0) {
    cout << "0" << endl;
    return 0;
  }
  // int ans = 0;
  int a,b;
  for (size_t i = 1; i < N - 1; i++) {
    int n = pow(2, i + 1);
    a = A % n;
    b = B % n;
    // debug(n);
    // debug(a);
    // debug(b);
    if (a >= n/2) {
      v[i] = v[i] ^ ((a - n/2)%2);
    }
    if (b >= n/2) {
      v[i] = v[i] ^ !((b - n/2)%2);
    }
  }
  // v[0] = (1 + B - A) % 2;
  if (M == N) {
    v[N - 1] = (1 + B - A) % 2;
  } else {
    v[N - 1] = (1 + B - (int)pow(2, N - 1)) % 2;
  }
  for (size_t i = 1; i < N; i++) {
    if (v[i] % 2 == 1) {
      ans += pow(2, i);
    }
  }
  // debug(v);
  // debug(ans);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (int j=0; j < H; ++j) {
        cin >> a[j];
    }
    vector<bool> row(H), col(W);
    for (int j=0; j < H; ++j) {
        bool isBlank = true;
        for (int k=0; k < W; ++k) {
            if (a[j][k] == '#') {
                isBlank = false;
                break;
            }
        }
        if (isBlank) {
            row[j] = false;
        } else {
            row[j] = true;
        }
    }
    for (int j=0; j < W; ++j) {
        bool isBlank = true;
        for (int k=0; k < H; ++k) {
            if (a[k][j] == '#') {
                isBlank = false;
                break;
            }
        }
        if (isBlank) {
            col[j] = false;
        } else {
            col[j] = true;
        }
    }
    for (int j=0; j < H; ++j) {
        if (row[j]) {
        for (int k=0; k < W; ++k) {
            if (col[k]) {
                cout << a[j][k];
            }
        }
        cout << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int n = sc.nextInt();
      if (n == 0) break;
      int[] s = new int[n];
      int sum = 0;
      for (int i = 0; i < n; i++) {
        s[i] = sc.nextInt();
        sum += s[i];
      }
      double m = (double)sum / n;
      double std = 0.0;
      for (int i = 0; i < n; i++) {
        std += (s[i] - m) * (s[i] - n);
      }
      System.out.println(Math.sqrt(std / n));
    }
  }
}


Measured memory_bytes: 31288
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  ll n,k,r,s,p;
  string m;
  cin>>n>>k>>r>>s>>p>>m;
  ll ans = 0;
  char last;
  map<char,char> win;
  win['r'] = 'p';
  win['p'] = 's';
  win['s'] = 'r';
  FORN(j,0,k){
    last = win[m[j]];
    for(int i = j; i < n; i += k){
      if(i - k >= 0 && m[i] == m[i-k] && last != '*'){
	last = '*';
	continue;
      }
      if(m[i] == 'r') ans += p;
      else if(m[i] == 's') ans += r;
      else ans += s;
      last = win[m[i]];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// typedef long long ll;
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using P = pair<int, int>;

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

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

signed main() {
  int a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<double>p(n);
    rep(i,n)cin>>p[i];
    //i枚目までにj枚のコインが表になる確率
    vector<vector<double>>dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;
    rep(i,n){
        rep(j,i+1){
        dp[i+1][j+1]+=dp[i][j]*p[i];//i枚めで表の確率
        dp[i+1][j]+=dp[i][j]*(1-p[i]);//i枚めで裏の確率
        }
    }
    double ans=0;
    rep(j,n+1)if(j>=(double)n/2)ans+=dp[n][j];
    printf("%.10lf\n",ans);
    return 0;
}


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

int main(){
    Init();
    ll n, ans = 0; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    // +は繰り上がりがある、xorは繰り上がりが無い加算と考える
    ll left = 0, right = 0;
    ll sum = 0, xsum = 0;

    for(left = 0; left<n; left++){
        if(right == n) ans += right-left;
        else{
            while(sum == xsum && right < n){
                sum += a[right];
                xsum ^= a[right];
                right++;
            }
            if(sum != xsum){
                right--;
                sum -= a[right];
                xsum ^= a[right];
            }
            ans += (right - left);
            sum -= a[left];
            xsum ^= a[left];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    cin >> n;
    int num = n;
    int i;
    for (i = 0; i < n;i++){
         int l;
         int r;
        cin >> l >> r;
        num += r;
        num -= l;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * author  : UshanGhosh
 * created : 2020-09-19 19:20:21
**/ 

#include<bits/stdc++.h>
using namespace std;

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (int)1e9+7
#define    inf     (long long)1e18
#define    endl    '\n'

ll ar[100000], pos[1000000];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>a>>b>>c;
    ll ans = b%c;
    ll pans = b%c;
    memset(ar,-1,sizeof(ar));
    ar[pans] = 0;
    pos[pans] = 1;
    ll rem = 0;
    for(i=2;i<=a;i++){
        pans = (pans*pans)%c;
        if(ar[pans]!=-1){
            ll lans = ans - ar[pans];
            ll cnt = i-pos[pans];
            rem = (a-i+1)%cnt;
            d = pans;
            ans += ((a-i+1)/cnt)*lans;
            break;
        }
        ar[pans] = ans;
        pos[pans] = i;
        ans+=pans;
        if(pans==0) break;
    }
    for(i=0;i<rem;i++){
        if(i==0) ans+=pans;
        else{
            pans*=pans;
            pans%=c;
            ans+=pans;
        }
    }
    cout<<ans<<"\n";
}

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

using namespace std;

int ar[100010];

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

    int n , k, x, m = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> ar[i];
        m = max(m, ar[i]);
    }

    if(k > m) {
        cout << "IMPOSSIBLE";
        return 0;
    }

    x = ar[0];
    for(int i = 1; i < n; i++) {
        x = __gcd(x, ar[i]);
    }

    if(k % x)
        cout << "IMPOSSIBLE";
    else
        cout << "POSSIBLE";



	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int N;
int A[SIZE];
ll K;

int main()
{
	string s;
	cin >> s;
	int c = 0;
	rep(i,0,s.size()){
		if(i%2==0){
			if(s[i]=='p')c--;
		}else{
			if(s[i]=='g')c++;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    int a[q], a_1[q];
    int b[q], b_1[q];
    rep(i, q) {
        cin >> a[i] >> b[i];
        a_1[i] = a[i];
        b_1[i] = b[i];
    }
    sort(b_1, b_1 + q);
    sort(a_1, a_1 + q);
    reverse(b_1, b_1 + q);
    int s = a_1[0];
    int e = b_1[0];
    int g[100001];
    memset(g, 0, sizeof(g));
    while(s <= e){
        int h = 0;
        if(s != 3 && (s + 1) % 4 == 0) h = 1;
        if(s == 1) h = 1;
        for(int i = 3; i * i <= s; i += 2) {
            if (s % i == 0){
                h = 1;
                }}

        for(int i = 3; i * i <= (s + 1) / 2; i += 2){
            if(((s + 1) / 2) % i == 0) h = 1;
        }
        /*
        if(s  ==  || ((s + 1) / 2) % 2 == 0) {
                h =1;
            }
            */

        //if(s == 3)
        if(h == 0) rep(j, s) g[j] += 1;
        s += 2;
    }
    //rep(i,12) cout << g[i] << endl;
    rep(i, q) cout <<-( g[b[i]] - g[a[i] - 1]) << endl;





}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

char s[200010];

int main(){

    scanf("%s", s);
    int len = strlen(s);
    int sum = 0;
    for(int i=0; i<len; i++){
        sum += s[i] - '0';
    }
    if(sum % 9 == 0){
        puts("Yes");
    } else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, C;
    cin >> N >> C;
    vector<ll> x(N + 1, 0), v(N + 1, 0);
    vector<vector<ll>> sum(2, vector<ll>(N + 1, 0));

    rep(i, N) cin >> x[i] >> v[i];
    sum[0][0] = max(0LL, v[0] - x[0]);
    ll V = v[0];
    repd(i, 1, N) { 
        V += v[i];
        sum[0][i] = max(sum[0][i - 1], V - x[i]);
    }

    sum[1][N - 1] = max(0LL, v[N - 1] - (C - x[N - 1]));
    V = v[N - 1];
    repd(i, 1, N) { 
        V += v[N - 1 - i];
        sum[1][N - 1 - i] = max(sum[1][N - i], V - (C - x[N - 1 - i]));
    }

    ll ans = 0;

    //rep(i, N + 1) cout << sum[0][i] << " " << sum[1][i] << endl;
    rep(i, N) {
        if (i != N - 1) chmax(ans, sum[0][i] - x[i] + sum[1][i + 1]);
        if (i != 0) chmax(ans, sum[1][i] - (C - x[i]) + sum[0][i - 1]);
        chmax(ans, sum[0][i]);
        chmax(ans, sum[1][i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,t;
int main(){
	cin>>a>>b>>c;
	for (i=1;i<=1000000;i++)
	if(a*i%b==c)t=1;
if(t==1)cout<<"YES";else cout<<"NO";
}

Measured memory_bytes: 256
n, m, d = map(int, raw_input().split())
fld = [raw_input() for i in range(n)]

ans = 0
for i in range(n):
  for j in range(m):
    if i <= n-d:
      fl = True
      for k in range(d):
        fl &= fld[i+k][j] == '.'
      if fl:
        ans += 1
    if j <= m-d:
      fl = True
      for k in range(d):
        fl &= fld[i][j+k] == '.'
      if fl:
        ans += 1

print ans

Measured memory_bytes: 6444
import java.util.Scanner;
class Main {

	public static void main(String[] args)
    {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int t=sc.nextInt();
		int time=t;
		int x1=x;
		while(x<n)
		{
			t=t+time;
			x=x+x1;
		}
		System.out.println(t);
		
		sc.close();		
	}

}


Measured memory_bytes: 27048