akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8
n, m = map(int, input().split())
num = '0' * n
count = [0, 0, 0]


for i in range(m):
    s, c = map(int, input().split())
    if (n >= 2 and s == 1 and c == 0) or (count[s-1] >= 1 and int(num[s-1]) != c):
        print(-1)
        exit()
    else:
        count[s-1] += 1
        if int(num[s-1]) != c:
            num = list(num)
            num[s-1:s] = str(c)
            num = ''.join(num)

if len(num) >= 2 and num[0] == '0':
    num = list(num)
    num[0:1] = '1'
    num = ''.join(num)

print(num)


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

int main()
{
    std::size_t H, W, K;
    std::cin >> H >> W >> K;
    std::vector<std::vector<bool>> chocolate(H, std::vector<bool>(W, false));

    for(auto& line : chocolate)
    {
        std::string S;
        std::cin >> S;
        for(std::size_t i=0; i<W; ++i)
        {
            line.at(i) = S.at(i) == '1';
        }
    }


    std::size_t min_div = 0xFFFF'FFFF'FFFF'FFFF;
    for(std::uint16_t i=0; i<512; ++i)
    {
        const std::bitset<16> b(i);

        std::array<std::size_t, 10> num_whites; // per line
        num_whites.fill(0);

        bool is_possible = true;
        std::size_t count = b.count();
        for(std::size_t i=0; i<W; ++i)
        {
            for(std::size_t j=0; j<H; ++j)
            {
                num_whites[j] += chocolate[j][i] ? 1 : 0;
            }

            bool less_than_K = true;
            std::size_t num_white_in_block = 0;
            for(std::size_t j=0; j<H; ++j)
            {
                num_white_in_block += num_whites[j];
                if(K < num_white_in_block)
                {
                    less_than_K = false;
                    break;
                }
                if(b[j])
                {
                    num_white_in_block = 0; // divided. reset
                }
            }

            if(not less_than_K)
            {
                num_whites.fill(0);
                for(std::size_t j=0; j<H; ++j)
                {
                    num_whites[j] += chocolate[j][i] ? 1 : 0;
                }

                // check whether this division can achieve the goal
                num_white_in_block = 0;
                for(std::size_t j=0; j<H; ++j)
                {
                    num_white_in_block += num_whites[j];
                    if(K < num_white_in_block)
                    {
                        is_possible = false;
                        break;
                    }
                    if(b[j])
                    {
                        num_white_in_block = 0; // divided. reset
                    }
                }
                if(not is_possible) {break;}

                count += 1;
            }
        }
        if(is_possible)
        {
            min_div = std::min(min_div, count);
        }
    }
    std::cout << min_div << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,x;
    cin >> N >> x;
    
    if(x == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }
    
    deque<int> A;
    A.push_back(x);
    int s = 1,t = N*2-1;
    
    int n = 1;
    while (n*2-1 < 2*N-1) {
        if(n % 2 == 1){
            A.push_front(s);
            A.push_back(t);
            s++,t--;
            n++;
        }else{
            A.push_front(t);
            A.push_back(s);
            s++,t--;
            n++;
        }

        if(s == x) s++;
        if(t == x) t--;
    }
    
    cout << "Yes" << endl;
    rep(i,N*2-1) cout << A[i] << endl;
    

    return 0;
}


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

string N;
int K;
int dp[110][3][5];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K;
    int L = N.size();
    dp[0][0][0] = 1;
    rep(i, L) {
        int D = N[i]-'0';
        rep(j, 2) rep(k, K+1) {
            int max_d = j==0 ? D+1:10;
            rep(d, max_d) {
                int nk = k+(d!=0 ? 1:0);
                if (nk>K) continue;
                dp[i+1][j|(d<D)][nk] += dp[i][j][k];
            }
        }
    }
    cout << dp[L][0][K]+dp[L][1][K] << endl;
}

Measured memory_bytes: 256
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
    int a[101][101][101];
    int p[100000]={0};
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                a[i][j][k]=i*i+j*j+k*k+i*j+j*k+i*k;
                p[a[i][j][k]]++;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cout<<p[i]<<endl;
    return 0;
}


Measured memory_bytes: 4036
import java.util.*;

public class Main {
	static long[] pattyCounts = new long[51];
	static long[] burgerLengths = new long[51];
	static long layers;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		layers = in.nextLong();
		for( int i = 0; i <= 50; i++ ) {
			pattyCounts[i] = pattyCount(i);
		}
		for( int i = 0; i <= 50; i++ ) {
			burgerLengths[i] = burgerLength(i);
		}
		System.out.println(solve(n, 1, burgerLengths[n]));
	}
	public static long solve(int level, long min, long max) {
		long mid = (max-min)/2 + min;
		if(layers == mid || min == max) {
			//System.out.printf("Base Case: %d Level: %d\n",(long)Math.ceil((double)pattyCounts[level]/2),pattyCounts[level]);
			if( layers >= mid ) return (long) Math.ceil((double)pattyCounts[level]/2);
			else return 0;
		} else if(layers > mid) {
			//System.out.printf("Greater Case: %d\n", pattyCounts[level-1]);
			return (long) pattyCounts[level-1] + 1 + solve( level-1, mid+1, max-1 );
		} else {
			return solve( level-1, min+1, mid-1 );
		}
	}
	public static long pattyCount(int n) {
		if( n == 0 ) return 1;
		return pattyCount(n-1)*2 + 1;
	}
	public static long burgerLength(int n) {
		if( n == 0 ) return 1;
		return burgerLength(n-1)*2 + 3;
	}
}

// BPPPB
// BBPPPBPBPPPBB
// 0012334456777
// 1234567890123
// 2

Measured memory_bytes: 22868
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int doku = Math.min(b+a+1, c);
        so.println(doku + b);
    }
}


Measured memory_bytes: 23764
#include <cstdio>

typedef long long ll;

inline int Abs(int x) {
	return x > 0 ? x : -x;
}

int main() {
	int x1, x2, v1, v2, t;
	scanf("%d%d%d%d%d", &x1, &v1, &x2, &v2, &t);
	puts(v1 > v2 && (ll)(v1 - v2) * t >= Abs(x1 - x2) ? "YES" : "NO");
	return 0;
}

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

int main() {
  string a,b;
  cin >> a >> b;
  int d=0;
  int e = b.size();
  int f = a.size();
  int c = f-e+1;
  for(int i=0;i<c;i++){
    int count = 0;
    for(int j=0;j<e;j++){
      if(a.at(i+j)==b.at(j))count++;
  }
    d = max(d,count);
  }
  cout << e-d << endl;
}

Measured memory_bytes: 3604
void main() {
    int n = readln.chomp.to!int;
    if (n == 1) {
        "Hello World".writeln;
    } else {
        writeln(readln.chomp.to!int + readln.chomp.to!int);
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

int idx,val[5000];
bool cand[5000]; // candidate leaf かどうか
vector<int> G[5000];

// u を根とする部分木を削除
void destroy(int u,int pre){
	rep(i,G[u].size()) if(G[u][i]!=pre) destroy(G[u][i],u);
	G[u].clear();
}

// numbosome の計算
void dfs0(int u,int pre){
	int a=3*val[u]+1;
	while(a%2==0) a/=2;
	if(a>12345678) a-=12345678;
	cand[u]=(G[u].size()<=1&&val[u]<a);
	val[u]=a;
	rep(i,G[u].size()) if(G[u][i]!=pre) dfs0(G[u][i],u);
}

// val==1 の頂点を削除
bool dfs1(int u,int pre){
	if(val[u]==1){
		if(pre!=-1 && G[u].size()==2){ // special case
			int v=(G[u][0]==pre?G[u][1]:G[u][0]);
			G[u].clear();
			rep(i,G[v].size()) if(G[v][i]==u) G[v].erase(G[v].begin()+i);
			G[pre].push_back( v );
			G[ v ].push_back(pre);
			dfs1(v,pre);
			return false;
		}
		else{
			destroy(u,pre);
			return pre==-1;
		}
	}
	else{
		rep(i,G[u].size()) if(G[u][i]!=pre) {
			int v=G[u][i];
			if(val[v]==1) G[u].erase(G[u].begin()+i--);
			dfs1(v,u);
		}
		return false;
	}
}

// leaf bonus の処理
void dfs2(int u,int pre){
	if(cand[u]){
		G[ u ].push_back(idx);
		G[idx].push_back( u );
		val[idx]=(val[u]+1)/2;
		if(val[idx]%2==0) val[idx]++;
		idx++;
	}
	else{
		rep(i,G[u].size()) if(G[u][i]!=pre) dfs2(G[u][i],u);
	}
}

// 生きている頂点のリストを求める
void dfs3(int u,int pre,vector<int> &res){
	res.push_back(u);
	rep(i,G[u].size()) if(G[u][i]!=pre) dfs3(G[u][i],u,res);
}

int main(){
	while(scanf("%d",val),val[0]){
		idx=1;
		int t,leader=0,sz=1;
		for(t=1;;t++){
			// step 0
			dfs0(leader,-1);

			// step 1
			if(dfs1(leader,-1)) break;

			// step 2
			dfs2(leader,-1);

			// step 3
			vector<int> seq;
			dfs3(leader,-1,seq);
			int next=-1;
			bool dup=false;
			rep(i,seq.size()){
				if(next==-1 || val[seq[i]]>val[next]){
					next=seq[i];
					dup=false;
				}
				else if(val[seq[i]]==val[next]){
					dup=true;
				}
			}
			if(!dup){ // leader bonus
				leader=next;
				G[leader].push_back(idx);
				G[idx].push_back(leader);
				val[idx]=(val[leader]+1)/2;
				if(val[idx]%2==0) val[idx]--;
				seq.push_back(idx);
				idx++;
			}

			sz=max(sz,(int)seq.size());
		}

		printf("%d %d\n",t,sz);
	}

	return 0;
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int k,t;
    cin >> k >> t;
    int ans = 0;
    rep(i,t){
        int x;
        cin >> x;
        ans = max(ans,x);
    }
    cout << max(0, ans - 1 - (k - ans)) << endl;
    return 0;
}

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

int main(void) {
    int N, ans=0;
    cin >> N;
    int p[N];
    for(int i=0; i<N; i++){
      cin >> p[i];
     }

    for(int i=0; i<N-2; i++){
       if(p[i]<p[i+1] && p[i+1]<p[i+2])
          ans++;
        else if(p[i]>p[i+1] && p[i+1]>p[i+2])
          ans++;
     }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<< endl;
  }
  if(S=="Cloudy"){
    cout<<"Rainy"<< endl;
  }
  if(S=="Rainy"){
    cout<<"Sunny"<< endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    g = defaultdict(set)
    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    path = deque([1])
    path.append(list(g[1])[0])
    path_s = set(path)
    while not (g[path[0]] | g[path[-1]]).issubset(path_s):
        l = g[path[0]] - path_s
        if l:
            for v in l:
                path.appendleft(v)
                path_s.add(v)
                break
            continue
        r = g[path[-1]] - path_s
        if r:
            for v in r:
                path.append(v)
                path_s.add(v)
                break
            continue

    print(len(path))
    print(' '.join(map(lambda x: str(x), path)))


def main():
    # N = read_int()
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    (slv(N, M, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 121044
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> b(N),a;
  rep(i,N){
    cin >> b[i];
  }

  while(b.size() > 0){
    auto it=b.begin(),mItr=b.begin()-1;
    int max = 0;
    int count=0;

    while(it != b.end()){
      if(count+1 == *it){
        if(max <= *it) {
          mItr = it;
          max = *it;
        }
      }
      count++;
      it++;
    }

    //ラストが1じゃないときはエラー
    if(mItr == b.begin()-1){
      cout << -1 << endl;
      return 0;
    }

    a.push_back(max);
    b.erase(mItr);
    if(b.size()==0) break;
  }
  rep(i,a.size()){
    cout << a[a.size()-1-i] << endl;
  }
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

int main() {
    int N, T; cin >> N >> T;
    int best = INT_MAX;
    rep(i,N){
        int ci,ti; cin >> ci >> ti;
        if (ti <= T) best = min(best, ci);
    }
    if (best == INT_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << best << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int L; cin >> L;
	cout << setprecision(15);
	cout << (L * L * L / 27.0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f[55],e[55][55];
inline int ff(int a){
    if(f[a]==a)
        return a;
    return f[a]=ff(f[a]);
}
int main(int argc, char** argv) {
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        e[u][v]=1;
        e[v][u]=1;
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(!e[i][j]) continue;
            e[i][j]=0;
            for(int k=1;k<=n;k++) f[k]=k;
            for(int k=1;k<=n;k++){
                for(int l=k+1;l<=n;l++){
                    if(e[k][l])
                        f[ff(l)]=ff(k);
                }
            }
            for(int k=2;k<=n;k++){
                if(ff(k)!=ff(k-1)){
                    ++ans;
                    break;
                }
            }
            e[i][j]=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean canTravel = true;
		int T = 0, X = 0, Y = 0;
		for(int i = 0; i < N; i++) {
			int t = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
			int diff = t - T - Math.abs(x - X) - Math.abs(y - Y);
			canTravel = (diff % 2 == 0 && diff >= 0);
			T = t; X = x; Y = y;
		}
		System.out.println(canTravel ? "Yes" : "No");
	}
}

Measured memory_bytes: 86172
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    
    var ans = (0 until n).map { listOf(a[it], b[it], c[it]).distinct().size - 1 }.sum()
    println(ans)
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n;
vector<int> c;
bool dp[105][105];
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    c.resize(n);
    REP(i, n) cin >> c[i];

    REP(i, n-1){
        FOR(j, i+1, n){
            if(c[i] != c[j]) break;
            dp[i][j] = true;
        }
    }
    
    for(int len = 4; len <= n; len++){
        for(int l = 0; l < n; l++){
            int r = l + len - 1;
            if(r >= n) break;
            
            // ok ok パターン
            for(int m = l+2; m < n-1; m++){
                if(dp[l][m-1] && dp[m][r]) dp[l][r] = true;
            }
            
            // x ok x パターン
            if(c[l] == c[r] && dp[l+1][r-1]){
                for(int m = r; m < n; m++){
                    if(c[l] != c[m]) break;
                    dp[l][m] = true;
                }
                for(int m = l; m >= 0; m--){
                    if(c[r] != c[m]) break;
                    dp[m][r] = true;
                }
            }

            // x ok x ok x パターン
            for(int m = l+1; m < r; m++){
                if(c[l] == c[m] && c[m] == c[r]){
                    if(l + 1 != m && !dp[l+1][m-1]) continue;
                    if(m + 1 != r && !dp[m+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }

            // x ok x ok x パターンをどうするか -> 既にできてるっぽい？
            /* 例1:
            7
            1 2 2 1 2 2 1
            no <-これはyesになるはず
                
            例2:
            10
            1 2 2 1 2 2 1 2 2 1
            yes

            例3:
            10
            1 2 3 4 5 5 4 3 2 1
            yes
            */
        }
    }
    

    cout << (dp[0][n-1] ? "yes":"no") << endl;
}



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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
// #define INF 1e9
const ll INF = 1LL << 60;
ll square(ll x){
  return x * x;
}
ll dp[20005][300];

int main(){
  while(true){
    int N, M;
    cin >> N >> M;
    if(N == 0 && M == 0) break;
    vector<int> C(M), x(N);
    REP(i, M){
      cin >> C[i];
    }
    REP(i, N){
      cin >> x[i];
    }
    REP(i, 20005){
      REP(j, 258){
        dp[i][j] = INF;
      }
    }
    dp[0][128] = 0;
    REP(i, N){
      REP(j, 256){
        if(dp[i][j] == INF) continue;
        REP(k, M){
          int nx = max(0, min(255, j+C[k]));
          dp[i+1][nx] = min(dp[i+1][nx], dp[i][j] + square(x[i]-nx));
        }
      }
    }
    ll ans = INF;
    REP(i, 256){
      ans = min(ans, dp[N][i]);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 50072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double ang;
		double c;
		double angA = h * 30 + m * 0.5;
		double angB = m * 6;
		if(angA > angB) {
			ang = angA - angB;
			if(ang >= 180) ang = 360 - ang;
		}
		else if ( angA == angB) ang = 0;
		else {
			ang = angB -angA ;
			if(ang >= 180) ang = 360 - ang;
		}
		c = Math.pow(a, 2) + Math.pow(b, 2)
					- 2 * a * b * Math.cos(Math.toRadians(ang));
		c = Math.sqrt(c);
		String s = String.format("%.11f", c);
		System.out.println(s);
	}
}


Measured memory_bytes: 35996
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int main(void){

	int t,n;
	cin >> t;

	rep(i,t){
	cin >> n;

	vector<int>h(n),ud(n,0);
	rep(j,n)
	cin >> h[j];

	REP(k,1,n-1)
	ud[k]=h[k]-h[k-1];

	sort(ud.begin(),ud.end());

	cout << ud[n-1] << ' ' << abs(ud[0]) << endl;

	}

	return 0;

}

Measured memory_bytes: 1216
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    if(n>12)cout<<m<<endl;
    else if(n>5)cout<<m/2<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main()
{
    int n, R[MAX];
    cin>>n;
    for(int i=0; i<n; i++) cin>>R[i];
    int minv = R[0];
    int maxv = R[1]-R[0];
    for(int i=1; i<n; i++)
    {
        maxv = max(maxv,R[i]-minv);
        minv = min(minv, R[i]);

    }
    cout<<maxv<<endl;
    return 0;

}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stack>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険

#define rep(i,l,r)for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r)for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k)for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す
/*
   upll : (a<b)なら-1, (a=b)なら0, (a>b)なら1
 downll : (a<b)なら1, (a=b)なら0, (a>b)なら-1

 const void* a : 型を縛らずにconstをつける(=変数aが読み込み専用の変数であることを明示する)
        (ll*)a : 変数aがconst long long *型であると明示する
*/
// int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
// int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
// void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
// void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << b-a+1 - (b/c - (a-1)/c + b/d - (a-1)/d - b/(c*d/gcd(c,d)) + (a-1)/(c*d/gcd(c,d)))  << endl;

}

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

int main(){
    string s;
    string t;

    cin >> s >> t;
    t.erase(t.end() -1);
    if (s == t) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll Q;
    cin >> Q;
    multiset<ll> lst, rst;
    ll f = 0;
    ll lcnt = 0, rcnt = 0, B = 0, pre = -INF;
    while(Q--){
        ll t;
        cin>>t;
        if(t==1){
            ll a, b;
            cin >> a >> b;
            B += b;

            ll c;
            if(a>pre){
                if(lcnt<=rcnt){
                    lst.emplace(pre);
                    rst.emplace(a);
                    lcnt++;

                    c = *rst.begin();
                    rst.erase(rst.begin());
                    f += a - c;
                    pre = c;
                }
                else{
                    if(pre!=-INF){
                        rst.emplace(a);
                        rcnt++;
                        f += a - pre;
                    }
                    else{
                        pre = a;
                    }
                    
                }
            }
            else if(a<pre){
                if(lcnt<=rcnt){
                    lst.emplace(a);
                    lcnt++;
                    f += pre - a;
                }
                else{
                    rst.emplace(pre);
                    lst.emplace(a);
                    rcnt++;

                    c = *lst.rbegin();
                    auto dl = lst.end();
                    lst.erase(--dl);
                    f += pre - a;
                    pre = c;
                }
            }
            else{
                if(lcnt<=rcnt){
                    lst.emplace(a);
                    lcnt++;
                }
                else{
                    rst.emplace(a);
                    rcnt++;
                }
            }

        }
        else{
            cout << pre << " " << f + B << "\n";
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int N, M;
	cin >> N >> M;
	int L = 1;
	REP(i, M){
		L *= 2;
	}
	cout << (1900*M + 100*(N-M)) * L << endl;
    return 0;
}

Measured memory_bytes: 256
def judge(str)
  size = str.size
  (size/2).times do |i|
    return false unless str[i] == str[size-1-i]
  end
  true
end

a, b = gets.split(' ').map(&:to_i)
ret = 0
(a..b).each do |num|
  str = num.to_s.split('')
  ret += 1 if judge(str)
end
puts ret


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <set>
#include <map>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    int ans = 9999999;
    for (int i = 1; i < N/2+1; i++) {
        int A = i;
        int B = N-A;
        int l = 0;
        while (A > 0) {
            l += A%10;
            A/=10;
        }
        while (B > 0) {
            l += B%10;
            B/=10;
        }
        ans = min(ans, l);
    }

    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int count=0;
        for(int i=0;i<=9;i++)
            for(int j=0;j<=9;j++)
                for(int k=0;k<=9;k++)
                    for(int l=0;l<=9;l++)
                        if(n==i+j+k+l)
                            count++;
        printf("%d\n",count);
    }
    return 0;
}

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

int fnc(int a){
	if ( a%2 == 0 )
      return a / 2;
	else
      return a * 3 + 1;
}

int main(){
  int s ;
  cin >> s ;
  
  set<int> a;
  a.insert(s);
  vector<int> v;
  v.push_back(s);
  
  for ( int i = 1 ; i < 1000000 ; i++ ){
    v.push_back(fnc(v.at(i-1)));
    if(a.count(v.at(i))){
      cout << i+1 << endl;
      break;
    }    
    a.insert(v.at(i));
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 998244353;
i64 n, dp1[2][90001], dp2[2][90001];
vector<i64> a;

i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}

int main() {
  cin >> n;
  read_n(a, n);

  i64 sum = accumulate(begin(a), end(a), 0);

  dp1[0][0] = dp2[0][0] = 1;
  for (i64 i = 1; i <= n; ++i) {
    i64 x = a[i - 1], j = i & 1, k = (i ^ 1) & 1;
    for (i64 l = 0; l <= sum; ++l) {
      dp1[j][l] = (2 * dp1[k][l] + (l - x >= 0 ? dp1[k][l - x] : 0)) % mod;
      dp2[j][l] = (    dp2[k][l] + (l - x >= 0 ? dp2[k][l - x] : 0)) % mod;
    }
  }
  i64 y = 0;
  for (i64 l = (sum + 1) / 2; l <= sum; ++l)
    y += dp1[n & 1][l] - 2 * dp2[n & 1][l];
  y = (y + 301 * mod) % mod;

  i64 all = (ipow(3, n) - 3 * ipow(2, n) + 10 * mod) % mod;
  i64 ans = (all - 3 * y + 10 * mod) % mod;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3072
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        
        while(sc.hasNext()){
            //中間試験
            int m = Integer.parseInt(sc.next());
            //期末試験
            int f = Integer.parseInt(sc.next());
            //再試験
            int r= Integer.parseInt(sc.next());
            //全て-1の場合処理終了
            if(m+f+r == -3) break;
            
            System.out.println(grades(m,f,r));
            
        }
    }
    //成績
    public static String grades(int m, int f, int r){
        //中間試験、期末試験のいずれかが-1(欠席)の場合はF
        if(m == -1 || f == -1) return "F";
        //中間試験と期末試験の合計点数
        int sum = m+f;
        //合計点数80以上ならばA
        if(sum >= 80) return "A";
        //合計点数65以上80未満ならばB
        else if(sum >= 65 && sum < 80) return "B";
        //合計点数50以上65未満ならばC
        else if(sum >= 50 && sum < 65) return "C";
        //合計点数30以上50未満ならば
        else if(sum >= 30 && sum < 50){
            //再試験の点数50以上ならばC
            if(r >= 50) return "C";
            //上記以外ならばD
            else return "D";
        }
        //合計点数30未満ならばF
        else return "F";
    }

}



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

int main()
{
  int n;
  cin >> n;
  char c[n];
  int a[n];
  for(int i=0;i<n;i++)
    {
      cin >> c[i] >> a[i];
    }
 
  char x[52];
  int y[52];

  for(int i=0;i<13;i++)
    {
      x[i]='S';     y[i]=i+1;
      x[i+13*1]='H';y[i+13*1]=i+1;
      x[i+13*2]='C';y[i+13*2]=i+1;
      x[i+13*3]='D';y[i+13*3]=i+1;
    }

  for(int i=0;i<52;i++)
    {
      for(int j=0;j<n;j++)
	{
	  if(x[i]==c[j]&&y[i]==a[j])goto out;
	 

	}
      cout << x[i] << " " << y[i] << endl;
    out:
      ;
    }

  return 0;
}

    

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int score(int s) {
  if (s>21) return 0;
  else return s;
}

int main() {
  string s;
  while(getline(cin, s)) {
    //cout << s << endl;
    stringstream ss(s);
    int a;
    int sum = 0;
    int num1 = 0;
    while(ss >> a) {
      if (a > 10)
        a = 10;
      sum += a;
      if (a == 1)
        num1++;
    }
    if (a == 0) break;
    int ans = 0;
    REP(i,num1+1) {
      ans = max(ans, score(sum + i*10));
    }
    cout << ans << endl;
  }
}

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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N; cin >> N;
    vector<int> A(N); cin >> A;
    A.erase(unique(A.begin(), A.end()), A.end());
    N = A.size();

    ll cash = 1000;

    int mi = INT_MAX, ma = 0;
    rep(i, N) {
        if (A[i] < mi) {
            mi = A[i];
        } else if (A[i] > ma) {
            ma = A[i];
        }
        if (i == N-1 || A[i+1] < A[i]) {
            if (mi < ma) {
                if (cash > mi) {
                    ll s = cash / mi;
                    cash += (ma - mi) * s;
                }
                mi = INT_MAX;
                ma = 0;
            }
        }
    }

    cout << cash << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], b[100005], k;
vector<int> c[100005];
set<pair<int, int> > used;
map<pair<int, int>, int> color;
bool v[100005];
void dfs(int idx){
	v[idx]=1; int j=1;
	for (int i=0; i<c[idx].size(); i++){
		if (!v[c[idx][i]]){
			for (j;;j++){
				if (used.find(make_pair(idx, j))==used.end()){
					used.insert(make_pair(idx, j));
					used.insert(make_pair(c[idx][i], j));
					color[make_pair(idx, c[idx][i])] = j;
					color[make_pair(c[idx][i], idx)] = j;
					dfs(c[idx][i]);
					break;
				}
			}
		}
	}
	return;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=1; i<n; i++){
	cin >> a[i] >> b[i];
	c[a[i]].push_back(b[i]);
	c[b[i]].push_back(a[i]);
}
for (int i=1; i<=n; i++){
	k=max(k, (long long)c[i].size());
}
cout << k;
dfs(1);
for (int i=1; i<n; i++)
	cout << endl << color[make_pair(a[i], b[i])];
return 0;
}

Measured memory_bytes: 29568
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    H = sorted([int(x) for x in input().split()])

    if K == 0:
        print(sum(H))
    elif N > K:
        print(sum(H[:-K]))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31612
#include <iostream>
#include <cmath>

int main(int argc, char const* argv[])
{
  int n;
  std::cin >> n;

  int tb = 0;
  int xb = 0;
  int yb = 0;

  for (int i = 0; i < n; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;

    int required_step = abs(x - xb) + abs(y - yb);
    int duration = t - tb;
    if (required_step > duration || (0x1 & required_step) != (0x1 & duration)) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def tleft(fn, lo, hi):
    """
    fn の結果が最も小さくなるインデックスを三分探索する
    :param callable fn:
    :param int lo: 最小のインデックス
    :param int hi: 最大のインデックス + 1
    :return: lo <= ret < hi
    """
    left = lo
    right = hi
    while abs(right - left) >= 3:
        r1 = (left * 2 + right) // 3
        r2 = (left + right * 2) // 3
        if fn(r1) <= fn(r2):
            right = r2
        else:
            left = r1
    if left + 1 >= hi or fn(left) <= fn(left + 1):
        return left
    if left + 2 >= hi or fn(left + 1) <= fn(left + 2):
        return left + 1
    return left + 2


def cost(n):
    return np.abs(A + n).sum()


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
A = np.array(A, dtype=int) - np.arange(N, dtype=int)

i = tleft(cost, -1e18, 1e18)
print(int(cost(i)))


Measured memory_bytes: 31020
N = int(input())
a = list(map(int, input().split()))
a.sort()
alice = 0
bob = 0
ban = 0
while len(a) > 0:
    if ban % 2 == 0:
        alice += a.pop()
    else:
        bob += a.pop()
    ban += 1
print(alice - bob)

Measured memory_bytes: 3060
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        for(int i=0; i<s.Length-1; i++) {
            if(s[i] != s[i + 1]) {
                return "Yes";
            }
        }
        return "No";
    }
}

Measured memory_bytes: 11092
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <tuple>
#include <unordered_map>
using namespace std;
class frog
{
private:
	unordered_map<int,int> memo;
	int hop_from(int);
	int k;
	vector<int> stones;
	int n;
public:
	frog();
};

frog::frog() {
	cin >> n;
	cin >> k;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		stones.push_back(h);
	}
	int value = hop_from(0);
	cout << value;
}

int frog::hop_from(int x) {
	if (x == n-1) {
		return 0;
	}
	if (memo.find(x) == memo.end()) {
		int h = stones[x];
		int shortest_path = -1;
		for (int i = 1; i <= k; i++) {
			if (x + i >= n) {
				break;
			}
			int temp_path = abs(h - stones[x + i]);
			temp_path += hop_from(x + i);
			if (shortest_path < 0 || temp_path < shortest_path) {
				shortest_path = temp_path;
			}
		}
		memo[x] = shortest_path;
		return shortest_path;
	}
	else {
		return memo[x];
	}
}

int main(){
  frog* x = new frog();
  return 0;
}

Measured memory_bytes: 11024
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;


	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    ll N, Z, W;
    ll ans;
    cin >> N >> Z >> W;
    ll A[N];
    rep(i,N) cin >> A[i];
    if(N==1){
        ans = abs(A[0]-W);
    }else{
        ll tmp1 = abs(A[N-1]-W);
        ll tmp2 = abs(A[N-2]-A[N-1]);
        ans = max(tmp1, tmp2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[16][16],cnt;
bool vis[65536];
long long dp[65536];
vector<int>tmp;
long long dfs(int msk){
	if(msk==0)return 0;
	if(vis[msk])return dp[msk];
	for(int i=1;i<=msk-i;i++)
		if((msk|i)==msk)
			dp[msk]=max(dfs(i)+dfs(msk-i),dp[msk]);
	vis[msk]=1;
	return dp[msk];
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<n;j++)
			if(i&(1<<j))
				for(int k=j+1;k<n;k++)
					if(i&(1<<k))
						dp[i]+=a[j][k];
	cout<<dfs((1<<n)-1);
}

Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))

ans = 0
A = sorted(A)
#print(A)
l = 0
for i in range(1, N):
  while A[i] - A[l] > 2:
    l += 1
  now = i - l + 1
  ans = max(ans, now)
  #print(i, l, ans, now)
  
print(max(ans, 1))





Measured memory_bytes: 20756
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;cin>>k;
  string ss;cin>>ss;
  if(ss.size()<=k)cout<<ss<<endl;
  else {
    rep(i,k)cout<<ss[i];
    cout<<"..."<<endl;
  }
  return 0;
}


Measured memory_bytes: 3640
N, H = map(int,input().split())
L = []
maxi = 0
for _ in range(N):
    a,b = map(int,input().split())
    maxi = max(maxi, a)
    L.append((a,b))
cand = []
throw = 0
cnt = 0
for l in L:
    if maxi <  l[1]:
        throw += l[1]
        cand.append(l[1])
        cnt += 1
import math
if H - throw > 0: 
    print(math.ceil((H - throw)/maxi) + cnt )
else:
    throw = 0
    cnt = 0
    cand.sort()
    for x in cand[::-1]:
        throw += x
        cnt += 1
        if throw >= H:
            print(cnt)
            quit()



Measured memory_bytes: 18052
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef short T;
const int MOD = 10000;

bool even_is_up;
inline bool up_turn(int col) {
    bool even = (col & 1) == 0;
    return even_is_up ? even : !even;
}

// テ・ツ青?、ツスツ催」ツ?ョ M テ」ツ?ォテ」ツつ暗」ツつ?MODテッツシツ?
// mod_of[0]テ」ツ??テ」ツ?ョテ、ツスツ催ッツシツ稽od_of[1]テ」ツ??0テ」ツ?ョテ、ツスツ催「ツ?ヲテ「ツ?ヲ
int mod_of[501];
int M;

// memo[high_limited][low_limited][prev_digit][column][acc]
T memo[2][2][16][512][500];
vector<int> low_digits, high_digits;
int dfs(int col, int high_limited, int low_limited, int prev, int acc) {
    if(col == -1) return acc == 0;
    bool first_digit = (prev < 0 || prev >= 10);
    T dmy = -1;
    T &res =  first_digit ? dmy : memo[high_limited][low_limited][prev][col][acc];
    //cout << "come " << col << ' ' << prev << ' ' << acc << ": res = " << res << endl;
    if(res < 0) {
        res = 0;
        int low = low_limited ? low_digits[col] : 0;
        int high = high_limited ? high_digits[col] : 9;
        if(first_digit) low = max(low, 1);
        if(up_turn(col)) {
            low = max(low, prev+1);
        } else {
            high = min(high, prev-1);
        }
        for(int digit = low; digit <= high; ++digit) {
            int next_hl = high_limited && (digit == high_digits[col]);
            int next_ll = low_limited && (digit == low_digits[col]);
            //cout << col << ' ' << high_limited << ' ' << low_limited << ' ' << acc << ": choose " << digit << endl;
            res += dfs(col-1, next_hl, next_ll, digit, (acc+mod_of[col]*digit) % M);
            res %= MOD;
        }
    }
    return res;
}

void clear_memo() {
    const int nelems = sizeof(memo) / sizeof(T);
    fill_n((T*)memo, nelems, -1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string A, B;
    cin >> A >> B >> M;

    mod_of[0] = 1 % M;
    for(int i = 1; i <= 500; ++i) {
        mod_of[i] = (mod_of[i-1]*10) % M;
    }
    for(string::reverse_iterator it = A.rbegin(); it != A.rend(); ++it) {
        low_digits.push_back(*it - '0');
    }
    for(string::reverse_iterator it = B.rbegin(); it != B.rend(); ++it) {
        high_digits.push_back(*it - '0');
    }
    for(int i = 0; i < (int)B.size()-(int)A.size(); ++i) {
        low_digits.push_back(0); // sentinel
    }
    const int low_ord = (int)A.size()-1;
    const int high_ord = (int)B.size()-1;
    int res = 0;
    for(int step = 0; step < 2; ++step) {
        //cout << "step " << step << endl;
        even_is_up = (step == 0);
        clear_memo();
        for(int col = high_ord; col >= low_ord; --col) {
            if(col == 0 && step == 1) break; // 1テヲツ。ツ?」ツ?ョテヲツ閉ーテ」ツ?ョテ、ツコツ古ゥツ?催」ツつォテ」ツつヲテ」ツδウテ」ツδ暗ゥツ伉イテヲツュツ「
            bool low_limited = (col == low_ord);
            bool high_limited = (col == high_ord);
            int prev = up_turn(col) ? -1 : 10;
            res += dfs(col, high_limited, low_limited, prev, 0);
            res %= MOD;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 33284