akhauriyash/Code-Regression huggingface dataset:
def insertSort(A,n,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt +=1
        A[j+g] = v

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
cnt = 0
g = []
h = 1
while 1:
    g.append(h)
    h = 3*h+1
    if h > N:
        break
m = len(g)
for i in range(m-1,-1,-1):
    insertSort(A,N,g[i])
print(m)
g.reverse()
print(*g)
print(cnt)
for i in range(N):
    print(A[i])



Measured memory_bytes: 45512
def s(n)
  ret=0
  while n>0
    ret+=n%10
    n/=10
  end
  ret
end
k=[*1..9]
1.upto(9){|i|k<<10*i+9}
2.upto(9){|i|
  d=10**i
  nnn=d-1
  100.times{|j|
    k<<j*d+nnn
  }
}
10.upto(16){|i|
  d=10**i
  nnn=d-1 
  1000.times{|j|
    k<<j*d+nnn
  } 
}
k.sort!
k.uniq!
min=10**18
ans=[]
k.reverse.each{|a|
  f=a.to_f/s(a)
  if f<=min
    min=f
    ans<<a
  end
}

n=gets.to_i
puts ans.reverse.take(n)



Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, M;
  cin >> N >> M;
  VEC<pair<LL, LL>> E(N);
  REP(i, 0, N) { cin >> E[i].first >> E[i].second; }
  sort(E.begin(), E.end());
  int rem = M;
  LL mon = 0;
  int i = 0;
  while (rem > 0) {
    REP(j, 0, E[i].second) {
      rem--;
      mon += E[i].first;
      if (rem <= 0) break;
    }
    ++i;
  }
  cout<<mon<<endl;

  return 0;
}


Measured memory_bytes: 1792
s=input()
s_=list(s)
S=list(enumerate(s))
num=len(S)
empty=[]
for x,y in S:
    if (x%2==0 and (y=='R' or y=='U' or y=='D')) or (x%2==1 and (y=='L' or y=='U' or y=='D')):
        empty.append(y)
if empty==s_:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <numeric>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
    int a,b;cin>>a>>b;
    if(a>b)cout<<a-1;
    else cout<<a;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <queue>
using namespace std;

int *d;
int *k;
int **a;

void bfs(){
    int i, v, u;
    queue<int> q;
    q.push(1);
    d[1] = 0;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(i=0;i<k[u];i++){
            v = a[u][i];
            if(d[v]<0){
                q.push(v);
                d[v] = d[u] + 1;
            }
        }
    }
}

int main(){
    int i, j, n, u, v;
    scanf("%d",&n);
    d = (int *)malloc(sizeof(int)*(n+1));
    k = (int *)malloc(sizeof(int)*(n+1));
    a = (int **)malloc(sizeof(int *)*(n+1));
    for(i=0;i<=n;i++)d[i] = -1;

    for(i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",k+u);
        a[u] = (int *)malloc(sizeof(int)*k[u]);
        for(j=0;j<k[u];j++){
            scanf("%d",&v);
            a[u][j] = v;
        }
    }

    bfs();

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

    return 0;
}



Measured memory_bytes: 2748
def answer_143d():    
    n = int(input())
    ls = list(map(int,input().split()))

    ls.sort()
    ans = 0

    for i in range(n-1, 0, -1):
        l = 0
        r = i - 1

        while l < r:
            if ls[l] + ls[r] > ls[i]:
                ans += r - l
                r -= 1
            else:
                l += 1
    print(ans)

if __name__ == '__main__':
    answer_143d()

Measured memory_bytes: 3188
# coding: utf-8
# 51

while True:
    n = int(input())
    if n==0:
        break
    c = [int(input()) for i in range(n)]
    m =max(c)
    #print(m)
    k = int(0)
    A = '*'
    for i in range(m+1):
        k = c.count(i)
        if k==0:
            print('-')
        else:
            print(A*k)
        
    


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

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

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n>>k;
    	vi v(k+1,0);
    	ll ans=0;
    	for(i=k;i>=1;i--)
    	{
    		ll x=(k/i);
    		ll y=expo(x,n,hell);
    		for(j=i;j<=k;j+=i)
    			y=(y-v[j]+hell)%hell;
    		v[i]=y;
    		ans=(ans+y*i)%hell;
    	}
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int x;
	for(int i = 0; i < 5; i++){
		cin >> x;
		if(x == 0)cout << i+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3600
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
      primes(i) = primes(i) + primes(i-1)
      primes(i+1) = primes(i+1) + primes(i)
    }

    for(i<-Math.sqrt(n).toInt+1 to n)
      primes(i) = primes(i)+primes(i-1)

    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000000)
    println{
       { for(i <- stdin.getLines) yield p(i.toInt) }.mkString("\n")
    }
  }
}

Measured memory_bytes: 63692
from collections import defaultdict


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]

    lens = defaultdict(int)

    for x in xs:
        lens[x] += 1

    max_a = 0
    max_b = 0

    sides = sorted(
        [(length, num) for length, num in lens.items() if num >= 2],
        reverse=True,
    )

    if len(sides) >= 1 and sides[0][1] >= 4:
        max_a = sides[0][0]
        max_b = max_a
    elif len(sides) >= 2:
        max_a = sides[0][0]
        max_b = sides[1][0]

    print(max_a * max_b)


if __name__ == "__main__":
    main()



Measured memory_bytes: 68760
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define Mod 998244353

using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double pi=acos(-1);
    double min=m*6;
    double hr=h*30+m/2;
    double deg=fabs(min-hr);
    if(deg>180)
    deg=360-deg;
    double val=pi/180.0;
    double res=cos(val*deg);
//    cout<<deg;
    double ans=sqrt(a*a+b*b-res*2*a*b);
    cout<<fixed<<setprecision(20)<<ans;
}

Measured memory_bytes: 4224
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static long ans=0;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        int[][] ans = new int[H][W];
        int row=0,col=0;
        int flag=1;
        for(int i=0;i<n;i++){
            int cnt = a[i];
            for(int j=0;j<cnt;j++){
                if(col==-1||col==W){
                    col = col==-1?0:W-1;
                    row++;
                    flag=flag*(-1);
                }
                ans[row][col] = i+1;
                col += flag;
            }
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W-1;j++){
                System.out.print(Integer.toString(ans[i][j])+" ");
            }
            System.out.println(ans[i][W-1]);
        }
    }
}


Measured memory_bytes: 33000
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)


using namespace std;
typedef long long ll;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find {
	vector<int> par, r;

	union_find(int n) {
		par.resize(n);
		r.resize(n);
		for (int i = 0; i < n; i++) par[i] = i, r[i] = 0;
	}

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

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

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

int main()
{
	int n, k, l;
	cin >> n >> k >> l;

	union_find road(n), train(n);
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		road.unite(a, b);
	}
	for (int i = 0; i < l; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		train.unite(a, b);
	}

	vector<pair<int, int> > com(n);
	map<pair<int, int>, int> s;
	for (int i = 0; i < n; i++) {
		com[i].first = road.find(i);
		com[i].second = train.find(i);
		s[com[i]]++;
	}

	for (int i = 0; i < n; i++) {
		cout << s[com[i]] << " ";
	}printf("\n");

		return 0;
}

Measured memory_bytes: 16640
using System;
using System.Collections.Generic;

class ABC_131_D
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        long allTask = 0;
        List<Pair> task = new List<Pair>();
        for (int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            allTask += A;
            task.Add(new Pair(A, B));
        }

        task.Sort((a, b) => a.B - b.B);

        long time = 0;

        for (int i = 0; i < N; i++)
        {
            time += task[i].A;
            if (time > task[i].B)
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }

    class Pair
    {
        public Pair(int a, int b)
        {
            A = a;
            B = b;
        }
        public int A;
        public int B;
    }

}


Measured memory_bytes: 27556
#include <iostream>
using namespace std;
const int N = 200005;
bool s[N], t[N];
int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int u, v;
		cin >> u >> v;
		if (u == 1)
			s[v] = true;
		if (v == n)
			t[u] = true;
	}
	for (int i = 2; i < n; i++)
		if (s[i] && t[i])
		{
			cout << "POSSIBLE\n";
			return 0;
		}
	cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  cin >> n;
  vl a(n),b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n%2==1){
    cout << b[(n-1)/2]-a[(n-1)/2]+1 << endl;
  }
  else{
    cout << (b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1])+1 << endl;
  }
}

Measured memory_bytes: 6364
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int asum = 0;
			int bsum = 0;
			while (n-- > 0) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				if (a > b)
					asum += a + b;
				else if (a < b)
					bsum += a + b;
				else {
					asum += a;
					bsum += b;
				}
			}
			System.out.println(asum + " " + bsum);
		}

	}
}

Measured memory_bytes: 51712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

int main() {
  char b;
  cin >> b;
  
  char ans;
  if(b == 'A') ans = 'T';
  if(b == 'C') ans = 'G';
  if(b == 'G') ans = 'C';
  if(b == 'T') ans = 'A';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B, C, K;
  cin>>A>>B>>C>>K;
  for(int i=0;i<K;++i) {
    if(A>=B) {
      B*=2;
      continue;
    }
    if(B>=C) {
      C*=2;
      continue;
    }
  }
  if(A<B && B<C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3628
from collections import defaultdict

children = defaultdict(list)
parent = defaultdict(list)
le = []

N = int(input())
for _ in range(N - 1):
    ai, bi = list(map(int, input().split()))
    le.append((ai, bi))
    children[ai].append(bi)
    parent[bi].append(ai)

# print(children)
# print(parent)

K = -1
degree = {}
for n in range(1, N + 1):
    knp = 0 if n not in parent else len(parent[n])
    knc = 0 if n not in children else len(children[n])
    # print(n, knp + knc)
    degree[n] = knp + knc
    K = max(K, knp + knc)

print(K)


root = 1
color = {}
queue = []

# init
for idx, v in enumerate(children[root]):
    color[root, v] = idx + 1
    queue.append((v, idx + 1))

while queue:
    u, pc = queue.pop()
    new_color = 1
    for idx, v in enumerate(children[u]):
        if new_color == pc:
            new_color += 1
        # print(u, pc, idx, v, new_color)
        color[u, v] = new_color
        queue.append((v, new_color))
        new_color += 1

# print(color)
for edge in le:
    print(color[edge])

Measured memory_bytes: 124884
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;




P dequeue(){
  P x;
  x = Q [head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){return a<b ? a : b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  P x;
  scanf("%d %d", &n, &q);
  for( i = 1;i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if( u.t > 0 ){
      {
        Q[tail] = u;
        tail = (tail + 1) % LEN;
      }
    }
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}



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

using namespace std;

int main()
{
    long long int i,n,s,ss,p,j,k,v[110];

    scanf("%lld",&n);

        s=0;
        for(i=0;i<n;i++)
    {
        scanf("%lld",&v[i]);

    }
    for(k=0;k<n;k++)
                {
                    printf("%lld",v[k]);
                    if(k!=n-1)
                        printf(" ");
                }
                printf("\n");
    for(i=1;i<n;i++)
        {
            ss=v[i];
            for(j=i-1;j>=0&&v[j]>ss;j--)

                {
                    v[j+1]=v[j];

                }
                v[j+1]=ss;
                for(k=0;k<n;k++)
                {
                    printf("%lld",v[k]);
                    if(k!=n-1)
                        printf(" ");
                }
                printf("\n");



        }

    return 0;
}

Measured memory_bytes: 3184
/*Lucky_Glass*/
#include<bits/stdc++.h>
using namespace std;
string A,B;
int totA[26],totB[26];
int main(){
	cin>>A>>B;
	for(int i=0;i<A.length();i++)
		totA[A[i]-'a']++;
	for(int i=0;i<B.length();i++)
		totB[B[i]-'a']++;
	sort(totA,totA+26);
	sort(totB,totB+26);
	for(int i=0;i<26;i++)
		if(totA[i]!=totB[i]){
			printf("No\n");
			return 0;
		}
	printf("Yes");
	return 0;
}//

Measured memory_bytes: 776
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main(){
  int[] a;
  a = new int[](10);
  
  foreach(i; 0..10){
    a[i] = readln().chomp().to!int();
  }

  sort!("a > b")(a);

  foreach(i; 0..3){
    writeln(a[i]);
  }
}

Measured memory_bytes: 2416
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeu(int n){
		if(n<10)
			putchar(n+'0');
		else{
			writeu(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		int result=0;
		int prev=-1;
		while(--n!=-1){
			int cur=readu();
			if(prev==cur){
				++result;
				cur=-1;
			}
			prev=cur;
		}
		writeu(result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = 0

for i in range(2 ** (n-1)):
    d = [0, n]
    for j in range(n-1):
        if ((i >> j) & 1):
            d.append(j+1)
    d.sort()
    for i in range(len(d)-1):
        ans += int(s[d[i]:d[i+1]])

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>=b){
printf("No\n");
}
else if(b>=c){
printf("No\n");
}
else{
printf("Yes\n");
}
return 0;
}

Measured memory_bytes: 580
import sys
S=input()
S_seq=[]
for i in S:
    S_seq.append(i)
if(len(S_seq)==1):
    print(int(S))
    sys.exit()
separate=[]
for i in range(len(S_seq)-1):
    a=[]
    if(i==0):
        a.append("*")
        a.append("_")
    else:
        for j in separate:
            a.append(j+"*")
            a.append(j+"_")
    separate=a

separated=[]
for i in separate:
    a=[]
    for j in i:
        a.append(j)
    separated.append(a)

pre_calculated=[]
for i in separated:
    a=[]
    for j in range(len(S_seq)-1):
        a.append(S_seq[j])
        if(i[j]=="*"):
            a.append("+")
        elif(i[j]=="_"):
            continue
    a.append(S_seq[-1])
    pre_calculated.append(a)

sumation=0
for i in pre_calculated:
    number=[]
    for j in range(len(i)):
        new_number=[]
        if(j==len(i)-1):
            for k in number:
                sumation+=k*10
            sumation+=int(i[j])
        elif(i[j]=="+"):
            for k in number:
                sumation+=k
            number=[]
        else:
            for k in number:
                new_number.append(k*10)
            new_number.append(int(i[j]))
        
        number=new_number
print(sumation)

    


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int h,w,k,ans = 0;
    cin>>h>>w>>k;
    vector<string>maze(h);
    rep(i,h)cin>>maze[i];

    int bit_all = pow(2,(h + w));
    rep(i,bit_all){
        vector<string>m = maze;
        int bit_ptr = 0,cnt = 0;
        rep(j,h){
            if(i & (1LL << bit_ptr)){
                rep(l,w){
                    m[j][l] = 'x';
                }
            }
            bit_ptr++;
        }
        rep(j,w){
            if(i & (1LL << bit_ptr)){
                rep(l,h){
                    m[l][j] = 'x';
                }
            }
            bit_ptr++;
        }
        rep(j,h)rep(l,w)if(m[j][l] == '#')cnt++;
        if(cnt == k)ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4020
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY 1000000000

int H,A[MAX+1];

void maxHeapify(int i){
    int l = 2 * i;
    int r = 2 * i  +1;
    int largest,t;
    
    // 左の子、自分、右の子で値が最大のノードを選ぶ
    if(l<=H && A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest]) largest=r;
    
    if(largest != i){
        t=A[i];
        A[i]=A[largest];
        A[largest]=t;
        maxHeapify(largest);
    }
}


int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv = A[1];
    A[1]=A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if ( key < A[i] ) return;
    int tmp;
     A[i] = key;
    while ( i > 1 && A[i / 2] < A[i] ) {
        tmp = A[i];
        A[i]=A[i/2];
        A[i/2]=tmp;
       
        i = i / 2;
         }
     }

void insert(int key) {
  H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
int key;
 char com[10];

 while ( 1 ) {
     scanf("%s", com);
     if ( com[0] == 'e' && com[1] == 'n' ) break;
     if ( com[0] == 'i' ) {
         scanf("%d",&key);
         insert(key);
     }else{
         printf("%d\n",extract());
     }
 }
    return 0;
}
   


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

main()
{	
	#ifndef ONLINE_JUDGE
//		freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
//		freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
	#endif
	
	clock_t clk = clock();
	
	int n;
	cin >> n;
	int m = n, s = 0;
	
	while(m) {
		s += m % 10;
		m /= 10;
	}
	
	cout << (n % s? "No" : "Yes") << '\n';
	
	cerr << double(clock() - clk) * 1000.0 / cps << '\n';
}








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


inline long long read()
{
	long long s=0,f=1; char ch;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+ch-'0';
	return s*f;
}
int main()
{
	int N,d[100],sum=0;
	cin>>N;
	for(int i=1;i<=N;++i) cin>>d[i];
	for(int i=1;i<=N;++i) for(int j=i+1;j<=N;++j) sum+=d[i]*d[j];
	cout<<sum<<endl;
}

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

using namespace std;

string intToBinStr(int i, int digit)
{
	string str;
	while (i > 0)
	{
		str.push_back('0' + (i & 1));
		i >>= 1;
	}
	reverse(str.begin(), str.end());
	while (str.size() < digit)
	{
		str.insert(0, "0");
	}
	return str;
}

int ctoi(char ch)
{
	if ('0' <= ch && ch <= '9')
	{
		return (int)(ch - '0');
	}
	else
	{
		return 0;
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int q;
	cin >> q;
	vector<int> m(q);
	vector<bool> can_make(q, false);
	for (int i = 0; i < q; i++)
	{
		cin >> m[i];
	}
	string mask;
	for (int i = 1; i < pow(2, n); i++)
	{
		sum = 0;
		mask = intToBinStr(i, n);
		for (int j = 0; j < n; j++)
		{
			sum += ctoi(mask[j]) * a[j];
		}
		for (int j = 0; j < q; j++)
		{
			can_make[j] = can_make[j] | (sum == m[j]);
		}
	}
	for (int i = 0; i < q; i++)
	{
		if (can_make[i] == true)
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3392
primes = [0, 0] + [1]*9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0
pnums = [i for i in range(10001) if primes[i]]
while True:
    n = int(input())
    if n == 0:
        break
    m = n
    while not primes[m]:
        m -= 1
    ans = 0
    end = pnums.index(m)+1
    for i in range(end):
        tmp = 0
        for j in range(i, end):
            tmp += pnums[j]
            if tmp == n:
                ans += 1
                break
            if tmp > n:
                break
    print(ans)

Measured memory_bytes: 7728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int a,b,c,d;
cin >> a >> b >> c >> d;
if (abs(a-c) <= d)
{
    cout << "Yes" << endl;
}else if (abs(a-b) <= d && abs(b-c) <= d)
{
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
}



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import numpy as np
import sys
if __name__ == "__main__":
    N, K = map(int, input().split())
    A = list(map(int, input().rstrip().split(' ')))
    visit = [False]*N
    a_now = 1
    visit[a_now - 1] = True
    step = 0
    for i in range(N):
        a_now = A[a_now - 1]
        step += 1
        #print(a_now)
        if visit[a_now - 1]:
            break
        else:
            visit[a_now - 1] = True
        if step == K:
            #print("K:")
            print(a_now)
            sys.exit()
    
    self_loop = []
    start = a_now
    for i in range(N):
        a_now = A[a_now - 1]
        step += 1
        self_loop.append(a_now)
        if a_now == start:
            break
        if step == K:
            #print("K:")
            print(a_now)
            sys.exit()
    
    ## self_loop が見つかった場合
    #print("a_now:{}".format(a_now))
    #print("step:{}".format(step))
    #print(self_loop)
    n = len(self_loop)
    left = K-step
    left -= (left // n) * n
    #print(step)
    print(self_loop[left - 1])
    





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

#define REP(i,n) for(int i=0; i<n; i++)
#define DEBUG(x) cerr << #x << ": " << (x) << endl

int main(){
	int l;
	string s;
	cin>>l>>s;
	int ans = 0;
	REP(i,l)if(s[i]=='.'){
		string t = s;
		t[i] = 'W';
		// check
		int x = i, y = i;
		while(x>0 && t[x]=='W')x--;
		while(y+1<l && t[y]=='W')y++;
		if(t[x]=='B' && t[y]=='B')continue;
		// check
		x = i, y = i;
		x--;
		if(x>0 && t[x]=='B'){
			int c = 0;
			while(t[x]=='B')x--,c++;
			if(x>=0 && t[x]=='W')ans=max(ans,c);
		}
		y++;
		if(y+1<l && t[y]=='B'){
			int c = 0;
			while(t[y]=='B')y++,c++;
			if(y<l && t[y]=='W')ans=max(ans,c);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    map<char, int> m;
    int n = s.length();
    REP(i,n) ++ m[s[i]];
    bool ans = ((max({m['a'], m['b'], m['c']}) - min({m['a'], m['b'], m['c']}))<2);
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
grid = [list(map(int, input().split())) for _ in range(3)]

ans = "Yes"

for i in range(2):
    x = grid[0][2] - grid[0][i]
    y = grid[1][2] - grid[1][i]
    z = grid[2][2] - grid[2][i]

    if x != y or x != z:
        ans = "No"
        
print(ans)

Measured memory_bytes: 3064
n=int(input())
def ac():
    for h in range(1,3501):
        for w in range(1,3501):
            try:
                num=(n*h*w)/(4*h*w-n*w-n*h)
                #正整数かどうかの判定
                if (num).is_integer() and num>0:
                    print("{} {} {}".format(h,w,int(num)))
                    return
            except:
                pass
if __name__=="__main__":
    ac()

Measured memory_bytes: 39152
#n + 1 = マスの数
#m = 料金所の数(a)
#x = 最初のマス
n,m,x = map(int,input().split())
#a = 料金所の場所
a = list(map(int,input().split()))

for i in range(m):
    if a[i] > x:
        p = i
        break

#p = xより右か左かを判別
i = p
j = m - p

print(min(i,j))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long int ll;
typedef complex<double> base;
ll mod=998244353;
double eps=1e-9;

ll ans, add;
ll mu[1111111];
ll inv[1111111];
ll sqs[1111111];
ll s[1111111];
ll n, a[222222];
ll val[1111111];
ll cnt[1111111];
bool ispr[1111111];
int C=1050000;

int main(void)
{
	fio; cin>>n; ll i, j; ispr[1]=false; mu[1]=1;
	inv[1]=1;
	for(i=2 ; i<=C ; i++) inv[i]=((mod-mod/i)*inv[mod%i])%mod;
	for(i=1 ; i<=n ; i++) cin>>a[i];
	for(i=1 ; i<=n ; i++) cnt[a[i]]++;
	for(i=2 ; i<=C ; i++) ispr[i]=true, mu[i]=1;
	for(i=2 ; i<=C ; i++)
	{
		if(ispr[i])
		{
			mu[i]=-1;
			for(j=2 ; i*j<=C ; j++)
			{
				ispr[i*j]=false;
				mu[i*j]=-mu[i*j];
				if(j%i==0) mu[i*j]=0;
			}
		}
	}
	for(i=1 ; i<=C ; i++)
		for(j=i ; j<=C ; j+=i) val[j]+=i*mu[i];
	for(i=1 ; i<=C ; i++) val[i]=(val[i]%mod+mod)%mod;
	for(i=1 ; i<=C ; i++)
		for(j=i ; j<=C ; j+=i)
			sqs[i]+=cnt[j]*j*j, s[i]+=cnt[j]*j;
	for(i=1 ; i<=C ; i++) sqs[i]%=mod, s[i]%=mod;
	for(i=1 ; i<=C ; i++)
	{
		add=(s[i]*s[i]-sqs[i]+mod)%mod;
		add=(add*inv[2])%mod;
		add=(add*val[i])%mod;
		add=(add*inv[i])%mod;
		ans+=add;
	}
	cout<<ans%mod; return 0;
}

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

int main() {
  long long N;
  int K;
  cin >> N >> K;
  int a = 0;
  for(int i = 0; i < 1000000000000000; i++) {
    if(std::pow(K,i)<=N && std::pow(K,i+1)>N) {
      a = i+1;
      break;
    }
  }
    
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
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() {
    int N;
    cin >> N;
    ll a[1001000][3];
    REP(i,N) REP(j,3) cin >> a[i][j];
    ll dp[1002000][3];

    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j == k) continue;
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }

    ll ans = 0;
    REP(i,3) chmax(ans,dp[N][i]);
    cout << ans << endl;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	SORT(a);
	vi b;
	b.push_back(1);
	rep2(i,1,n){
		if(a[i]!=a[i-1]) b.push_back(1);
		else b[b.size()-1]++;
	}
	int m = b.size();
	if(m%2) cout << m << endl;
	else cout << m-1 << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define double long double
#define all(x) x.begin(),x.end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	fast_io //REMOVE FOR interactive problems
	int n;
	cin>>n;
	int ls=0;
	lli ans=0;
	forn(i,n)
	{
		int x;
		cin>>x;
		if(ls>x)
		{
			ans+=(lli)(ls-x);
			x=ls;
		}
		ls=x;
	}
	cout<<ans;
}



Measured memory_bytes: 3648
Uses math;
var
	a,b,c,x,y,ans:Longint;
begin
	read(a,b,c,x,y);
	c:=c*2;
	ans:=Min(x,y)*Min(a+b,c);
	if x<y then begin
		dec(y,x);
		x:=0;
	end else begin
		dec(x,y);
		y:=0;
	end;
	inc(ans,x*Min(a,c));
	inc(ans,y*Min(b,c));
	writeln(ans);
end.


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A[2][111];

  std::cin >> N;

  for (int i = 0; i < 2; i ++)
    for (int j = 0; j < N; j ++)
      std::cin >> A[i][j];

  int sp = 0;
  
  for (int i = 0; i < N; i ++) {
    int s = 0;

    for (int j = 0; j <= i; j ++)
      s += A[0][j];

    for (int j = i; j < N; j ++)
      s += A[1][j];

    sp = std::max(s, sp);
  }

  std::cout << sp << std::endl;

  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n, k, c; cin >> n >> k >> c; c++;
    string s; cin >> s;

    int t = 0, last = -MAX * 2;
    vector<int> jun, gyaku;

    while(t < n && jun.size() < k){
        if(s[t] == 'x' || t < last + c){
            t++; continue;
        }
        jun.push_back(t); last = t; t++;
    }

    t = n - 1; last = MAX * 2;
    while(t >= 0 && gyaku.size() < k){
        if(s[t] == 'x' || t > last - c){
            t--; continue;
        }
        gyaku.push_back(t); last = t; t--;
    }
    reverse(all(gyaku));

    rep(i, k){
        if(jun[i] == gyaku[i]){
            out(jun[i]+1);
        }
    }
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long 
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
 
using namespace std;
 
bool compare(ll &x, ll &y){
    return x>=y;
}
ll mode=pow(10,9)+7;


int main(){ 
    
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll n;
	cin>>n;
	ll a[n]={0};
	ll b[n-1];
	for (int i=0;i<n-1;i++){
		 cin>>b[i];
	}
	a[0]=b[0];
	a[1]=b[0];
	for (int i=1;i<n-1;i++){
		a[i+1]=b[i];
		a[i]=min(a[i], b[i]);
	}
	
	ll ans=0;
	for (auto i:a) ans+=i;
	cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=1e5+5;



int main(){
    IOS;
    make(ll,n);
    makevec(ll,a,n);
    ll c1=0; ll c2=0;
    fr(i,n){
        if(a[i]%4==0) c1++;
        if(a[i]%2!=0) c2++;
    }
    if((c1>=c2) || (c1==c2-1 && c1+c2==n)) cout<<"Yes \n";
    else cout<<"No \n";


    return 0;
}


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

int digit(ll n)
{
    int res = 0;
    while (n > 0)
    {
        res++;
        n /= 10;
    }
    return res;
}

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

    ll a = sqrt(N);

    while (N % a != 0)
    {
        a--;
    }

    cout << digit(N / a) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(void) {
  long long n, k;
  scanf(" %lld %lld", &n, &k);
  n=n % k < -n % k + k ? n % k : -n % k + k;
  printf("%lld\n", n);
}


Measured memory_bytes: 128
def dfs():
  stack = [K]
  while len(stack) > 0:
    i = stack.pop()
    for k,v in E[i].items():
      if visited[k]:
        continue
      visited[k] = True
      distd[k] = distd[i] + v
      stack.append(k)

# input
N = int(input())
E = {}

for i in range(N-1):
  a, b, c = map(int, input().split())
  if a in E:
    E[a].setdefault(b,c)
  else:
    E[a] = {b:c}

  if b in E:
    E[b].setdefault(a,c)
  else:
    E[b] = {a:c}

#print(E)

Q, K = map(int, input().split())

# 1-indexedでとる
visited = [False] * (N+1)
distd = [1e15] * (N+1)

visited[K] = True
distd[K] = 0

dfs()

for i in range(Q):
  x, y = map(int, input().split())
  print(distd[x] + distd[y])

Measured memory_bytes: 110040
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let m: i64 = input();
    const MOD: i64 = 1000000007;

    let mut ans = 1;
    if (n - m).abs() > 1 {
        ans = 0;
    } else {
        for i in 1..n + 1 {
            ans *= i;
            ans %= MOD;
        }
        for i in 1..m + 1 {
            ans *= i;
            ans %= MOD;
        }

        if n == m {
            ans *= 2;
            ans %= MOD;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    int S = accumulate(A.begin(), A.end(), 0);
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        if (A[i] * 4 * M >= S) {
            cnt ++;
        }
    }
    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3572