akhauriyash/Code-Regression huggingface dataset:
main = getLine >>= putStrLn . solve . map read . words

solve :: [Int] -> String
solve [x, y] =
	if x == 4 || x == 6 || x == 9 || x == 11 then 
    	(if y == 4 || y == 6 || y == 9 || y == 11 then "Yes" else "No")
    else if x == 2 then
    	(if y == 2 then "Yes" else "No")
    else
    	(if y == 2 || y == 4 || y == 6 || y == 9 || y == 11 then "No" else "Yes")

Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, k, x;
    scanf("%d", &n);
    scanf("%d", &k);
    int ans = 0;
    while(n){
        scanf("%d", &x);
        if(abs(x - k) < x) ans+= abs(x - k) * 2;
        else ans += x * 2;
        n--;
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    queue<long long int> que;
    stack<long long int> st;
    long long int a;
    if(N%2==0) {
        for(int n=0; n<N; n++) {
            cin >> a;
            if(n%2==0) {
                que.push(a);
            } else {
                st.push(a);
            }
        }
    } else {
        for(int n=0; n<N; n++) {
            cin >> a;
            if(n%2==0) {
                st.push(a);
            } else {
                que.push(a);
            }
        }
    }
    
    while(!st.empty()) {
        cout << st.top() << " ";
        st.pop();
    }
    while(!que.empty()) {
        cout << que.front() << " ";
        que.pop();
    }
    cout << endl;

    return 0;
    
}

Measured memory_bytes: 3840
function main()
const lines=readlines()
const N,Q=map(x->parse(Int,x),split(shift!(lines)))
const G=[Int[] for _=1:N]
const C=zeros(Int,N)
for i=2:N
	a,b=map(x->parse(Int,x),split(shift!(lines)))
	push!(G[a],b)
	push!(G[b],a)
end
for i=1:Q
	p,x=map(x->parse(Int,x),split(shift!(lines)))
	C[p]+=x
end
function dfs(u,p)
	for v=G[u]
		if v!=p
			C[v]+=C[u]
			dfs(v,u)
		end
	end
end
dfs(1,0)
println.(C)
end
main()

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

int main()
{
	double a,b,x;
	cin>>a>>b>>x;
	cout << std::setprecision(10) <<fixed;
	if(2*x>=a*a*b)
		cout<<90.0 - 180*atan(0.5*a/(b-x/(a*a)))/M_PI;
	else cout<<90.0 - 180*atan(2*x/(a*b*b))/M_PI;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] str = new String[N];
		for(int i =0;i<N;i++) {
			str[i]=sc.next();
		}

	     List<String> listA = new ArrayList<String>(Arrays.asList(str));
	     List<String> listB = new ArrayList<String>(new HashSet<>(listA));

	    if(listA.size()==listB.size()) {
	    	System.out.println("YES");
	    }else {
	    	System.out.println("NO");
	    }
	}
}

Measured memory_bytes: 72584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long r = sc.nextInt();
		sc.close();

		long result;
		if (n >= 10) {
			result = r;
		}else {
			result = r + 100 * (10 - n);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int bitcnt(long bits){
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> grid(H, vector<char>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> grid[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) grid[i][j] -= '0';
	
	int ans = INF;
	for (int bit = 0b0; bit < (1 << (H - 1)); bit++) {

		int cnt = bitcnt(bit);

		vector<int> id(H);
		for (int i = 0; i < H - 1; i++) {
			if (bit & (1 << i)) id[i + 1] = id[i] + 1;
			else id[i + 1] = id[i];
		}

		vector<int> sum(H);
		for (int w = 0; w < W; w++) {

			bool reset = false;

			for (int h = 0; h < H; h++) {

				sum[id[h]] += grid[h][w];

				if (sum[id[h]] > K) {
					if (reset) {
						cnt = w = h = INF;
					}
					else {
						reset = true;
						cnt++;
						fill(sum.begin(), sum.end(), 0);
						h = -1;
					}
				}

			}
		}

		chmin(ans, cnt);

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int t1,t2,r1,r2;
    cin >> t1 >> t2 >> r1 >> r2;
    if(r1 == -1 || r2 == -1){
        if(t1 < t2){
            cout << "Alice" << endl;
        }else if(t1 > t2){
            cout << "Bob" << endl;
        }else{
            cout << "Draw" << endl;
        }
    }else{
        if(r1 > r2){
            cout << "Alice" << endl;
        }else if(r1 < r2){
            cout << "Bob" << endl;
        }else{
            cout << "Draw" << endl;
        }
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main() {
  int a,b,c,x,cnt=0; cin>>a>>b>>c>>x;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i+100*j+50*k==x) cnt++;
      }
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))


Measured memory_bytes: 52956
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}

ll inverse(ll n)
{
	return exp(n,MOD-2);
}
int LIM=6010;
v64 factorial(LIM,1);

void solve()
{
//Read Comments below main
	ll n;
	cin>>n;
	ll a=n/500;
	ll rem=n-a*500;
	ll ans=a*1000+(rem/5)*5;
	cout<<ans<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// BITMASK:
// 1)When some constraint is of the order of 15-20, think of bitmask DP.
// 2)When some constraint is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algo

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int a,b,c,d,e,f,g,h,H,K;
    cin>>e>>f>>g>>h>>a>>b>>c>>d;
    H = e*a+f*b+c*(e/10)+d*(f/20);
    K = g*a+h*b+c*(g/10)+d*(h/20);
    puts(H>K?"hiroshi":H==K?"even":"kenjiro");
}


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

int main() {
  int N;
  cin >> N;
  int min_count=30;
  for(int i=0; i<N; i++){
    int A;
    cin >> A;
    int count=0;
    while(A%2==0){
      A/=2;
      count++;
    }
    if(count < min_count) min_count = count;
  }
  cout << min_count << endl;

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec _A(N);
    REP(i,0,N) cin >> _A[i];
    
    ASC(_A);
    deque<ll> A;
    FORR(a,_A) A.push_back(a);

    deque<ll> D;
    D.push_back(A.front());
    A.pop_front();
    D.push_back(A.back());
    A.pop_back();

    while(!A.empty()) {
        ll amin = A.front(), amax = A.back();
        ll dl = D.front(), dr = D.back();
        vector<pll> p = {{abs(amin-dl), 0}, {abs(amin-dr), 1}, {abs(amax-dl), 2}, {abs(amax-dr), 3}};
        DESC(p);
        if(p[0].second == 0) {
            D.push_front(amin);
            A.pop_front();
        }
        else if(p[0].second == 1) {
            D.push_back(amin);
            A.pop_front();
        } 
        else if(p[0].second == 2) {
            D.push_front(amax);
            A.pop_back();
        }
        else {
            D.push_back(amax);
            A.pop_back();
        }
    }

    ll sum = 0;
    REP(i,0,SZ(D)-1) sum += abs(D[i+1] - D[i]);
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 5004
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    char x; 
    cin >> x; 
    if (isupper(x))  
        cout << "A" ; 
    else 
        cout << "a";     
    return 0; 
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

class Main {
	Scanner sc;
	int N;
	List<Edge>[] edges;
	int[] a, b, c;
	int K;
	
	static class Edge {
		int next, idx;
		Edge(int n, int i) {next = n; idx = i;}
	}
	
	@SuppressWarnings("unchecked")
	void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		edges = new ArrayList[N];
		a = new int[N];
		b = new int[N];
		c = new int[N];
		for (int i = 0; i < N; i++) edges[i] = new ArrayList<Edge>();
		for (int i = 0; i < N-1; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			edges[a[i]].add(new Edge(b[i], i));
		}
		K = 0;
		coloring(0, -1);
		System.out.println(K);
		for (int i = 0; i < N-1; i++) System.out.println(c[i]+1);
	}
	
	void coloring(int vidx, int startColor) {
		int n = edges[vidx].size();
		if (startColor > -1) n++;
		for (int i = 0; i < edges[vidx].size(); i++) {
			startColor = (++startColor)%n;
			c[edges[vidx].get(i).idx] = startColor;
			coloring(edges[vidx].get(i).next, startColor);
		}
		K = Math.max(K, n);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 100428
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9+7;

int main () { _read(); 
      int S;
      cin >> S;
      vector<int> dp(S+1);
      dp[0] = 1;
      for( int s = 3; s <= S; s++) {
            for ( int i = 3; i <= s; i++) {
                  ( dp[s] += dp[s-i] ) %= mod;
            }
      }
      cout << dp[S] << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


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

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

    vector<int> q(N);
    for (int i = 0; i < N; i++)
    {
        q.at(p.at(i) - 1) = i + 1;
    }

    vector<int> a(N), b(N);
    a.at(0) = 1;
    b.at(0) = q.at(0) - 1;
    for (int i = 1; i < N; i++)
    {
        a.at(i) = max(a.at(i - 1) + 1, q.at(i) - (b.at(i - 1) - 1));
        b.at(i) = q.at(i) - a.at(i);
    }
    int b_mn = b.at(N - 1);
    for (int i = 0; i < N; i++)
    {
        cout << a.at(i) << " ";
    }
    cout << endl;
    for (int i = 0; i < N; i++)
    {
        cout << b.at(i) - b_mn + 1 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
a, b, c = gets.split.map(&:to_i)
m = [a,b,c].max

if m%2 == 0 && (a+b+c)%2 == 0
  puts (3*m-(a+b+c))/2.floor
elsif m%2 == 1 && (a+b+c)%2 == 1
  puts (3*m-(a+b+c))/2.floor
else
  m+=1
  puts (3*m-(a+b+c))/2.floor
end


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

int main(void){
    int N;
    int i,j;
    int count=0;
    int stackcount=0;
    int buf;
    int piv=0;
    int delnum=0;
    char str[1000];
    int *stack;
    int *newstack;
    int ans=0;
    
    scanf("%d\n",&N);
    stack=malloc(sizeof(int)*2*N);
    newstack=malloc(sizeof(int)*2*N);
    for (i=0;i<1000;i++){
        str[i]='\0';
    }
    for (i=0;i<2*N;i++){
        stack[i]=0;
    }
    
    scanf("%[^\n]",str);
    for (i=0;i<1000;i++){
        if((str[i]!=' ')&&(str[i]!='\0')){
            count++;
        }
        else{
            for(j=0;j<count;j++){
                stack[stackcount]+=(str[i-j-1]-48)*pow(10,j);
            }
            stackcount++;
            count=0;
        }
        if(str[i]=='\0') break;
    }
    for(i=0;i<2*N;i++){
        for(j=0;j<2*N;j++){
            if(stack[j]>=piv){
                piv=stack[j];
                delnum=j;
            }
        }
        newstack[i]=piv;
        stack[delnum]=0;
        piv=0;
    }
    for(i=0;i<N;i++){
        ans+=newstack[2*i+1];
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
using ll = long long;
string str;

int solve(){
    bool flag = 1;
    while(1){
        int cnt=0,num=0;
        string str2;
        vector<int> vc;
        for(int i=0;i<=str.size();i++){
            if('0'<=str[i]&&str[i]<='9'){
                if(num==0)  num = (str[i]-'0');
                else  num = 10*num + (str[i]-'0');
            }
            else if(str[i]==']'){
                if(num==0){
                    if(vc.size()==0)    str2 = str2 + "]";
                    else{
                        int temp=0;
                        sort(vc.begin(),vc.end());
                        if(flag==1){
                            for(int j=0;j<((vc.size()+1)/2);j++)   temp+=((vc[j]+1)/2);
                        }
                        else{
                            for(int j=0;j<((vc.size()+1)/2);j++)   temp+=(vc[j]);
                        }
                        str2 = str2 + to_string(temp)+"]";
                        vc.clear();
                    }
                }
                else{
                    vc.push_back(num);
                    num = 0;
                }
            }
            else if(str[i]=='\0'){
                if(vc.size()>=1) return vc[0];
            }
            else    str2 = str2 + "[";
        }
        str = str2;
        flag = 0;
    }
}

int main(){
    int n;
    cin >> n;
    while(n--){
        cin >> str;
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3340
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto primes = () {
        long[] primes;
        long i;
        while (primes.length < 55)
        {
            long x = 5 * i + 2;
            if (factorize(x).length == 1)
                primes ~= x;
            i++;
        }
        return primes;
    }();
    long N = lread();
    primes[0 .. N].map!text().join(' ').writeln();
}

long[] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[] result;
    while ((x & 1) == 0)
    {
        x /= 2;
        result ~= 2;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            result ~= i;
        }
    if (x != 1)
        result ~= x;
    return result;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a[] = new long[n + 1];
            long st[] = new long[61];
            long temp = 0;
            long ans = 0;
            long tn = n;
            for (int i = 0; i < n; i++) {
                temp = in.nextLong();
                a[i] = temp;
                for (int j = 0; j < 61; j++) {
                    if ((temp & 1) == 1) st[j]++;
                    temp /= 2;
                }

//            for(int j=0;j<61;j++)out.print(st[j]);
//            out.println();
            }
            long mod = 1000000007;
            for (int i = 0; i < n; i++) {
                temp = a[i];
                long slash = 1;
                tn--;
                for (int j = 0; j < 61; j++) {
                    if ((temp & 1) == 1) {
                        st[j]--;
                        ans += ((tn - st[j]) * slash) % mod;
                        ans %= mod;
                    } else {
                        ans += (st[j] * slash);
                        ans %= mod;
                    }
                    temp /= 2;
                    slash = (slash << 1) % mod;
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}




Measured memory_bytes: 79340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll tests=1 ;
   //cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     ///cout<<"Case #"<<testcase<<": " ;
     ///Read ,Think and Test Properly,then code
     string s ;
     cin>>s ;
     ll n=s.length() ;
     string r=s.substr(0,n/2) ;
     string u=s.substr((n+1)/2,n/2) ;
     string a=r,b=u ;
     reverse(all(a)) ;
     reverse(all(b)) ;
     string c=s ;
     reverse(all(c)) ;
     if(a==r&&b==u&&c==s)
        cout<<"Yes" ;
     else
        cout<<"No" ;

   }
}


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


int main(){
	int k, x;
	cin>>k>>x;
	vector<int> ans;
	ans.push_back(x);
	for(int i = 1; i<k; i++){
		ans.push_back(x-i);
		ans.push_back(x+i);
	}
	sort(ans.begin(), ans.end());
	for(int i = 0; i<ans.size(); i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	b := make([]int, N)
	b[0] = a[0]
	for i := 1; i < N; i++ {
		b[i] += b[i-1] + a[i]
	}

	// out(b)
	ans := math.MaxInt64
	for i := 0; i < N-1; i++ {
		// out(ans, b[N-1], b[i+1], b[i])
		ans = min(ans, abs(b[N-1]-b[i]-b[i]))
	}
	out(ans)

}


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

#define mp       make_pair
#define mt       make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll N,L;
vector<ll> A;
int main(){
  cin >> N >> L;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  vector<int> result;
  for (int i = 0; i < N - 1; i++){
    if (A[i] + A[i + 1] >= L){
      result.push_back(i);
      for (int j = i - 1; j >= 0; j--){
	result.push_back(j);
      }
      for (int j = i + 1; j < N - 1; j++){
	result.push_back(j);
      }
      break;
    }
  }
  // cout << A.size() << endl;
  // for (auto &val : result){
  //   cout << val << " " ;
  // }
  // cout << endl;
  if (result.size() == N - 1){
    reverse(result.begin(), result.end());
    cout << "Possible" << endl;
    for (auto &val : result){
      cout << val + 1 << endl;
    }
  }else{
    cout << "Impossible" << endl;
  }

}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) 			a.begin(),a.end()
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define MOD 			1000000007
#define FOR(i,a,b) 		for(int i = a; i <= b ; i++)
#define forn(i,n) 		for(int i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			int t;cin>>t;while(t--)
#define ll				long long
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define ff				first
#define ss 				second
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vb 				vector<bool>
#define INF				INT_MAX
#define INFL			LLONG_MAX

using namespace std;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
using namespace __gnu_pbds;

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


vi prime_generator()
{
	vector<int> pr;
	const int N = 10000000;
	vi lp(N+1);
	

	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}


vi z_function(string t)
{
	int n = t.size();
	vi z(t.size());
	for(int i = 1,r = 0,l = 0 ; i <  n ; i++)
	{
		if(i <= r)
			z[i] = min(r - i + 1,z[i - l]);
		while(i + z[i] < n && t[z[i]] == t[i + z[i]])
			z[i]++;
		if(i + z[i] - 1 > r)
			r = i + z[i] - 1,l = i;
	}
	return z;
}


ll power(ll a,ll b,ll mod)
{
	ll res = 1;
	a = a % mod;
	while(b)
	{
		if(b & 1)
			res = (res * a) % mod;
		b = b >> 1;
		a = (a * a) % mod;
	}
	return res;
}

template<typename T>
void answer(T s)
{
	cout<<s<<endl;
	exit(0);
}
//use for string in strcpy([string],s.c_str())
//stringstream fs---->fs>>string_name**this will copy the value from fs to string_name
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


int main()
{
	fast
	ll n;cin>>n;
  	cout<<n * n * 3<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val sx = sc.nextInt()
  val sy = sc.nextInt()
  val tx = sc.nextInt()
  val ty = sc.nextInt()

  var ans = ""
  for(i <- sx to tx-1)
    ans += "R"
  for(i <- sy to ty-1)
    ans += "U"
  for(i <- sx to tx-1)
    ans += "L"
  for(i <- sy to ty-1)
    ans += "D"

  ans += "D"
  for(i <- sx to tx)
    ans += "R"
  for(i <- sy to ty)
    ans += "U"
  ans += "L"

  ans += "U"
  for(i <- sx to tx)
    ans += "L"
  for(i <- sy to ty)
    ans += "D"
  ans += "R"

  println(ans)
}


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

int main() {
    long long int n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1;
    }
    else if (n == 1 || m == 1) {
        cout << n * m - 2;
    }
    else {
        cout << (n-2) * (m-2);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    pair<int,int> P[M];
    for(int i=0;i<M;i++){
        cin >> P[i].second >> P[i].first;
    }
    sort(P,P+M);
    int ans = 0;
    int now = P[0].first;
    for(int i=0;i<M;i++){
        if(now <= P[i].second){
            ans++;
            now = P[i].first;
        }
    }
    cout << ans + 1 << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int a, b;
    cin >> a >> b;
    //cout << b%2;
    if (a%2==0) {
        cout << "No";
        return 0;
    } else if (b%2==0) {
        cout << "No";
        return 0;
    } else {
        cout << "Yes" << endl;
        return 0;
    }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long a, b, x;
	cin >> a >> b >> x;

	if(x == 1){
		printf("%lld\n", b - (a - 1));
		return 0;
	}

	long long ans = 0;
	long long r = (a % x);
	if(r == 0){
		ans = (b - a) / x;
		ans += 1;
	}
	else{
		long long u = a + (x - r);
		if(u > b){
			ans = 0;
		}
		else{
			ans = (b - u) / x;
			ans += 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3792
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
        cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;
 
int fpow(int a, int n) 
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = ans*a;
        a = a*a;
        n = n >> 1;
    }
    return ans;
}
 
signed main() 
{
    fast_io();
    string s; cin >> s;
    int ans = 0;
    int n = s.size();
    For(i,0,n/2) {
    	if (s[i] != s[n-i-1])
    		++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

struct Node {
	int value;
	Node *next;
};

int main() {
	for(int N, M; cin >> N >> M, N;) {
		vector<Node> v(N);
		for(int i = 0; i < N; i++) {
			v[i].value = i + 1;
			v[i].next = &v[(i+1)%N];
		}
		Node *cur = &v[N - 1];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M - 1; j++) {
				cur = cur->next;
			}
#if 0
			cerr << "skip: " << cur->next->value << endl;
#endif
			Node *skip = cur->next;
			cur->next = cur->next->next;
			cur = skip;
#if 0
			debug(cur->value);
			debug(cur->next->value);
#endif
		}
		cout << cur->value << endl;
	}
}

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

using namespace std;

int main(){
    string n;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    long long len = n.length();
    len -= 1;
    if(n[len] == '2' || n[len] == '4' || n[len] == '5' || n[len] == '7' || n[len] == '9')  cout << "hon";
    else if(n[len] == '0' || n[len] == '1' || n[len] == '6' || n[len] == '8') cout << "pon";
    else if(n[len] == '3') cout << "bon";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main(){
    double n;
    cin  >> n;
    cout << 2 * n * M_PI << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int t[1000100] , s;
int zhuan (int a){
	if ( a % 2 == 0 ) return a / 2;
	else return a * 3 + 1;
}

int main(){
	cin >> s ;
	t [ s ] ++ ;
	int x = s ;
	int cnt = 2;
	while ( 1 ){
		x = zhuan ( x );
		if ( t [ x ] ){
			cout << cnt << endl;
			return 0;
		}
		t[ x ] ++ ;cnt ++;
	}
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100005];

int main()
{
    int N, K;
    cin >> N >> K;
    REP(i, N)
    {
        cin >> H[i];
    }
    sort(H, H + N);
    ll min = INF;
    REP(i, N)
    {
        if (i + K - 1 >= N)
            break;
        min = std::min(min, abs(H[i] - H[i + K - 1]));
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define len(x) (int) x.length()
#define all(x) x.begin(),x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-4;
const int MAX=1e5+10;
const ll mod=1e9+7;
/****************************************  head  ****************************************/
int n,flag;
string s;
ll ans;
map<pair<string,string>,int> mp;
void dfs(int p,string a,string b)
{
	if(p==n)
	{
		if(flag) ans+=mp[MP(a,b)];
		else mp[MP(a,b)]++;
		return;
	}
	dfs(p+1,a+s[p],b);
	dfs(p+1,a,b+s[p]);
}
int main()
{
	while(~scanf("%d",&n))
	{
		cin>>s;
		mp.clear();
		flag=0;
		dfs(0,"","");
		flag=1;
		reverse(all(s));
		ans=0;
		dfs(0,"","");
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 87808
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
const int mo=1e9+7;
int Mod(int x){return x>=mo?x-mo:x;}
int n,fa[N];;
vector<int>E[N];
struct node
{
	int x,y,z;
};
deque<node>f[N];
#define pb push_back
void input()
{
	n=read<int>();
	For(i,1,n)fa[i]=read<int>(),E[fa[i]].pb(i);
}
int inv2;
void DP(int u)
{
	int v;
	int fir=0,sec=0;
	For(i,0,E[u].size()-1)
	{
		v=E[u][i];
		DP(v);
		if(f[v].size()>fir)sec=fir,fir=f[v].size();
		else cmax(sec,(int)f[v].size());
		if(f[v].size()>f[u].size())swap(f[u],f[v]);
		For(j,0,f[v].size()-1)
		{
			node t;
			t.x=(1ll*f[u][j].x*f[v][j].y+1ll*f[u][j].y*f[v][j].x)%mo;
			t.y=1ll*f[u][j].y*f[v][j].y%mo;
			t.z=(1ll*f[u][j].y*f[v][j].z+1ll*f[u][j].z*f[v][j].y+1ll*f[u][j].x*f[v][j].x+
					1ll*f[u][j].x*f[v][j].z+1ll*f[u][j].z*f[v][j].x+1ll*f[u][j].z*f[v][j].z)%mo;
			f[u][j]=t;
		}
	}
	For(j,0,sec-1)
	{
		f[u][j].y=Mod(f[u][j].y+f[u][j].z);
		f[u][j].z=0;
	}
	f[u].push_front((node){inv2,inv2,0});
}
ll power(ll x,int y)
{
	ll res=1;
	for(;y;x=x*x%mo,y>>=1)if(y&1)res=res*x%mo;
	return res;
}
void work()
{
	inv2=power(2,mo-2);
	DP(0);
	int ans=0;
	For(j,0,f[0].size()-1)ans=Mod(ans+f[0][j].x);
	write(1ll*ans*power(2,n+1)%mo,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}

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

map<long,long> memo;
int A,B,C,D;
long N;

long _min( long a, long b ) {
	return a<b ? a : b;
}

long solve(long N) {
		if(memo.find(N)!=memo.end())
			return memo[N];

		long min = 0x3f3f3f3f3f3f3f3f;
		if(N < 0x3f3f3f3f3f3f3f3f/D)
			min = N*D;

		for(int i=-1; i<=1; i++) {
			if((N+i)%2==0)
				min = _min(min, solve((N+i)/2)+abs(i)*D+A);
		}
		for(int i=-1; i<=1; i++) {
			if((N+i)%3==0)
				min = _min(min, solve((N+i)/3)+abs(i)*D+B);
		}
		for(int i=-2; i<=2; i++) {
			if((N+i)%5==0)
				min = _min(min, solve((N+i)/5)+abs(i)*D+C);
		}

		memo[N] = min;
		return min;
	}

int main() {
	int T;
	cin>>T;

	for(int i=0; i<T; i++) {
		cin>>N>>A>>B>>C>>D;

		memo.erase(memo.begin(),memo.end());
		memo[0] = 0;
		memo[1] = D;
		
		cout<<solve(N)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long a[n];
    long long cum[n+1];
    memset(cum, 0,sizeof(cum));
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cum[i + 1] += cum[i] + a[i];
    }
    long long dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    for(int k = 0; k < n; k++){
        for(int i = 1; i + k <= n; i++){
            if(k == 0){
                dp[i][i] = 0;
            }
            else{
                long long ans = -1;
                //dp[i][i+k] = dp[i][j] and dp[j+1][i+k]
                for(int j = i; j < i+k; j++  ){
                    if(ans == -1){
                        ans = dp[i][j] + dp[j+1][i+k] + cum[i+k] - cum[i-1];
                    }
                    ans = min(ans, dp[i][j] + dp[j+1][i+k] + cum[i+k] - cum[i-1] );
                }
                dp[i][i+k] = ans;
            }
        }
    }
    cout << dp[1][n]  << endl;
    return 0;
}

Measured memory_bytes: 1536
n,m,c = map(int,raw_input().strip().split())

br = list(map(int,raw_input().strip().split()))

arr = []

for i in range(n):
    arr.append(list(map(int,raw_input().strip().split())))

ans = 0
for i in range(n):
    val = 0
    for j in range(m):
        val+=arr[i][j]*br[j]
    val+=c
    #print(val)
    if val>0:
        ans+=1
print(ans)

Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,m,x,y,i,inp;
	cin >> n >> m >> x >> y;
	for(i=0; i<n; ++i){
		cin >> inp;
		x = max(inp,x);
	}
	for(i=0; i<m; ++i){
		cin >> inp;
		y = min(inp,y);
	}
	cout << ((x<y)?"No War":"War") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int dp[3009][3009];
int solve(int i,int j){
	if(i>=s1.length()||j>=s2.length())
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(s1[i]==s2[j])
		return dp[i][j]=1+solve(i+1,j+1);
	return dp[i][j]=max(solve(i+1,j),solve(i,j+1));
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>s1;
	cin>>s2;
	for(int i=0;i<3009;i++)
		for(int j=0;j<3009;j++)
			dp[i][j]=-1;
	int k=solve(0,0);
	string ans="";
	int i=0,j=0;
	while(i<s1.length()&&j<s2.length()){
		if(s1[i]==s2[j]){
			ans.push_back(s1[i]);
			i++;
			j++;
			continue;
		}
		if(dp[i][j+1]>=dp[i+1][j])
			j++;
		else 
			i++;
	}
	cout<<ans;
}

Measured memory_bytes: 35968
#include<iostream>
#include<map>

using namespace std;

map<int, int> mp;

int main(void)

{
    int n, k, d, i, j, a;
    cin>>n>>k;
    for(i = 1; i <= n; i++)
        mp[i]++;
    for(i = 0; i < k; i++){
        cin>>d;
        for(j = 0; j < d; j++){
            cin>>a;
            mp.erase(a);
        }
    }
    cout<<mp.size()<<endl;
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

vector<vector<long long> > g;
vector<char> used;
vector<long long> pl;

void dfs(long long v, long long d){
    used[v] = true;
    for(int i : g[v])
        if(!used[i]) dfs(i, d + pl[v]);
    pl[v] += d;
}

int main(){
    long long n, k, fr, to, p, x;
    cin >> n >> k;
    g.resize(n + 1);
    pl.resize(n + 1);
    used.assign(n + 1, false);
    for(int i = 0; i < n - 1; ++i){
        cin >> fr >> to;
        g[fr].push_back(to);
        g[to].push_back(fr);
    }
    for(int i = 0; i < k; ++i){
        cin >> p >> x;
        pl[p] += x;
    }

    dfs(1, 0);
    for(int i = 1; i <= n; ++i) cout << pl[i] << " ";
}


Measured memory_bytes: 24448
import std.stdio;
import core.bitop;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const M = 10;
alias int[M][M] F;

struct P {
    int y, x;
}

int m, n;
int[int][23] cache;
int[M][M] id;
int vCount;
P[] pos;
F cur;

int[] next(int v) {
    int[] ret;
    static const dy = [0, 1, 0, -1],
                 dx = [1, 0, -1, 0];
    foreach (i; 0 .. 4) {
        int y = pos[v].y, x = pos[v].x;
        while (true) {
            y += dy[i];
            x += dx[i];
            if (y < 0 || y >= n) break;
            if (x < 0 || x >= m) break;
            if (cur[y][x] == 2) {
                ret ~= id[y][x];
                continue;
            }
            if (cur[y][x] == 1) {
                ret ~= id[y][x];
                break;
            }
        }
    }
    return ret;
}

int dfs(int v, int used) {
    int popCount = used.popcnt;
    if (popCount < 18) {
        if (used in cache[v - 1]) return cache[v - 1][used];
    }
    int ans = 0;
    //writeln(pos[v], next(v).map!((i) => pos[i]));
    int[] z = next(v);
    foreach (i; z) {
        if (i == 0) {
            //writefln("%b", used);
            if (used == (1 << vCount - 1) - 1) ans++;
            continue;
        }
        if (used & (1 << i-1)) continue;
        int ny = pos[i].y,
            nx = pos[i].x;
        if (cur[ny][nx] == 1) {
            cur[ny][nx] = 3;
            ans += dfs(i, used | (1 << i-1));
            cur[ny][nx] = 1;
        } 
    }
    delete(z);
    if (popCount < 18) {
        cache[v - 1][used] = ans;
    }
    return ans;
}

void main() {
    while (scanf("%d %d\n", &m, &n), m || n) {
        memset(cast(void*)id, -1, id.sizeof);
        vCount = 1;
        foreach (i; 0 .. n) {
            foreach (j; 0 .. m) {
                scanf("%d", &cur[i][j]);
                if (cur[i][j] == 1) {
                    id[i][j] = vCount++;
                }
                if (cur[i][j] == 2) {
                    id[i][j] = 0;
                }
            }
        }
        pos = new P[vCount];
        foreach (i; 0 .. n) {
            foreach (j; 0 .. m) {
                if (id[i][j] >= 0) {
                    pos[id[i][j]] = P(i, j);
                }
            }
        }
        int ans = 0;
        foreach(i; next(0)) {
            foreach (j; 0 .. 23) cache[j] = null;
            cur[pos[i].y][pos[i].x] = 3;
            ans += dfs(i, 1 << i-1);
            cur[pos[i].y][pos[i].x] = 1;
        }
        ans.writeln;
    }
}

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

using namespace std;
#define M 1005
#define N 15
#define ll long long
int arr[N];


int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int cnt = 0;
    for(int i = 0 ; i < n ; i++)
    {
        int x;
        cin>>x;
        if(x >= k)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/


Measured memory_bytes: 3600
import sys
N = int(input())
ABs = [list(map(int,input().split())) for _ in range(N)]
ABs.sort(key=lambda x: x[1]) 
time = 0
for i in range(N):
    time += ABs[i][0] 
    if time > ABs[i][1]:
        print('No')
        sys.exit()


print('Yes')


Measured memory_bytes: 53600
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;

int main(){
 int n;
 cin>>n;
 int ans =0;
 for(int i =1;i<=n;i++){
   if(i==0)continue;
   int count =0;
   for(int j =1;j<=i;j++){
     if(j==0)continue;
     if(i%j==0)count++;
   }
   if(count==8&&i%2==1)ans++;
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 256