akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int p[2][100001];
int main() {
  string s;
  int m,k;
  cin>>m>>k;
  cin>>s;
  int n=s.length();
  if(n==1){
    cout<<"1"<<endl;
    return 0;
  }else if(n==k){
    cout<<n<<endl;
    return 0;
  }
  int ans=0,ch,c,q=0;
   if(s[0]=='0')ch=c=0;
  else ch=c=1;
  for(int i=0;i<n;i++){
    if(ch==0&&s[i]=='1'){
      ch=1;
      q++;
    }else if(ch==1&&s[i]=='0'){
      ch=0;
      q++;
    }
    p[ch][q]++;
  }  
  for(int i=0;i<m-k;i++){
      int tmp=0,j,l=0;
    ch=(c+i)%2;
    if(ch==0){
      for(j=0;j<2*k;j++){
        tmp+=p[0][i+j];
      j++;
      if(i+j<n) tmp+=p[1][i+j];
        //cout<<"p"<<tmp<<endl;
      }
    }
    if(ch==1){
      tmp+=p[1][i];
      for(j=0;j<2*k;j++){
        tmp+=p[0][i+j+1];
      	j++;
      if(i+j<n) tmp+=p[1][i+j+1];
        //cout<<"q"<<tmp<<endl;
      }
    }
    ans=max(ans,tmp);
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1280
N,Y = map(int,input().split())

y = Y//1000
a_ans = -1
b_ans = -1
c_ans = -1
for a in range(0,N+1):
	b = (y-9*a-N)//4
	c = N-a-b
	if b >= 0 and c >= 0 and (y-9*a-N)%4 == 0:
		print(a,b,c)
		exit()

print(-1,-1,-1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <cstring>
int main(){
  char N[200100];
  int sum;
  sum=0;
  scanf("%s",N);
  int len = strlen(N);
  for(int i=0;i<len;i++){
    sum += N[i]-'0';
  }
  if(sum%9==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
}

Measured memory_bytes: 1876
#include <stdio.h>
int main(void)
{
    long long int a,b;
    int k;
    scanf("%lld %lld %d",&a,&b,&k);
    long long int down,up;
    down=a+k-1;
    up=b-k+1;
    if(down>=up)
    {
        for(long long int p=a;p<=b;p++)
        {
            printf("%lld\n",p);
        }
    }
    else
    {
        for(long long int q=a;q<=down;q++)printf("%lld\n",q);
        for(long long int r=up;r<=b;r++)printf("%lld\n",r);
    }
}


Measured memory_bytes: 128
n = input()
a = input()
a = list(map(int, a.split()))
i = 0
cont_flg = True
while cont_flg:
  if sum(list(map(lambda x: x % 2, a))) == 0:
  	i += 1
  	a = list(map(lambda x: x / 2, a))
  else:
    cont_flg = False
print(i)

Measured memory_bytes: 9148
s=input()

flag=True
for i in range(len(s)):
    if s[i]!=s[-i-1]:
        flag=False
if flag:
    for i in range((len(s)-1)//2):
        if s[i]!=s[(len(s)-1)//2-1-i]:
            flag=False
if flag:
    print('Yes')
else:
    print('No')

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

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        string X,Y;cin>>X>>Y;
        int M[X.size()][Y.size()]={};
        //まずは端を埋める
        int flg=0;
        for(int i=0;i<Y.size();i++){//Xの一文字目を固定
            if(X[0]==Y[i])flg=1;
            if(flg)M[0][i]=1;
        }
        flg=0;
        for(int i=0;i<X.size();i++){//Yの一文字目を固定
            if(Y[0]==X[i])flg=1;
            if(flg)M[i][0]=1;
        }
        for(int i=1;i<X.size();i++){
            for(int j=1;j<Y.size();j++){
                if(X[i]==Y[j]){
                    M[i][j]=M[i-1][j-1]+1;
                }else{
                    M[i][j]=max(M[i-1][j],M[i][j-1]);
                }
            }
        }

        cout<<M[X.size()-1][Y.size()-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 7068
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

const int MAX = 1e6+1;

int mapTo(int a, int b)
{
    return min(a,b) * 1000 + max(a,b);
}

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

    int n;
    cin >> n;
    vector<vector<int>> graph (MAX);

    vector<int> ind (MAX,0);

    for(int i =0 ; i< n; ++i)
    {
        int last; cin >> last; last--;
        for(int j = 0; j<n-2; ++j)
        {
            int curr; cin >> curr; curr--;

            int ear = mapTo(i,last);
            int lat = mapTo(i,curr);

            graph[ear].push_back(lat);
            ind[lat]++;
            last = curr;
        }
    } 

    vector<int> tbr;

    for(int i = 0; i< MAX; ++i)
    {
        if(ind[i]==0)
            tbr.push_back(i);
    }

    int proc = 0;
    int day = 0;

    while(tbr.size())
    {
        day++;
        proc += tbr.size();

        vector<int> nxtTbr;
        for(int x = 0; x < (int) tbr.size(); ++x)
        {
            int i = tbr[x];
            for(int y = 0; y < (int) graph[i].size(); ++y)
            {
                int nxt = graph[i][y];
                ind[nxt]--;
                if(ind[nxt] == 0) nxtTbr.push_back(nxt);
            }
        }
        tbr = nxtTbr;
    }
    if (proc != MAX) {
		cout << -1 << endl;
	} else {
		cout << day << endl;
	}
    return 0;
}

Measured memory_bytes: 45432
#include<bits/stdc++.h>
using namespace std;
const bool DBG = 1;

#define TRACE(x)    x
#define WATCH(x)    TRACE(cout << #x" = " << x << endl)
#define WATCHR(a,b) TRACE(for(auto it=a; it!=b;) cout<<*(it++)<<" ";cout<<endl)
#define WATCHC(V)   TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#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 trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

void solve() {
}

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

    int n,m; cin >> n >> m;
    if(n % 2) {
        F0R(i,m) {
            cout << i+1 << " " << 2*m-i << "\n";
        }
    } else {
        int max_odd_m = m, max_even_m = m;
        if(m % 2 == 0) max_odd_m--;
        else max_even_m--;
        for(int i = 0; 2*i+1 <= m; i++) {
            cout << i+1 << " " << max_odd_m+1-i << "\n";
        }
        for(int i = 0; 2*i+2 <= m; i++) {
            cout << max_odd_m+2+i << " " << max_odd_m+2+max_even_m-i << "\n";
        }
    }

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}




int main() {
	ll a;
	cin >> a;
	ll a0 = a;

	vector<int> x;

	//if (a == 2) {
	//	cout << 1 << endl;
	//	return 0;
	//}

	for (ll i = 2; i*i <= a0; i++) {
		if (a%i == 0) {
			int c = 0;
			while (a % i == 0) {
				c++;
				a /= i;
			}
			x.push_back(c);
		}
	}

	if (a >= 2) {
		x.push_back(1);
	}


	int ans = 0;
	rep(i, x.size()) {
		int c = x[i];
		int e=1;
		while (c >= e) {
			c -= e;
			ans++;
			e++;
		}
	}
	cout << ans << endl;
}



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

using namespace std;
typedef long long ll;

int main()
{
	ll h;
	scanf("%lld", &h);
	ll x = 1, res = 0;
	while(h >= 1)
	{
		res += x;
		h /= 2;
		x *= 2;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N=input()

for a in range(1,3501):
    for b in range(1,3501):
        if (4*a*b-N*(b+a))!=0:   #Cの計算式の分母がゼロではない
            if (N*a*b)%(4*a*b-N*(b+a))==0: #Cの計算式
                c=(N*a*b)/(4*a*b-N*(b+a))
                if 0<c:
                    print a,b,c
                    quit()

Measured memory_bytes: 32620
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, k = input().strip().split()
n, m, k = int(n), int(m), int(k)
friends = [0] + [[] for _ in range(n)]
blocks = [0] + [[] for _ in range(n)]

for _ in range(m):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    friends[p1].append(p2)
    friends[p2].append(p1)
for _ in range(k):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    blocks[p1].append(p2)
    blocks[p2].append(p1)

connected_num = 0
def dfs(graph, current, seen, connected_id):
    global connected_num
    seen[current] = connected_id
    connected_num += 1

    children = graph[current]
    for c in children:
        if seen[c] != -1:
            continue
        dfs(graph, c, seen, connected_id)

seen = [-1] * (n + 1)
connected_id = 0
connected = []
for i in range(1, n + 1):
    if seen[i] != -1:
        continue
    dfs(friends, i, seen, connected_id)
    connected.append(connected_num)
    connected_num = 0
    connected_id += 1

ans = []
for i in range(1, n + 1):
    i_connected_id = seen[i]
    exclude = 0
    for f in friends[i]:
        f_connected_id = seen[f]
        if i_connected_id == f_connected_id:
            exclude += 1
    for b in blocks[i]:
        b_connected_id = seen[b]
        if i_connected_id == b_connected_id:
            exclude += 1
    ans.append(str(connected[i_connected_id] - exclude - 1))

print(' '.join(ans))


Measured memory_bytes: 365424
#include <bits/stdc++.h>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int inf = 1e9+7;
 
class TreeDistanceConstruction { public: vector<int> construct(vector<int> d); };
vector<int> TreeDistanceConstruction::construct(vector<int> d) {
    int n = d.size();
    vector<int> result;
    int min_d = *whole(min_element, d);
    int cnt_min_d = whole(count, d, min_d);
    if (cnt_min_d == 1 or cnt_min_d == 2) { // construct
        int l = whole(find, d, min_d) - d.begin();
        int r;
        if (cnt_min_d == 1) {
            r = l;
        } else {
            r = find(d.begin() + l + 1, d.end(), min_d) - d.begin();
            result.push_back(l);
            result.push_back(r);
        }
        int m = l;
        int tick = 0;
        vector<int> que(n);
        whole(iota, que, 0);
        whole(sort, que, [&](int i, int j) { return d[i] < d[j]; });
        repeat_from (top, cnt_min_d, n) {
            int i = que[top];
            if (d[m] + 1 < d[i]) {
                tick = 0;
                m = l;
            }
            if (tick == 0) {
                result.push_back(l);
                result.push_back(i);
                l = i;
            } else if (tick == 1) {
                result.push_back(r);
                result.push_back(i);
                r = i;
            } else {
                result.push_back(m);
                result.push_back(i);
            }
            ++ tick;
        }
    } else {
        // impossible
    }
    if (not result.empty()) { // validate
        vector<vector<int> > dist = vectors(n, n, inf);
        repeat (i,n) dist[i][i] = 0;
        repeat (i,n-1) {
            int u = result[2*i  ];
            int v = result[2*i+1];
            dist[u][v] = 1;
            dist[v][u] = 1;
        }
        repeat (k,n) { // W/F
            repeat (i,n) {
                repeat (j,n) {
                    setmin(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
        vector<int> eccentricity(n);
        repeat (i,n) {
            repeat (j,n) {
                setmax(eccentricity[i], dist[i][j]);
            }
        }
        repeat (i,n) {
            if (d[i] != eccentricity[i]) {
                result.clear();
            }
        }
    }
    return result;
}
 
 
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    cout << (TreeDistanceConstruction().construct(a).empty() ? "Impossible" : "Possible")  << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        a: usize,
        b: f64,
    }

    let ans = (a * (b * 100.1) as usize) / 100;
    println!("{}", ans);
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int cnt(string s, string t) {
    int ret = 0;
    for (int i = 0; i < 26; ++i) {
        if (s.find('a' + i) != string::npos && t.find('a'+ i) != string::npos)
            ret++;
    }
    return ret;
}
int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 1; i <= n - 1; ++i) {
        ans = max(ans, cnt(s.substr(0, i), s.substr(i, n)));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using pii = pair<int, int>;

int main() {
    int K;
    cin >> K;
    int INF = K;
    deque<pii> deq;
    vector<int> dp(K, INF);
    dp[1] = 0;
    deq.push_back(pii(dp[1], 1));
    while (!deq.empty()) {
        int d, n;
        tie(d, n) = deq.front();
        deq.pop_front();
        if (dp[n] < d) {
            continue;
        }
        int n1 = (n + 1) % K;
        int n2 = (n * 10) % K;
        if (dp[n1] > d + 1) {
            dp[n1] = d + 1;
            deq.push_back(pii(dp[n1], n1));
        }
        if (dp[n2] > d) {
            dp[n2] = d;
            deq.push_front(pii(dp[n2], n2));
        }
    }
    int result = dp[0] + 1;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int main(){
	fastread;
	int n,l;
	cin>>n>>l;
	vector<string> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	for(string s:a){
		cout<<s;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n_5 int
	var n_7 int

	t := make([]int, 3)

	fmt.Scan(&t[0], &t[1], &t[2])

	for i := 0; i < 3; i++ {
		if t[i] == 5 {
			n_5++
		} else if t[i] == 7 {
			n_7++
		}
	}

	if n_5 == 2 && n_7 == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
n,d = map(int,input().split())
import math

x = [0]*n
c = 0
for i in range(n):
  x[i] = input().split()
  
for i in range(n-1):
  for j in range(i+1,n):
    dis = 0
    for k in range(0,d):
      dis = dis + (int(x[j][k])-int(x[i][k]))**2
    dis = math.sqrt(dis)
    #print(dis)
    dis = str(dis)
    if(dis[-1] == "0" and dis[-2] == "."):
      c = c + 1
print(c)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N, H;
    cin >> N >> H;
    vector<ll> a(N);
    vector<ll> b(N);
    rep(i, N) { 
        cin >> a[i] >> b[i];
    }
    ll ma = *max_element(all(a));
    ll cnt = 0;
    sort(all(b), greater<ll>());
    rep(i, N) {
        if (b[i] > ma) {
            H -= b[i];
            cnt++;
            if (H <= 0) {
                print(cnt);
                return 0;
            }
        } else {
            break;
        }
    }
    cnt += (H+ma-1) / ma;
    print(cnt);
    return 0;
}

Measured memory_bytes: 1792
#include <cstdint>
#include <iostream>

using namespace std;

#define SIZE 100001
static uint32_t led[SIZE];
static bool status[SIZE];

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 1; i <= num; i++) {
    status[i] = false;
    uint32_t val;
    cin >> val;
    led[i] = val;
  }

  uint32_t index = 1;
  uint32_t count = 0;
  while ((index != 2) && !status[index]) {
    status[index] = true;
    count++;

    index = led[index];
  }

  if (index == 2) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

using namespace std;

int h[205];
vector <int> a[2][205];
int main(){
        int n;
        cin>>n;
        for(int j=0;j<=1;j++){
                for(int i=1;i<=n;i++){
                        int x,y;
                        cin>>x>>y;
                        a[j][x].push_back(y);
                }
        }
        int ans=0;
        for(int cx=2*n-1;cx>=0;cx--){
                for(auto i:a[0][cx]){
                        int j=i+1;
                        while (j<2*n&&!h[j]) j++;
                        if (h[j]){
                                ans++;
                                h[j]--;
                        }
                }
                for(auto i:a[1][cx]) h[i]++;
        }
        cout<<ans;
}


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

#define int long long
#define ll long long
#define F first 
#define S second 
#define pb push_back
#define ld long double

using namespace std ; 

const int MAXN = 1001 * 1001 , MOD =  1e9 + 7 ;



int32_t main()
{
	ios::sync_with_stdio(0) ;
	int a , b; 
	cin >> a >> b ; 	
	if(a==1) a = 14 ; 
	if(b==1) b = 14 ; 
	if(a>b) cout << "Alice" << endl ; 
	if(a==b) cout << "Draw" << endl ; 
	if(a<b) cout << "Bob" << endl ; 
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    vector<long double> p(N);
    rep(i,0,N) cin >> p[i];

    const i64 size=3000;
    vector<vector<long double>> dp(N,vector<long double>(size));
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    rep(i,0,N-1){
        rep(j,0,size){
            dp[i+1][j]+=dp[i][j]*(1-p[i+1]);
            if(j+1<size) dp[i+1][j+1]+=dp[i][j]*p[i+1];
        }
    }

    long double ans=0;
    rep(i,0,N+1){
        if(i<=N-i) continue;
        ans+=dp[N-1][i];
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 141056
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		
		for(int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
		}
		
		Arrays.sort(p);
		int sum = 0;
		
		for(int i = 0; i < (N - 1); i++) {
			sum += p[i];
		}
		
		sum += p[N - 1] / 2;
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;
typedef long double ld;
 
const int INF = 190000000;
const int MOD = 1e9+7;
 
int main(){
	tint x; cin >> x;
	for(tint i=-150;i<=150;i++){
		for(tint j=-150;j<=150;j++){
			if(pow(i, 5)-pow(j,5) == x){
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4056
n=int(input())
a=list(map(int,input().split()))

from collections import Counter		#defaultdictやなくてConter使ってこ

C=Counter(a)

sum=0
for v in list(C.values()):
	sum+=v*(v-1)//2

for k in range(n):
	x=C[a[k]]
	print(sum-(x*(x-1)//2)+((x-1)*(x-2)//2))

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n = 1, m;
	string s;
	if ( cin >> n >> m );
	else return false;
	
	vcL num1( n+1, 0 );
	vcL num2( m+1, 0 );
	
	lli _min = INT_MAX, _max = 0;
	
	for (int i = 1; i <= n; ++i) cin >> num1[i];
	for (int i = 1; i <= m; ++i) cin >> num2[i];
	
	vvL dp( n+1, vcL( m+1, 1 ) );
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			dp[i][j] = dp[ i-1 ][j] + dp[i][ j-1 ] - dp[ i-1 ][ j-1 ];
			if ( num1[i] == num2[j] ) dp[i][j] += dp[ i-1 ][ j-1 ];
			dp[i][j] = ( dp[i][j] + 10*mod ) % mod;
		}
	}
	
	cout << dp[n][m] << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}



Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  ll x,y;cin >> x >> y;
  ll lim = x;
  ll len = 0;
  if(lim == y) {
    cout << 1 << endl;
    return 0;
  }
  while(lim <= y){
    len++;
    lim*=2;
  }
  cout << len << endl;
}

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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;

	if (abs(a-b) <= (v-w)*t) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

}

Measured memory_bytes: 3648
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	ll x, k, d;
	cin >> x >> k >> d;

	x = abs(x);

	ll cnt = x / d;
	if (k <= cnt) {
		RET(x - d * k);
	}

	if ((k - cnt) % 2LL == 0LL) {
		RET(x % d);
	}
	else {
		RET(d - x % d);
	}

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3644
// AOJ ALDS1_13_B 8 Puzzle
// 2018.5.8 bal4u

#include <stdio.h>

typedef unsigned char uchar;

#define HASHSIZ 543217    // 181441
typedef struct { unsigned s; char x, v; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(unsigned s, int x)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return 0;
}

void insert(unsigned s, int x, char v)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->x = x, hp->v = v;
}

#define QMAX 30000
typedef struct { unsigned s; char x, v; } T;
T s[QMAX+3]; int top, end;
int hi[9] = {2,3,2,3,4,3,2,3,2};
int to[9][4] = {{1,3},{0,2,4},{1,5},{0,4,6},{1,3,5,7},{2,4,8},{3,7},{4,6,8},{5,7}};

void toArray(char *nine, unsigned s, int x)
{
	int i;
	
	for (i = 8; i >= 0; i--) {
		if (i == x) nine[i] = 0;
		else nine[i] = s & 0xf, s >>= 4;
	}
}

unsigned swap(char *nine, int zero, int nx)
{
	int i;
	unsigned res;
	
	res = 0;
	for (i = 0; i < 9; i++) {
		if      (i == zero) res <<= 4, res |= nine[nx];
		else if (i != nx)   res <<= 4, res |= nine[i];
	}
	return res;
}

int main()
{
	int i;
	int x, nx, v, nv, t;
	unsigned a, na;
	unsigned gs; int gx;	// goal
	char nine[9];
	
	gs = 0; for (i = 0; i < 9; i++) {
		scanf("%d", &t);
		if (t == 0) gx = i;
		else gs <<= 4, gs |= t;
	}
	s[0].s = 0x12345678, s[0].x = 8, s[0].v = 0;
	top = 0, end = 1;
	insert(s[0].s, s[0].x, 0);
	while (top != end) {
		a = s[top].s, x = s[top].x, v = s[top].v;
		if (++top == QMAX) top = 0; 
		if (x == gx && a == gs) break;
		if (lookup(a, x) < v) continue;

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx, s[end].v = nv;
				if (++end == QMAX) end = 0;
				insert(na, nx, nv);
			}
		}
	}
	printf("%d\n", v);
	return 0;
}



Measured memory_bytes: 6268
a=list(map(int,input().split()))
#b=input()
b=[i for i in input()]
n=a[1]-1
tmp=b[n]
if tmp=="A":
    b[n]="a"
if tmp=="B":
    b[n]="b"
if tmp == "C":
    b[n]="c"
    
    
print("".join(b))

Measured memory_bytes: 3064
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
Do not pray for an easy life, pray for the strength to endure a difficult one.
When something is important enough, you do it even if the odds are not in your favor.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.
No matter how hard it gets, NEVER GIVE UP*/

#include <bits/stdc++.h>

#define pb push_back
#define MP make_pair
#define ALL(r) (r).begin(),(r).end()

typedef long long int ll;

#define FOR(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; ++i )
#define FORN(i,m,n) for(ll i=(ll)(m-1) ; i >= (ll) (n) ; --i )

#define RUN_FAST ios::sync_with_stdio(false);

using namespace std;



void solve()
{
    ll a,b,c,d,m,n,p,q,r,x,y,z,aa,bb,cc,dd; //variable
    ll i,j,k,l; //pointer
    ll cnt=0,cnt1=0,cnt2=0,cnt3=0,sum=0,mx=LLONG_MIN,mn=LLONG_MAX; //counter
    ll flag=0,flag2=0; //flag
    vector <ll> vec1,vec2,vec3;
    string s1,s2,s3;

    //PULOK SAHA
    //BMO

    cin >> x;

    if(x==0)
        cout << "1\n";
    else if(x==1)
        cout << "0\n";

}

int main()
{
    RUN_FAST
    //PULOK SAHA
    //BMO

    ll t=1;//test case

    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}






//PULOK SAHA

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

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

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

bool check(string t, string b) {
    if (b.length() <= 0 || t.length() <= 0) return false;
    return (t[0] != b[b.length() - 1]);
}

int main() {
    string N;
    cin >> N;
    string tower = N;
    string box = "";
    int count = 0;
    while (tower.length() > 0) {
        box = box + tower[0];
        tower = tower.substr(1);
        while (check(tower, box)) {
            box = box.substr(0, box.length() - 1);
            tower = tower.substr(1);
            count += 2;
            if (tower.length() == 0 && box.length() != 0) {
                tower = box;
                box = "";
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 856
a, b, c, x, y = [int(e) for e in input().split()]
ans = 0
if a + b <= 2 * c:
    ans = a * x + b * y
elif a + b > 2 * c:
    if x == y:
        ans = x * 2 * c
    elif x < y:
        ans = x * 2 * c
        if b <= 2 * c:
            ans = ans + b * (y-x)
        else:
            ans = ans + 2 * c * (y-x)
    elif y < x:
        ans = y * 2 * c
        if a < 2 * c:
            ans = ans + a * (x-y)
        else:
            ans = ans + 2 * c * (x-y)
print(ans)

Measured memory_bytes: 3064
S = int(input())
p = [0 for _ in range(max(4,S + 1))]
p[3] = 1
for i in range(4,S + 1):
    p[i] += 1
    for j in range(1,i-2):
        p[i] += p[j]
        p[i] %= 10 ** 9+ 7
print(p[S])

Measured memory_bytes: 65260
#include <iostream>

using namespace std;

int main(){

  while(1)
    {
      
  int k;
  int kazu,sum=0;

  cin >> k;

  if(k == 0)
    {
      break;
    }

  for(int i = 0;i < k*(k-1)/2;i++)
    {
      cin >> kazu;

      sum += kazu;
    }

  cout << sum/(k-1) << endl;
    }
}



Measured memory_bytes: 2980
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  vi a(n),b(n);
  for(int i=1;i<=n;i++){
    cin >> a[i-1] >> b[i-1];
  }
  sort(all(a));
  sort(all(b));
  if(n%2){
    cout << (b[n/2]-a[n/2]+1) << endl;
    return 0;
  }
  int l = (a[n/2]+a[(n-1)/2]);
  int r = (b[n/2]+b[(n-1)/2]);
  cout << (r-l+1) << endl;

return 0;
}
///....


Measured memory_bytes: 6392
#include<stdio.h>

int main(){
  int i,j,n,r[200000],maxv=-1000000000,minv;

 scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&r[i]);
  minv=r[0];
  for(j=1;j<n;j++){
    if(maxv<r[j]-minv)maxv=r[j]-minv;
 if(minv>r[j])minv=r[j];
}
  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int f;
  cin >> f;
  cout << (f - 30) / 2 << '\n';
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	unordered_map<string, int> table;
	for (int i = 0; i < n; i++) {
		cin >> s;
		table[s]++;
	}
	int cnt = 0;
	for (auto it = table.begin(); it != table.end(); it++) {
		if ((it->second) % 2 == 1) cnt++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 11940
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct station {
    int cost;
    int limit;
};

struct status {
    int vertex;
    int cost;

    bool operator>(const status &rhs) const {
        if (cost != rhs.cost) return cost > rhs.cost;
        return vertex > rhs.vertex;
    }
};

int n;
vector<station> stations;
vector<vector<int>> raw_graph;
vector<vector<int>> graph;

void bfs(int start) {
    queue<int> que;
    que.push(start);
    que.push(-1);

    vector<bool> reached(n);
    while (stations[start].limit >= 0) {
        int nowv = que.front();
        que.pop();
        if (nowv < 0) {
            stations[start].limit--;
            que.push(-1);
        } else {
            reached[nowv] = true;
            for (auto nextv:raw_graph[nowv])
                if (!reached[nextv])que.push(nextv);
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == start)continue;
        if (reached[i])graph[start].push_back(i);
    }
}

vector<int> min_cost;

void dijkstra(int s) {
    priority_queue<status, vector<status>, greater<>> que;
    min_cost = vector<int>(n, 1145141919);
    min_cost[s] = 0;
    que.push({s, 0});

    while (!que.empty()) {
        status now = que.top();
        que.pop();

        if (min_cost[now.vertex] < now.cost)continue;

        int next_cost = now.cost + stations[now.vertex].cost;
        for (auto nextv:graph[now.vertex]) {
            if (min_cost[nextv] > next_cost) {
                min_cost[nextv] = next_cost;
                que.push({nextv, next_cost});
            }
        }
    }
}

int main() {
    int m;
    cin >> n >> m;
    stations = vector<station>(n);
    for (int i = 0; i < n; i++)cin >> stations[i].cost >> stations[i].limit;
    raw_graph = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        raw_graph[from].push_back(to);
        raw_graph[to].push_back(from);
    }

    graph = vector<vector<int>>(n);
    for (int i = 0; i < n; i++)bfs(i);

    dijkstra(0);
    cout << min_cost[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 70744
def calc_sum_digit(n):
    current_num = n
    sum_digit = 0
    for _ in range(5):
        sum_digit += current_num % 10
        current_num = current_num // 10

    return sum_digit


N, A, B = list(map(int, input().split(' ')))

sum = 0
for i in range(1, N+1):
    sum_digit = calc_sum_digit(i)
    if (A <= sum_digit) and (sum_digit <= B):
        sum += i

print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll k,X,Y,a,b;
vector<P> ans;
void solve(int x,int y){
    int dx=1,dy=1;
    if(x<0) dx=-1;
    if(y<0) dy=-1;
    if(abs(x)+abs(y)==k) a=x,b=y;
    else if(abs(x)+abs(y)<=2*k){
        if((abs(x)+abs(y))%2==0){
            if(abs(x)<abs(y)) b=dy*(abs(x)+abs(y))/2,a=-dx*(k-abs(b));
            else a=dx*(abs(x)+abs(y))/2,b=-dy*(k-abs(a));
        }
        else{
            if(abs(x)<abs(y)) a=0,b=dy*k;
            else a=dx*k,b=0;
        }
    }
    else{
        if(abs(x)<abs(y)) a=0,b=dy*k;
        else a=dx*k,b=0;
    }
}
void answer(int x,int y){
    solve(X-x,Y-y);
    ans.push_back(P(x+a,y+b));
    if(x+a!=X||y+b!=Y) answer(x+a,y+b);
}
int main(){
    cin>>k>>X>>Y;
    if(k%2==0&&(abs(X)+abs(Y))%2==1){cout<<-1;return 0;}
    answer(0,0);
    cout<<ans.size()<<"\n";
    for(auto i:ans) cout<<i.first<<" "<<i.second<<"\n";
}

Measured memory_bytes: 18284
n,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if A[i]>x:
        ans+=A[i]-x
        A[i]=x
    if A[i]+A[i+1]>x:
        ans+=A[i]+A[i+1]-x
        A[i+1]=x-A[i]
print(ans)

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

using namespace std;

typedef long long ll;

int main(){
	int h, w;
	cin >> h >> w;
	int ww = 0;
	for(int i = 0; i < h; i++){
		bool ny = true;
		bool re = false;
		for(int j = 0; j < w; j++){
			char aa;
			cin >> aa;
			if(ny && (aa=='#')){
				if(j == ww)ny = false;
				else{
					cout << "Impossible" << endl;
					return 0;
				}
				re = true;
			}
			else if(!ny&&(aa=='#')){
				if(j != ww+1){
					cout << "Impossible" << endl;
					return 0;
				}
				else ww++;
				re = true;
			}
		}
		if(!re){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int N, K;
int D[10];

bool contains(int n) {
  string s = to_string(n);
  rep(i, s.length()) {
    rep(j, K) {
      if (s[i] == '0' + D[j]) return true;
    }
  }
  return false;
}

int main() {
  scanf("%d %d", &N, &K);
  rep(i, K) scanf("%d", &D[i]);

  while (contains(N)) {
    N++;
  }
  printf("%d\n", N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	char C;
	cin >> C;
	cout << (char)(C + 1) << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
	Prime Number
*/

#include <stdio.h>
int main(void)
{
	/* ??¨???????????????????????? */
	int i,j,k,l,n,prime;

	while(scanf("%d", &n) != EOF){
		int a[n];
		for (i = 0; i <= n; ++i)
		{
			a[i] = 1;
		}

		/* 0,1????´???°??§????????? */
		a[0] = 0;
		a[1] = 0;

		for (j = 2; j * j <= n; ++j)
		{
			if (a[j] == 1)
			{
				for (k = 2; k * j <= n; ++k)
				{
					a[k*j] = 0;
				}
			}
		}

		prime = 0;
		for (l = 2; l <= n; ++l)
		{
			if (a[l] == 1)
			{
				prime++;
			}
		}
		printf("%d\n", prime);
	}
	return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define EPS (1e-12)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, int> DI;

double calc_dist(int x1, int y1, int x2, int y2){
	double res = (sqrt)((x1 - x2) * (x1 - x2) + (y1 - y2)*(y1 - y2));
	return res;
}

double calc_area(double a, double b, double c){
	double s = (a + b + c) / 2.;
	double res = sqrt(s * (s - a) * (s - b) * (s - c));

	return res;
}

double calc_cos(double a, double b, double c){
	double res = (-a*a + b*b + c*c) / 2. / b / c;
	return res;
}

double calc_sin(double a, double b, double c, int i){
	double s = calc_area(a, b, c);
	double res = 2.* s;
	switch(i){
		case 0: res /= b; res /= c; break;
		case 1: res /= c; res /= a; break;
		case 2: res /= a; res /= b; break;
	} // end switch;

	return res;
}

double calc_half_cos(double cos){
	return sqrt((1. + cos) / 2.);
}

double calc_half_sin(double cos){
	return sqrt((1. - cos) / 2.);
}

double calc_half_inv_tan(double cos){
	return sqrt((1. + cos) / (1. - cos));
}

double calc_term_plus(double cos){
	return sqrt(1. + cos);
}

double calc_term_minus(double cos){
	return sqrt(1. - cos);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x[3] = {0};
	int y[3] = {0};
	rep (i, 3) cin >> x[i] >> y[i];
	DI l[3];
	rep (i, 3){
		l[i].first = calc_dist(x[i], y[i], x[(i+1)%3], y[(i+1)%3]);
		l[i].second = i;
	} // end rep
	sort(l, l+3);

	double s = calc_area(l[0].first, l[1].first, l[2].first);
	double a = l[2].first;
	double b = l[1].first;
	double c = l[0].first;

	double min_r = 0.;
	double max_r = 2.* s / (a + b + c);

	double min_cos = calc_cos(l[0].first, l[1].first, l[2].first);
	double half_min_cos = calc_half_cos(min_cos); 
	double half_min_sin = calc_half_sin(min_cos);

	double mid_cos = calc_cos(l[1].first, l[2].first, l[0].first);
	double half_mid_cos = calc_half_cos(mid_cos);
	double half_mid_sin = calc_half_sin(mid_cos);


	double min_term_plus = calc_term_plus(min_cos);
	double min_term_minus = calc_term_minus(min_cos);
	double mid_term_plus = calc_term_plus(mid_cos);
	double mid_term_minus = calc_term_minus(mid_cos);

	double res = 0.;
	while(abs(max_r - min_r) > EPS){
		double mid_r = (min_r + max_r) / 2.;
//		cerr << "mid_r: " << mid_r << endl;
	
		if (mid_r * (min_term_plus*mid_term_minus + mid_term_plus*min_term_minus + 2.*min_term_minus*mid_term_minus) 
			< a*min_term_minus*mid_term_minus + EPS){
			res = max(res, mid_r);
			min_r = mid_r;
		}else{
			max_r = mid_r;
		} // end if
	} // end while

	printf("%.12lf\n", res);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a > b){
  cout << "a > b" << endl;
  }
  else if( a == b){
  cout << "a == b" << endl;
  }
  else{

  cout << "a < b" << endl;
  }
  return 0;
}


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

int main(){
  int A, B;
  cin >> A >>B;
  vector<int> vec(0);
  vec.push_back(A + B);
  vec.push_back(A - B);
  vec.push_back(A * B);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec[0] << endl;
}

Measured memory_bytes: 3572
#!/usr/bin/env python

def main():
    N, M = map(int, input().split())
    INF = float('inf')

    LR = [-INF, INF]
    for _ in range(M):
        L, R = map(int, input().split())
        if LR[0] < L:
            LR[0] = L
        if LR[1] > R:
            LR[1] = R
    if LR[1] < LR[0]:
        return 0
    else:
        return int(LR[1] - LR[0] + 1)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 44648