akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long K, long[] t, long[] d) {
    alias Sushi = Tuple!(long, "d", long, "t");

    auto s = make!(RedBlackTree!(Sushi, "a > b", true));
    foreach (di, ti; zip(d, t))
        s.insert(Sushi(di, ti));
    
    long[long] hist;
    long dp;
    auto bag = make!(RedBlackTree!(Sushi, "a < b", true));
    foreach (_; 0 .. K) {
        auto x = s.front;
        s.removeFront;

        hist[x.t]++;
        dp += x.d;
        bag.insert(x);
    }
    
    long tp = hist.keys.length;
    long ans = dp + tp ^^ 2;

    while (true) {
        while (!bag.empty && hist[bag.front.t] <= 1)
            bag.removeFront;
        if (bag.empty) break;
        
        dp -= bag.front.d;
        hist[bag.front.t]--;
        bag.removeFront;
        
        while (!s.empty && s.front.t in hist)
            s.removeFront;
        if (s.empty) break;

        dp += s.front.d;
        hist[s.front.t]++;
        tp++;
        s.removeFront;

        ans = max(ans, dp + tp ^^ 2);
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] t = new long[](cast(size_t) (N));
    long[] d = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        t[i] = input.front.to!long;
        input.popFront;
        d[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, K, t, d);
    else
        solve(N, K, t, d).writeln;
}


Measured memory_bytes: 21756
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int min(int a,int b){
	if(a>=b)return b;
	else return a;
}

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void babbleSort(int *data,int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(data[j]>=data[j-1]){
				swap(&data[j],&data[j-1]);
			}
		}
	}
}


using namespace std;

/*
cin.ignore();
	getline(cin,dataStr);
	data = new int[n];
	stringToInteger(&dataStr,data,n);
*/

void stringToInteger(string *str,int *data,int n){
	for(int i=1;i<=n;i++){
		int spaceN = str->find(' ',0);

		data[i] = atoi(str->substr(0,spaceN).c_str());
		str->erase(0,spaceN+1);
	}
}



int dp[1010];
//dp[i] i:重さ




int main(){


	int w,n;
	int cnt=1;
	while(1){
		cin>>w;
		if(w==0)break;

		cin>>n;

		for(int i=0;i<=w;i++){
			dp[i]=0;
		}
		int value,weight;
		for(int i=0;i<n;i++){
			scanf("%d,%d",&value,&weight);
			for(int j=w;j>=0;j--){
				if((j==0||dp[j]>0)&&((j+weight)<=w)){
					int tmp = dp[j]+value;
					dp[j+weight] = max(tmp,dp[j+weight]);
				//	cout<<j+weight<<" "<<dp[j+weight]<<endl;
				}
			}
		}

		int ans=0;
		int ansCnt=0;
		for(int i=0;i<=w;i++){
			if(ans<dp[i]){
				ans=dp[i];
				ansCnt=i;
			}
		}
		cout<<"Case "<<cnt<<":"<<endl;
		cout<<ans<<endl;
		cout<<ansCnt<<endl;
		cnt++;
	}



	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	rarr(a, n);
	bool flag = true;
	int i;
	for(i = 0; i < k; i++){
		flag = true;
		int b[n + 1] = {0};
		pair<int, int> p[n];

		for(int j = 0; j < n; j++){
			p[j] = {((j - a[j] <= 0) ? 0 : j - a[j]), ((j + a[j] >= n - 1) ? n - 1 : j + a[j])};
		}

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

		for(int i = 1; i < n + 1; i++){
    		b[i] += b[i - 1];
		}	

		for(int j = 0; j < n; j++){
			if(flag != false && a[j] != b[j]){
				flag = false;
			}
			a[j] = b[j];
		}

		if(flag){
			break;
		}
	}
	parr(a, n);
} 

Measured memory_bytes: 6740
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static final String NOT_FOUND = "UNRESTORABLE";

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);

		final String sDash = sc.next();
		final String T = sc.next();
		List<String> candidates = new ArrayList<>();
		for (int i = 0, bound = sDash.length() - T.length(); i <= bound; i++) {
			if (fuzzyMatch(sDash.substring(i, i + T.length()), T)) {
				String c = sDash.substring(0, i).replace('?', 'a') + T
						+ sDash.substring(i + T.length(), sDash.length()).replace('?', 'a');
				candidates.add(c);
			}
		}

		if (candidates.size() > 0) {
			Collections.sort(candidates);
			System.out.println(candidates.get(0));
		} else {
			System.out.println(NOT_FOUND);
		}
		sc.close();
	}

	private boolean fuzzyMatch(String s, String t) {
		for (int i = 0, len = s.length(); i < len; i++) {
			if (s.charAt(i) != '?' && s.charAt(i) != t.charAt(i)) {
				return false;
			}
		}
		return true;
	}

}

Measured memory_bytes: 25300
a,b,k = map(int,input().split())


list1 = []
list2 = []

for i in range(1,a+1):
  if a % i == 0:
    list1.append(i)
    
for i in range(1,b+1):
  if b % i == 0:
    list2.append(i)
li = sorted(list(set(list2) &set(list1)),reverse=True)
print(li[k-1])

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace Problem0000
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (int i in Enumerable.Range(1, 9))
                foreach (int j in Enumerable.Range(1, 9))
                    Console.WriteLine(i.ToString() + "x" + j.ToString() + "=" + (i * j).ToString());
        }
    }
}

Measured memory_bytes: 9244
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){
    
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    map<int, char>m;
    m[-1] = '-';
    m[1] = '+';
    for(ll i = -1; i <= 1; i += 2){
        for(ll j = -1; j <= 1; j += 2){
            for(ll k = -1; k <= 1; k += 2){
                if(a + b * i + c * j + d * k == 7){
                    cout << a << m[i] << b << m[j] << c << m[k] << d << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    
    return 0;
}

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

struct UF{
    vector<int> par, rank, size;

    void init(int n){
        par.assign(n, 0);
        rank.assign(n, 0);
        size.assign(n, 1);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x != y){
            if(rank[x] < rank[y]){
                par[x] = y;
                size[y] += size[x];
            }else{
                par[y]=x;
                size[x] += size[y];
                if(rank[x]==rank[y]) rank[x]++;
            }
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int get_size(int x){
        return size[find(x)];
    }
};

int main(void){
    int n, m, ans = 0;
    UF uf;
    vector<int> p;
    cin >> n >> m;
    p.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> p[i];
        p[i]--;
    }
    uf.init(n);
    for(int i=0;i<m;i++){
        int x, y;
        cin >> x >> y;
        uf.unite(--x, --y);
    }
    
    for(int i=0;i<n;i++){
        if(uf.same(i, p[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#define INF 100000000
using namespace std;
int h,w;
int d[51][51];
string s[51];
void search(int x,int y,int cnt){
  if(x<0||y<0||x>=h||y>=w) return;
  if(d[x][y]<=cnt) return;
  if(s[x][y]=='#')return;
  d[x][y]=cnt;
  cnt++;
  search(x,y+1,cnt);
  search(x,y-1,cnt);
  search(x+1,y,cnt);
  search(x-1,y,cnt);
}
int main(){
  int cnt=0;
  cin >> h >> w;
  fill(d[0],d[51],INF);
  for(int i=0;i<h;i++){
    cin >> s[i];
    for(int j=0;j<s[i].size();j++){
      if(s[i][j]=='.') cnt++;
    }
  }
  search(0,0,1);
  if(d[h-1][w-1]==INF)cout <<"-1\n";
  else cout << cnt - d[h-1][w-1]<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll k;
    if (N % 2 == 0)
    {
        k = N / 2;
    }
    else
    {
        k = N / 2 + 1;
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int a[3];
int cnt[4];
 
bool calc(){
  for(int i=0;i<3;i++){
    if(a[i] + a[(i+1)%3] <= a[(i+2)%3]) return false;
  }
  cnt[0]++;
  if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) cnt[1]++;
  if(a[0] * a[0] + a[1] * a[1] > a[2] * a[2]) cnt[2]++;
  if(a[0] * a[0] + a[1] * a[1] < a[2] * a[2]) cnt[3]++;
  return true;
}
 
main(){
  fill(cnt, cnt+4, 0);
  bool f = true;
  while(cin >> a[0] >> a[1] >> a[2]){
    sort(a, a+3);
    if(f){
      if(!calc()) f = false;
    }
  }
  for(int i=0;i<4;i++){
    if(i) cout << ' ';
    cout << cnt[i];
  }
  cout << endl;
}

Measured memory_bytes: 1176
n,m = map(int,input().split())
P = list(map(int,input().split()))
uf = {i:-1 for i in range(1,n+1)}

def get_p(i):
  while uf[i] != i:
    if uf[i] == -1:
      return i
    i = uf[i]
  return i

for _ in range(m):
  x,y = map(int,input().split())
  if x > y:
    x,y = y,x
  if uf[x]== uf[y] == -1:
    uf[x] = x
    uf[y] = x
  elif uf[x] != -1 and uf[y] != -1:
    p = get_p(x)
    uf[x] = p
    index = y
    while index != uf[index]:
      index = uf[y]
      uf[y] = p
      y = index
    else:
      uf[index] = p
  else:
    if uf[x] == -1:
      p = get_p(y)
    else:
      p = get_p(x)
    uf[x] = p
    uf[y] = p

ans = 0  
for i, p in enumerate(P):
  if get_p(i+1) == get_p(p):
    ans += 1
print(ans)

Measured memory_bytes: 80232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    string sa;
    cin>>sa;
    a=0,b=0;
    for(i=0;i<sa.size();i++){
        if(sa[i]=='R')a++;
        else{
            b=max(a,b);
            a=0;
        }
    }
    b=max(a,b);
    cout<<b<<endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

const int MOD = 1000000007;

ll mypow(ll x, ll n) {
  if(n == 0) return 1;
  if(n % 2 == 1) return mypow(x*x%MOD, n/2)*x%MOD;
  return mypow(x*x%MOD, n/2);
}

ll fac[200000+10];
ll invfac[200000+10];

inline ll cmb(ll n, ll k) {
  if(k > n || k < 0) return 0;
  return fac[n] * invfac[k] % MOD * invfac[n-k] % MOD;
}

ll noB[200000+10];
ll noW[200000+10];
int B, W;

ll solveNoW(int idx);
ll solveNoB(int idx);

// idx個既に引いて黒がもう無い確率
ll solveNoB(int idx) {
  ll &res = noB[idx];
  if(res < 0) {
    if(idx == 0) {
      res = 0;
    } else {
      // // cerr << "B> " << idx << " " << B << endl;
      ll p = solveNoB(idx-1);
      res = cmb(idx-1, B-1) * mypow(mypow(2, idx), MOD-2) % MOD;
      res = (res + p) % MOD;
    }
  }
  return res;
}

// idx個既に引いて白がもう無い確率
ll solveNoW(int idx) {
  ll &res = noW[idx];
  if(res < 0) {
    if(idx < W) {
      res = 0;
    } else {
      // cerr << "W> " << idx << " " << W << endl;
      ll p = solveNoW(idx-1);
      res = cmb(idx-1, W-1) * mypow(mypow(2, idx), MOD-2) % MOD;
      res = (res + p) % MOD;
    }
  }
  return res;
}

int main(void) {
  fac[0] = 1;
  REP(i, 200000) {
    fac[i+1] = (fac[i] * (i+1)) % MOD;
  }
  invfac[200000] = mypow(fac[200000], MOD-2);
  for(int i = 200000; i > 0; --i) {
    invfac[i-1] = (invfac[i] * i) % MOD;
  }
  
  scanf("%d%d", &B, &W);
  memset(noB, -1, sizeof noB);
  memset(noW, -1, sizeof noW);
  ll inv2 = mypow(2, MOD-2);
  REP(i, B+W) {
    ll pnb = solveNoB(i);
    ll pnw = solveNoW(i);
    ll res = 0;
    // E = (黒が無い確率)*0 + (白が無い確率)*1 + (両方ある確率)/2
    // (両方ある確率) = 1 - (黒が無い確率) - (白が無い確率) + (両方無い確率)
    res = (pnw + (1 - pnb + MOD - pnw + MOD) % MOD * inv2 % MOD) % MOD;
    printf("%lld\n", res);
  }
  return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;
string S;
signed main(){
    cin >> N >> S;
    for(int i=0;i<N;i++) {
        if(S[i]=='R') tmp++;
    }
    for(int i=0;i<tmp;i++) {
        if(S[i]=='W') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int k, n;
	scanf("%d%d", &k, &n);
	if(k % 2)
	{
		vector<int> a(n, k / 2 + 1);
		for(int i = 0, j = n - 1; i < n / 2; ++i)
		{
			if(--a[j])
			{	
				for(; j < n - 1;)
				{ 
					a[++j] = k;
				}
			}
			else
			{
				--j;
			}
		}
		printf("%d", a[0]);
		for(int i = 1; i < n; ++i)
		{
			if(a[i])
			{
				printf(" %d", a[i]);
			}
			else
			{
				break;
			}
		}
		printf("\n");
	}
	else
	{
		printf("%d", k / 2);
		for(int i = 1; i < n; ++i)
		{
			printf(" %d", k);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3456
import java.util.Scanner;
public class Main {
     
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        String p = stdIn.next();
         
        boolean ans = false;
         
        IN:for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < p.length(); j++) {
                if(s.charAt((i + j) % s.length()) != p.charAt(j)) {
                    continue IN;
                }
            }
            ans = true;
            break;
        }
         
        System.out.println((ans)?"Yes":"No");
         
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x,y;
cin>>x>>y;

ll val=x;
ll cnt=0;
while(val<=y){
    cnt++;
    val*=2;
}
cout<<cnt<<endl;

//system("pause");
return 0;
}

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; 
#define ll long long
#define MOD 1000000007
#define ull unsigned long long int
#define db double
#define fi first
#define se second
#define pb push_back
#define vec vector<ll>
#define pr pair<ll,ll>
#define pq priority_queue<ll,vector<ll>, compare_queue >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define GS(s)   string s; getline(cin,s);
#define lll __int128_t
#define endl "\n"
#define Next cout.flush()

struct compare_queue
{
    bool operator()(const pair<ll,pr>& a, const pair<ll,pr>& b)
    {
        return a.fi < b.fi;
    }
};

ll gcd(ll u,ll v)
{
	if(v==0)
	return u;
	
	else
	return gcd(v,u%v);
}

// ll power(ll x,ll y) 
// { 
//     if (y == 0) 
//         return 1; 
//     ll p = power(x, y/2)%MOD; 
//     p = ((p%MOD) * (p%MOD))%MOD; 

//     return (y%2 == 0)? p%MOD : ((x%MOD) * (p%MOD))%MOD; 
// } 

// ll modInverse(int a) 
// { 
//     if(a==1){return 1;}
//     return power(a,MOD-2); 
// } 
  
// // // #define MAX 1000000
// int primes[100009],cnt=0;
// // vector<int> factors[1000009];
// char str[1000009];
// void pre()
// {
//     // calcualting primes
//     int n=100000;
//     for(int i=2; i*i<=n; i++)
//         if(str[i]==0)
//             for(int j=i; j*i<=n; j++)
//                 str[i*j]=1;
//     for(int i=2; i<=n; i++)
//         if(str[i]==0)primes[cnt]=i,cnt++;
// }


// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
// vector<ll> getFactorization(ll x) 
// { 
//     vector<ll> ret; 
//     while (x != 1) 
//     { 
//         ret.push_back(spf[x]); 
//         x = x / spf[x]; 
//     } 
//     return ret; 
// } 

// C:\Users\A\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\lambda


void Function(){
ll n;
cin >> n;
vec x(n),y(n);
repn(i,n){cin >> x[i] >> y[i];}
ll flag=0;
rep(i,2,n){
    if(x[i]==y[i] && x[i-1]==y[i-1] && x[i-2]==y[i-2]){flag=1; break;}
}

if(flag==0){cout << "No" << endl;}
else{cout << "Yes" << endl;}

}


int main(){ 
fast;
ll t=1,i=0,j=0,k,h;
 //pre();
// cin >> t;
for(h=1;h<=t;h++){

Function();

}


return 0;

}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 2e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
ld d1, x, tmpd1, tmpx;
ld ans;

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

	cin >> n >> d1 >> x;
	while (n)
	{
		ll now = (2 * n - 1);
		ans += (now * x) / 2 + d1;
		tmpd1 = (d1 + 2 * x) / (2 * n) + (d1 * 3 + x * 3) / (2 * n) + (n - 1) * d1 / n;
		tmpx = (d1 + 3 * x) / n + (d1 * 3 + 6 * x) / (2 * n) + (d1 + x) / (2 * n) + (n - 2) * (d1 + x) / n;
		tmpx -= tmpd1;

		d1 = tmpd1, x = tmpx;
		n--;
	}
	cout << setprecision(15) << fixed << ans << endl;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let r: usize = read();

    println!("{}", r * r);
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<29;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    double d;
    d=din();
    dprint(fmax(d*sqrt(2),(int)d+1));
    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[3 * n];
    rep(i, 0, 3 * n) cin >> a[i];

    sort(a, a + 3 * n, greater<int>());
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += a[2 * i - 1];
    }

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


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll 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;
int main(){
    int n,k,q;
    string s;
    cin>>n>>s>>q;
    rep(j,q){
        cin>>k;
        ll d=0,m=0,dm=0,ans=0;
        rep(i,n){
            if(i>=k){
                if(s[i-k]=='D') d--,dm-=m;
                if(s[i-k]=='M') m--;
            }
            if(s[i]=='D') d++;
            if(s[i]=='M') m++,dm+=d;
            if(s[i]=='C') ans+=dm;
            
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  multiset<ll> pos;
  pos.insert(A.at(0));
  ll ans = 0;
  for (ll i = 1; i < N; ++i) {
    auto next = pos.end();
    next--;
    // cout << *next << "\n";
    ans += (ll)*next;
    pos.insert(A.at(i));
    pos.insert(A.at(i));
    pos.erase(next);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 14284
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
map<char,int> mp;
string s;
void input(){
    cin>>s;
}
void src(){
    int rest = 15-s.length();
    rep(i,s.length()){
        mp[s[i]]++;
    }
    YES(mp['o']+rest>=8);
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
std::string x;
int n;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
inline std::string qwq(std::string x){
	std::string ans=x;
	std::reverse(ans.begin(),ans.end());
	return ans;
}
int main(void){
	std::cin>>x;
	n=x.size();
	if(qwq(x.substr(0,n/2))==x.substr(0,n/2)&&qwq(x.substr(n/2+1,n/2))==x.substr(n/2+1,n/2)&&qwq(x)==x){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int64_t a,b; cin>>a>>b;
  int64_t dif=b-a;
  int64_t ans=0;
  while(dif>0){
    dif--;
    ans += dif;
  }
  ans=a-ans;
  cout<<abs(ans)<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,A,B;
  cin >> N >> A >> B;
  if(A+B-1 > N || A*B < N){
    cout << -1 << "\n";
    return 0;
  }
  vector<vector<ll>> G(B);
  int cnt = 0;
  for(int i=0; i<A; i++){
    G[B-1].emplace_back(1LL + i*B);
    cnt++;
  }
  int pos = (B-2+B)%B;
  int now = 2;
  while(cnt < N){
    if(pos != B-1){
      G[pos].emplace_back(now);
      cnt++;
      now++;
      if(now%B == 1){
        now++;
      }
    }
    pos = (pos-1+B)%B;
  }
  vector<ll> ans;
  for(int i=0; i<B; i++){
    for(int j=0; j<G[i].size(); j++){
      ans.emplace_back(G[i][j]);
    }
  }
  vector<ll> temp;
  temp = ans;
  sort(temp.begin(),temp.end());
  temp.erase(unique(temp.begin(),temp.end()),temp.end());
  for(int i=0; i<ans.size(); i++){
    ans[i] = lower_bound(temp.begin(),temp.end(),ans[i]) - temp.begin();
    ans[i]++;
  }
  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << " \n"[i+1 == ans.size()];
  }
  return 0;
}

Measured memory_bytes: 18364
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    if(N > M//2):
        print(M//2)
    else:
        print(N+(M-2*N)//4)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
# 入力
D, G = map(int, input().split())
ps = [0] * D
cs = [0] * D

for i in range(D):
    ps[i], cs[i] = map(int, input().split())

ans = 0

def dfs(n, d, g):
    """
    d以下の問題でg点以上取るために必要な最小の問題数を返す

    Parameters
    ----------
    n : int
        dより大きいレベルを解いた数
    d : int
        レベル
    g : int
        点数

    Returns
    -------
    g点取るための問題数
    """
    if d < 1:
        return float('inf')
    m = min(-(-g // (100 * d)), ps[d-1])
    p = 100 * m * d + cs[d-1] if m == ps[d-1] else 100 * m * d
    if p >= g:
        return min(n+m, dfs(n, d-1, g))
    else:
        return min(dfs(n + m, d - 1, g - p), dfs(n, d -1, g))
print(dfs(ans, D, G))


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

using namespace std;

int main() {
    bitset<64> bst;

    int q;
    cin >> q;
    while (q--) {
        int op;
        cin >> op;

        unsigned int idx = 0;
        if (op < 4) cin >> idx;

        switch (op) {
            case 0:
                cout << bst.test(idx) << endl;
                break;
            case 1:
                bst.set(idx);
                break;
            case 2:
                bst.reset(idx);
                break;
            case 3:
                bst.flip(idx);
                break;
            case 4:
                cout << bst.all() << endl;
                break;
            case 5:
                cout << bst.any() << endl;
                break;
            case 6:
                cout << bst.none() << endl;
                break;
            case 7:
                cout << bst.count() << endl;
                break;
            case 8:
                cout << bst.to_ullong() << endl;
                break;
            default:
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll k;
    cin>>k;
    queue<ll>q;
    for(ll i=1;i<10;i++){
        q.push(i);
    }
    ll temp,lastDigit;
    while(1){
        temp=q.front();
        q.pop();
        lastDigit=temp%10;
        --k;
        if(!k){
            cout<<temp<<"\n";
            return;
        }
        for(ll i=max(0LL,lastDigit-1);i<=min(9LL,lastDigit+1);i++){
            q.push(temp*10+i);
        }
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> a;
    rep(i,n){
        vector<ll> b(4);
        cin >> b[1] >> b[2] >> b[3];
        b[0] = b[1] + b[2];
        a.push_back(b);
    }
    sort(a.begin(), a.end());

    ll dp[20005] = {};
    ll ans = 0;
    rep(i,n){
        vector<ll> b = a[i];
        ll w = b[1], s = b[2], v = b[3];
        drep(j,s+1){
            dp[j+w] = max(dp[j+w], dp[j] + v);
            ans = max(ans, dp[j+w]);
        }
    }

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




Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var NXY = Sarray();
            var N = NXY[0];
            var X = NXY[1] - 1;
            var Y = NXY[2] - 1;
            var ans = new int [N];
            for(var sv=0;sv<N;sv++)
            {
                var dist = new int[N].Select(x=>int.MaxValue).ToArray();
                var q = new Queue<int>();
                Action<int, int> push = (v, d) =>
                 {
                     if (dist[v] != int.MaxValue) return;
                     dist[v] = d;
                     q.Enqueue(v);
                 };
                push(sv, 0);
                while(q.Any())
                {
                    var v = q.Dequeue();
                    var d = dist[v];
                    if (v - 1 >= 0) push(v - 1, d + 1);
                    if (v + 1 < N) push(v + 1, d + 1);
                    if (v == X) push(Y, d + 1);
                    if (v == Y) push(X, d + 1);
                }
                for (var i = 0; i < N; i++) ans[dist[i]]++;
            }
            for (var i = 0; i < N; i++) ans[i] /= 2;
            for (var i = 1; i <= N - 1; i++) WriteLine(ans[i]);
        }
    }
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  for (int i=A; i<=min(B, A+K-1); i++) cout << i << endl;
  for (int i=max(B-K+1, A+K); i<=B; i++) cout << i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 +7;







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

  
  int n,k;
  cin>>n>>k;
  vector<int>a(n),f(n);

  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>f[i];
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());

 

  int s=0,e=(int)1e12;
  int mid ,ans;

  while(s<=e)
  {
     mid=(s+e)/2;

     int x=0;
     for(int i=0;i<n;i++)
     {
        x+=max(0ll,a[i]-mid/f[i]);
     }
     if(x<=k)
     {
        ans=mid; e=mid-1;
     }

     else
     {
        s=mid+1;
     }
     
  }

  cout<<ans<<"\n";


  

   
}

 

 
 
 
 
 

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


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

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

int main() {
  int64_t N;
  cin >> N;
  
  int64_t ans[N+1];
  for (int i=0; i<N+1; i++){
  	if (i==0){
      ans[i] = 2; 
    }
    else if (i==1) {
      ans[i] = 1;
    }
    else {
      ans[i] = ans[i-1] + ans[i-2];
    }
  }  
  cout << ans[N] << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main()
{
	int a,b,c,d;cin >> a >> b >> c >> d;
	int cou = 0;
	if(abs(a - b) <= d)cou++;
	if(abs(c - b) <= d)cou++;
	if(abs(a - c) <= d)cou+=2;
	
	cout << (cou >= 2 ? "Yes" : "No" ) << endl;
	
	return 0;
}

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

int main(){
	int H1, M1, H2, M2, K; 
	scanf ("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
	int Tot1 = (H1*60)+M1;
	int Tot2 = (H2*60)+M2;
	int Time = (Tot2 - Tot1) - K;
	printf ("%d", Time); 



return 0;
}

Measured memory_bytes: 1728
#include <vector>
#include <iostream>

using namespace std;

typedef vector<int> int_vec;

bool linear_search(const int_vec& v, int n) {
    for (int_vec::const_iterator it = v.begin(); it != v.end(); ++it) {
        if (*it == n) {
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    int_vec S;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        S.push_back(x);
    }

    int q;
    cin >> q;
    int_vec T;
    for (int j = 0; j < q; ++j) {
        int x;
        cin >> x;
        T.push_back(x);
    }

    int c = 0;
    for (int_vec::iterator it = T.begin(); it != T.end(); ++it) {
        if (linear_search(S, *it))
            c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,dp[101][100001],a[200001],b[200001],ans,B;
int main () {
    cin>>n>>m;
    B=1e16;
    for (i=1;i<=n;i++) {
        cin>>a[i]>>b[i];
    }
    for (i=0;i<=n;i++) {
        for (j=0;j<=100000;j++) {
            dp[i][j]=B;
        }
    }
    for (i=0;i<=n;i++) {
        dp[i][0]=0;
    }
    for (i=1;i<=n;i++) {
        for (j=1;j<=100000;j++) {
            if (j-b[i]<0) {dp[i][j]=dp[i-1][j];continue;}
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-b[i]]+a[i]);
        }
    }
        for (i=1;i<=100000;i++) {
            if (dp[n][i]<=m) ans=i;
        }
        cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,ans=0,lmax=0;cin>>n;
    for(int i=0;i<n;i++){
        int l;cin>>l;
        ans+=l;
        lmax=max(l,lmax);
    }
    ans-=lmax;
    if(ans>lmax) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//Optional FAST

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

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

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

//Required typedefs

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

//Required Constants

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

//Required Functions

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

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(A,N+1);
    ll ans=0;
    ll dp2[N+1]={0};
    ll prev=0;
    FORD(i,N,-1)
    {
        dp2[i]=prev+A[i];
        prev=dp2[i];
    }
    prev=1;
    ll dp1[N+1]={0};
    dp1[0]=prev;
    FORI(i,1,N+1)
    {
        if(dp1[i-1]>=inf || dp1[i-1]<0)
        {
            dp1[i]=dp1[i-1];
        }
        else
        {
            dp1[i]=2*(dp1[i-1]-A[i-1]);
        }
        dp1[i]=min(inf,dp1[i]);
    }
    bool ok=true;
    FORI(i,0,N+1)
    {
        if(dp1[i]<=0 || dp2[i]<=0 || min(dp1[i],dp2[i])<A[i])
        {
            ok=false;
        }
        ans+=min(dp1[i],dp2[i]);
    }
    if(ok)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
    


//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 6148
N = int(input())
for i in range(2000):
    if i*(i-1)//2 == N:
        c = 1
        X = [[] for _ in range(i)]
        for j in range(i):
            for k in range(j+1, i):
                X[j].append(c)
                X[k].append(c)
                c += 1
        print("Yes")
        print(len(X))
        for x in X:
            print(len(x), *x)
        break
else:
    print("No")


Measured memory_bytes: 9416
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int ifPrime( int number )
{
        int count = 3, isprime = 0;
        if ( number == 2 )
        {
                return 1;
        }

        if (( number < 2 ) || ( number % 2 == 0 ))
        {
                return 0;
        }

        if ( number == 3 )
        {
                return 1;
        }

        for ( count = 3 ; count <= sqrt(number) ; count = count + 2 )
        {
                if ( number % count == 0 )
                {
                        return 0;
                }
        }

        return 1;

}

int main()
{
        int prime_number = 0, count = 0, answer = 0;
        int prime[10000];

        scanf("%d", &prime_number);
        while ( count < prime_number )
        {
                scanf("%d", &prime[count]);
                count = count + 1;
        }

        count = 0;
        while ( count < prime_number )
        {
                answer = answer + ifPrime( prime[count] );
                count = count + 1;
        }

        printf("%d\n", answer);

        return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxi = 1e6 + 1, mod = 998244353;

int main()
{
    ll n, k, m, i;
    cin >> n >> k;
    vector <ll> dp(n + 1), dummy(n + 2, 0);
    vector <pair <int, int> > a(k);
    for(i = 0; i < k; i++)
        cin >> a[i].first >> a[i].second;
    ll s = 0;
    dummy[n] = 1;
    for(i = n; i >= 1; i--)
    {
        s = (s + dummy[i]) % mod;
        dp[i] = s;
        for(auto x: a)
        {
            if(i - x.first < 1)
                continue;
            int r = max(0ll, i - x.second - 1), l = max(1ll, i - x.first);
            dummy[r] = (dummy[r] + mod - dp[i]) % mod;
            dummy[l] = (dummy[l] + dp[i]) % mod;   
        }
        // for(ll j = 1; j <= n; j++)
        //     cout << dummy[i] << ' ';
        // cout << endl;
    }
    // for(i = 1; i <= n; i++)
    //     cout << dp[i] << ' ';
    // cout << endl;
    cout << dummy[1] << endl;
    return 0;
}

Measured memory_bytes: 6420
import sys

As = []
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        As.append({'value': tmp[j], 'isMarked': False})


N = int(input())

for i in range(N):
    b = int(input())
    for Ai in As:
        if Ai['value'] == b:
            Ai['isMarked'] = True

bingo_list = [[0,1,2],[3,4,5],[6,7,8],  # 横
              [0,3,6],[1,4,7],[2,5,8],  # 縦
              [0,4,8],[2,4,6]]          # ななめ

for bingo in bingo_list:
    if As[bingo[0]]['isMarked'] and As[bingo[1]]['isMarked'] and As[bingo[2]]['isMarked']:
        print('Yes')
        sys.exit(0)

print('No')


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

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

	long long count = 0;
	long long frontI = 0;
	long long backI = n - 1;
	while(frontI < backI){
		if(colors[frontI] == 'W'){
			while(frontI < backI){
				if(colors[backI] == 'R'){
					count++;
					backI--;
					break;
				}
				backI--;
			}
		}
		frontI++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include <iostream>
#define ll long long int
using namespace std;
int main() {
	long long int w,n;
	cin>>n>>w;
	vector<ll> w1(n),v(n);
	for(ll i=0;i<n;i++){
		cin>>w1[i]>>v[i];
	}
	ll dp[n+1][w+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(i==0||j==0)dp[i][j]=0;
			else if(w1[i-1]>j)dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=max(v[i-1]+dp[i-1][j-w1[i-1]],dp[i-1][j]);
			}
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
N,M = map(int,input().split())

E = [[] for _ in range(N)]
visited = [False]*N
visited_all = [True]*N

def DFS(V):
    if visited == visited_all:
        return 1
    count = 0
    for e in E[V]:
        if not visited[e]:
            visited[e] = True
            count += DFS(e) 
            visited[e] = False
    else:
        return count

for i in range(M):
    a,b = map(int,input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

visited[0] = True
print(DFS(0))

Measured memory_bytes: 3064
#include <stdio.h>

int main (int argc, char* argv[])
{
  int i, j, temp, height[10];

  for (i=0; i<10; i++) {
    scanf("%d", &height[i]);
  }
  
  for (i=9; 0<i; i--) {
    for (j=0; j<i; j++) {
      if (height[j+1] < height[j]) {
	temp = height[j];
	height[j] = height[j+1];
	height[j+1] = temp;
      }
    }
  }

  for (i=9; 6<i; i--) {
    printf("%d\n", height[i]);
  }
  return 0;
}

Measured memory_bytes: 0
from operator import mul
from functools import reduce

mod = 10**9+7

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


x, y = map(int, input().split())
if (2*y - x) % 3 != 0:
	print(0)
	exit()

if (x+y) % 3 != 0 or not (x <= 2*y and y <= 2*x):
    print(0)
    exit()

a = (2*y - x) // 3
b = y - 2 * a
print(combination(a+b, a))

Measured memory_bytes: 3572