akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std ;

#define N 200000

int n , s , t , tot , Res ;
int fire[N] , nex[2*N] , to[2*N] , Ans[N] , dep[N] ;

void add(int u , int v){
    nex[++tot] = fire[u] ;
    fire[u] = tot ;
    to[tot] = v ;
    return ;
}

void dfs1(int x , int fr){
    dep[x] = dep[fr] + 1 ; Ans[x] = dep[x] ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        dfs1( v , x ) ;
        Ans[x] = max( Ans[x] , Ans[v] ) ;
    }
}

int dfs2(int x , int fr , int now ){
    if( now >= dep[x] ) return 0 ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        if( dfs2( v , x , now + 1 ) == 0 ){
            Res = x ;
        }
    }
    return 1 ;
}

int main()
{
    scanf("%d%d%d" , &n , &s , &t ) ;
    for(int i = 1 ; i <= n - 1 ; i++ ){
        int u , v ;
        scanf("%d%d" , &u , &v ) ;
        add( u , v ) ; add( v , u ) ;
    }
    dfs1( t , 0 ) ;
    dfs2( s , 0 , 0 ) ;
    printf("%d\n" , Ans[Res] - 2 ) ;
    return 0 ;
}

Measured memory_bytes: 7808
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;
//bool comp(
//
//	st pll &a, const pll &b) {
//	return a.first < b.first;
//}
//std::vector<int> enum_div(int n)//nの約数を列挙
//{
//	std::vector<int> ret;
//	for (int i = 1; i*i <= n; ++i)
//	{
//		if (n%i == 0)
//		{
//			ret.push_back(i);
//			if (i != 1 && i*i != n)
//			{
//				ret.push_back(n / i);
//			}
//		}
//	}
//	return ret;
//}

template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}

int main()
{
	priority_queue<int> q;
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	string s = {};
	char x[302][302] = {};
	ll y[302][302] = {};

	cin >> h;
	cin >> w;
	cin >> a;

	for (int i = 0; i < h; i++)
	{
		for (int k = 0; k < w; k++)
		{
			cin >> x[i][k];
		}
	}
	ans = 1;
	for (int i = 0; i < h; i++)
	{
		for (int k = 0; k < w; k++)
		{
			if (y[i][k] == 0 && x[i][k] == '#')
			{
				y[i][k] = ans;
				b = k;
				while (b > 0)
				{
					if (y[i][b - 1] == 0 && x[i][b - 1] == '.')
					{
						b--;
						y[i][b] = ans;
					}
					else
					{
						break;
					}
				}
				c = k;
				while (c < w - 1)
				{
					if (y[i][c + 1] == 0 && x[i][c + 1] == '.')
					{
						c++;
						y[i][c] = ans;
					}
					else
					{
						break;
					}
				}
				d = 0;
				for (int p = i-1; p >= 0; p--)
				{
					for (int q = b; q <= c; q++)
					{
						if (y[p][q] != 0 || x[p][q] == '#')
						{
							d = 1;
							break;
						}
					}
					if (d == 0)
					{
						for (int q = b; q <= c; q++)
						{
							y[p][q] = ans;
						}
					}
					else
					{
						break;
					}
				}
				d = 0;
				for (int p = i + 1; p < h; p++)
				{
					for (int q = b; q <= c; q++)
					{
						if (y[p][q] != 0 || x[p][q] == '#')
						{
							d = 1;
							break;
						}
					}
					if (d == 0)
					{
						for (int q = b; q <= c; q++)
						{
							y[p][q] = ans;
						}
					}
					else
					{
						break;
					}
				}
				ans++;

			}
		}
	}
	for (int p = 0; p < h; p++)
	{
		for (int q = 0; q < w; q++)
		{
			cout << y[p][q]<<' ';

		}
		cout << endl;
	}
	//cout<<factorial<10><<endl;

	//cin >> a >> b;
	//for (int i = 0; i < a; i++)
	//{
	//	cin >> s[i];
	//	if (s[i] >= b)
	//	{
	//		ans++;
	//	}
	//}

	//cout << ans << endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> p.at(i);
    }
    int ans = 1;
    int mi = p.at(1);
    for (int i = 2; i <= n; i++) {
        if (mi > p.at(i)) {
            ans++;
            mi = p.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3972
let rec sumDigit ret N =
  if N<10 then
    ret+N
  else
    sumDigit (ret + N%10) (N/10)

let check a b x = a<=x && x<=b

stdin.ReadLine().Split(' ')
|> Array.map int
|> fun [|N;A;B|] -> List.filter ((check A B) << (sumDigit 0)) [1..N]
|> List.sum
|> printfn "%d"

Measured memory_bytes: 13276
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 
int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int s = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            s += a[i]*a[j];
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll A[5];
    ll mod = 0;
    rep(i,5){
        cin >> A[i];
        ll tmp = N/A[i]-1;
        if(N%A[i]!=0) tmp++;
        if(tmp>mod) mod = tmp;
    }
    ll out = mod+5;
    cout << out << endl;
    return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    set<string> s;
    int n;
    cin >> n;
    rep(i, n)
    {
        string str;
        cin >> str;
        s.insert(str);
    }

    cout << s.size() << endl;

 

 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 19272
#include <stdio.h>
 
int main(void){
  int result = 0;
  int R,G,B,N;
  scanf("%d %d %d %d", &R, &G, &B, &N);
  
  for(int r = 0; r <= N/R; r ++){
    for(int g = 0; g <= (N-R*r)/G; g ++){
      if ((N-R*r-G*g)%B == 0){
        result ++;
      }
    }
  }
  printf("%d", result);
  return 0;
}

Measured memory_bytes: 128
a,b = map(int,input().split())
if a < 0 and b > 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
elif a > 0:
    print("Positive")
else:
    n_c = b-a+1
    if n_c % 2 == 0:
        print("Positive")
    else:
        print("Negative")

Measured memory_bytes: 2940
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>
#pragma optimize("", off)
using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll h, w;
    cin >> h >> w;
    vector<bool> v;
    v[0];
    vector<int> v2;
    v2[0];
    int a[h][w], b[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    ll max_diff = 2 * 80 * 160;
    volatile bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = true;

    ll mid = max_diff / 2;
    dp[0][0][b[0][0] - a[0][0] + mid] = false;
    dp[0][0][-b[0][0] + a[0][0] + mid] = false;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                if(i + 1 <= h - 1) {

                    dp[i + 1][j][l + b[i + 1][j] - a[i + 1][j]] &= dp[i][j][l];
                    dp[i + 1][j][l - b[i + 1][j] + a[i + 1][j]] &= dp[i][j][l];
                }
                if(j + 1 <= w - 1) {
                    dp[i][j + 1][l + b[i][j + 1] - a[i][j + 1]] &= dp[i][j][l];
                    dp[i][j + 1][l - b[i][j + 1] + a[i][j + 1]] &= dp[i][j][l];
                }
            }
        }
    }
    ll ans = 1e18;
    rep(i, max_diff) {
        if(!dp[h - 1][w - 1][i])
            ans = min(ans, abs(i - mid));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 160256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <tuple>

using namespace std;
using Int = long long;

typedef tuple<string, Int, Int> mytuple;

bool mycompare( const mytuple &lhs, const mytuple &rhs){
    if (std::get<0>(lhs) != std::get<0>(rhs)) return std::get<0>(lhs) < std::get<0>(rhs);
    return std::get<1>(lhs) > std::get<1>(rhs);
}

signed main(){
    Int n;
    cin >> n;
    vector<mytuple> vec;
    for (Int i = 0; i < n; i++) {
        string tmp_s;
        Int tmp_p;
        cin >> tmp_s >> tmp_p;
        vec.emplace_back(tmp_s, tmp_p, i+1);
    }
    sort(vec.begin(), vec.end(), mycompare);

    for (Int i = 0; i < n; i++){
        cout << get<2>(vec[i]) << endl;
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	int K=sc.nextInt();
    	int T=sc.nextInt();

    	List<Integer> A=new ArrayList<Integer>();

    	for(int i=0;i<T;i++) {
    		A.add(sc.nextInt());
    	}

    	Collections.sort(A,Collections.reverseOrder());

    	int at=A.get(0);

    	int result=Math.max(at-1-(K-at),0);

    	System.out.println(result);


    }

}



Measured memory_bytes: 23124
from collections import deque
q = deque()
K = int(input())
q.append((1, 1))
m = {}
while len(q):
 n, s = q.popleft()
 if n in m:continue
 m[n] = s
 q.appendleft((n * 10 % K, s))
 q.append(((n + 1) % K, s + 1))
print(m[0])

Measured memory_bytes: 24300
rows,cols = map(int, input().split())

matrix = [[0 for r in range(cols)] for c in range(rows)]
vector =  [0 for c in range(cols)]

for row in range(rows):
    vs = list(map(int, input().split()))
    for index, value in enumerate(vs):
        matrix[row][index] = value

for col in range(cols):
    v = int(input())
    vector[col] = v

for row in range(rows):
    output = 0
    for col in range(cols):
        output += matrix[row][col] * vector[col]
    print(output)


Measured memory_bytes: 5848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        vp v;
        rep(i, n){
            cin >> a >> b;
            v.pb(mp(a, b));
        }
        sort(all(v));
        each(p, v){
            m -= p.second;
            if(m <= 0){
                print(p.first);
                break;
            }
        }
    }
}



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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n)-1;  i >= 0; i--)

int main()
{
  int sum = 0;
  REP(i, 5)
  {
    int x; cin >> x;
    sum += x;
  }
  cout << 15-sum << endl;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll a,b;
string s;

int main(){
	cin>>a>>b>>s;
  int n=s.size();
  bool ok=true;
  rep(i,n){
    if((i==a&&s[i]!='-')||(i!=a&&s[i]=='-'))ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;

int n, m, k;
int dp[2][10000010];

int w[maxn], v[maxn];
int cnt[10], base[10], t[10];

long long calc(int u) {
    long long ans = 0;
    ans += (long long)(u % cnt[0]) * k;       u /= cnt[0];
    ans += (long long)(u % cnt[1]) * (k + 1); u /= cnt[1];
    ans += (long long)(u % cnt[2]) * (k + 2); u /= cnt[2];
    ans += (long long)u * (k + 3);
    return ans;
}
int main() {

    scanf("%d%d", &n, &m);

    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 1;
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &w[i], &v[i]);
        if(i == 0) k = w[i];
        ++cnt[ w[i] -= k ];
    }

    for(int i = 0; i < 4; i++) t[i] = cnt[i];

    base[0] = 1;
    for(int i = 1; i < 4; i++) 
        base[i] = t[i-1], t[i] *= t[i-1];

    int cur = 1;
    memset(dp, -1, sizeof dp);

    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 1000000+10-1; j >= base[w[i]]; j--) {
            dp[cur][j] = dp[cur^1][j]; 
            if(dp[cur^1][j-base[w[i]]] >= 0)
                dp[cur][j] = max(dp[cur][j], dp[cur^1][j-base[w[i]]] + v[i]);
        }

        for(int j = base[w[i]]-1; j >= 0; j--)
            dp[cur][j] = dp[cur^1][j];

        cur ^= 1;
    }
    int ans = 0, lim = 0;
    for(int i = 0; i < n; i++) lim += base[w[i]];

    if(lim >= 10000000) for(;;);

    for(int j = 0; j <= lim; j++) {
        if(calc(j) <= m) {
            if(dp[cur^1][j] > ans) {
                ans = dp[cur^1][j];
            }
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 78336
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int
var Max, Min int = 0, 1e9

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	K, _ := strconv.Atoi(read())
	var j int = 1
	for j < K {
		j += N - 1
		ans++
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;

void solve()
{
   int n;
   cin>>n;
   vector<vector<int> > v(n, vector<int>(3));

   for(int i=0;i<n;i++)
   {
    cin>>v[i][0]>>v[i][1]>>v[i][2];
   }

   int dp[n][3];
   dp[0][0]=v[0][0];
   dp[0][1]=v[0][1];
   dp[0][2]=v[0][2];

   for(int i=1;i<n;i++)
   {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + v[i][0];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + v[i][1];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0]) + v[i][2];
   }

   cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;



}
signed main()

{
    FAST_IO;
    int t = 1;

    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>

void treeReconstruction(int** pre, int* in, int** post, int left, int right, int size);
int binarySearch(int* arr, int val, int left, int right);

int main(int argc, char** argv) {
    int len, *pre, *in, *post, *preTmp, *postTmp;

    scanf("%d", &len);
    pre = (int *) calloc(sizeof(int), len + 1);
    in = (int *) calloc(sizeof(int), len + 1);
    post = (int *) calloc(sizeof(int), len + 1);
    preTmp = pre;
    postTmp = post;
    for (int i = 0; i < len; i++) {
        scanf("%d", pre + i);
    }
    for (int i = 0; i < len; i++) {
        scanf("%d", in + i);
    }

    treeReconstruction(&preTmp, in, &postTmp, 0, len, len);

    for (int i = 0; i < len; i++) {
        if (i) {
            printf(" ");
        }
        printf("%d", post[i]);
    }
    printf("\n");

    free(pre);
    free(in);
    free(post);
    return 0;
}

void treeReconstruction(int** pre, int* in, int** post, int left, int right, int size) {
    // printf("%p\n", pre);

    if (left >= right) {
        return;
    }

    int root = *(*pre)++;
    int posIn = binarySearch(in, root, 0, size);

    if (posIn >= 0) {
        treeReconstruction(pre, in, post, left, posIn, size);
        treeReconstruction(pre, in, post, posIn + 1, right, size);

        *(*post)++ = root;
    } else {
        return;
    }
}

int binarySearch(int* arr, int val, int left, int right) {
    if (left >= right) {
        return -1;
    }

    int halfPos = left + (right - left) / 2;

    if (*(arr + halfPos) == val) {
        return halfPos;
    }

    int foundLeft = binarySearch(arr, val, left, halfPos);

    if (foundLeft < 0) {
        return binarySearch(arr, val, halfPos + 1, right);
    } else {
        return foundLeft;
    }
}


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

int main(void){
    char a[128],b[128];
    int i;
    scanf("%s%s",a,b);
    if(strlen(a)>strlen(b)){printf("GREATER\n");return 0;}
    if(strlen(a)<strlen(b)){printf("LESS\n");return 0;}
    for(i = 0;i < strlen(a);i++){
        if(a[i]>b[i]){printf("GREATER\n");return 0;}
        if(a[i]<b[i]){printf("LESS\n");return 0;}
    }
    printf("EQUAL\n");
    return 0;
}

Measured memory_bytes: 128
a1 = input().split()
a2 = input().split()
a3 = input().split()

n = int(input())

bingo_sheet = a1 + a2 + a3

atari = []


for _ in range(n):
    num = input()
    try:
        atari_index = bingo_sheet.index(num)
        atari.append(str(atari_index + 1))
    except:
        continue


atari_true = False

if '1' in atari:
    if '2' in atari:
        if '3' in atari:
            atari_true = True
    if '4' in atari:
        if '7' in atari:
            atari_true = True
    if '5' in atari:
        if '9' in atari:
            atari_true = True

if '2' in atari:
    if '5' in atari:
        if '8' in atari:
            atari_true = True

if '3' in atari:
    if '6' in atari:
        if '9' in atari:
            atari_true = True
    if '5' in atari:
        if '7' in atari:
            atari_true = True

if '4' in atari:
    if '5' in atari:
        if '6' in atari:
            atari_true = True

if '7' in atari:
    if '8' in atari:
        if '9' in atari:
            atari_true = True
            
if atari_true:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3064
N = int(input())
count = [0,0,0,0]
for i in range(N):
    s = input()
    if s == 'AC':
        count[0] += 1
    elif s == 'WA':
        count[1] += 1
    elif s == 'TLE':
        count[2] += 1
    elif s == 'RE':
        count[3] += 1
    else:
        continue
print('AC x ' + str(count[0]))
print('WA x ' + str(count[1]))
print('TLE x ' + str(count[2]))
print('RE x ' + str(count[3]))

    
    
    

Measured memory_bytes: 9216
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in=new Scanner(System.in);
	    int n=in.nextInt();
	    int a=in.nextInt();
	    int b=in.nextInt();
	    if(Math.abs(a-b)%2==0){
	        System.out.println("Alice");
	    }
	    else{
	        System.out.println("Borys");
	    }
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(){
int a,b,op;
int x;
while(1){


scanf("%d %c %d",&a,&op,&b);

if( op == '+'){
   x=a+b;
   printf("%d\n",x);
}
else if( op == '-' ){
   x=a-b;
   printf("%d\n",x);
}
else if( op == '*'){
   x=a*b;
   printf("%d\n",x);
}
else if( op == '/'){
   x=a/b;
   printf("%d\n",x);
}
else if( op == '?')
 break;


}
return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll nasya,sum=0;
 cin>>nasya;
 ll a[nasya+10];
 rep(i,0,nasya){
  cin>>a[i];
  sum+=a[i];
 }
 sum/=2;
 ll ans[nasya+10]={};
 ans[0]=sum;
 i=1;
 while(i<nasya){
  ans[0]-=a[i];
  i+=2;
 }
 //tmpが一つ目の山に降った雨
 rep(i,1,nasya){
  ans[i]=a[i-1]-ans[i-1];
 }
 ans[nasya-1]=a[nasya-1]-ans[0];
 rep(i,0,nasya)pr(ans[i]*2);
return 0;}


Measured memory_bytes: 5132
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, L = map(int, raw_input().split())
a = map(int, raw_input().split())
b = [0]*(N - 1)
for i in xrange(N - 1):
    b[i] = a[i] + a[i + 1]

mx, idx = 0, 0
for i, bi in enumerate(b):
    if bi > mx:
        mx = bi
        idx = i

if mx >= L:
    print "Possible"
    for i in xrange(idx):
        print i + 1
    for i in xrange(N - 1, idx, -1):
        print i
else:
    print "Impossible"


Measured memory_bytes: 12620
N=input()
ans=0
for i in range(2**((len(N)-1))):
  b = N[len(N)-1]
  for j in range(len(N)-1):
    if (i>>j)&1==1:
      ans += int(b)
      b = N[len(N)-2-j]
    else:
      b = N[len(N)-2-j] + b
  else:
    ans += int(b)
print(ans)  

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

int main()
{
	int nInput1, nInput2, nInput3;

	while (cin >> nInput1 >> nInput2 >> nInput3)
	{
		if ((nInput1 < nInput2) && (nInput2 < nInput3))
		{
			cout << "Yes"<< endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3096
import math
n = int(input())
#P position t time
P = [0,0]
t0 = 0
for _ in range(n):
  t,x,y = map(int, input().split( ))
  dt = t - t0
  dis = abs(x - P[0])  + abs(y - P[1])
  if dis > dt:
    print('No')
    exit()
  elif (dt - dis)%2 == 1:
    print('No')
    exit()
  t0 = t
  P = [x,y]
print('Yes')
    


Measured memory_bytes: 9204
#pragma comment(linker, "/stack:200000000")

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

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 3e3 + 123 , mod = 1e9 + 7;
int n , m ;
ld dp[N][N] , a[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n ;
	ld ror = 1;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
		ror *= a[i];
	}
	dp[1][1] = a[1];
	dp[1][0] = 1.0L - a[1];
	for(int i = 2 ; i <= n ; i++){
		for(int j = 0 ; j <= i ; j++){
			ld prob1 = dp[i - 1][j] * (1.0L - a[i]); 
			ld prob2 = dp[i - 1][j - 1] * a[i];
			dp[i][j] = prob1 + prob2;
		}
	}
	ld ans = 0;
	for(int i = n / 2 + 1 ; i <= n ; i++){
		ans += dp[n][i];
	}
	
	printf("%.10Lf" , ans);
}

Measured memory_bytes: 145920
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
const int mod = 998244353;

int main() {
    ll n, s; cin >> n >> s;
    vl a(n); rep(i,n) cin >> a[i];
    vl dp(6060);
    dp[0] = 1;
    rep(i,n) {
        vl ndp(6060);
        rep(j,3030) {
            (ndp[j] += dp[j] * 2) %= mod;
            (ndp[j+a[i]] += dp[j]) %= mod;
        }
        dp = ndp;
    }
    cout << dp[s] << endl;
    return 0;
}


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

int main()
{
	int d,t,s;
	cin>>d>>t>>s;

	float d1,t1,s1,req;

	req=(float)d/(float)t;
	float req1=(float)s;
	if(req<=req1)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;

	return 0;

}

Measured memory_bytes: 3632
a,b = map(int,input().split())
s = list(input())
x = ["0","1","2","3","4","5","6","7","8","9"]
flag = True
for i in range(a):
    if not s[i] in x:
        flag = False
for i in range(b):
    if not s[a+1+i] in x:
        flag = False
if s[a] != "-":
    flag = False
if flag:
    print("Yes")
else:
    print("No")
    

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[2][1000100];

void solve() {
    ll N, W;
    cin >> N >> W;
    Vl ws(N), vs(N);
    for (ll i = 0; i < N; i++) {
        cin >> ws[i] >> vs[i];
    }

    for (ll i = 0; i < N; i++) {
        swap(dp[0], dp[1]);
        memset(dp[1], 0, sizeof(ll) * W);
        for (ll j = 0; j <= W; j++) {
            dp[1][j] = dp[0][j];
            if (j - ws[i] >= 0)
                chmax(dp[1][j], dp[0][j - ws[i]] + vs[i]);
        }
    }

    prints()(dp[1][W]);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
	ll x;
	cin >> x;
	ll ans = x / (ll)11;
	ans *= 2;
	ll get = x % (ll)11;
	if (get > 6) ans += 2;
	else if (get > 0) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a < b){
				int t = a;
				a = b;
				b = t;
			}
			int t = 0;
			while(true){
				t = a % b;
				if(t == 0){
					break;
				}
				a = b;
				b = t;
			}
			System.out.println(b);
		}
	}
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> flag(n, true);
    for (int i = 0; i < n; ++i){
        cin >> h[i];
    }
    for (int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        if (h[a] <= h[b]) flag[a] = false;
        if (h[b] <= h[a]) flag[b] = false;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i){
        if (flag[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
fun main(args: Array<String>) = ABC167D.main()

object ABC167D {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (N, K) = readLongs()
        val A = listOf(-1) + readInts() // 1-indexed

        val visited = mutableSetOf(1)
        val dests = mutableListOf(1)

        var next = A[dests.last()]
        while (!visited.contains(next)) {
            dests.add(next)
            visited.add(next)
            next = A[dests.last()]
        }
        val loopStart = dests.indexOf(next)
        val loopRange = dests.size - loopStart

        val destIndex = if (K <= dests.lastIndex) K
        else ((K - loopStart) % loopRange) + loopStart

        val ans = dests[destIndex.toInt()]
        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 86680
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;

int N, temp;
int ans = 1;
int line[100100];

int checkList(){
    if(N % 2 == 1){
        /*if(line[0] != 0){
            return 0;
        }
        for(int i = 0; i < N; i++){
            temp = i;
            if(i % 2 == 1){
                temp++;
            }
            if(line[i] != temp){
                return 0;
            }
        }*/
        for(int i = 0; i < N; i++){
            if(line[i] != (i+1)/2*2){
                return 0;
            }
        }
        for(int i = 0; i < N / 2; i++){
            ans *= 2;
            ans %= 1000000007;
        }


        return ans % 1000000007;
    }else{
        /*for(int i = 0; i < N; i++){
            temp = i;
            if(i % 2 ==0){
                temp++;
            }
            if(line[i] != temp){
                return 0;
            }
        }*/
        for(int i = 0; i < N; i++){
            if(line[i] != i/2*2+1){
                return 0;
            }
        }
        for(int i = 0; i < N / 2; i++){
            ans *= 2;
            ans %= 1000000007;
        }
        return ans;
    }
}


int main(){
    cin >>N;
    for(int i = 0; i < N; i++){
        cin >>line[i];
    }
    sort(line, line + N);
    ans = checkList();
    //for(int i = 0; i < N; i++) {
    // if(i)cout << " ";
    //   cout << line[i];
    //}
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, K, c;
    cin >> n >> K >> c;
    string s;
    cin >> s;
    vector<int> l(n), r(n);
    {
        int pos = 0;
        while (s[pos] == 'x') pos++;
        int cnt = 1;
        for (int i = pos; i < n;) {
            int j = i + c + 1;
            while (j < n && s[j] == 'x') j++;
            for (int k = i; k < min(n, j); k++) l[k] = cnt;
            cnt++;
            i = j;
        }
    }
    {
        int pos = n - 1;
        while (s[pos] == 'x') pos--;
        int cnt = 1;
        for (int i = pos; i >= 0;) {
            int j = i - c - 1;
            while (j >= 0 && s[j] == 'x') j--;
            for (int k = i; k > max(-1, j); k--) r[k] = cnt;
            cnt++;
            i = j;
        }
    }
    for (int i = 0; i < n; i++) {
        int now = 0;
        if (i > 0) now += l[i - 1];
        if (i < n - 1) now += r[i + 1];
        if (now < K) cout << i + 1 << endl;
    }
}


Measured memory_bytes: 3332
a,b,c = map(int,input().split())
if c-a-b>0:
    if 4*(a*b)<(c-a-b)**2:
        print("Yes")
    else:
        print("No")
else:
    if a+b+2*(a*b)**0.5<c:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>
#define ms(x,y)                     memset(x,y,sizeof(x))
#define ump                         unordered_map<int,int>

#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265

const int MOD = 1e9 + 7;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}

inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}

inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}

inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}

bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}

int dp[3001][3001];
int arr[3001];
int solve(int i, int j)
{
    if (dp[i][j] != -1)return dp[i][j];
    if (i == j)return arr[i];

    int ans = max(arr[i] - solve(i + 1, j), arr[j] - solve(i, j - 1));
    return dp[i][j] = ans;
}
int32_t main()
{

    int n; cin >> n;

    for (int i = 0; i < n; i++)cin >> arr[i];
    ms(dp, -1);
    int ans = solve(0, n - 1);
    cout << ans << endl;

}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
bool is_acgt(char x){
  if( x=='A' || x=='C' || x=='G' || x=='T'){
    return true;
  } else {
    return false;
  }
}

int main(void) {
  string s;
  cin >> s;

  int tmp=0, ans=0;
  rep(i,s.size()){
    if(is_acgt(s[i])){
      tmp++;
    } else {
      tmp=0;
    }
    ans=max(ans, tmp);
  }

  prt(ans);

}


Measured memory_bytes: 256
s=input()
l=[s[0]]
ans=0
last_pos=-1
for i in range(1,len(s)):
    if i<=last_pos:
        continue
    n=1
    while i+n-1<=len(s):
        t=s[i:i+n]
        if t!=l[-1]:
            l.append(t)
            ans+=1
            last_pos=i+n-1
            break
        n+=1
#print(l)
print(len(l))

Measured memory_bytes: 8064
#include <cstdio>
int main() {
  long long A, B, C, D, N;
  long long ans = 0;
  scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &D, &N)+1;
  long long MIN2 = A * 8;
  if (B*4 < MIN2) MIN2 = B*4;
  if (C*2 < MIN2) MIN2 = C*2;
  if (D < MIN2) MIN2 = D;
  ans += (N / 2) * MIN2;
  N = N % 2;
  
  long long MIN1 = A * 4;
  if (B*2 < MIN1) MIN1 = B*2;
  if (C < MIN1) MIN1 = C;
  
  if (N == 1) ans += MIN1;
  
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b,c, temp;
    scanf("%d %d %d",&a,&b,&c);

    if(a>b){
        temp = a;
        a = b;
        b = temp;
    }
    if(b>c){
        temp = b;
        b = c;
        c = temp;
    }
    if(a>b){
        temp = a;
        a = b;
        b =temp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(), vec.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define repc(bit, k, n) for (ll bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit))
#define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr)
using namespace std;

bool not_prime_number[100001];
int dp[100001];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n = 100000;
  not_prime_number[0] = true;
  not_prime_number[1] = true;
  rep(i, n)
  {
    if (not_prime_number[i])
      continue;
    rep(j, n)
    {
      if (i * (j + 2) > n)
        break;
      not_prime_number[i * (j + 2)] = true;
    }
  }
  rep(i, n)
  {
    if (i * 2 + 1 > n || i + 1 > n)
      break;
    if (not_prime_number[i * 2 + 1] || not_prime_number[i + 1])
      dp[i * 2 + 1] = dp[i * 2 - 1];
    else

      dp[i * 2 + 1] = dp[i * 2 - 1] + 1;
  }
  int q;
  cin >> q;
  rep(i, q)
  {
    int l, r;
    cin >> l >> r;
    if (l == 1)
      cout << dp[r] << endl;
    else
      cout << dp[r] - dp[l - 2] << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
import sys
rl = sys.stdin.readline


def solve():
    S = input()
    reverse_S = list(reversed(S))
    for i in range(len(S)):
        if S[i] != reverse_S[i]:
            print('No')
            exit()
    s2 = S[:(len(S) - 1) // 2]
    reverse_s2 = list(reversed(s2))
    for i in range(len(s2)):
        if s2[i] != reverse_s2[i]:
            print('No')
            exit()
    s3 = S[(len(S) + 3) // 2 - 1:]
    reverse_s3 = list(reversed(s3))
    for i in range(len(s3)):
        if s3[i] != reverse_s3[i]:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

const int INF = 100000000;

int main(void)
{

    int n, m;
    if (scanf("%d%d", &n, &m) < 2) return 0;

    array<int, 1000> a;
    array<int, 1000> b;
    array<int, 1000> c;
    array<array<int, 100>, 100> dist;

    for(int i = 0; i < m; i++)
    {
        if (scanf("%d%d%d", &a[i], &b[i], &c[i]) < 3) return 0;

        // 0-indexed
        a[i]--;
        b[i]--;
    }

    // initialization
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }

    for (int i = 0; i < m; i++)
    {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
    }

    // Warshall-Floyd
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = m;
    for (int i = 0; i < m; i++)
    {
        bool shortest = false;
        for (int j = 0; j < n; j++)
        {
            if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
        }

        if (shortest == true)
        {
            ans = ans - 1;
        }
    }

    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
   int n,m,cnt=0,ans;
   cin >> n >> m ;

   int a[m];
   for(int i=0; i<m; i++){
       cin >> a[i] ;
       cnt += a[i];
   }
   
   if(cnt > n){
       ans = -1;
   }else{
       ans = n - cnt;
   }

   cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X,Y; cin>>X>>Y;
    vint v;
    v.push_back(X);
    while(X*2<=Y){
        X*=2;
        v.push_back(X);
    }
    cout<<v.size()<<endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
p.insert(0, 0)
c.insert(0, 0)
visit = [0] * (n + 1)
cyclelist = []
for i in range(1, n + 1):
    if visit[i] == 0:
        a = [c[i]]
        visit[i] = 1
        while visit[p[i]] == 0:
            i = p[i]
            visit[i] = 1
            a.append(c[i])
        cyclelist.append(a)
ans = -1145141919810
for cycle in cyclelist:
    s = sum(cycle)
    l = len(cycle)
    a = 0
    if l < k and s > 0:
        a = s * ((k - 1) // l)
    now = 0
    x = k % l
    if x == 0:
        x = l
    for i in range(min(k, l)):
        now += cycle[i]
        for j in range(l):
            now += cycle[(i + j + 1) % l] - cycle[j]
            if i < x:
                ans = max(ans, a + now)
            else:
                ans = max(ans, now)
print(ans)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int result=0;
  for(int i=1;i<N+1;i++){
    int count=i%10+i/10%10+i/100%10+i/1000%10+i/10000;
    if(A<=count&&count<=B) result+=i;
  }
  cout << result << endl;
}


Measured memory_bytes: 256