akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N,K = map(int, input().split())
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
for i in range(1,N):
  s = max(0,i-K)
  dp[i] = np.min(dp[s:i] + np.abs(H[i]-H[s:i]))
  
print(dp[-1])

Measured memory_bytes: 22836
#include<cstdio>
#include<cstring>
#include<iostream>
#include<set>
using namespace std;
int main(){
   int x, y;
   cin >> x >> y;
   set<int>s1, s2, s3;
   int a[7] = {1, 3, 5, 7, 8, 10, 12}, b[4] = {4, 6, 9, 11}, c[1] = {2};
   for(int i = 0; i<7; ++i)s1.insert(a[i]);
   for(int i = 0; i<4; ++i)s2.insert(b[i]);
   for(int i = 0; i<1; ++i)s3.insert(c[i]);
   if(s1.count(x) && s1.count(y) || s2.count(x) && s2.count(y) || s3.count(x) && s3.count(y))
       cout << "Yes"<< endl;
   else cout << "No" << endl;
   return 0;
}

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

int main() {
  int N;
  cin >> N;
  int cnt = 0, ans = 0, maxcnt = 0, x;
  for(int i=1; i<=N; i++){
    x = i;
    while(x%2==0){
      x = x/2;
      cnt++;
    }
    if(maxcnt<=cnt){
      maxcnt = cnt;
      ans = i;
    }
    cnt = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map{it.toLong()}.sorted()

    val mn: List<Long>
    val ps: List<Long>

    if (A[0] >= 0) {
        mn = A.take(1)
        ps = A.drop(1)
    } else if (A.last() < 0) {
        mn = A.dropLast(1)
        ps = A.takeLast(1)
    } else {
        mn = A.filter { it < 0 }
        ps = A.filter { it >= 0 }
    }

    println(ps.sum() - mn.sum())

    var t = mn[0]

    for (a in ps.dropLast(1)) {
        println("$t $a")

        t -= a
    }

    println("${ps.last()} $t")

    t = ps.last() - t

    for (a in mn.drop(1)) {
        println("$t $a")
        t -= a
    }
}


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

using namespace std;

long double EPS = 1e-8;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    bool ans = false;
    if (v > w) {
        if (abs(a - b) <= (v-w)*t) {
            ans = true;
        }
    }
    cout << (ans ? "YES" : "NO")  << endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

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

    int ans = 0;
    for (int i=1; ; ) {
        if (i >= N)break;
        i += (K - 1);
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
using ll = long long;

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

    ll ans = 0;
    for (int i = 0; i <=n ; ++i) {
        if (i - 1 >= k) {
            ans += n / i * max(0ll, (i - k));
            ans += max(0ll, (n % i) - k + 1);
        }
    }

    if (k == 0) ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
/*
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
fscanf(STDIN, "%s", $s);
*/
fscanf(STDIN, "%s", $n);
fscanf(STDIN, "%s", $a);
fscanf(STDIN, "%s", $b);
fscanf(STDIN, "%s", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);

$min = min([$a, $b, $c, $d, $e]);
$plus = ceil($n / $min);
printf("%d", $plus + 4);

?>


Measured memory_bytes: 5112
#include <iostream>
using namespace std;
int main(){
    char t;
    string s;
    int n,i,ans=1;
    cin >> n;
    cin >> s;
    for (i=0;i<n-1;i++){
        t=s[i];
        if (t!=s[i+1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    vector<bool> seen(K, false);
    for (int i = 1, R = 0; ; ++i) {
        R = (R * 10 + 7) % K;
        if (R == 0) {
            cout << i << '\n';
            return 0;
        }
        if (seen[R]) {
            cout << "-1\n";
            return 0;
        }
        seen[R] = true;
    }
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
int w[110];

void init() {

}

void input() {
  cin >> n ;
  REP(i, n) cin >> w[i];
}

void solve() {
  int res = 100000;
  REP(i, n-1){
    int s1 = 0;
    int s2 = 0;
    REP(ii, i+1) {
      s1 += w[ii];
    }
    FOR(jj, i+1, n) {
      s2 += w[jj];
    }
    chmin(res, abs(s1-s2));
  }
  cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  for(int i = 1; i < s.size(); ++i) {
    if((s.size() - i) % 2 != 0) {
      continue;
    }
    auto half = (s.size() - i) / 2;
    string s1 = s.substr(0, half);
    string s2 = s.substr(half, half);
    if(s1 == s2) {
      cout << half * 2 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b)) < EPS)

#define sz size()
using namespace std;
typedef vector<int> vi;
typedef double D;
typedef complex<D> P;
typedef pair<D,vi> sol;

const D EPS = 1e-8;
const D INF = 1e9;

namespace std{
  bool operator<(const P &a,const P &b){
    return EQ(imag(a),imag(b))?real(a)<real(b):imag(a)<imag(b);
  }
}

sol dp[41][41][41]; //dp[prev][cur][point_num];
vector<P> p,id;
vector<D> area;
vector<vi> vlist;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}
inline D cross(const P &x, const P &y){return imag(conj(x)*y);}
inline D tri_area(const P &a,const P &b,const P &c){ return cross(b-a,c-a)/2; }

inline int ccw(const P &a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

int main(){
  int n,q,x,y;
  
  cin >> n;
  p.resize(n); id.resize(n);
  rep(i,n){
    cin >> x >> y;
    id[i] = p[i] = P(x,y);
  }
  sort(all(p));

  area = vector<D>(n+1,INF);
  vlist = vector<vi>(n+1,vi());

  rep(init,n){
    rep(i,n)rep(j,n)rep(k,n+1)dp[i][j][k] = sol(INF,vi());
    for(int i=init+1;i<n;i++){
      vi tmp(2); tmp[0] = init; tmp[1] = i;
      dp[init][i][2] = sol(0,tmp);
    }
    for(int num=2;num<n;num++){
      for(int cur=init+1;cur<n;cur++){
	for(int nxt=init+1;nxt<n;nxt++){
	  if(ccw(p[init],p[cur],p[nxt])!=1)continue;
	  for(int prev=init;prev<n;prev++){
	    if(cross(p[cur]-p[prev],p[nxt]-p[cur]) <= EPS)continue;

	    D S = dp[prev][cur][num].first + tri_area(p[init],p[cur],p[nxt]);
	    if(S +EPS < dp[cur][nxt][num+1].first){
	      dp[cur][nxt][num+1].first = S;
	      dp[prev][cur][num].second.push_back(nxt);
	      dp[cur][nxt][num+1].second = dp[prev][cur][num].second;
	      dp[prev][cur][num].second.pop_back();
	    }
	  }
	}
      }
    }

    rep(i,n)rep(j,n)rep(k,n+1){
      if(area[k] > dp[i][j][k].first + EPS){
	area[k] = dp[i][j][k].first;
	vlist[k] = dp[i][j][k].second;
      }
    }
  }

  cin >> q;
  while(q--){
    cin >> x;
    if(EQ(area[x],INF))cout << "NA\n";
    else{
      rep(i,vlist[x].sz)rep(j,n){
	if(EQ(p[vlist[x][i]],id[j])){
	  cout << j+1 << (i+1==(int)vlist[x].sz?"\n":" ");
	  break;
	}
      }
    }
  }
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
	int N;
	cin >> N;
	vector<pair<string, int>> playlist(N);
	for(int i = 0;i < N;i++){
		cin >> playlist[i].first >> playlist[i].second;
	}
	string target;
	cin >> target;
	
	auto i = playlist.begin();
	while(i != playlist.end() && (*i).first != target) i++;
	i++;
	int ans = 0;
	while(i != playlist.end()) ans += (*i++).second;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,i;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
else{
for(i=0;i<9;i++){
scanf("%d\n",&b);
a=a-b;
}
printf("%d\n",a);
}
}
return 0;
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll ceil(ll a, ll b){
	if(a % b == 0) return a / b;
	return a / b + 1;
}

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

	ll n, m;
	cin >> n >> m;

	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] /= 2;
	}

	if(n == 1){
		cout << ceil((m / a[0]), 2) << endl;
		return 0;
	}

	int ctz = __builtin_ctzll(a[0]);
	rep(i, n - 1){
		if(ctz != __builtin_ctzll(a[i+1])){
			cout << 0 << endl;
			return 0;
		}
	}

	ll lcm_all = lcm(a[0], a[1]);
	rep(i, n - 2){
		lcm_all = lcm(lcm_all, a[i+2]);
	}

	cout << ceil(m / lcm_all, 2) << endl;

}


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

int main(int argc, char* argv[])
{
  int n;
  std::vector< int > va;
  std::vector< int > vb;

  std::cin >> n;
  for (int i=0; i < n; i++) {
    int tmp;
    std::cin >> tmp;
    va.push_back(tmp);
  }

  vb.resize(n, 0);

  int sign = n % 2 == 0 ? 1 : -1;
  int idx = (int)(n/2);
  for (int i=0; i < n; i++) {
    idx += sign * i;
    vb[idx] = va[i];
    sign *= -1;
  }

  std::vector< int >::iterator it;
  for (it = vb.begin(); it != vb.end(); it++) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 3828
S = list(input())
T = list(input())

# S=list("BBAAABA")
# T=list("BBBA")

q = int(input())

l = []
for i in range(q):
	l.append(list(map(int,input().split(" "))))


sta = [0 for i in range(len(S))]
stb = [0 for i in range(len(S))]

tta = [0 for i in range(len(T))]
ttb = [0 for i in range(len(T))]

if S[0] == "A":
	sta[0] = 1
else:
	stb[0] = 1

if T[0] == "A":
	tta[0] = 1
else:
	ttb[0] = 1

for i in range(1,len(S)):
	if S[i] == "A":
		sta[i] = sta[i-1]+1
		stb[i] = stb[i-1]
	else:
		sta[i] = sta[i-1]
		stb[i] = stb[i-1]+1

for i in range(1,len(T)):
	if T[i] == "A":
		tta[i] = tta[i-1]+1
		ttb[i] = ttb[i-1]
	else:
		tta[i] = tta[i-1]
		ttb[i] = ttb[i-1]+1


def get(l,a,b):
	if a == 0:
		return(l[b])
	else:
		return(l[b]-l[a-1])

for a,b,c,d in l:
	sa = get(sta,a-1,b-1)
	sb = get(stb,a-1,b-1)
	ta = get(tta,c-1,d-1)
	tb = get(ttb,c-1,d-1)


	if (sa+sb*2)%3 == (ta+tb*2)%3:
		print("YES")
	else:
		print("NO")





















Measured memory_bytes: 80804
a,b,c,d = gets.chomp.split(" ").map(&:to_i)

alice = Array.new(100, 0)
bob = Array.new(100, 0)

100.times do |i|
  alice[i] = 1 if i >= a && i < b
end

100.times do |i|
  bob[i] = 1 if i >= c && i < d
end

counter = 0
100.times do |i|
  counter += 1 if alice[i] * bob[i] == 1
end

print(counter)

Measured memory_bytes: 1788
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define con continue;
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
void coutv(vector<ll> v)
{
    for (auto it : v)
        cout << it << " ";
    cout << endl;
}
bool can(ll x, ll y)
{
    return y <= 2 * x;
}
int fibonacci(int n)
{
    if (n == 1 || n == 2)
    {
        return 1;
    }
    return fibonacci((n - 1)) + fibonacci((n - 2));
}
int main()
{
    MOAE;
    long double a, b;
    cin >> a >> b;
    cout << fixed << setprecision(0) << floor(a * b) << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;

constexpr ll MOD = 1000000000 + 7;

// O(log(n))
ll mpow(ll n, ll base) {
    if (n == 1) { return base % MOD; }
    if (n % 2) { return (base * mpow(n - 1, base)) % MOD; }
    ll sub = mpow(n / 2, base);
    return (sub * sub) % MOD;
}

// O(a)
ll X(ll n, ll a) {
    ll ans = 1;
    rep(i, 0, a) { ans = (ans * (n - i)) % MOD; }
    return ans;
}

// O(log(MOD))
ll Y_inv(ll a) {
    // O(a)
    ll Y = X(a, a);
    // O(log(MOD))
    return mpow(MOD - 2, Y);
}

ll comb(ll n, ll a) {
    ll x = X(n, a);
    ll y_inv = Y_inv(a);
    return (x * y_inv) % MOD;
}

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

    ll ans = mpow(n, 2) - 1;
    ans = (ans - comb(n, a)) % MOD;
    ans = (ans - comb(n, b)) % MOD;
    if (ans < 0) { ans += MOD; }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n;
char s[5];
scanf("%d",&n);
for(int count=0;count<n;count++){
scanf("%s",s);
if(s[0]=='Y'){printf("Four");return 0;}
}
printf("Three");return 0;

}

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

int main() {
	int n, d, x;
	std::cin >> n >> d >> x;
	std::vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int temp;
		std::cin >> temp;
		vec.push_back(temp);
	}
	int choco = x;
	for (auto v : vec) {
		choco += 1 + ((d - 1) / v);
	}
	std::cout << choco << std::endl;
	return 0;
}

Measured memory_bytes: 256
from math import sqrt, floor

def is_prime(x: int) -> bool:
    if x <= 1:
        return False

    for i in range(2, floor(sqrt(x))):
        if x % i == 0:
            return False

    return True


x = int(input())
while not is_prime(x):
    x += 1
print(x)


Measured memory_bytes: 2940
// 2020-07-25 05:27:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int dp[3030], p[3030];
void answer() {
  int n, t;
  cin >> n >> t;
  vector<P> c(n);
  rep(i, n) cin >> c[i].first >> c[i].second;
  sort(ALL(c));
  int ans = 0;
  rep(i, n) {
    swap(p, dp);
    int a, b;
    tie(a, b) = c[i];
    rep(j, t) {
      dp[j] = p[j];
      if(a <= j) chmax(dp[j], p[j-a] + b);
    }
    chmax(ans, p[t-1] + b);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3680
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AAC {
public:
	void solve(istream& in, ostream& out) {
    string s; in >> s;
    if(s == "ABC") out << "ARC" << endl;
    else out << "ABC" << endl;
	}
};

int main() {
	AAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;
map<ll, int> dp;
int n;
int f(ll num)
{
	if(dp[num] != 0) return dp[num];
	if(num > n) return 0;
	bool bo[] = {0,0,0};
	ll ax = num;
	while(ax > 0)
	{
		if(ax%10 == 3) bo[0] = 1;
		if(ax%10 == 5) bo[1] = 1;
		if(ax%10 == 7) bo[2] = 1;
		ax /= 10;
	}
	return dp[num] = (bo[0]&&bo[1]&&bo[2]) + f(num*10 + 5) + f(num*10 + 3) + f(num*10 + 7);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	cin>>n;
	cout<<f(5) + f(7) + f(3)<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 5760
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}

int main() {
	int N, Z, W; cin >> N >> Z >> W;
	auto cards = vector<int>(N);
	int max_card = 0;
	for (size_t i = 0; i < N; i++) {
		cin >> cards[i];
		max_card = max(max_card, cards[i]);
	}
	if (N == 1) cout << abs(W - cards[N - 1]) << endl;
	else cout << max(abs(W - cards[N - 1]), abs(cards[N - 2] - cards[N - 1]));
}

Measured memory_bytes: 384
n = int(input())
mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 2 * 10**5 + 10
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

# 前準備
import sys
input = sys.stdin.readline
from collections import deque

graph = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

def calc(a,b):
    p_a, e_a = a
    p_b, e_b = b
    e = e_a + e_b
    p = p_a * p_b * com(e,e_a) % mod
    return(p,e)

# calc1 の定義
def calc1(c,p):
    p_num, e_num = 1,0
    for i in graph[c]:
        if i == p:
            continue
        p_num,e_num = calc((p_num, e_num) , dp1[i] )
    e_num += 1
    dp1[c] = (p_num, e_num)

# calc2 の定義
def calc2(p):
    arr = [dp1[c] if c != parent[p] else dp2[p] for c in graph[p]]

    left = [(1,0)]
    for i in arr[:-1]:
        left.append( calc(left[-1], i ) )
    right = [(1,0)]
    for i in arr[:0:-1]:
        right.append( calc(right[-1], i) )
    right = right[::-1]

    prod = []
    for a,b in zip(left,right):
        p_tmp,e_tmp = calc(a,b)
        prod.append( (p_tmp, e_tmp) )


    for c,x in zip(graph[p], prod):
        if(c != parent[p]):
            p_tmp,e_tmp = x
            dp2[c] = (p_tmp,e_tmp+1)



# 根から探索して親と探索順を記録
root = 1
order = []
parent = [0] * (n+1)
stack = deque()
stack.append(root)
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        stack.append(y)
        parent[y] = x

# 親→子の値を算出
dp1 = [None] * (n+1)
for i in order[::-1]:
    calc1(i, parent[i])

# 子→親の値を算出　累積和チックにすることでうに対策。
dp2 = [None] * (n+1)
dp2[root] = (1,0)
for i in order:
    calc2(i)

for i in range(1,n+1):
    p1,e1 = dp1[i]
    p2,e2 = dp2[i]
    e1 -= 1
    ans = calc((p1,e1), (p2,e2))[0]
    print(ans)


Measured memory_bytes: 129600
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.length() + 1;

    int Zero_Point[n] = {-1};

    // search zero point
    int j = 0;
    if(s[0] == '<') {
        Zero_Point[j] = 0;
        j++;
        Zero_Point[j] = -1;
    }
    for(int i = 0; i < n - 1; i++) {  
        if(s[i] == '>' && s[i + 1] == '<') {
            Zero_Point[j] = i + 1;
            j++;
            Zero_Point[j] = -1;
        }
    }
    if(s[n - 2] == '>') {
        Zero_Point[j] = n - 1;
        j++;
        Zero_Point[j] = -1;
    }

    // print zero point
    /*
    int k = 0;
    while(Zero_Point[k] != -1) {
        cout << Zero_Point[k] << ' ';
        k++;
    }
    cout << endl;
    */

    int k = 0;
    long long ans = 0;
    long long count_less = 0;
    long long count_greater = 0;
    if(s[0] == '>') {
        k = 0;
        while(s[k++] == '>') {
            count_greater++;
        }
    }
    ans += count_greater * (count_greater + 1) / 2;

    /*
    cout << "'>'" << count_greater << "分足されました" << endl;
    cout << "===" << endl;
    */

    k = 0;
    while(Zero_Point[k] != -1) {
        count_less = 0;
        count_greater = 0;
        for(int i = Zero_Point[k]; i < Zero_Point[k + 1]; i++) {
            if(s[i] == '<') count_less++;
            if(s[i] == '>') count_greater++;
        }
        long long maximum = max(count_less, count_greater);
        long long minimum = min(count_less, count_greater);
        ans += maximum * (maximum + 1) / 2;
        ans += minimum * (minimum - 1) / 2;
        /*
        cout << "'<'" << count_less << "分足されました" << endl;
        cout << "'>'" << count_greater << "分足されました" << endl;
        */
        k++;
    }


    // cout << "===" << endl;

    count_less = 0;
    count_greater = 0;
    if(s[n - 2] == '<') {
        k = n - 2;
        while(s[k--] == '<') {
            count_less++;
        }
    }
    ans += count_less * (count_less + 1) / 2;

    // cout << "'<'" << count_less << "分足されました" << endl;

    cout << ans << endl;

    return 0;
}

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

int n, m;
int graph[8][8];

// 訪れた頂点=bool配列で引数に渡す
int dfs(int v, bool visited[8])
{
  bool judge = true;
  for (int i = 0; i < n; ++i)
  {
    if (!visited[i])
      judge = false;
  }
  if (judge)
  {
    return 1;
  }
  int ret = 0;
  for (int i = 0; i < n; ++i)
  {
    if (graph[v][i] == 0)
      continue;
    if (visited[i])
      continue;
    visited[i] = true;
    ret += dfs(i, visited);
    visited[i] = false;
  }

  return ret;
}

int main()
{
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a][b] = graph[b][a] = 1;
  }
  bool visited[8] = {};
  visited[0] = true;
  cout << dfs(0, visited) << endl;

  return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int n;
    cin >> n;
    int data[n];
    REP(i, n)
    {
        cin >> data[i];
    }

    int max = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (abs(data[i] - data[j]) > max)
                max = abs(data[i] - data[j]);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		string s=Console.ReadLine();
		string[][] arr=new string[4][];
		arr[0]=new string[n];arr[1]=new string[n];
		arr[2]=new string[n];arr[3]=new string[n];
		string ans="-1";

		arr[0][1]="S";arr[0][n-1]="S";
		arr[1][1]="W";arr[1][n-1]="W";
		arr[2][1]="S";arr[2][n-1]="W";
		arr[3][1]="W";arr[3][n-1]="S";
		if(s[0]=='o'){arr[0][0]="S";arr[1][0]="S";arr[2][0]="W";arr[3][0]="W";}
		else{arr[0][0]="W";arr[1][0]="W";arr[2][0]="S";arr[3][0]="S";}
		for(int i=1;i<n-2;i++){
			for(int j=0;j<4;j++){
				if(s[i]=='o'&&arr[j][i]=="S"){arr[j][i+1]=arr[j][i-1];}
				else if(s[i]=='o'&&arr[j][i]=="W"){arr[j][i+1]=arr[j][i-1]=="S"?"W":"S";}
				else if(s[i]=='x'&&arr[j][i]=="S"){arr[j][i+1]=arr[j][i-1]=="S"?"W":"S";}
				else if(s[i]=='x'&&arr[j][i]=="W"){arr[j][i+1]=arr[j][i-1];}
			}
		}
		for(int j=0;j<4;j++){
			if(fu(arr[j][n-3],arr[j][n-2],arr[j][n-1],s[n-2])&&fu(arr[j][n-2],arr[j][n-1],arr[j][0],s[n-1])){ans=String.Join("",arr[j]);}
		}
		Console.WriteLine("{0}",ans);
	}
	static bool fu(string a,string b,string c,char d){
		if(d=='o'&&b=="S"&&a==c){return true;}
		else if(d=='o'&&b=="W"&&a!=c){return true;}
		else if(d=='x'&&b=="S"&&a!=c){return true;}
		else if(d=='x'&&b=="W"&&a==c){return true;}
		return false;
	}
}

Measured memory_bytes: 17120
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	llong n;
	cin>>n;
	
	llong ans=n;
	for(llong i=1;i*i<=n;++i){
		if(n%i==0){
			ans=min(ans,i+n/i-2);
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 8010;
vi d[2];
int x,y;
bool dp[N][2*N]; // dp[i][j], in ith step, reachability of coordinate j+N.
bool frst = false;

bool solve(int turn, int target) {
	target += 8000;
	memset(dp, false, sizeof(dp));
	dp[0][8000]=true;
	int sz = d[turn].size();
	FOR(i, 1, sz+1) {
		int jmp = d[turn][i-1];
		FOR(j, 0, 2*N) {
			if(j - jmp >= 0) {
				dp[i][j] |= dp[i-1][j-jmp];
			}
			if(turn == 0 && i == 1 && frst) {
				continue;
			}
			if(j + jmp < 2*N) {
				dp[i][j] |= dp[i-1][j+jmp];
			}
		}
	}
	return dp[sz][target];
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int turn=0, n = s.size(),cnt=0;
    FOR(i, 0, n) {
    	if(s[i] == 'T') {
    		if(cnt) {
    			d[turn].push_back(cnt);
    			cnt = 0;
			}
    		turn = 1 - turn;
    		continue;
    	}
    	if (i==0)
    	{
    		frst = true;
    	}
    	cnt++;
    }
    if(cnt) {
    	d[turn].push_back(cnt);
    }
    cin>>x>>y;
    bool poss = solve(0, x) && solve(1, y);
    if(poss) {
    	cout<<"Yes";
    } else {
    	cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
P x[200000];
P y[200000];
bool saw[200000];
ll ans;

int main() {
    cin >> n;
    rep(i,n) cin >> x[i].first >> x[i].second;
    rep(i,n) ans += x[i].first;
    ll tmp = 0;
    rep(i,n) tmp += x[i].second;
    ans = min(ans,tmp);
    rep(i,n) {
        y[i] = P(x[i].first,i);
        y[i+n] = P(x[i].second,i);
    }
    sort(y, y+2*n);
    tmp = 0;
    rep(i,n) {
        tmp += y[i].first;
        saw[y[i].second] = true;
    }
    rep(i,n) {
        if (!saw[i]) {
            cout << tmp << endl;
            return 0;
        }
    }
    for (int i = n; i < 2*n; i++) {
        if (y[i].second == y[n-1].second) {
            ans = min(ans, tmp-y[n-2].first+y[i].first);
        } else {
            ans = min(ans, tmp-y[n-1].first+y[i].first);
        }
    }
    cout << ans << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, h;

int main() {
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << ln;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string ans="keyence";
    string s;cin >>s;
    int n=s.size();
    vector<string>f(8);
    vector<string>b(8);
    for (int i = 0; i < 8; ++i) {
        f[i]=s.substr(0,i);
    }
    for (int i = 0; i < 8; ++i) {
        b[i]=s.substr(n-i,i);
    }
    bool flg=false;
    for (int i = 0; i < 8; ++i) {
        if(f[i]+b[7-i]==ans)flg=true;
//        cout <<f[i]<<" "<<b[7-i]<<endl;
    }
    if(flg)puts("YES");
    else puts("NO");
}


Measured memory_bytes: 3616
#include <stdio.h> 
 
 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 if(i==0||i==h-1||j==0||j==w-1){ 
                     printf("#"); 
                 }else{ 
                     printf("."); 
                 } 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=998244353;
const ll maxn=1e10;
//vector<vector<int> > adj(maxn);
//vector<bool> used(maxn,false);
//vector<int> d(maxn),p(maxn);
ll bin(ll a, ll b) {
	//a%=m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a; //mod
        a = a * a; //mod
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll fact(ll x)
{
  ll res=1;
  for(ll i=1;i<=x;i++)
    res=(res*i)%mod;

  return res;
}

ll lmod(string n,ll x)
{
	
	ll res=0;
	for(ll i=0;i<n.length();++i)
	{
		res=(res*10+(int)n[i]-'0')%x;
	}
	return res;
}
bool ispal(string s,int l,int r)
{
	string t=s;
	for(int i=l,j=r;i<=r;++i)
	{
		if(s[i]!=s[j])
			return false;
		else
			{
				--j;
			}
	}
	return true;
}
bool pl(string s)
{
	string t(s.rbegin(),s.rend());
	return t==s;
}
/*void bfs(int s,int &ans)
{
	queue<int> q;
	used[s]=true;
	p[s]=-1;
	d[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int u: adj[v])
		{
			if(!used[u])
			{
				used[u]=true;
				q.push(u);
				d[u]=d[v]+1;
				ans=max(ans,d[u]);
				p[u]=v;
			}
			
		}
	}
}*/


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll k,n,i,j,ans=0;
	cin>>k>>n;
	ll a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
		ans=max(a[1]-a[0],k-a[n-1]+a[0]);
	for(i=1;i<n-1;i++)
	{
		ans=max(ans,max(a[i+1]-a[i],a[i]-a[i-1]));
	}
	ans=max(ans,max(a[n-1]-a[n-2],k-a[n-1]+a[0]));
	
	cout<<k-ans;


	
	
	
}

Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101
 
#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#include<set>
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INFLL 9223372036854775807
#define INF 2147483647
#define pi acos(-1.0)
#define ll long long
#define endll printf("\n")
#define CASE printf("Case %lld: ",T)
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define ull unsigned long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define endl '\n'
#define ld long double
 
 
using namespace std;


int main(){
  char c;
  ll flips = 0, currentFlips = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i)
  {
    if(s[i] == 'B'){
      currentFlips ++;
    }
    else{
      flips += currentFlips;
    }
  }
  cout<<flips<<endl;
  return 0;
}

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

int main() {
    stack<int> S;
    int a, b;

    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        } else if (s[0] == '-'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b - a);
        } else if (s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        } else {
            S.push(atoi(s));
        }
    }

    cout << S.top() << endl;
}


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

int main() {
	int x;
	cin >> x;
	int mx = 0;
	for(int i = 1;i < 33;i++)
	{
		for(int j = 2;j < 10;j++)
		{
			int p = pow(i,j);
			if(p <= x)
			{
				mx = max(mx,p);
			}
			else
			{
				break;
			}
		}
	}
    cout << mx << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,W;
    cin >> N >> W;
    vector<P>cnt(N);
    vector<vector<int>>kati(4);
    for(int i = 0; i < N; i++) {
        cin >> cnt[i].first >> cnt[i].second;
        kati[cnt[i].first-cnt[0].first].push_back(cnt[i].second);
    }
    for(int i = 0; i < 4; i++) {
        kati[i].push_back(INF);
        sort(kati[i].rbegin(),kati[i].rend());
        kati[i][0] = 0;
        for(int j = 1; j < kati[i].size(); j++) {
            kati[i][j] = kati[i][j]+kati[i][j-1];
        }
    }
    int ans = 0;
    for(int i = 0; i < kati[0].size(); i++) {
        for(int j = 0; j < kati[1].size(); j++) {
            for(int k = 0; k < kati[2].size(); k++) {
                for(int l = 0; l < kati[3].size(); l++) {
                    int sum = (i+j+k+l)*cnt[0].first;
                    sum += j;
                    sum += k*2;
                    sum += l*3;
                    if(sum <= W) {
                        ans = max(ans,kati[0][i]+kati[1][j]+kati[2][k]+kati[3][l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    REP(i,0,N) cin >> L[i];

    ll D = 0, m = 1;
    REP(i,0,N) {
        D += L[i];
        if(D > X) break;
        ++m;
    }
    _PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    if a[i]==0:
        ans=0
        break
for i in range(n):
    ans=ans*a[i]
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)

Measured memory_bytes: 21652
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int x = 0, y =0;
	int a;
	REP(i, 3) {
		cin >> a;
		if (a == 5)x++;
		if (a == 7)y++;
	}
	cout << (x == 2 && y == 1 ? "YES" : "NO") << endl;
}



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

int main(){
  string S;
  cin >> S;
  int N = S.size(); 
  int d[N];
  
  for(int i = 0;i < N;i++){
    d[i] = S.at(i) - 'a';
  }
  
  int num[N] = {0};
  for(int i = 0;i < N;i++){
    num[d[i]]++;
  }
  
  char m = 'a';
  for(int i = 0;i < 26;i++){
    if(num[i] == 0){
      break;
    }
    m++;
  }
  
  if(m == '{'){
    cout << "None" << endl;
  }else{
    cout << m << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <map>
// #include <cstdio>
#include <stack>

using namespace std;

int main() {
	while(1) {
	int w, h, data[52][52]={{0}};
	cin >> w >> h;
	if (w == 0 && h ==0) break;
	// memset(data, 0, sizeof(data));
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			cin >> data[i][j];
		}
	}
	// for (int i=0; i<h; i++) {
	// 	for (int j=0; j<w; j++) {
	// 		cout << data[i][j] << "," ;
	// 	}cout <<endl;
	// }
	stack<pair<int, int> > s;
	int count=0;
	int H[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, W[8] ={-1, 0, 1, -1, 1, -1, 0, 1};
	for(int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			if (data[i][j]) {
				count++;
				s.push(make_pair(i, j));
				while (!(s.empty())) {
					pair<int, int> now;
					now = s.top();
					s.pop();
					data[now.first][now.second]=0;
					for (int k=0; k<8; k++) {
						if (data[H[k]+now.first][W[k]+now.second])
							s.push(make_pair(H[k]+now.first, W[k]+now.second));
					}
				}
			}
		}
	}
	cout << count <<endl;
}
}

Measured memory_bytes: 1288
#include <stdio.h>

#define MAX 100000

int partition(int*,int,int);

int main(){
	int array[MAX] = {};
	int i,ans,times;
	
	scanf("%d\n", &times);
	
	for ( i = 0; i < times; i++ ) scanf("%d ", &array[i]);
	
	ans = partition(array, 0, times-1);
	for ( i = 0; i < times - 1 ; i++ ) {	
		if ( i == ans ) printf("[%d] ",array[i]);
        else printf("%d ",array[i]);
	}
	printf("%d\n",array[i]);
	return 0;
}

int partition( int *array, int p, int r ){
	int num,i,j,kari;

	num = array[r];
	i = p - 1;
	for ( j = p; j < r; j++ ) {
		if ( array[j] <= num ) {
			i = i+1;
			kari = array[i];
			array[i] = array[j];
			array[j] = kari;
		}
	}

	kari = array[r];
	array[r] = array[i+1];
	array[i+1] = kari;

	return i+1;
}


Measured memory_bytes: 2244
#include<stdio.h>

int main(){
	int A, B, K;
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	int i = 0;
	for(i = 0; A+i <= B; i++){
		if((A+i) %K == 0){
			printf("OK\n");
			break;
		}
	}
	if(A+i == B + 1){
		printf("NG\n");
	}
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<ll,ll>;

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

constexpr ll MOD = 1'000'000'007;
int N;
std::map<P, int> m;

P f(P p){
    auto [A, B] = p;

    if(A == 0){
        return std::make_tuple(1, 0);
    }else if(A < 0){
        return std::make_tuple(B, -A);
    }
    
    return std::make_tuple(-B, A);
}

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

    std::cin >> N;

    int numZero = 0;

    for(int i=0;i<N;++i){
        ll A, B;
        std::cin >> A >> B;

        if(A == 0 && B == 0){
            numZero += 1;
            continue;
        }

        if(B == 0){
            m[std::make_tuple(1, 0)] += 1;
            continue;
        }

        if(B < 0){
            A = -A;
            B = -B;
        }

        ll gcd = std::gcd(A, B);
        A /= gcd;
        B /= gcd;

        m[std::make_tuple(A, B)] += 1;
    }

    ll res = 1;

    for(auto &p : m){
        auto [A, B] = p.first;
        int count = p.second;

        if(A > 0){
            if(m.count(f(p.first)) > 0){
                int count2 = m[f(p.first)];
                
                ll x = 1;
                x += mod_expt<ll>(2, count, MOD) - 1;
                x += mod_expt<ll>(2, count2, MOD) - 1;
                x %= MOD;
            
                res = res * x % MOD;
            }else{
                res = res * mod_expt<ll>(2, count, MOD) % MOD;
            }
        }else if(m.count(f(p.first)) == 0){
            res = res * mod_expt<ll>(2, count, MOD) % MOD;
        }
    }

    if(res > 0){
        res -= 1;
    }else{
        res = MOD - 1;
    }

    res = (res + numZero) % MOD;

    std::cout << res << std::endl;
}



Measured memory_bytes: 16020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    Scanner scan = new Scanner(System.in);
    
    String s = scan.next();
    String t = scan.next();
    
    if(s.length()>t.length())
    {
        System.out.println("GREATER");
        return;
    }
    else if(s.length()<t.length())
    {
        System.out.println("LESS");
        return;
    }
    
    for(int i=0;i<s.length();i++)
    {
        if(s.charAt(i)>t.charAt(i))
        {
            System.out.println("GREATER");
            return;
        }
        else if(s.charAt(i)<t.charAt(i))
        {
            System.out.println("LESS");
            return;
        }
    }
    System.out.println("EQUAL");
    }
}

Measured memory_bytes: 22484
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @n = gets.to_s.to_i
    @s = gets.chomp
    @c = s.chars.tally
  end

  def solve
    return 0 if n < 3

    ans = total
    1.upto((n-1)/2) do |w|
      ans -= equal_interval(w)
    end
    ans
  end

  def total
    return 0 if c.keys.size != 3
    c.values.inject(1, :*)
  end

  def equal_interval(w)
    k = n - w * 2
    return 0 if k <= 0

    k.times.inject(0) do |ans, i|
      ans + query(i,i+w,i+w*2)
    end
  end

  def query(i,j,k)
    s[i] != s[j] && s[j] != s[k] && s[k] != s[i] ? 1 : 0
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14752