akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=10002;
int S,T,cur[N<<1],fir[N<<1],dep[N<<1];
char map[N];
struct edge{
	int to,wi,nx;
}eg[N*400];

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10+c-48,(c=getchar())>='0'&&c<='9');
	return x;
}

inline void add(int a,int b,int v){
	static int cnt=1;
	eg[++cnt]=(edge){b,v,fir[a]};
	fir[a]=cnt;
	eg[++cnt]=(edge){a,0,fir[b]};
	fir[b]=cnt;
}

inline bool bfs(){
	static int que[N<<1];
	memset(dep,0,sizeof(dep));
	int hd=0,tl=1;
	que[0]=S+N;
	dep[S+N]=1;
	while(hd!=tl){
		int x=que[hd++];
		for(int i=cur[x]=fir[x];i;i=eg[i].nx){
			int y=eg[i].to;
			if(!dep[y]&&eg[i].wi){
				dep[y]=dep[x]+1;
				que[tl++]=y;
			}
		}
	}
	return dep[T];
}

int dfs(int x,int t){
	if(x==T) return t;
	int tt=t,tp;
	for(int &i=cur[x];i;i=eg[i].nx){
		int y=eg[i].to,v=eg[i].wi;
		if(v&&tt&&dep[y]==dep[x]+1&&(tp=dfs(y,std::min(v,tt)))){
			eg[i].wi-=tp;
			eg[i^1].wi+=tp;
			tt-=tp;
		}
	}
	return t-tt;
}

int main(){
	int R=nxi(),C=nxi();
	for(int i=1;i<=R;++i){
		for(int j=1;j<=C;++j){
			char c;
			while((c=getchar())!='S'&&c!='T'&&c!='.'&&c!='o');
			if(c=='S') S=(i-1)*C+j;
			if(c=='T') T=(i-1)*C+j;
			map[(i-1)*C+j]=c;
		}
	}
	if((S-1)/C==(T-1)/C||S%C==T%C){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=R;++i){
		for(int j=1;j<=C;++j){
			int now=(i-1)*C+j;
			if(map[now]=='.'||map[now]=='T') continue;
			if(map[now]!='S') add(now,now+N,1);
			for(int k=1;k<=R;++k){
				char tp=map[(k-1)*C+j];
				if(k!=i&&(tp=='o'||tp=='T')){
					add(now+N,(k-1)*C+j,1);
				}
			}
			for(int k=1;k<=C;++k){
				char tp=map[(i-1)*C+k];
				if(k!=j&&(tp=='o'||tp=='T')){
					add(now+N,(i-1)*C+k,1);
				}
			}
		}
	}
	int ans=0;
	while(bfs()){
		ans+=dfs(S+N,N);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 47488
#include <stdio.h>
#define N 2000002
#define MAX 10000

int A[N],B[N];
int main(){

  int C[MAX+1];
  int v, i, j;

  for ( i = 0; i <= MAX; i++ ) C[i] = 0;

  scanf("%d", &v);

  for ( i = 0; i < v; i++ ){
    scanf("%d", &A[i + 1]);
    C[A[i + 1]]++;
  }


  for ( i = 1; i <= MAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= v; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

    for ( i = 1; i <v; i++ ){
    printf("%d ", B[i]);
  }
  printf("%d",B[i]);
  printf("\n");

  return 0;
}




Measured memory_bytes: 17520
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a,b, c, q, l, r;


int32_t main(){
INIT
// c>b>a
cin>>a>>b>>c>>k;


while( (b<=a) && (k>0) ){
    b*=2; k--;
}

while( (c<=b) && (k>0) ){
    c*=2; k--;
}
if( (c>b) && (b>a) ){
    cout<<"Yes";
}
else{
    cout<<"No";
}


return 0;
}



Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N, X = map(int, input().split())
xn = list(map(int, input().split()))
xn2 = []

for xi in xn:
    xn2.append(abs(xi - X))

xn2.sort()

gcd_num = max(xn2)
for xi2 in xn2:
    tmp = gcd(xi2,gcd_num)
    if tmp < gcd_num:
        gcd_num = tmp

print(gcd_num)


Measured memory_bytes: 14224
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let n = lines[0].trim() - 0
let v = lines[1].trim().split(' ').map(Number)

const s = {}
const b = {}
for (let i = 0; i < n; i += 2) {
    s[v[i]] = s[v[i]] ? s[v[i]] + 1 : 1
    b[v[i + 1]] = b[v[i + 1]] ? b[v[i + 1]] + 1 : 1
}

const a1 = []
for (let key in s) {
    a1.push([key, s[key]])
}

const a2 = []
for (let key in b) {
    a2.push([key, b[key]])
}

a1.sort((a, b) => b[1] - a[1])
a2.sort((a, b) => b[1] - a[1])

let as = 0
if (a1[0][0] !== a2[0][0]) {
    as = a1[0][1] + a2[0][1]
} else {
    as = Math.max(
        a1[0][1] + (a2[1] ? a2[1][1] : 0),
        (a1[1] ? a1[1][1] : 0) + a2[0][1]
    )
}

console.log(n - as)


Measured memory_bytes: 63680
N, A, B, C, D = map(int, input().split())

# k : count of plus
diff = B - A

is_ok = False
for k in range(N - 1):
    min = k * C - (N - 1 - k) * D
    max = k * D - (N - 1 - k) * C
    if min <= diff and diff <= max:
        is_ok = True
        break

if is_ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
N=int(input())
H=list(map(int,input().split()))
ans=0
s=0
pre=H[0]
for x in H[1::]:
    if x<=pre:
        s+=1
    else:
        ans=max(ans,s)
        s=0
    pre=x
ans=max(ans,s)
print(ans)

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

int main(){
  long long n;
  cin >> n;
  if(n%2) cout << 0 << endl;
  else{
    long long ans=0;
    for(long long i=10;i<=n;i*=5){
      ans+=n/i;
    }
    cout << ans << endl;
  }
}

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

typedef long long ll;
ll MOD = 1000000007;

struct bit {
	vector<ll> v;
	bit(int n) : v(n + 1) {}
	ll sum(int i) {
		ll res = 0;
		for (; i > 0; i -= i & -i) res += v[i];
		return res;
	}
	void add(int i, ll x) {
		for (i++; i < v.size(); i += i & -i) v[i] += x;
	}
};

int B = 1000;

int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	vector<vector<int> > num(N / B + 1, vector<int>(N + 1));
	for (int i = 0; i < N; i++)
		num[p[i] / B][i + 1]++;
	for (int j = 0; j <= N / B; j++)
		for (int i = 0; i < N; i++)
			num[j][i + 1] += num[j][i];
	int Q; cin >> Q;
	vector<vector<int> > query(N);
	vector<int> l(Q), r(Q);
	for (int q = 0; q < Q; q++) {
		scanf("%d%d", &l[q], &r[q]);
		l[q]--; r[q]--;
		query[r[q]].push_back(q);
	}
	vector<int> index(N, -1);
	bit bt(N);
	vector<int> A(N / B + 1);
	vector<vector<int> > v(N / B + 1);
	vector<vector<ll> > sum(N / B + 1, vector<ll>(1));
	ll cur = 0;
	vector<ll> ans(Q);
	for (int i = 0; i < N; i++) {
		for (int x = N - 1; x > p[i];) {
			if (x % B == B - 1 && x - B >= p[i]) {
				A[x / B]++;
				cur += v[x / B].size();
				x -= B;
			}
			else {
				if (index[x] != -1) {
					bt.add(index[x], 1);
					cur++;
				}
				x--;
			}
		}
		int x = p[i];
		index[x] = i;
		ll prev = sum[x / B].back();
		v[x / B].push_back(i);
		sum[x / B].push_back(prev + A[x / B]);
		for (int k = 0; k < query[i].size(); k++) {
			int q = query[i][k];
			ans[q] = cur - bt.sum(l[q]);
			for (int i = 0; i <= N / B; i++) {
				int j = num[i][l[q]];
				ans[q] -= (ll)j * A[i] - sum[i][j];
			}
		}
	}
	for (int q = 0; q < Q; q++)
		printf("%lld\n", ans[q]);
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    vector<double> p(N); REP(i,N) cin >> p[i];
    REP(i,N) p[i] = 0.5*(p[i]+1);

    vector<double> S(N+1); S[0] = 0;
    REP(i,N) S[i+1] = S[i] + p[i];

    double ans = 0;
    REP(i,N-K+1){
        chmax(ans, S[i+K] - S[i]);
    }

    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair

char str[100001];

int main()
{
	int n, a, b, x, y, z, i, j;
	cin >> n >> a >> b;
	scanf("%s", str);
	x = y = z = 0;
	for (i = 0; str[i]; ++i) {
		if (str[i] == 'a') {
			if (z < a+b) {
				z++;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else if (str[i] == 'b') {
			if (z < a+b && y < b) {
				z++; y++;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else {
			printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	vector<int> p;
	bool b;
	int n;

	while(cin >> n){
		p.clear();
		if(n > 1){
			p.push_back(2);
			for(int i = 3; i <= n; i++){
				b = true;
				for(int j = 0; j < p.size(); j++){
					if(p[j]*p[j] > i){
						break;
					}
					if(i % p[j] == 0){
						b = false;
						break;
					}
				}
				if(b){
					p.push_back(i);
				}
			}
		}
		cout << p.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  string s, t;
  cin >> s >> t;
  int dp[3010][3010];
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) dp[i][j] = 0;
  }
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
    }
  }
  //復元
  string ans;
  int si = s.size(), ti = t.size();
  while (si > 0 && ti > 0) {
    if (dp[si][ti - 1] == dp[si][ti]) {
      ti--;
    } else if (dp[si - 1][ti] == dp[si][ti]) {
      si--;
    } else {
      ans = s[si - 1] + ans;
      si--, ti--;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    int n, m;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    rep(i, 0, m) cin >> t[i];

    map<string, int> cnt;
    rep(i, 0, n) cnt[s[i]] = 0;
    rep(i, 0, n) cnt[s[i]] ++;
    rep(i, 0, m) cnt[t[i]] --;
    int ans = -101010;
    rep(i, 0, n) ans = max(ans, cnt[s[i]]);

    if(ans <= 0) cout << 0 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	h, w = MAP()
	if h > 1 and w > 1:
		print(ceil((h * w) / 2))
	else:
		print(1)

if __name__=='__main__':
	main()


Measured memory_bytes: 5772
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  long n;
  cin >> n;
  vector<long> a;
  long max,max2,maxp,max2p;
  max = 0;
  max2 = 0;
  maxp = -1;
  max2p = -1;
  a.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
    if(a[ii] > max){
      max2 = max;
      max2p = maxp;
      max = a[ii];
      maxp = ii;
    }
    else if(a[ii] > max2){
      max2 = a[ii];
      max2p = ii;
    }
  }

  for(ii=0;ii<n;ii++){
    if(ii == maxp){
      cout << max2 << endl;
    }
    else{
      cout << max << endl;
    }
  }
  return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

string a, b;
int x;

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

	cin >> a >> b;

	string ab = a+b;

	stringstream X(ab);

	X >> x;

	int ans = sqrt(x);

	if(ans*ans == x){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;		
}

Measured memory_bytes: 256
l=[int(input()) for _ in range(5)]
l_1=[]
for i in l:
  if i%10!=0:
    l_1.append(((i+9)//10)*10)
  else:l_1.append(i)
nnn=9999999    
for i in range(5):
  num_1=0
  for j in range(5):
    if i==j:
      num_1+=l[j]
    else:num_1+=l_1[j]
  nnn=min(nnn,num_1)
print(nnn)

Measured memory_bytes: 3064
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << 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...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int s; cin >> s;
	vector<int>dp(200000);
	dp[0] = 1;
	for (int i = 3; i <= s; i++)
		for (int j = 3; j <= i; j++)
			dp[i] += dp[i - j], dp[i] = dp[i] % 1000000007;

	cout << dp[s];

}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}



void solve(){
    ll h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    ll x2=h2*60+m2;
    ll x1=h1*60+m1;
    cout<<max(x2-x1-k,0LL)<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0){
        ll res=(b-a)/2;
        cout<<res<<endl;
    }else{
        ll buf=min(a-1,n-b);
        ll res=buf+1+(b-a-1)/2;
        cout<<res<<endl;
    }
}

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

bool kaibun(string s, int i, int j) {
    if (i >= j) return true;
    else if (s.at(i) == s.at(j)) return kaibun(s, i+1, j-1);
    else return false;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    if (kaibun(S, 0, N-1) && kaibun(S, 0, (N-1)/2-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    //https://atcoder.jp/contests/abc129/tasks/abc129_b
    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < arr.length; i++)
            arr[i] = scanner.nextInt();

        if (arr.length == 2)
            System.out.println(Math.abs(arr[0] - arr[1]));

        int min = Integer.MAX_VALUE;
        for (int i = 1; i < arr.length; i++) {

            int sum1 = 0, sum2 = 0;
            for (int j = 0; j <= i; j++) {
                sum1 += arr[j];
            }

            for (int k = i + 1; k < arr.length; k++) {
                sum2 += arr[k];
            }

            min = Math.min(min, Math.abs(sum1 - sum2));
        }

        System.out.println(min);
    }
}


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

int main() {

	string N;
	cin>>N;
  
  for(int i=0; i<26; i++){
    for(int j=0; j<N.size(); j++){
    if((char)('a'+i)==N.at(j))break;
    if(j==N.size()-1){cout<<(char)('a'+i)<<endl;goto end;}}
    if(i==25){cout<<"None"<<endl;}
  }
	end: N=N;
	//cout<< <<endl;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n):
        if (i+1)%2==1 and a[i]%2==1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
r, c = [int(i) for i in input().split()]
data = [[int(i) for i in input().split()] for j in range(r)]
ans = [data[i] + [sum(data[i])] for i in range(r)]
last_ans = ans + [[sum([ans[i][j] for i in range(r)]) for j in range(c+1)]]
for i in last_ans:
    print(*i)


Measured memory_bytes: 6296
/*_47*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pll pair<ll,ll>
#define pk pair<pll,ll>
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define pr_vec(v) for(auto __:v) cout<<__<<" ";
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const int N = 1e6 + 5;
void solve()
{
    ll n, m, tot = 0;
    cin >> n >> m;
    std::vector<ll> v(n);
    rep(i, n) cin >> v[i], tot += v[i];
    sort(all(v));
    ll f = (tot + 4 * m - 1) / (4 * m);
    auto it=lower_bound(all(v),f);
    f=v.end()-it;
    cout<<(f>=m?"Yes":"No");

}

int main()
{




    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        // cout << endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
      cin>>v[i];
    ll dp[n+1];
    for(auto &x:dp)
      x=INF;
    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
      if(i!=2)
      {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
      }
      else
        dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> counts(M, 0);
    for (size_t i = 0; i < N; i++) {
        int n;
        cin >> n;
        for (size_t j = 0; j < n; j++) {
            int x;
            cin >> x;
            counts[x - 1]++;
        }
    }
    int res = 0;
    for (size_t i = 0; i < M; i++) {
        if (counts[i] == N) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  long int n;

  scanf("%ld", &n);

  int number = 0;

  for (int i = n; i > 0;) {
    number += i % 10;
    i /= 10;
  }

  if (n % number == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

int calc(int x,int y,int b,int p){
  if(b<5)b=5;
  if(p<2)p=2;
  return (x*b + y*p)*0.8;
}

int main(){
  int n;
  cin>>n;
  int x,y,b,p;
  for (int i = 0; i < n; i++){
    cin>>x>>y>>b>>p;
    cout << min(calc(x,y,b,p),x*b + y*p) << endl;   
  }
  return 0;
}

Measured memory_bytes: 1164
INDEX_B = 1
INDEX_C = 0

N,M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list.sort()

BC_list = []
for i in range(M):
    line = list(map(int, input().split()))
    BC_list.append( (line[1], line[0]))
BC_list.sort()
BC_list.reverse()

#print(BC_list)

a_index = 0
comp_flag = False
for c, b in BC_list:
    count = 0
    while True:
        if A_list[a_index] >= c:
            comp_flag = True
            break
        elif count >= b:
            break

        A_list[a_index] = c

        if a_index == len(A_list) - 1:
            comp_flag = True
            break

        a_index += 1
        count += 1
    
    if comp_flag:
        break
print(sum(A_list))  
    


Measured memory_bytes: 21036
//30
#include<iostream>
#include<cctype>

using namespace std;

void in(char c,int &a,int &b){
  if(c=='A'){
    a++;
  }else if(isalpha(c)){
    b+=10;
  }else{
    b+=c-'0';
  }
}

int pn(int a,int b){
  b+=a;
  if(b<=11&&a){
    b+=10;
  }
  return b;
}

int main(){
  int n;
  cin>>n;
  while(n--){
    char c[2];
    cin>>c[0]>>c[1];
    char d[8];
    for(int i=0;i<8;i++){
      cin>>d[i];
    }
    int a=0,b=0;
    in(c[0],a,b);
    in(c[1],a,b);
    if(pn(a,b)==21&&isalpha(c[0])&&isalpha(c[1])){
      cout<<"blackjack"<<endl;
    }else{
      for(int i=0;pn(a,b)<=16||pn(a,b)==17&&pn(0,b)<=6;i++){
	in(d[i],a,b);
      }
      if(pn(a,b)<=21){
	cout<<pn(a,b)<<endl;
      }else{
	cout<<"bust"<<endl;
      }
    }
  }
  return 0;
}
    
    

Measured memory_bytes: 1160
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int main()
{
    int x = 0, k = 0;
    scanf("%d %d",&k, &x);

    if ((k*500) >= x) {
        printf("Yes\n");
    } else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i=a; i<(b); i++)

int x;

void solve(){
    int ans;
    if (x >= 400) ans = 8;
    if (x >= 600) ans = 7;
    if (x >= 800) ans = 6;
    if (x >= 1000) ans = 5;
    if (x >= 1200) ans = 4;
    if (x >= 1400) ans = 3;
    if (x >= 1600) ans = 2;
    if (x >= 1800) ans = 1;
    cout << ans << "\n";
}


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

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


int main() {
  int k;
  string s;
  
  cin >> k ;
  cin >> s ;
  
  if(s.size()<=k){
    cout << s;
  }
  
  else{
    for(int i = 0; i<k; i++){
      cout << s.at(i);
    }
    cout << "...";
  }
 
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

class Node {
 public:
  int id;
  int parent_id;
  int sibling_id;
  int degree;
  int depth;
  int height;

  int left_child_id;
  int right_child_id;

  Node() {}
  Node(const int& id) : id(id), parent_id(-1), degree(0) {}
  bool operator<(const Node& another) const { return id < another.id; };
};

int AddDepthAndHeight(vector<Node>& nodes, int id, int depth) {
  if (id == -1) return -1;
  nodes[id].depth = depth;
  depth++;
  int height = 0;
  if (nodes[id].left_child_id != -1) {
    height = AddDepthAndHeight(nodes, nodes[id].left_child_id, depth);
  }
  if (nodes[id].right_child_id != -1) {
    int right_height =
        AddDepthAndHeight(nodes, nodes[id].right_child_id, depth);
    height = max(height, right_height);
  }
  nodes[id].height = height;
  return height + 1;
}

int main() {
  int n;
  cin >> n;
  vector<Node> nodes(n);
  FOR(i, 0, n) {
    int id;
    int left;
    int right;
    cin >> id >> left >> right;
    Node node(id);
    node.left_child_id = left;
    node.right_child_id = right;
    if (left != -1) {
      node.degree++;
    }
    if (right != -1) {
      node.degree++;
    }
    nodes[i] = node;
  }
  sort(nodes.begin(), nodes.end());
  // define family
  FOR(i, 0, n) {
    if (nodes[i].left_child_id != -1) {
      nodes[nodes[i].left_child_id].parent_id = i;
      nodes[nodes[i].left_child_id].sibling_id = nodes[i].right_child_id;
    }
    if (nodes[i].right_child_id != -1) {
      nodes[nodes[i].right_child_id].parent_id = i;
      nodes[nodes[i].right_child_id].sibling_id = nodes[i].left_child_id;
    }
  }
  // // define depth and height
  FOR(i, 0, n) {
    if (nodes[i].parent_id == -1) {
      nodes[i].sibling_id = -1;
      AddDepthAndHeight(nodes, i, 0);
      break;
    }
  }
  FOR(i, 0, n) {
    cout << "node " << nodes[i].id << ": parent = " << nodes[i].parent_id
         << ", sibling = " << nodes[i].sibling_id
         << ", degree = " << nodes[i].degree << ", depth = " << nodes[i].depth
         << ", height = " << nodes[i].height;
    if (nodes[i].parent_id == -1) {
      cout << ", root" << endl;
    } else if (nodes[i].degree > 0) {
      cout << ", internal node" << endl;
    } else {
      cout << ", leaf" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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 void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using P = pair<int, int>;
P farthest(vector<VI>& g, int now, int par) {
    P ret = { 0,now };
    each(to, g[now]) {
        if (to == par)continue;
        auto a = farthest(g, to, now);
        ++a.first;
        chmax(ret, a);
    }
    return ret;
}

VI memo;
int solve(int n) {
    if (n == 0)return 1;
    if (n == 1)return 0;
    if (memo[n] != -1)return memo[n];
    if (solve(n - 1) == 0 || solve(n - 2) == 0)return memo[n] = 1;
    else return memo[n] = 0;
}

int main() {
    init();

    int n; cin >> n;
    auto g = vec<VI>(n);
    FOR(i, 0, n - 1) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int s = farthest(g, 0, -1).second;
    int d = farthest(g, s, -1).first;
    memo.resize(d + 1, -1);
    cout << (solve(d) == 1 ? "First" : "Second") << "\n";
}

Measured memory_bytes: 27648
#include <iostream>
#include <stdio.h>
#include <math.h>
 
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <complex>
#define ll long long
#define REP(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef complex <double> P;
int ans,n,k;
char d[10];
string s;


bool hantei(string s){
	rep(i,(int)s.size()){
		rep(j,k){
			if (s[i]==d[j])return false;
		}		
	}
	return true;
}
int main(){
	ans=0;
	cin >>n>>k;
	rep(i,k){
		cin>>d[i];
	}
	int j=n;
	while(1){
		stringstream ss;
		ss << j;
		s=ss.str();
		if (hantei(s)){
		ans=j;
		break;
		}
		else {j++;}
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    string str;
    cin>>str;
    int n=str.size();
    bool valid=1;
    vector<int> pos;
    if(str[0]=='1') pos.pb(0);
    for(int i=1;i<n-1;i++){
        if(str[i]!=str[n-i-2]){
            valid=0;
            break;
        }
        if(str[i]=='1') pos.pb(i);
    }
    if(str[0]=='0' || str.back()=='1') valid=0;
    if(!valid) cout<<-1<<endl;
    else{
        int cur=1;
        for(int i=0;i<(int)pos.size();i++){
            cout<<cur<<" "<<(cur+1)<<"\n";
            cur++;
        }
        for(int i=1;i<(int)pos.size();i++){
            for(int j=0;j<(pos[i]-pos[i-1]-1);j++){
                cout<<i+1<<" "<<++cur<<"\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4164
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

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

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

S = sys.stdin.readline().rstrip()
if S[0] == S[-1]:
    if len(S) % 2 == 0:
        print('First')
    else:
        print('Second')
else:
    if len(S) % 2 == 1:
        print('First')
    else:
        print('Second')


Measured memory_bytes: 13640
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define fi first
#define se second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SHOWVECTOR(v) {std::cerr << #v << "\t: ";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}}
//math


const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;

void solve(){
	int a,b;
	cin >> a >> b >> n;
	int x = min(n,b-1);
	cout << a*x/b << endl;
}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    string ans;

    //1~26
    if(n<=26) ans='a'+n-1; 
    
    //27~
    else{                  
        while(n>0){
            n--;
            char a='a'+n%26;
            ans.push_back(a);
            n/=26;
        }
    }

    ll len=ans.size();

    repr(i,len-1,0)cout<<ans[i];

    cout<<endl;

}




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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  if (n == 1) {
    cout << a.at(0) << endl;
    return 0;
  }

  int ans = 0;
  int tmp_min = 0;
  for (int i = 1; i < n; i ++) {
    if (a.at(i) >= a.at(i - 1) && i == n - 1) ans += a.at(i) - tmp_min;
    else if (a.at(i) >= a.at(i - 1)) continue;
    else {
      ans += a.at(i - 1) - tmp_min;
      tmp_min = a.at(i);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void) {
  int i, N, K;
  double n, prob = 0.0;
  string tmp;

  cin >> tmp;  
  N = stoi(tmp);
  cin >> tmp;  
  K = stoi(tmp);
  
  for(i = 1; i <=N; i++) {
    if(i >= K) {
      prob += 1.0 / (double)N;
      continue;
    }
    //n = ceil( (log((double)K) - log((double)i)) / log(2.0) );
    n = ceil( log( (double)K/(double)i ) / log(2.0) );
    
    prob += pow(0.5, n) / (double)N;
  }
  
  cout << setprecision(12) << prob << endl;
  
  return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int c = 1;

    while (n)
    {
        ((c * 2) < (c + k)) ? c *= 2 : c += k;
        n--;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
a=int(input())
a_list=[]
amari=0
count=0
flag=False
if a%2==0 or a%5==0 :
  flag=True
else :

  while(True) :
    k=(amari*10+7)%a
    if k==0 :
      count+=1
      break
    else :
      count+=1
      amari=k



if flag :
  print('-1')
else :
  print(count)

Measured memory_bytes: 62992
s=list(input())
lst=['A','T','G','C']
l=len(s)
ans=[[]]

for i  in range(l):
  for j in range(i+1,l+1):
    a=True
    L=s[i:j]
    
    for k in L:
      if k not in lst:
        a=False
        break
    if a:
      ans.append(L)
num=0

for i in ans:
  num=max(num,len(i))
print(num)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	x := nextInt()
	happy := x / 500 * 1000
	x = x % 500
	happy += x / 5 * 5
	fmt.Println(happy)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int answer[5][100];
    int n,m;
    int k = 0;
    int am[5];
    while(cin >> n >> m){
        if(n == 0 && m == 0)break;
        am[k] = m;
        int a[1000][100];
        vector<int> s(m);
        vector<int> c(m);
        for(int i = 0;i < m;i++){
            s[i] = 0;
        }
        for(int i = 0;i < n;i++)for(int j = 0;j < m;j++){
            cin >> a[i][j];
            if(a[i][j] == 1)c[j] = s[j] = s[j] + 1;
            
        }
        
        sort(c.begin(),c.end());
        
        c.erase(unique(c.begin(),c.end()),c.end());
        
        reverse(c.begin(),c.end());
        
        
        int l = 0;
        for(int i = 0;i < c.size();i++){
            for(int j = 0;j < m;j++){
                if(s[j] == c[i]){
                    answer[k][l] = j;
                    l++;
                }
            }
        }
        k++;

    }
    for(int i = 0; i < k;i++){
        for(int j = 0;j < am[i];j++){
            cout << answer[i][j] + 1;
            if(j != am[i] - 1)cout << " ";
            else cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3512
package main

import (
	"fmt"
)

func solve(k, n int, as []int) int {
	max := 0
	prev := as[0]
	for i := 1; i < n; i++ {
		diff := as[i] - prev
		if diff > max {
			max = diff
		}
		prev = as[i]
	}

	diff := (k - as[n-1]) + as[0]
	if diff > max {
		max = diff
	}
	return k - max
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	s := scanNums(2)
	t := scanNums(s[1])
	fmt.Println(solve(s[0], s[1], t))
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    vector<string>v(n);
    vector<char>ch;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++){
        if(v[i]=="AB"&&a==0&&b==0) {cout<<"No";return;}
        if(v[i]=="BC"&&b==0&&c==0) {cout<<"No";return;}
        if(v[i]=="AC"&&a==0&&c==0) {cout<<"No";return;}
        if(v[i]=="AB"&&(a==0||b==0)) {if(a==0){a++;b--;ch.push_back('A');}else{a--;b++;ch.push_back('B');}}
        else if(v[i]=="AC"&&(a==0||c==0)){if(a==0){a++;c--;ch.push_back('A');}else{a--;c++;ch.push_back('C');}}
        else if(v[i]=="BC"&&(b==0||c==0)){if(b==0){b++;c--;ch.push_back('B');}else{b--;c++;ch.push_back('C');}}
        else if(v[i]=="AB"&&a==1&&b==1&&c==0&&i!=n-1){
            if(v[i+1]=="AB"){a++;b--;ch.push_back('A');}
            else if(v[i+1]=="BC"){b++;a--;ch.push_back('B');}
            else if(v[i+1]=="AC"){a++;b--;ch.push_back('A');}
        }
        else if(v[i]=="BC"&&b==1&&c==1&&a==0&&i!=n-1){
            if(v[i+1]=="AB"){b++;c--;ch.push_back('B');}
            else if(v[i+1]=="BC"){b++;c--;ch.push_back('B');}
            else if(v[i+1]=="AC"){b--;c++;ch.push_back('C');}
        }
        else if(v[i]=="AC"&&a==1&&c==1&&b==0&&i!=n-1){
            if(v[i+1]=="AB"){a++;c--;ch.push_back('A');}
            else if(v[i+1]=="BC"){c++;a--;ch.push_back('C');}
            else if(v[i+1]=="AC"){a++;c--;ch.push_back('A');}
        }
        else if(v[i]=="AB") {if(a>=b){a--;b++;ch.push_back('B');}else{a++;b--;ch.push_back('A');}}
        else if(v[i]=="BC") {if(b>=c){b--;c++;ch.push_back('C');}else{b++;c--;ch.push_back('B');}}
        else if(v[i]=="AC") {if(a>=c){a--;c++;ch.push_back('C');}else{a++;c--;ch.push_back('A');}}
        if(a<0||b<0||c<0) {cout<<"No";return;}
    }
    cout<<"Yes\n";
    for(auto x:ch) cout<<x<<'\n';
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 6664
/**
 * Created by hiroqn on 13/10/11.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');

var BOIN = 'aiueo'.split('').reduce(function (c, p) {
      c[p] = true;
      return c;
    }, {}),
    MUSEI = 'ksthp'.split('').reduce(function (c, p) {
      c[p] = true;
      return c;
    }, {});
function isMusei(str, i) {
  var c = str[i],len=str.length;
  if (i === 0) {
    return false;
  }
  if (c === 'i' || c === 'u') {
    return (MUSEI[str[i - 1]] || i > 1 && MUSEI[str[i - 2]] && str[i - 1] === 'y') &&
        (i === len - 1 || MUSEI[str[i + 1]])
  }
  if (c === 'a' || c === 'o') {
    return (MUSEI[str[i - 1]] || i > 1 && MUSEI[str[i - 2]] && str[i - 1] === 'y') &&
        (i < len - 2 && MUSEI[str[i + 1]] && c === str[i + 2] ||
            i < len - 3 && MUSEI[str[i + 1]] && str[i + 2 ] === 'y' && c === str[i + 3] )
  }
  return false;
}
main();
function main() {
  var str, res,
      i, len,
      jpList, mbList,//museiboin
      cur, jp,
      seqFlag;

  while (input[0] !== '#') {
    str = input.shift();
    seqFlag = false;
    res = '';
    for (i = 0, len = str.length; i < len; i++) {
      if (BOIN[str[i]]) {
        if (!seqFlag && isMusei(str, i)) {
          res += '(' + str[i] + ')';
          seqFlag = true;
        } else {
          seqFlag = false;
          res += str[i];
        }
      } else {
        res += str[i];
      }
    }
    console.log(res);
  }
}

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

const int N = 2e3 + 4;
vector<int> V[N];
int odl[N];
bool odw[N];
int wx[N];

void czysc(int n) {
	for(int i=1; i<=n; i++) {
		odl[i] = -1;
		odw[i] = 0;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x, y;
	cin>>n>>x>>y;
	for(int i=1; i<n; i++) {
		V[i].push_back(i+1);
		V[i+1].push_back(i);
	}
	V[x].push_back(y);
	V[y].push_back(x);
	for(int i=1; i<=n; i++) {
		czysc(n);
		queue<int> Q;
		Q.push(i);
		odl[i] = 0;
		odw[i] = 1;
		while(!Q.empty()) {
			int v = Q.front();
			Q.pop();
			for(int j=0; j<V[v].size(); j++) {
				int u = V[v][j];
				if(!odw[u]) {
					odw[u] = 1;
					odl[u] = odl[v] + 1;
					Q.push(u);
				}
			}
		}
		for(int j=1; j<=n; j++) {
			wx[odl[j]]++;
		}
	}
	for(int i=1; i<n; i++)
		cout<<wx[i]/2<<"\n";
}


Measured memory_bytes: 512