akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0004
{
    class Program
    {
        static void Main(string[] args)
        {
            string str ;
            List<string> answerList = new List<string>();
            while ((str = Console.ReadLine()) != null)
            {
                decimal[] number = str.Split(' ').Select(decimal.Parse).ToArray();
                decimal y = (number[3] * number[2] - number[0] * number[5]) / (number[1] * number[3] - number[0] * number[4]);
                decimal x = (number[2] - number[1] * y) / number[0];
                Math.Round(y,4);
                Math.Round(x,4);
                answerList.Add(x.ToString("F3") + " " + y.ToString("F3"));
            }
            foreach (string answer in answerList)
            {
                Console.WriteLine(answer);
            }
        }
    }
}



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

int main() {
	char O[51], E[51];
	scanf("%s %s", O, E);
	int i, j = 0, k = 0;
	int O_len = strlen(O);
	int E_len = strlen(E);
	char pass[O_len + E_len];
	for (i = 0; i <= O_len + E_len; i++) {
		if (i % 2 == 0) {
			if (O_len >= j) {
				pass[i] = O[j];
				j++;
			}
		} else {
			if (E_len >= k) {
				pass[i] = E[k];
				k++;
			}
		}
	}
	printf("%s\n", pass);
	return 0;
}

Measured memory_bytes: 128
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple((a), (b), (c))
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}


int solve(){
  int n,m,l;cin>>n>>m>>l;

  // init
  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i,m){
    int a,b,c;cin>>a>>b>>c;
    a--;b--;
    if (c<=l){
      d[a][b] = c;
      d[b][a] = c;
    }
  }
  // calc
  rep(k, n){
    rep(i, n){
      rep(j, n){
        chmin(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  dump_2d(d, n, n);
  rep(i, n){
    rep(j, n){
      if (d[i][j]<=l) d[i][j]=1;
      else d[i][j] = INF;
    }
  }
  dump_2d(d, n, n);
  rep(k, n){
    rep(i, n){
      rep(j, n){
        chmin(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  dump_2d(d, n, n);

  int Q;cin>>Q;
  rep(q, Q){
    int s,t;cin>>s>>t;
    s--;t--;
    cout << (d[s][t]==INF?-1:d[s][t]-1) << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>A>>B>>K;
    cout<<(B / K) - (A == 0 ? -1 : (A - 1) / K)<<endl;
}

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

using namespace std;

int p[200001];

int main()
{
    p[0] = 1;
    p[1] = 1;
    for (int i = 4; i <= 200000; i += 2) p[i] = 1;
    
    for (int i = 3; i * i <= 200000; i += 2){
        if (!p[i]){
            for (int j = i * 3; j <= 200000; j += 2 * i) p[j] = 1;
        }
    }
    
    int N, P;
    
    while (scanf("%d %d", &N, &P) && ~N){
        vector<int> v, v2;
        
        for (int i = N + 1; ; i++){
            if (!p[i]) v.push_back(i);
            if (v.size() == 100) break;
        }
        
        for (int i = 0; i < 100; i++){
            for (int j = i; j < 100; j++){
                v2.push_back(v[i] + v[j]);
            }
        }
        sort(v2.begin(), v2.end());
        
        printf("%d\n", v2[P - 1]);
    }
    
    return (0);
}

Measured memory_bytes: 2048
#include<stdio.h>
int main()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x>=0 && y>=0 && x+r<=W && y+r<=H)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2108
n = gets.to_i
a = gets.split.map(&:to_i)

x = [0,0,0]
ans = 1
a.each{|t|
  ans *= x.count(t)
  ans %= 10**9+7
  idx = x.index(t)
  if !idx
    p 0
    exit
  end
  x[idx] += 1
}

p ans


Measured memory_bytes: 8068
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    string S;
    long K;
    cin >> S >> K;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != '1' || i == K - 1){
            cout << S[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;
int n,fa[N],c[N][2],f[N];ll ans;
struct st{int c0,c1,i;};
inline bool operator<(st a,st b){return 1ll*a.c0*b.c1<1ll*a.c1*b.c0;}
priority_queue<st>Q;
int fnd(int x){return !f[x]?x:f[x]=fnd(f[x]);}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&fa[i]);
	for(int i=1,x;i<=n;i++)scanf("%d",&x),c[i][x]=1;
	for(int i=2;i<=n;i++)Q.push((st){c[i][0],c[i][1],i});
	while(!Q.empty())
	{
		st x=Q.top();Q.pop();int u=fnd(x.i);
		if(c[u][0]==x.c0&&c[u][1]==x.c1)
		{
			int v=fnd(fa[u]);ans+=1ll*c[v][1]*c[u][0];
			c[v][1]+=c[u][1];c[v][0]+=c[u][0];f[u]=v;
			if(v!=1)Q.push((st){c[v][0],c[v][1],v});
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

string s;
int broj[300];
long long sol;

int main(){
    cin >> s;
    sol = s.size() * (s.size() + 1) / 2;
    for(int i = 0; i < s.size(); i ++){
        broj[s[i]] ++;
    }
    for(int i = 0; i < s.size(); i ++){
        sol -= (long long)broj[s[i]] * (broj[s[i]] + 1) / 2;
        broj[s[i]] = 0;
    }
    cout << sol + 1;
    return 0;
}


Measured memory_bytes: 640
# coding: utf-8
def divisor(N):
    # 約数列挙
    divs = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divs.append(i)
            divs.append(N//i)
    return divs
def f(a, b):
    return max(len(str(a)), len(str(b)))

N = int(input())
divs = divisor(N)
ans = float("inf")
for i in range(0, len(divs), 2):
    a, b = divs[i], divs[i+1]
    ans = min(ans, f(a, b))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll x;
  cin >> x;
  int ans = 1;
  while(true){
    if(ans*(ans+1)>=(2*x)) break;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math

n = int(input())
#a = list(map(int, stdin.readline().rstrip().split()))
a = sorted(list(map(int, stdin.readline().rstrip().split())))


count_max = 1

count_prev = 0
count_curr = 1
count_next = 0

current_value = a[0]
for i in range(1, n):
    if a[i] == current_value:
        count_curr += 1
    elif a[i] == current_value + 1:
        count_next += 1
    elif a[i] == current_value + 2:
        count_max = max(count_max, (count_prev + count_curr + count_next))
        current_value = current_value + 1
        count_prev = count_curr
        count_curr = count_next
        count_next = 1
    elif a[i] >= current_value + 3:
        count_max = max(count_max, (count_prev + count_curr + count_next))
        current_value = a[i]
        count_prev = 0
        count_curr = 1
        count_next = 0
    else:
        print("Error")

count_max = max(count_max, (count_prev + count_curr + count_next))

print(count_max)


Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    LL a,b;
    int k;
    cin >> a >> b >> k;
    if(abs(a-b)+1<=2*k){
        for(int i=a;i<=b;i++){
            cout << i << endl;
        }
    }
    else{
        for(int i=0;i<k;i++){
            cout << a+i << endl;
        }
        for(int i=0;i<k;i++){
            cout << b-k+i+1 << endl;
        }
    }
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x, y;
    cin >> x >> y;

    int ans = 0;
    if(x==3) {
        ans += 100000;
    } else if(x==2) {
        ans += 200000;
    } else if(x==1){
        ans += 300000;
    }

    if(y==3) {
        ans += 100000;
    } else if(y==2) {
        ans += 200000;
    } else if(y==1){
        ans += 300000;
    }

    if(x==1 && y==1) {
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

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

int calc(int A, int B){
	int res = 0;
	while(A > 0 || B > 0){
		if (A > 0){
			res += A % 10;
			A /= 10;
		} // end if
		if (B > 0){
			res += B % 10;
			B /= 10;
		} // end if
	} // end while
	return res;
}

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

	int res = INF;
	for (int A = 1; A < N; ++A){
		int B = N - A;
		int curr = calc(A,B);
		res = min(res, curr);
	} // end for

	cout << res << endl;	

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    lli p[n];
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
    }

    vector<lli> a;
    for (int i = 0; i < n; ++i) {
      a.push_back(30000 * (i + 1));
    }
    vector<lli> b = a;
    reverse(b.begin(), b.end());

    for (int i = 0; i < n; ++i) {
      a[p[i] - 1] += i;
      b[p[i] - 1] += i;
    }
    
    for (int i = 0; i < n; ++i) {
      if (i) cout << ' ';
      cout << a[i];
    }
    cout << endl;

    for (int i = 0; i < n; ++i) {
      if (i) cout << ' ';
      cout << b[i];
    }
    cout << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 1276
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))

inf=1000000007

l=[1,1]
for i in range(n+2):
    l.append((l[i]+l[i+1])%inf)



if m!=0:
    k=[a[0]]
    for i in range(m-1):
        k.append(a[i+1]-a[i]-1)
    k.append(n-a[m-1])

    flag=True
    for i in range(1,len(k)):
       if k[i]==0:
            flag=False
    ans=1

    for j in range(len(k)):
        ans=(ans*l[k[j]-1])%inf

    if flag:
        print(ans%inf)
    else:
        print(0)
else:
    print(l[n])


Measured memory_bytes: 11816
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
 
void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}
 
const int N=2e6+3,M=5e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;
 
int n,m,k,tc,ans,a[N];
 
int main(){
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
        scanf("%d",&a[i]);
    ll cur = 1000;
    for(int i = 1 ; i < n ; i++)
        if (a[i] > a[i - 1])
            cur = ((ll)cur / a[i - 1]) * a[i] + cur % a[i - 1];
    printf("%lld\n", cur);
}


Measured memory_bytes: 3772
#include <stdio.h>

int main() {
    int i,n,maxp,minp,a,b,c,d,e,sum;

    while(1){
        scanf("%d",&n);

        if(n == 0) break;

        maxp = 0;
        minp = 1000000;

        for(i=0; i<n; i++){
            scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
            sum = a + b + c + d + e;
            if(sum > maxp) maxp = sum;
            if(sum < minp) minp = sum;
        }

        printf("%d %d\n",maxp,minp);

    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  int n, r;
  cin >> n >> r;
  
  if ( n >= 10) printf("%d", r);
  else printf("%d", r+100*(10-n));
  
  return 0;
}


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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int a[n];
    REP(i,n)
        cin >> a[i];
    
    // A1 + A2 + ... + An = X1 + X2 + ... + Xn = Sまた
    // Ai = (Xi + X(i+1)) / 2 => 2 * Ai = Xi + X(i+1)
    // X1 = S - 2 * (X2 + X4 + ... Xn-1)
    // 漸化式 X(i+1) = 2 * Ai - Xi

    // Xiを求める
    ll x[n] = {0}, s = 0;

    REP(i,n)
        s+=a[i];
    
    for (ll i = 1; i <= n-2; i+=2)
    {
        s-= 2*a[i];
    }
    x[0] = s;

    FOR(i,1,n-1)
    {
        x[i] = 2*a[i-1] - x[i-1];
    }

    REP(i,n)
    {
        cout << x[i];
        if (i == n-1)
            cout << endl;
        else
            cout << " ";
    }

}


Measured memory_bytes: 2432
def main():
    n = int(input())
    nums = set(range(1, 13 + 1))

    cards = {
        "S": set(),
        "H": set(),
        "C": set(),
        "D": set(),
    }
    for _ in range(n):
        mark, num = input().split()
        cards[mark].add(int(num))

    for mark in ("S", "H", "C", "D"):
        a = nums - cards[mark]
        for num in sorted(list(a)):
            print(mark, num)


if __name__ == "__main__":
    main()

Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main() {
      int n,m,zec[100],j;
      cin >>n>>m;
      for(int i=1;i<=n;i++)cin>>zec[i];
      for(int i=1;i<=m;i++)for(j=1;j<n;j++)if(zec[j]%i>zec[j+1]%i)swap(zec[j+1],zec[j]);
      for(int i=1;i<=n;i++)cout<<zec[i]<<endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[100]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int f=0;
    int g=0;
    if((n%2)==0){
        for(int i=0;i<n;i++){
            if((i%2)==0){
                g+=a[i];
            }else{
                f+=a[i];
            }
        }
    }else{
        for(int i=0;i<n;i++){
            if((i%2)==0){
                f+=a[i];
            }else{
                g+=a[i];
            }
        }
    }
    int ans=f-g;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		

		int a = scan.nextInt();
		int b = scan.nextInt();

		String str = a == b ? "a == b" : a > b ? "a > b" : "a < b";
		
		System.out.println(str);
		
		scan.close();

	}

}

Measured memory_bytes: 17228
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#include <iomanip>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	ll sum = 0;
	for (int i = 0; i < (1 << (n - 1)); i++) {
		vector <int> v;
		for (int j = 0; j < n - 1; j++) {
			if (i & (1 << j)) {
				v.push_back(j + 1);
			}
		}
		v.push_back(n);
		int l = 0;
		for (auto g : v) {
			ll val = 0;
			while(l < g) {
				val = val * 10 + (s[l] - '0');
				l++;
			}
			sum += val;
		}	
	}
	cout << sum;
}
		


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using std::vector;
int head = -1, tail = -1;
int N = -1;
int keep[300005];

void getPrevious(int k){
    if(keep[tail]==1){
        tail--;
    }
    else{
        keep[tail]--;
        for(int i = tail+1; i <= N; i++) keep[i] = k;
        tail = N;
    }
}

void getMiddle(int n,int k){
    //printf("n = %d, k = %d\n",n,k);
    if(n!=0){
        getMiddle(n-1,k);
        keep[--head] = k/2+1;
        if(n%2) getPrevious(k);
    }
    else{
        head = N+1, tail = N;
    }
}

int main(){
    int k,n;
    scanf("%d%d",&k,&n);
    if(k%2==0){
        printf("%d ",k/2);
        for(int i = 2; i <= n; i++) printf("%d ",k);
        printf("\n");
    }
    else{
        N = n;
        getMiddle(n-1,k);
        keep[--head] = k/2+1;
        for(int i = head; i <= tail; i++) printf("%d ",keep[i]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 12876
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;

    bool can = true;
    for (int i = 1; i < s.size()+1; i++) {
        if (i % 2 == 1 && s[i-1] == 'L') can = false;
        if (i % 2 == 0 && s[i-1] == 'R') can = false;
    }

    cout << ((can) ? "Yes" : "No" )<< endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	string s; cin >> s;
	string ans = "keyence";
	if (s == ans) {
		cout << "YES" << endl;
		return 0;
	}
	int n = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; i + j < n; j++) {
			string t = s.substr(0, i) + s.substr(i + j + 1, n);
			//cout << t << endl;
			if (ans == t) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


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

typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n;cin>>n;
    cout<<(n*(n-1))/2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<iomanip>
using namespace std;

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

    if((A==1&&B==2)||(A==2&&B==1)) cout<<3<<endl;
    if((A==2&&B==3)||(A==3&&B==2)) cout<<1<<endl;
    if((A==3&&B==1)||(A==1&&B==3)) cout<<2<<endl;
}

Measured memory_bytes: 256
import math
#####sorting a dictionary#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
def is_prime(n,k):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            res=i
            break
    return res
def inp():
    ls=list(map(int,input().split()))
    return ls
t=int(input())
s=input()
if len(s)<=t:
    print(s)
else:
    print(s[0:t]+"...")


Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	if (a == b && b == c)cout << "Yes" << endl;
	else cout << "No" << endl;
	ggr
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int H,W;
vector<string> s;

int x(int a){
  return a*a;
}

int bfs2D(int sh, int sw){
  vvi dist(H,vi(W,-1));
  queue<pii> q;
  int res = -1;

  if(s[sh][sw] == '#') return res;

  dist[sh][sw] = 0;
  q.push(pii(sh,sw));

  while(!q.empty()){
    int h = q.front().first;
    int w = q.front().second;
    q.pop();

    rep(dir,4) {
      int nh = h + dh[dir];
      int nw = w + dw[dir];
      if(nh < 0 || nh == H || nw < 0 || nw == W) continue;
      if(s[nh][nw] == '#' || dist[nh][nw] != -1) continue;
      dist[nh][nw] = dist[h][w] + 1;
      chmax(res,dist[nh][nw]);
      q.push(pii(nh,nw));
    }
  }

  return res;
}

int main(){
  cin >> H >> W;
  s.resize(H);
  rep(i,H) cin >> s[i];

  int ans = 0;
  rep(h,H) rep(w,W) {
    chmax(ans, bfs2D(h,w));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
bool isPrime(ll a)
{
  ll count=0,i;
  rep(i,2,a/2+1)
    if(a%i==0) count++;
    if(count) return false;
    else return true;
}
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a;
  ll ar[n+1]={0},br[n+1]={0};
 while(a--)
 {
   cin>>n>>s;
   if(ar[n]==0 && s=="WA")
   br[n]++;
   else if(ar[n]==0 && s=="AC")
   {
     ar[n]=1;k++;m+=br[n];
   }
 }
 cout<<k<<" "<<m;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 5132
N, K = map(int, input().split())
a = [int(i) for i in input().split()]

s = [0] + a[::]
t = [0] + [a[i] if a[i] > 0 else 0 for i in range(N)]

for i in range(1, N + 1) :
    s[i] += s[i-1]
    t[i] += t[i-1]

ret = -float('inf')
for i in range(1, N - K + 2) :
    ret = max(ret, t[N] - t[i+K-1] + t[i-1] + max(0, s[i+K-1] - s[i-1]))
print(ret)

Measured memory_bytes: 72224
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::map<lint,lint>map;
    while(n--){
        lint x;std::cin>>x;
        map[x]++;
    }
    lint ans=0;
    for(auto&&p:map)ans+=p.second%2;
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 6528
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, ll> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 2010;
const int MAXM = 10010;
const int MAXK = 110;
const int MAXQ = 200010;

ld pi = acos(-1);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, x;
    cin >> a >> b >> x;
    ld k = 2.0 * x / a / a - b;
    ld angle = 0;
    if (k < 0) {
        k = 2.0 * x / a / b;
        angle = atan(k / b);
    }
    else {
        angle = atan(a / (b - k));
    }

    angle = pi / 2 - angle;
    cout << fixed << setprecision(9) << angle / pi * 180;

    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define M int(1e9+7)
#define endl '\n'
#define largest(a,b,c) (a>b?(a>c? a:c):(b>c? b:c))
#define smallest(a,b,c) (a<b?(a<c? a:c):(b<c? b:c))

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;



int main() {
	fast_io; cout_precision;
	int n;	cin >> n;
	ll arr[n];
	for(int i=0; i<n; i++)	cin >> arr[i];
	ll res = 0;
	ll sum = 0;
	for(int i=0; i<n; i++){
		sum += arr[i];
	}
	ll curr = 0;
	for(int i=0; i<n; i++){
		curr += arr[i];
		res = (res%M +((arr[i]%M)*((sum-curr)%M))%M)%M;
	}
	cout << res%M<<endl;

	return 0;
}


Measured memory_bytes: 5216
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}


#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, BTreeMap, HashMap, HashSet};
#[allow(unused_imports)]
// use std::collections::btree_map::Entry::*;
#[allow(unused_imports)]
use std::collections::hash_map::Entry::*;

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! print { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! println { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }

    let s = readl!(String).into_bytes();
    let k = readl!(usize);
    // let mut dp = vec![vec![vec![None; k+1]; s.len()]; s.len()];
    let mut dp = HashMap::new();
    struct Env<'a> {dp: &'a mut HashMap<(isize, isize, usize), i32>, s: &'a Vec<u8>, }
    fn rec(env: &mut Env, l: isize, r: isize, k: usize) -> i32 {
        if let Some(v) = env.dp.get(&(l, r, k)) {
            return *v;
        }
        if l >= r {
            if l == r {
                1
            } else {
                0
            }
        } else {
            let mut res = 0;
            res = max(rec(env, l+1, r, k), res);
            res = max(rec(env, l, r-1, k), res);
            if env.s[l as usize] == env.s[r as usize] {
                res = max(rec(env, l+1, r-1, k)+2, res);
            } else if k != 0 {
                res = max(rec(env, l+1, r-1, k-1)+2, res);
            }
            env.dp.insert((l, r, k), res);
            // env.dp[l as usize][r as usize][k] = Some(res);
            res
        }
    }
    println!("{}", rec(&mut Env{dp: &mut dp, s: &s}, 0, s.len() as isize-1, k));
}


Measured memory_bytes: 249612
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FSugoroku {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M;
        in>>N>>M;
        string S;
        in>>S;
        vc<int> A;
        REP(i, N+1){
            if(S[i]=='0') A.pb(i);
        }
        vvc<pii> G(N+1);
        REP(i, N) G[i].eb(i+1, 0);
        RREP(i, N){
            if(S[i]=='1') continue;
            int id = lower_bound(ALL(A), i-M) - A.begin();
            if(A[id]<i) G[i].eb(A[id], 1);
        }

        const int INF = ten(9);
        vc<int> dist(N+1, INF);

        auto bfs = [&](){
            deque<pii> deq;
            deq.emplace_back(N, 0);
            while(not deq.empty()){
                int now = deq.front().first;
                int d = deq.front().second;
                deq.pop_front();
                if(dist[now]<=d) continue;
                dist[now] = d;
                for(auto& to : G[now]){
                    if(dist[to.first]<INF) continue;
                    if(to.second) deq.emplace_back(to.first, d+1);
                    else deq.emplace_front(to.first, d);
                }
            }
        };

        bfs();

        if(dist[0]==INF){
            out<<"-1\n";
            return;
        }
        vvc<int> X(N+1);
        RREP(i, N){
            X[dist[i]].pb(i);
        }
        vc<int> ans;
        {
            int now = 0, d = dist[0];
            while(now<N){
                sort(ALL(X[d-1]));
                int nxt = *upper_bound(ALL(X[d-1]), now);
                ans.pb(nxt-now);
                now = nxt;
                --d;
            }
        }
        for(auto& a : ans) out<<a<<' ';
        out<<'\n';
    }
};


int main() {
	FSugoroku solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 15784
#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);
int T,X;
cin>>T>>X;
cout<<T/(double)X<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
const int num = 16, ud[] = { -1, 0, 0, 1 }, lr[] = { 0, 1, -1, 0 }, nd = 4;
int md[num][num];
struct puzzle {
	int sp, p[num], mdp, cost;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
struct state {
	puzzle pu;
	int es;
	bool operator < (const state &s) const {
		//return pu.mdp + pu.cost > s.pu.mdp + s.pu.cost;
		return es > s.es;
	}
};
int astar(puzzle pz) {
	priority_queue<state> pq;
	int sum = 0;
	for (int i = 0; i < num; i++) {
		if (pz.p[i] == num) continue;
		sum += md[i][pz.p[i] - 1];
	}
	pz.mdp = sum;
	pz.cost = 0;
	map<puzzle, bool> m;
	puzzle u, v;
	state initial;
	initial.pu = pz;
	initial.es = pz.mdp;
	pq.push(initial);
	while (!pq.empty()) {
		state st = pq.top(); pq.pop();
		u = st.pu;
		if (!u.mdp) return u.cost;
		m[u] = true;
		int sx = u.sp / nd;
		int sy = u.sp % nd;
		for (int r = 0; r < nd; r++) {
			int tx = sx + ud[r];
			int ty = sy + lr[r];
			if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
			v = u;
			//v.mdp = p.mdp - md[tx * nd + ty][tmp.p[tx * nd + ty] - 1] + md[sx*nd + sy][tmp.p[tx * nd + ty] - 1];
			v.mdp -= md[tx * nd + ty][v.p[tx * nd + ty] - 1];
			v.mdp += md[sx*nd + sy][v.p[tx * nd + ty] - 1];
			swap(v.p[sx * nd + sy], v.p[tx * nd + ty]);
			v.sp = tx * nd + ty;
			if (!m[v]) {
				v.cost++;
				state news;
				news.pu = v;
				news.es = v.cost + v.mdp;
				pq.push(news);
			}
		}
	}
	return -1;
}

int main() {
	puzzle in;
	for (int i = 0; i < num; i++)
		for (int j = 0; j < num; j++)
			md[i][j] = abs(i / nd - j / nd) + abs(i%nd - j%nd);
	for (int i = 0; i < num; i++) {
		cin >> in.p[i];
		if (!in.p[i]) { in.sp = i;  in.p[i] = num; }
	}
	cout << astar(in) << endl;
	return 0;
}

Measured memory_bytes: 253524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

int main()
{
    long long n;
    scanf("%lld", &n);
    std::vector<long long> a(n);

    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        a[i] = x;
    }

    ll cost1 = 0;
    ll cost2 = 0;
    ll sum = 0;
    for(size_t i = 0; i < n; i++)
    {
        sum += a[i];
        if(i % 2 ==0){
            if(sum <= 0){
                cost1 += (1-sum);
                sum = 1;
            }
        }else{
            if(0 <= sum){
                cost1 += (sum+1);
                sum = -1;
            }
        }
    }
    
    sum = 0;
    for(size_t i = 0; i < n; i++)
    {
        sum += a[i];
        if(i % 2 == 0){
            if(0 <= sum){
                cost2 += (sum+1);
                sum = -1;
            }
        }else{
            if(sum <= 0){
                cost2 += (1-sum);
                sum = 1;
            }
        }
    }
    
    cout << min(cost1, cost2) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
//const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)

string al = "abcdefghijk";

void dfs(ll rem,string s,ll kind){
    if (rem==0){
        cout << s << endl;
        return;
    }
    rep(i,kind + 1){
        if(i<kind){
            dfs(rem - 1, s + al[i], kind);
        }else{
            dfs(rem - 1, s + al[i], kind + 1);
        }
    }
    return;
}

int main(){
    ll N; cin >> N;
    dfs(N-1,"a",1);
    return 0;
}

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

public class Main {
	int n;
	int[] a;
	void run() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();
		System.out.println(dfs(1, 0));
	}
	int dfs(int num, int depth) {
		if (depth == n) {
			if (num % 2 == 0)
				return 1;
			else
				return 0;
		}
		return dfs(num * a[depth],     depth + 1)
			 + dfs(num * (a[depth] + 1), depth + 1)
			 + dfs(num * (a[depth] - 1), depth + 1);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long X,x[2<<17],s[4<<17];
long ans=9e18;
main()
{
	cin>>n>>X;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<n;i++)s[i+1]=s[i]+x[n-i-1];
	for(int i=n;i<n+n;i++)s[i+1]=s[i];
	for(int k=1;k<=n;k++)
	{
		long now=(n+k)*X;
		for(int i=0;i<n;i+=k)
		{
			now+=(s[i+k]-s[i])*(i/k==0?5:i/k*2+3);
		}
		ans=min(ans,now<0?ans:now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6400
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

const int MAX_N = 3e2 + 6;
int n;
int cnt[4];
double dp[MAX_N][MAX_N][MAX_N];
double res1, res2, res3, tmp;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	for (int k = 0; k + 1 < MAX_N; k++)
		for (int j = 0; j + 1 < MAX_N; j++)
			for (int i = (!k && !j? 1: 0); i + 1 < MAX_N; i++) {
				res1 = (i? 1.0 * i / n * dp[i - 1][j][k]: 0);
				res2 = (j? 1.0 * j / n * dp[i + 1][j - 1][k]: 0);
				res3 = (k? 1.0 * k / n * dp[i][j + 1][k - 1]: 0);
				tmp = res1 + res2 + res3 + 1.0;
				tmp *= n;
				tmp /= i + j + k;
				dp[i][j][k] = tmp;
			}

	cout << fixed << setprecision(20) << dp[cnt[1]][cnt[2]][cnt[3]];
	return 0;
}

Measured memory_bytes: 223488
import math
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start

s = str_single()

cycles = []

temp = []
rs = 0
ls = 0
for i in range(len(s)):
    if s[i] == 'R':
        if ls == 0:
            rs += 1
        else:
            cycles.append([rs,ls])
            rs = 1
            ls = 0
    else:
        ls += 1

cycles.append([rs, ls])


res_str = ""
for cycle in cycles:
    rs, ls = cycle
    temp = [0] * (rs + ls)

    onrs = math.ceil(rs / 2) + (ls - math.ceil(ls / 2))
    onls = math.ceil(ls / 2) + (rs - math.ceil(rs / 2))

    res_str += ("0 " * (rs - 1)) + str(onrs) + " " + str(onls) + " " + ("0 " * (ls - 1))

print(res_str[:-1])


Measured memory_bytes: 8948
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int inf=1e9;
const int N=200005;

/*inline void normal(ll &a){if(a>mod) a%=mod; (a<0) && (a+=mod);}
inline ll mod_mul(ll a,ll b){normal(a),normal(b); return (a*b)%mod;}
inline ll mod_add(ll a,ll b){normal(a),normal(b); return (a+b)%mod;}
inline ll mod_sub(ll a,ll b){normal(a),normal(b); a-=b; normal(a); return a;}
inline ll mod_pow(ll a,ll b){ll r=1; while(b>0){if(b&1)r=mod_mul(r,a); a=mod_mul(a,a); b>>=1;} return r;}
inline ll mod_inverse(ll a){return mod_pow(a,mod-2);}
inline ll mod_div(ll a,ll b){return mod_mul(a,mod_inverse(b));}*/


int main()
{
    int n;
    cin>>n;
    if(!n)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3620