akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
const int _=1e2;

int main()
{
	int m,d,ans=0;
	scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
		{
			int u=j/10,v=j%10;
			if(u>=2&&v>=2&&u*v==i)ans++;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[N][3], dp[N][3];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for (int i = 0; i < 3; i++)
        dp[1][i] = a[1][i];
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = a[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
    return 0;
}

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


int main() {
    int N;
    string judge;
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> judge;
        if(judge == "Y"){
            cout << "Four" << endl;
            return 0;
            
        }else{
            continue;
        }
        
    }
    cout << "Three" << endl;

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func main() {
	// r := bufio.NewReader(os.Stdin)
	// w := bufio.NewWriter(os.Stdout)
	// defer w.Flush()
	sc.Split(bufio.ScanWords)
	n := scanInt()
	m := scanInt()
	x := scanInt()

	slice := make([][]int, n)
	for i := 0; i < n; i++ {
		slice[i] = make([]int, m+1)
		for j := 0; j < m+1; j++ {
			slice[i][j] = scanInt()
		}
	}

	mincost := 100000*12 + 1 //最大値
	for bit := 0; bit < (1 << n); bit++ {
		und := make([]int, m)
		cost := 0
		for i := 0; i < n; i++ {
			if ((bit >> i) & 1) == 1 {
				cost += slice[i][0]
				for j := 0; j < m; j++ {
					und[j] += slice[i][j+1]
				}
			}
		}
		flg := false
		for j := 0; j < m; j++ {
			if und[j] < x {
				flg = true
			}
		}
		if flg {
			continue
		}
		if mincost > cost {
			mincost = cost
		}

	}
	if mincost == (100000*12 + 1) {
		mincost = -1
	}
	fmt.Println(mincost)
}


Measured memory_bytes: 2176
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, has[MAXN];
ll fact[MAXN], inv[MAXN];
ll a[MAXN];

ll power_mod(ll a, ll b, ll mod) {
	ll res = 1;
	while (b) {
		if (b % 2) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	
	return res;
}

ll C(int k, int n) {
	if (k > n) return 0;
	return fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	fact[0] = 1; inv[0] = 1;
	for (int i=1; i<MAXN; i++) {
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = power_mod(fact[i], MOD - 2, MOD);
	}

	cin >> n;
	for (int i=0; i<=n; i++) {
		cin >> a[i];
		has[a[i]]++;
	}
	
	int find = -1;
	for (int i=1; i<=n; i++) {
		if (has[i] == 2) {
			find = i;
			break;
		}
	}
	
	int st = -1, en = -1;
	for (int i=0; i<=n; i++) {
		if (a[i] == find) {
			if (!~st) st = i;
			else en = i;
		}
	}
	
	int len = st + (n - en);
//	len++;
	
	for (int i=1; i<=n; i++) {
		ll tot = (C(i, n + 1) - C(i - 1, len) + 1ll * MOD * MOD) % MOD;
		cout << tot << '\n';
	}
	
	cout << 1;


}


Measured memory_bytes: 5504
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define INF 105
#define NMAX 105

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int ans = 0;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	char last = 's';
	for (int i = 0; i < S.size(); ++i)
	{
		if(S[i] != last){
			last = S[i];
			ans++;
		}
	}
	ans--;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 512
n = int(input())

if (n + 1) % 108 == 0:
    print(':(')
else:
    if n % 108 == 0:
        print(n // 108 * 100)
    else:
        a = int(n / 1.08)
        for i in range(a, a + 3):
            s = i * 1.08
            if n <= s and s < n + 1:
                print(i)
                break
            if i == a + 2:
                print(':(')

Measured memory_bytes: 3060
object Main extends App {
	val temp = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	val N = scala.io.StdIn.readLong

	val Q = temp(0)
	val H = temp(1)
	val S = temp(2)
	val D = temp(3)

	var a1 = Array(S,H*2L,H+Q*2L,Q*4L).min
	var a2 = Array(D,a1*2L).min

	if(N%2L == 0){
		println(a2 * (N/2L))
	}else{
		println(a1 + a2 * ((N-1L)/2L))
	}

}

Measured memory_bytes: 25424
a, b, c = map(int, input().split())
ans = 0
while True:
  if a%2 == 1 or b%2 == 1 or c%2 == 1:
    break
  if a == b == c:
    ans = -1
    break
  na = (b+c) // 2
  nb = (a+c) // 2
  nc = (a+b) // 2
  ans += 1
  a, b, c = na, nb, nc
  #print(na,nb,nc,ans)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
typedef long long LL;
const int MOD=1e9+7;
const int N=2003;

int n,k,all;
int f[N][N];
int fac[N*N];
int ifac[N*N];

inline int Pow(int x,int p) {
	int y=1;
	for(;p;p>>=1,x=1ll*x*x%MOD)
		if(p&1) y=1ll*y*x%MOD;
	return y;
}
inline LL C(int x,int y) {
	return 1ll*fac[x]*ifac[y]%MOD*ifac[x-y]%MOD;
}
int main() {
	scanf("%d %d",&n,&k);
	if(k==1) {
		puts("1");
		return 0;
	}
	all=n*k;
	fac[0]=ifac[0]=1;
	for(int i=1;i<=all;i++)
		fac[i]=1ll*i*fac[i-1]%MOD;
	ifac[all]=Pow(fac[all],MOD-2);
	for(int i=all-1;i>=1;i--)
		ifac[i]=(i+1ll)*ifac[i+1]%MOD;
	f[0][0]=1;
	for(int i=1;i<=n;i++) {
		f[i][0]=f[i-1][0];
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]+1ll*f[i][j-1]*C(n*k-i-(j-1)*(k-1)-1,k-2))%MOD;
	}
	printf("%lld\n",1ll*f[n][n]*fac[n]%MOD);
	return 0;
}

Measured memory_bytes: 46756
N,M  = map(int, input().split())
pc_list = []
for i in range(N):
    p, c = map(int,input().split())
    pc_list.append([p,c])
    

pc_list.sort(key=lambda x:(x[0],x[1]))

pc_list

cnt = M
sum_price = 0
for p,c in pc_list:
    
    if c <= cnt:
        sum_price += p*c
        cnt -= c
    else:
        sum_price += p*cnt
        break
#     print(sum_price)
print(sum_price)

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

int gcd(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int n;
int arr[100000];
vector<int> v;
string s;
int main() {
    cin >> n;
    int sum=0;
    int sub = n;
    while(sub){
        sum += sub%10;
        sub/=10;
    }
    if(n%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,m,q=map(int,input().split())
l=[i for i in range(1,m+1)]
ab=[list(map(int,input().split())) for _ in range(q)]
ans=0
for res in itertools.combinations_with_replacement(l, n):
    ans_r=0
    for i in range(q):
        a,b,c,d=ab[i]
        if c==res[b-1]-res[a-1]:
            ans_r+=d
    ans=max(ans,ans_r)
print(ans)

Measured memory_bytes: 74240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prog[] = new int[n];
		for(int i = 0; i < n; i++) {
			prog[i] = sc.nextInt();
		}

		int q = sc.nextInt();
		for(int i = 0; i < q; i++) {
			int com = sc.nextInt();
			int b = sc.nextInt();
			int e = sc.nextInt();
			if(com == 0) {  //最小値
				int min = prog[b];
				for(int j = b + 1; j < e; j++) {
					if(prog[j] < min) min = prog[j];
				}
				System.out.println(min);
			}
			else {
				int max = prog[b];
				for(int j = b + 1; j < e; j++) {
					if(prog[j] > max) max = prog[j];
				}
				System.out.println(max);
			}
		}
	}

}



Measured memory_bytes: 34032
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String A = sc.next();
		String B = sc.next();

		BigDecimal bA = new BigDecimal(A);
		BigDecimal bB = new BigDecimal(B);
		BigDecimal ans = bA.multiply(bB);
		ans = ans.setScale(0, RoundingMode.DOWN);

		System.out.println(ans);

	}

}


Measured memory_bytes: 36084
#include <stdio.h>

int main(void) {
	int shinpan_num;
	int now,total,max,min;
	int i;
	while(1) {
		scanf("%d",&shinpan_num);
		if(shinpan_num==0)break;
		total=0;
		max=0;
		min=0x7fffffff;
		for(i=0;i<shinpan_num;i++) {
			scanf("%d",&now);
			if(now>max)max=now;
			if(now<min)min=now;
			total+=now;
		}
		total-=max+min;
		shinpan_num-=2;
		printf("%d\n",total/shinpan_num);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

 
int main(void){
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H){ 
     printf("Yes\n");
    }
    else{ 
     printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

int main(){
  char string[120];
  cin >> string;
  int n = strlen(string);
 
  for(int i=0;i<n;i++){
    int count = 0;
    for(int j =0; j<n;j++){
      if(string[i] == string[j]){
        count++;
      }
    }
    if(count % 2 != 0){
      cout << "No";
      return 0;
     }
  }
  cout <<"Yes";
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    string str;
    while(cin>>str){
        int cnt = 0;
        for(auto c:str){
            cnt=cnt+c-'0';
        }
        if(cnt%9==0)puts("Yes");
        else{
            puts("No");
        }
    }
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <map>
using namespace std;

vector<uint64_t> divisor(uint64_t N)
{
    vector<uint64_t> ret;
    for (uint64_t i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


bool ruijyo(uint64_t v)
{
    bool ret = false;
    
    map<uint64_t, uint64_t> m;
    uint64_t a = 2;
    while(v >= a * a) {
        if (v % a == 0) {
            v /= a;
            m[a] = 1;
        }else {
            a++;
        }
    }
    
    if (v != 1) {
        m[v] = 1;
    }
    
    if(m.size() == 1) {
        ret = true;
    }
    return ret;
}

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    uint64_t ans = 0;
    
    map<uint64_t, bool> z;
    while (N > 1) {
        vector<uint64_t> d = divisor(N);
        
        bool success = false;
        
        for (uint64_t v : d) {
            if (v == 1) {
                continue;
            }
            
            if (z.count(v) == 0) { // まだ未使用。
                if (ruijyo(v)) { // vが素数の累乗か判断する。
                    z[v] = true;
                    N /= v;
                    ans++;
                    success = true;
                    break;
                }
            }
        }
        
        if (!success) {
            break;
        }
        
    }
    std::cout << ans;
    
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,m,k;cin >> n >> m >> k;
  rep(i,n+1) {
    rep(j,m+1) {
      int tmp = i*m + j*n - 2*i*j;
      if(tmp == k) {
	cout << "Yes" << "\n";
	return 0;
      }
    }
  }
  cout << "No" << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
#define mx 1000000000
#define N 100005



int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int len=s.size();
    bool f=0;
    if(len==6){
        if(s[2]==s[3]&&s[4]==s[5]) f=1;
    }
    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

int main(){
  int n;
  ll x;
  cin>>n >>x;
  vector<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  ll cnt = 0;
  if(a[0]>x){
    cnt+=a[0]-x;
    a[0]=x;
  }
  
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      cnt+=a[i]+a[i+1]-x;
      a[i+1]-=a[i]+a[i+1]-x;
    }
  }
  
  cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  vector<int> w(v);
  sort(w.begin(), w.end());
  int a = w[n/2-1], b = w[n/2];
  for(auto e:v){
    if(e <= a) cout << b << endl;
    else cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <tuple>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N;
    cin >> N;
    ll n = N;
    //ごりっごり
    map<tuple<ll, ll, ll >, ll> conf;
    vector<tuple<ll, ll, ll > > ans;

    //入力
    vector<tuple<ll, ll, ll > > input;
    for(ll i = 0; i < N; i++){
        ll x, y, h;
        cin >> x >> y >> h;

        if(h == 0){
            n--;
        }

        input.push_back(make_tuple(x, y, h));
        
    }

    for(ll i = 0; i < N; i++){
        ll x, y, h;
        x = get<0>(input[i]);
        y = get<1>(input[i]);
        h = get<2>(input[i]);

        if(h == 0){
            continue;
        }

        for(ll X = 0; X <= 100; X++){
            for(ll Y = 0; Y <= 100; Y++){
                //cout << abs(x - X) + abs(y - Y) + h << endl;
                
                conf[make_tuple(abs(x - X) + abs(y - Y) + h, X, Y)]++;
                
                //cout << ans[make_tuple(abs(x - X) + abs(y - Y) + h, X, Y)] << endl;
                if(conf[make_tuple(abs(x - X) + abs(y - Y) + h, X, Y)] == n){
                    //cout << X << " " << Y << " " << abs(x - X) + abs(y - Y) + h << endl;
                    ans.push_back(make_tuple(X, Y, abs(x - X) + abs(y - Y) + h));
                    //cout << "good" << endl;
                }
            }
        }
    }


    //整合性を確認>あってるやつを出力

    for(ll i = 0; i < ans.size(); i++){
        ll cn = 0;
        ll cx, cy, ch;
        cx = get<0>(ans[i]);
        cy = get<1>(ans[i]);
        ch = get<2>(ans[i]);

        for(ll j = 0; j < N; j++){
            ll x, y, h;
            x = get<0>(input[j]);
            y = get<1>(input[j]);
            h = get<2>(input[j]);

            ll t_h =  max(ch - abs(x - cx) - abs(y - cy), ll(0) );

            if(h == t_h){
                cn++;
            }
        }

        if(cn == N){
            cout << cx << " " << cy << " " << ch << endl;
            break;
        }

    }

    //cout << ans.size() << endl;


} 

Measured memory_bytes: 38784
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	ll gcd(ll a, ll b, ll c) {
		ll res = std::gcd(a, b);
		res = std::gcd(res, c);
		return res;
		//return gcd(a, gcd(b, c));
	}

	void solve() {
		IOS;
		ll n;
		cin >> n;
		string s;
		cin >> s;
		ll res = 0;
		REP(i, n) {
			REP(j, n) {
				ll t1 = i + j;
				ll t2 = i + j * 2;
				if (t2 < n) {
					if (s[i] != s[t1] && s[i] != s[t2] && s[t1] != s[t2]) {
						res++;
					}
				}
			}
		}
		ll tmp = 0;
		vector<ll> cnt(3, 0);
		REP(i, n) {
			if (s[i] == 'R') {
				cnt[0]++;
			} else if (s[i] == 'G') {
				cnt[1]++;
			} else {
				cnt[2]++;
			}
		}
		tmp = cnt[0] * cnt[1] * cnt[2];
		put(tmp - res);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
string S;
int P[2];
int Q[2];
int belong[214514];

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N;
  rep(i, 2) {
    cin >> P[i];
    P[i]--;
  }
  rep(i, 2) {
    cin >> Q[i];
    Q[i]--;
  }

  cin >> S;
  int cnt = 0;
  int l = -1;
  vector<pii> segs;
  rep(i, N) {
    if (S[i] == '#') {
      cnt++;
      if (cnt == 2) {
        if (l != -1) {
          segs.eb(pii(l, i-1));
          assert(l < i-1);
        }
        l = -1;
        cnt = 0;
      }
    } else if (S[i] == '.') {
      if (l == -1) l = i;
      cnt = 0;
    } else assert(0);
  }
  if (l != -1) {
    segs.eb(pii(l, N));
  }

  fill(belong, belong+N, -1);
  rep(i, segs.size()) {
    //cout << segs[i].X<<" "<<segs[i].Y<<endl;
    reps(j, segs[i].X, segs[i].Y) {
      assert(belong[j] == -1);
      belong[j] = i;
    }
  }

  rep(i, 2) {
    assert(belong[P[i]] != -1);
    assert(belong[Q[i]] != -1);
    if (belong[P[i]] != belong[Q[i]]) {
      puts("No");
      return 0;
    }
  }

  if (belong[P[0]] != belong[P[1]]) {
    puts("Yes");
    return 0;
  }

  assert(P[0] < P[1]);
  assert(P[0] < Q[0]);
  assert(P[1] < Q[1]);
  if (P[0] < P[1] && P[1] < Q[1] && Q[1] < Q[0]) {
    assert(belong[P[0]] == belong[P[1]]);
    assert(belong[P[1]] == belong[Q[1]]);
    assert(belong[Q[0]] == belong[Q[1]]);
    int idx = belong[P[0]];
    int cnt = 0;
    int l = max(P[1]-1, segs[idx].X);
    int r = min(Q[1]+2, segs[idx].Y);
    reps(i, l, r) {
      if (S[i] == '.') cnt++;
      else if (S[i] == '#') cnt = 0;
      else assert(0);
      if (cnt >= 3) {
        puts("Yes");
        return 0;
      }
    }
    puts("No");
  } else {
    puts("Yes");
  }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll a;
    double b;
    cin>>a>>b;
    int b100=b*100+0.1;
    cout<<a*b100/100<<endl;
return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a; 
    cin >> a ;
    if (a<1200){ cout << "ABC" <<endl; }
    else cout << "ARC" <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		
		int a = X/500;
		int b = X%500/5;
		
		System.out.println(a*1000 + b*5);
	}
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	ll a[n];
	rep(i,0,n-1)
	cin>>a[i];
	priority_queue <ll> q;
	rep(i,0,n-1)
	q.push(a[i]);
	ll x;
	while(m--)
	{	
		x=q.top();
		x/=2;
		q.pop();
		q.push(x);
	}
	ll ans=0;
	while(n--)
	{
		ans+=q.top();
		q.pop();

	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 5008
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
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 c = sc.nextInt();

		ArrayList<Integer> listA = new ArrayList<Integer>();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		listA.add(a);
		listA.add(b);
		listA.add(c);

		ArrayList<Integer> listB = new ArrayList<Integer>(new HashSet<>(listA));
		
		Collections.sort(listB);

		int cost = 0;
		
		//最大の数から素数を探す
		for(int i = 1;i < listB.size();i++)
		{
			int tmp =  listB.get(i-1) - listB.get(i);
			cost = cost + Math.abs(tmp);
		}

   		System.out.println(cost);
   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;




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

    vector<ll> ans(0);

    //右からM桁目を確定させる
    ll M=0LL;
    while(N!=0LL||M==65LL){
        if(llabs(N)%(1LL<<(M+1))!=0LL){
            ans.emplace_back(1);
            N-=pow(-2LL,M);
        }
        else ans.emplace_back(0);
        M++;
    }
    if(ans.empty()){
        cout<<0<<endl;return 0;
    }
    ll j=ans.size();
    for(ll i=j-1;i>=0;i--){
        cout<<ans[i]
    ;}cout<<endl;
    

    return 0;
}


Measured memory_bytes: 256
/*版权所有，拷贝必究！*/
/*若想获得，请联系许希泉*/
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
const int INF = 0x3f3f3f3f;
int maxn=5000005;
using namespace std;
struct node{

};
bool is_pal(string a)
{
    string s=a;
    reverse(s.begin(),s.end());
    if(s==a)
    return true;
    else
    return false;
}
bool is_prime(int n)
{
    if(n==1)
	return false;
    if(n==2||n==3)
	return true;
    if(n%6!=1&&n%6!=5)
	return false;
    for(register int i=5;i*i<=n;i+=6)
    if(n%i==0||n%(i+2)==0)
	return false;
    return true;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	string s1,s2,s;
    int n,t,m,x,y,p,mut=1,sum=0,maxv=0,minv=1E5;
    cin>>n;
    cout<<n+n*n+n*n*n; 
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(){
  int K,N,i,max,dis;
  int A[200000];
  max=0;
  scanf("%d%d",&K,&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<N;i++){
    dis=A[i]-A[i-1];
    if(dis>max)
      max=dis;
  }
  
  dis=A[0]+K-A[N-1];
  if(dis>max)
    max=dis;
  
  dis=K-max;
  
  printf("%d",dis);
  
  return 0;
}

Measured memory_bytes: 2512
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;
int a[maxn],b[maxn];//,c[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)cin>>b[i];
    int r=n,l;
    reverse(b+1,b+1+n);//for(int i=1; i<=n; i++)c[i]=b[r--];
    l=1;r=n;
    for(int i=1; i<=n; i++){
        if(a[i]!=b[i])continue;
        if(l<i&&b[l]!=a[i]&&a[l]!=b[i]){
            swap(b[l],b[i]);
            l++;
        }else if(i<r&&b[r]!=a[i]&&a[r]!=b[i]){
            swap(b[r],b[i]);
            r--;
        }else return cout<<"No"<<endl,0;
    }
    cout<<"Yes"<<endl;
    for(int i=1; i<=n; i++)cout<<b[i]<<' ';
    return 0;
}


Measured memory_bytes: 4748
use std::io::{BufRead, Write, stdin, stdout};
use std::collections::VecDeque;

fn main() {
    let stdin = stdin();
    let reader = stdin.lock();
    let writer = stdout();
    solve(reader, writer);
}

fn solve<R, W>(mut reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut buf = String::new();
    reader.read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    let n: usize = input.next().unwrap().parse().unwrap();
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n {
        let u: usize = input.next().unwrap().parse().unwrap();
        let k: usize = input.next().unwrap().parse().unwrap();
        for _ in 0..k {
            graph[u - 1].push(input.next().unwrap().parse::<usize>().unwrap() - 1);
        }
    }

    let mut d: Vec<isize> = vec![-1; n];
    d[0] = 0;
    let mut queue: VecDeque<usize> = VecDeque::new();
    queue.push_back(0);
    while !queue.is_empty() {
        let u = queue.pop_front().unwrap();
        let nexts = &graph[u];
        for &n in nexts {
            if d[n] == -1 {
                d[n] = d[u] + 1;
                queue.push_back(n);
            }
        }
    }

    for i in 0..n {
        writeln!(&mut writer, "{} {}", i + 1, d[i]).unwrap();
    }
}



Measured memory_bytes: 5040
import heapq
x,y,a,b,c = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

x_tmp = P[:x]
y_tmp = Q[:y]

tmp_li = x_tmp+y_tmp
heapq.heapify(tmp_li)

for i in range(c):
    if R[i]>tmp_li[0]:
        heapq.heapreplace(tmp_li,R[i])
print(sum(tmp_li))

Measured memory_bytes: 29724
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    n=n/100;
    cout<<"ai1333";
    rep(i,n)cout<<3;
    cout<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
int main(){
	ll l,r;
	cin>>l>>r;
	ll d;
	cin>>d;
	ll cnt = 0;
	rep(i,l,r+1){
		if(i%d==0) ++cnt;
	}
	cout<<cnt;
}
		 

Measured memory_bytes: 3592
s = int(input())

res = s
i = 1


while True:
    if s == 1:
        print(4)
        break
    if s == 2:
        print(4)
        break
    if res == 1:
        print(i+1)
        break
    if res % 2 == 0:
        res = res // 2
        i = i+1
    else:
        res = res * 3 + 1
        i = i+1

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#include <unordered_map>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(3e5) + 17;

int n;
string s;

bool read() {
    if (!(cin >> n >> s))
        return false;

    return true;
}

void solve() {
    unordered_map<string, int> mp;
    mp.rehash(1 << (n + 1));

    for (int mask = 0; mask < (1 << n); ++mask) {
        string s1, s2;

        for (int i = 0; i < n; ++i)
            if ((mask >> i) & 1)
                s1 += s[i];
            else
                s2 += s[i];

        reverse(s2.begin(), s2.end());
        ++mp[s1 + "#" + s2];
    }

    ll ans = 0;

    for (int mask = 0; mask < (1 << n); ++mask) {
        string s1, s2;

        for (int i = 0; i < n; ++i)
            if ((mask >> i) & 1)
                s1 += s[n + i];
            else
                s2 += s[n + i];

        reverse(s1.begin(), s1.end());
        ans += mp[s1 + "#" + s2];
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 64128
#include<stdio.h>
//累乗(power)a^n(mod10^9+7)
long long power(long long a,long long n){
  long long count=a,sum=1;
  while(n>0){
    if(n%2==1)
      sum*=count;
    count*=count;
    count%=1000000007;
    sum%=1000000007;
    n/=2;
  }
  return sum;
}

int main(){
  int n,m,x,min=2000000,pattern,i,j,k;
  scanf("%d%d%d",&n,&m,&x);
  pattern=power(2,n);
  int c[n+1],a[n+1][m+1];
  for(i=0;i<n;i++){
    scanf("%d",&c[i]);
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
  }
  for(i=1;i<pattern;i++){
    int b[m+1],sum=0,l=i;
    for(j=0;j<m;j++)
      b[j]=0;
    for(j=0;j<n;j++){
      if(l%2==1){
        for(k=0;k<m;k++)
          b[k]+=a[j][k];
        sum+=c[j];
      }
      l/=2;
    }
    int check=0;
    for(j=0;j<m;j++)
      if(b[j]<x)
        check=1;
    if(check==0 && min>sum)
      min=sum;
  }
  if(min!=2000000)
    printf("%d\n",min);
  else
    printf("-1\n");
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    double PI = 3.1415926536;
    ll r; cin >> r;
    cout << 2 * r * PI << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int N;
    cin >> N;
    set<int> d;
    rep(i, N)
    {
        int dd;
        cin >> dd;
        d.insert(dd);
    }
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] T = new int[N+1];
	int sum = 0;
	for(int i = 1; i<N+1; i++) {
	    T[i] = sc.nextInt();
	    sum += T[i];
	}
	int M = sc.nextInt();
	for(int i = 0; i<M; i++) {
	    int time = sum - T[sc.nextInt()] + sc.nextInt();
	    System.out.println(time);
	}
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

/* https://qiita.com/drken/items/4e1bcf8413af16cb62da#%E4%BE%8B%E9%A1%8C-3-edpc-l-%E5%95%8F%E9%A1%8C---deque-%E5%BE%97%E7%82%B9%E5%B7%AE%E3%82%82%E6%9C%80%E5%A4%A7%E5%8C%96%E3%81%97%E3%81%9F%E3%81%84-
*/

// DP テーブル
long long dp[3100][3100];

int main() {
  // 入力受け取り
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  
  // 初期条件
  for (int i = 0; i < N; ++i) dp[i][i] = 0;
  
  
  // DP
  for (int len = 1; len <= N; ++len) {
    for (int i = 0; i + len <= N; ++i) {
      int j = i + len;
//      cout << endl;
//      cout << "len:" << len << " i:" << i << " j:" << j << endl;
      // 先手番
      if ((N - len) % 2 == 0) {
//        cout << "先攻　" << endl;
//        cout << dp[i + 1][j] << " + " << a[i] << " " << dp[i][j - 1] << " + " << a[j - 1] << endl;
        dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
      }
      // 後手番
      else {
//        cout << "後攻" << endl;
//        cout << dp[i + 1][j] << " - " << a[i] << " " << dp[i][j - 1] << " - " << a[j - 1] << endl;
        dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
      }
//      cout << "dp:" << dp[i][j] << endl;
    }
//    cout << endl;
  }
  
//  for (int i = 0; i <= N; i++) {
//    for (int j = 0; j <= N; j++) {
//      cout << dp[i][j] << " ";
//    }
//    cout << endl;
//  }
  
  // 答え
  cout << dp[0][N] << endl;
}


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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;
const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5, Ns = 105;

typedef long long ll;

ll dp[Ns][N];
ll w[Ns];
ll v[Ns];

int main(){
    ll n, W;
    //cl(dp,63);
    for(ll i=0;i<Ns;i++){
        for(ll j=0;j<N;j++){
            dp[i][j] = LINF;
            if(j==0) dp[i][j] = 0;
        }
    }

    cin >> n >> W;

    for(ll i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    dp[0][v[0]] = w[0];
    for(ll i=1;i<n;i++){
        for(ll j=N;j>=0;j--){
            dp[i][j] = dp[i-1][j];
            if(j>=v[i]) dp[i][j] = min(dp[i][j] , dp[i-1][j-v[i]]+w[i]);
        }
    }
    ll ans = 0;

    for(ll i=0;i<Ns;i++){
        for(ll j=0;j<N;j++){
            if(dp[i][j]<=W) ans = max(j,ans);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 82304
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans;

    long quo = n / (a + b);
    long rem = n % (a + b);
    if(rem > a){
      ans = (quo + 1) * a;
    } else {
      ans = quo * a + rem;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;

int main(){
    int i;
    ll n,a,b,ans,m,l,rem; // 余り
    

    cin >> n >> a >> b;

        m =  n/(a+b);
        rem = n%(a+b);

        if (rem>=a)
        {
            rem = a;
        }
        
   
    
    ans = a*m + rem;

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int A[25];
	int B[25];
	int C[25];

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> A[i];
	for(int i=1;i<=N;i++)
		cin >> B[i];
	for(int i=1;i<=N-1;i++)
		cin >> C[i];

	int ans=0;
	for(int i=1;i<=N;i++)
	{
		ans+=B[A[i]];
		if(i!=N)
		{
			if(A[i]+1==A[i+1])
				ans+=C[A[i]];
		}
	}

	cout << ans << endl;
	return 0;
}



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

int main(){
	vector<int> ok(27,1) ;
	char c ;
	while(cin >> c){
		ok.at(c-'a') = 0 ;
	}
	for(int i=0;i<26;i++){
		if(ok.at(i)){
			cout << (char)('a'+i) << endl ;
			return 0 ;
		}
	}
	cout << "None" << endl ;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    vector<int> pos(n + 1), z(n + 1);
    pos[0] = l;
    z[n] = 1;
    for (int i = 0; i < n; i++) {
        pos[i + 1] = min(pos[i], abs(pos[i] - d[i]));
    }
    for (int i = n - 1; i > 0; i--) {
        if (z[i + 1] <= d[i] / 2) {
            z[i] = z[i + 1];
        } else {
            z[i] = z[i + 1] + d[i];
        }
    }
    int tt;
    cin >> tt;
    while (tt--) {
        int q;
        cin >> q;
        if (pos[q - 1] >= z[q] || pos[n] != 0) {
            cout << "YES" << '\n';
        } else {
            cout << "NO" << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 7808
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, input().split())

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    ll x,y;cin>>x>>y;
    ll ans=0;
    while(x<=y)
    {
        x*=2;
        ans++;
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi
 
using namespace std;
 
typedef long long ll;
 
inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}
 
inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}
 
int po[103], ans, n, m, a[200003], minn = 200003;
char s[100003];
 
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	int xx = n, cnt = 0;
	while (xx)
	{
		xx = xx / 10, ++cnt;
	}
	po[1] = 1;
	for (int i = 2; i <= 8; i+=1) po[i] = po[i - 1] * 10;
	for (int i = 1; i <= n; i+=1)
	{
		int ii = i, x = 0, y = ii % 10;
		if (!y) continue;
		while (ii)
		{
			x = ii % 10, ii /= 10;
		}
		for (int j = 1; j <= cnt; j+=1)
		{
			if (j == 1)
			{
				if (x == y) ++ans;
			}
			else if (j < cnt) ans += po[j - 1];
			else
			{
				int xsl = y * po[cnt] + x, xxsl = xsl;
				for (int k = 2; k < cnt; k+=1)
				{
					xxsl += 9 * po[k];
				}
				if (n >= xsl) 
				{
					ans += (min(xxsl, n) - xsl) / 10 + 1;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256