akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in); 
		
		int n = scan.nextInt();
		
		int H, S, D, C;
		int h[] = new int[14];
		int s[] = new int[14];
		int d[] = new int[14];
		int c[] = new int[14];
		
		for(int i = 1; i <= n; i++){
			String mark = scan.next();
			if(mark.equals("H")){
				h[scan.nextInt()] = 1;
			}else if(mark.equals("S")){
				s[scan.nextInt()] = 1;
			}else if(mark.equals("D")){
				d[scan.nextInt()] = 1;
			}else if(mark.equals("C")){
				c[scan.nextInt()] = 1;
			}
		}
		
		for(int i = 1; i <= 13; i++){
			if(s[i] != 1){
				System.out.println("S " + i);
			}
		}
		for(int i = 1; i <= 13; i++){
			if(h[i] != 1){
				System.out.println("H " + i);
			}
		}
		for(int i = 1; i <= 13; i++){
			if(c[i] != 1){
				System.out.println("C " + i);
			}
		}
		for(int i = 1; i <= 13; i++){
			if(d[i] != 1){
				System.out.println("D " + i);
			}
		}
	}
}
	
	

Measured memory_bytes: 26220
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  ll sum = 0;
  vll v(N);
  vll c(N);
  rep(i, N) {
    cin >> v[i];
  }
  rep(i, N) {
    cin >> c[i];
  }

  rep(i, N) {
    if (v[i] > c[i]) {
      sum += v[i] - c[i];
    }
  }
  COUT(sum);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	vector<int> a(6);
	rep(i, 6) cin >> a[i];
	vector<int> ans(4);
	rep(i, 6) ans[a[i]-1]++;
	bool b = true;
	rep(i, 4) {
		if (ans[i] == 3) b = false;
	}
	if (b) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int n, d;
    cin >> n >> d;
    int tmp = d * 2 + 1;
    if(n % tmp == 0) cout << n / tmp << endl;
    else cout << n / tmp + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import itertools

def distance(c1,c2):
    x1,y1 = c1
    x2,y2 = c2
    return math.sqrt((x1-x2)**2+(y1-y2)**2)

N = int(input())
Cord = []
ls = list(itertools.permutations(range(N)))
for _ in range(N):
    Cord.append(tuple(map(int,input().split())))
ans = 0
for l in ls:
    for i in range(N-1):
        ans+=distance(Cord[l[i]],Cord[l[i+1]])
print(ans/len(ls))

Measured memory_bytes: 13800
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a:usize=read!();
    if a==1 {println!("Hello World") }
    else {
        let a:usize=read!();
        let b:usize=read!();
        println!("{}",a+b) }
}

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

int main(){
	int a,b;
    cin>>a>>b;
    if(a>0){
    	cout<<"Positive";
	}else if(a==0||(a<0&&b>0)){
		cout<<"Zero";
	}else if((abs(b)-abs(a))%2!=0){
    	cout<<"Positive";
	}else{
		cout<<"Negative";
	}
	cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,j,n,v,max=-1000000000,a[200001];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    v=a[0];
    for(i=0;i<n;i++){
        if(i>0){
            if(max < a[i]-v) max=a[i]-v;
        }
        if(v>a[i]) v=a[i];
    }
    printf("%d\n",max);
}


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

using namespace std;

class Point {
    public:
        double x, y;
        Point(double x = 0.0, double y = 0.0): x(x), y(y) {}

        Point operator + (Point p) { return Point(x + p.x, y + p.y); }
        Point operator - (Point p) { return Point(x - p.x, y - p.y); }
        Point operator * (double k) { return Point(x * k, y * k); }
        Point operator / (double k) { return Point(x / k, y / k); }

        double friend norm(Point p) { return p.x * p.x + p.y * p.y; }
        double friend abs(Point p) { return sqrt(norm(p)); }
        double friend dot(Point p1, Point p2) { return p1.x * p2.x + p1.y * p2.y; }
};
typedef Point Vector;
struct Segment {
    Point p1, p2;
};

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Point reflection(Segment s, Point p) {
    Point x = project(s, p);
    return p + (x - p) * 2;
}

int main(void) {
    int q;
    Point p, ans;
    Segment s;

    cin >> s.p1.x >> s.p1.y;
    cin >> s.p2.x >> s.p2.y;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> p.x >> p.y;
        ans = reflection(s, p);
        printf("%.10f %.10f\n", ans.x, ans.y);
    }

    return 0;
}


Measured memory_bytes: 3292
import java.util.*

fun main(args: Array<String>) = p32()

fun p32() {
    data class Yx(val y: Int, val x: Int, val distant: Int) {
        override fun equals(other: Any?): Boolean {
            if (this === other) return true
            if (javaClass != other?.javaClass) return false

            other as Yx

            if (y != other.y) return false
            if (x != other.x) return false

            return true
        }

        override fun hashCode(): Int {
            var result = y
            result = 31 * result + x
            return result
        }
    }

    val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)

    var (w, h) = readLine()!!.split(' ').map { it.toInt() }
    val answer = StringBuilder()

    while (w != 0 && h != 0) {
        val width = w * 2 - 1
        val height = h * 2 - 1
        val grid = Array(height) { readLine()!!.toCharArray() }
        val queue = ArrayDeque(listOf(Yx(0, 0, 1)))
        val visited = mutableSetOf<Yx>()
        val distances = Array(height) { IntArray(width) }

        while (queue.isNotEmpty()) {
            val (y, x, distant) = queue.poll()
            distances[y][x] = distant

            around.forEach {
                val seeingY = y + it.first
                val seeingX = x + it.second
                val next = Yx(y + it.first * 2, x + it.second * 2, distant + 1)
                if (next.y in 0 until height && next.x in 0 until width
                    && grid[seeingY][seeingX] == '0' && visited.add(next)
                ) {
                    queue.add(next)
                }
            }
        }

        answer.appendln(distances.last().last())

        val (nw, nh) = readLine()!!.split(' ').map { it.toInt() }
        w = nw
        h = nh
    }

    print(answer)
}



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

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

long long pow(long long a, long long n, long long m) {
	if (n == 0) return 1 % m;
	long long t = pow(a, n / 2, m);
	t = mod(t * t, m);
	if (n & 1) t = mod(t * a, m);
	return t;
}


long long dp[1100][1100]; // i 人を j+A 人未満のグループで分ける方法

int main() {
	long long N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	COMinit();
	for (int i = 0; i < 1100; ++i) for (int j = 0; j < 1100; ++j) dp[i][j] = 0;
	dp[0][0] = 1;
	for (int i = 0; i <= N; ++i) for (int j = 0; j <= B - A + 1; ++j) {
		int num = A + j;

		//cout << i << ", " << num - 1 << ": " << dp[i][j] << endl;

		// num 人グループが 0 個
		dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;

		// num 人グループが C 以上 D 以下
		for (int k = C; k <= D; ++k) {
			int all = i + num*k;
			if (all > N) break;
			long long choose = COM(N - i, num * k);
			long long divide = fac[num*k] * pow(finv[num], k, MOD) % MOD;
			long long nonkubetsu = finv[k];
			long long mul = choose * divide % MOD * nonkubetsu % MOD;

			//cout << N - i << ", " << num << ", " << k << ": " << choose << ", " << divide << "; " << mul << endl;

			dp[all][j + 1] = (dp[all][j + 1] + dp[i][j] * mul % MOD) % MOD;
		}
	}

	cout << dp[N][B - A + 1] << endl;
}

Measured memory_bytes: 14720
N = int(input())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
icount = 0
if A[1] - A[0] >= N:
  print('OK')
  icount = icount + 1
else:
  for i in range(A[0], A[1]+1):
    if i % N == 0:
      print('OK')
      icount = icount + 1
      if icount == 1:
        break
      
if icount == 0:
  print('NG')


Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(s.size()<=k)
	{
		cout<<s<<endl;
		return 0;
	}
	for(int i=0;i<k;i++)
	{
		cout<<s[i];
	}
	cout<<"..."<<endl;
	return 0; 
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	rep(i,n) {
		int a;
		cin >> a;
		q.push(a);
	}
	for (int i = 0; i < m; i++) {
		int a = q.top(); q.pop();
		a /= 2;
		q.push(a);
	}
	ll ans = 0;
	while (!q.empty()) {
		int a = q.top(); q.pop();
		ans += a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int sum(int n) {
	int res = 0;
	while (n > 0) {
		res += n % 10;
		n /= 10;
	}
	
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = sum(N);
	int n = N;
	int a = 1;
	for (int i = 0; i < 17; i++) {
		a *= 10;
		n /= a;
		n *= a;
		n -= a;
		n += a - 1;
		if (n >= 0) {
			if (n <= N) {
				res = max(res, sum(n));
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    int mn = MOD;
    FOR(i,1,sqrt(N)+1){
        if(N % i == 0){
            ans = (int)to_string(N/i).length();
            mn = min(ans, mn);
        }
    }
    cout << mn << endl;
 }

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 変数の宣言
  int r; //現在のスコア
  int g; //目標スコア
  
  //値の取得
  cin >> r>> g;
  
  //出力
  cout << 2*g-r;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int[] wPoint = new int[10];
			for(int i=0;i<10;i++){
				wPoint[i] = Integer.parseInt(scan.nextLine());
			}
			int[] kPoint = new int[10];
			for(int i=0;i<10;i++){
				kPoint[i] = Integer.parseInt(scan.nextLine());
			}
			Point w = new Point(wPoint);
			Point k = new Point(kPoint);
			System.out.println(w.getPoint() + " " + k.getPoint());
		}
	}
}

class Point{
	private int p;
	
	public Point(){
		p = 0;
	}
	
	public Point(int[] num){
		getSumPoint(num);
	}
	
	public int getPoint(){
		return p;
	}
	
	public void getSumPoint(int[] num){
		int sum = 0;
		int[] maxPoint = {0,0,0};
		Scanner scan = new Scanner(System.in);
		
		for(int i=0;i<10;i++){
			if(maxPoint[0] < num[i]){
				maxPoint[2] = maxPoint[1];
				maxPoint[1] = maxPoint[0];
				maxPoint[0] = num[i];
			}else if(maxPoint[1] < num[i]){
				maxPoint[2] = maxPoint[1];
				maxPoint[1] = num[i];
			}else if(maxPoint[2] < num[i]){
				maxPoint[2] = num[i];
			}
		}
		
		for(int i=0;i<3;i++){
			sum += maxPoint[i];
		}
		p = sum;
	}
}

Measured memory_bytes: 17168
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


# 回文判定
def judge(s):
    news = ""
    for si in s:
        if si != 'x':
            news += si

    if news == news[::-1]:
        return True
    else:
        return False

# 操作の最小値
def min_insertion(s):
    news = ""
    for si in s:
        if si != 'x':
            news += si

    n = len(news)
    fir = [0] * ((n + 1)//2)
    lat = [0] * ((n + 1) // 2)

    # 前半
    cursor = 0
    for si in s:
        if si == 'x':
            fir[cursor] += 1
        else:
            cursor += 1

        if cursor == (n+1)//2:
            break

    # 後半
    cursor = 0
    for si in s[::-1]:
        if si == 'x':
            lat[cursor] += 1
        else:
            cursor += 1

        if cursor == (n + 1) // 2:
            break

    ans = 0
    for firi, lati in zip(fir, lat):
        ans += abs(firi - lati)

    return ans


# 入力
s = ns()

# x以外の回文判定
is_kaibun = judge(s)

# 回文でないならおわり
# 回文ならば最小値出す
if is_kaibun:
    if len(set(list(s))) == 1:
        print(0)
    else:
        print(min_insertion(s))
else:
    print(-1)


Measured memory_bytes: 4144
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    
    double p[n];
    double sum[n];
    double ans = 0.0;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        p[i] = ((double)tmp+1.0)/2.0;
        if(i == 0){
            sum[i] = p[i];
        }else{
            sum[i] = sum[i-1] + p[i];
        }
        //cout << sum[i] << ":";
        
        double tmpd = 0.0;
        if(i >= k-1){
            if(i == k-1){
                tmpd = sum[i] - 0.0;
            }else{
                tmpd = sum[i] - sum[i-k];
            }
            //;
            if(tmpd > ans) ans = tmpd;
        }
        //cout << tmpd << ", ";
    }
    //cout << endl;

    printf("%.7lf\n", ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    string S;
    cin >> S;
    int n = S.size();
    int s[n] = {};
    ll ans = 0;
    per (i, 0, n - 1) {
        if (S[i] == 'B' && S[i + 1] == 'C') {
            if (i + 2 < n) s[i + 1] = s[i + 2];
            s[i] = s[i + 1] + 1;
        } else if (S[i] == 'A') {
            s[i] = s[i + 1];
            ans += s[i];
        }
    }
    // rep (i, 0, n) cout << s[i] << " ";
    cout << ans << "\n";
}

Measured memory_bytes: 1284
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <random>

using namespace std;

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

ll H, W, N;
vector<P> st;

int main(){
  cin >> H >> W >> N;
  ll res[10];

  for(int i = 0; i < 10; i++) res[i] = 0;

  for(int i = 0; i < N; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    for(int i = max(a-2, 0); i <= a; i++){
      if(i + 2 >= H)  break;
      for(int j = max(b-2, 0); j <= b; j++){
        if(j + 2 >= W)  break;
        st.push_back(P(i, j));
      }
    }
  }
  sort(st.begin(), st.end());
  int num = 0;
  int i = 0;
  while(1){
    if(i >= st.size())  break;
    int l = i, r = st.size();
    while(r - l > 1){
      int m = (l + r) / 2;
      if(st[i] == st[m]){
        l = m;
      }
      else{
        r = m;
      }
    }
    res[l-i+1]++;
    i = l+1;
  }
  ll sum = 0;
  for(int i = 1; i < 10; i++) sum += res[i];
  res[0] = (H-2)*(W-2) - sum;

  for(int i = 0; i < 10; i++){
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 18536
#0004
while True:
    try:
        a,b,c,d,e,f = map(float,input().split())
        y = (a*f-d*c)/(a*e-b*d)
        x = (f*b-e*c)/(b*d-a*e)
        if x == -0.0:
            x = 0.000
        elif y == -0.0:
            y = 0.000
        print(format(x, '.3f'),format(y, '.3f'))
    except:
        break


Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,v,b,w,t;
    scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
    if(v*t-w*t>=fabs(a-b))
        printf("YES\n");
    else printf("NO\n");
}


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

using namespace std;

const int INF = 1000000009;

// dp[i+1][v] := i番目までの品物を見たとき, 価値の総和がv以上となるような重さの総和の最小値
long long dp[102][100005];

int main() {
  int n, lim_w;
  cin >> n >> lim_w;

  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < 102; i++) {
    for (int j = 0; j < 100005; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 100005; j++) {
      // i番目の品物を選ぶ
      if (j >= v[i]) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
      }
      // i番目の品物を選ばない
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }

  int ans = 0;
  for (int i = 0; i < 100005; i++) {
    if (dp[n][i] <= lim_w) {
      ans = max(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 80000
<?php

$N_K = explode(' ', trim(fgets(STDIN)));

$N = $N_K[0];
$K = $N_K[1];

$heights = explode(' ', trim(fgets(STDIN)));

$answer = 0;
for ($i=0; $i < count($heights); $i++) { 
    if ($heights[$i] >= $K) {
        $answer++;
    }
}

echo $answer;

Measured memory_bytes: 21372
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORN(i, n, s) for (int i = s; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACKN(a, n, s) \
  for (int i = s; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

int main() {
  int N, X;
  IN(N >> X);

  int m[N];
  int min = 1001;
  FOR(i, N) {
    IN(m[i]);
    if (m[i] < min) {
      min = m[i];
    }
    X -= m[i];
  }

  int num = N;
  while (true) {
    X -= min;
    if (X < 0) {
      break;
    }
    num++;
  }

  OUT(num);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main(void) {
  int n, m;
  cin >> n >> m;
  cout << (n-1) *(m-1) << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265358979323846
const ll MAX = 3e3+10;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    ll n,i,j,k,l,p,q,x,y;
    cin >> n;
    ll a[n+1];
    for(i=1;i<=n;i++)
        cin >> a[i];
    ll dp[n+1][n+1];
    for(i=n;i>=1;i--)
    {
        for(j=i;j<=n;j++)
        {
            if(i==j)
                dp[i][j] = a[i];
            else
                dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    cout << dp[1][n];
}

Measured memory_bytes: 46336
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, T, c[100], t[100], ans=10000;
	cin >> n >> T;
	for(int i=0; i<n; i++){
		cin >> c[i] >> t[i];
		if(t[i]<=T){
			ans=min(ans, c[i]);
		}
	}
	if(ans==10000){
		cout << "TLE" << endl;
		return 0;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    if (b == 1)
      cout << "Draw\n";
    else
      cout << "Alice\n";
  }
  else if (b == 1) {
    cout << "Bob\n";
  }
  else {
    cout << ((a > b) ? "Alice" : (a < b) ? "Bob" : "Draw") << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
while 1:
    n=int(input())
    if n==0: break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])>179 or c>239 or 100 in a: b='A'
        elif c>209 or (c>149 and max(a[:2])>79): b='B'
        else: b='C'
        print(b)

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

int main(){

  int a,b,c;
  string op;
  while(1){
    cin>>a>>op>>b;

    if(op=="+") c=a+b;
    else if(op=="-") c=a-b;
    else if(op=="*") c=a*b;
    else if(op=="/") c=a/b;
    else break;

    cout<<c<<endl;
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  long long sum=0;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=1;i<N;i++){
    if(A.at(i-1)>A.at(i)){
      sum+=A.at(i-1)-A.at(i);
      A.at(i)=A.at(i-1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4040
fun main(args: Array<String>) {
    val n = getInt()
    val a = getLongs()
    var now = a[0]
    var sum = 0L
    a.drop(1).forEach {
        if (now > it) sum += (now - it)
        else now = it
    }

    println(sum)
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 65164
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

const string YES = "Yes";
const string NO = "No";

int main()
{
  uint64_t N, K;
  vector<uint64_t> A;

  cin >> N >> K;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = K; i < A.size(); i++) {
    if (A[i - K] < A[i]) {
      cout << YES << endl;
    }
    else {
      cout << NO << endl;
    }
  }

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b); swap(a, c);
    cout << a << " " << b << " " << c << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll n;
vector<ll> a;

int main(){
    cin >> n;
    a.resize(n);
    rep(i, 0, n){
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());
    ll b = a[n/2];
    ll ans = 0;
    rep(i, 0, n) ans += abs(a[i]-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


#define MOD 1000000007ll
#define MX 206 //200005

ll m, n;
ll a[MX];
int main()
{
    #ifndef ONLINE_JUDGE
    //Fin;
    #endif
    int test=1;
    ll x,y, k, ans;
    ll r,g,b;
    //cin>>test;
    //test=1;
    while(test--)
    {
        k=25;
        cin>>r>>g>>b;
        cin>>k;
        while(k--)
        {
                if(r>=g)g*=2;
                else{
                    b*=2;
                }
        }
        if(r<g && g<b)puts("Yes");
        else puts("No");
    }
    return 0;
}



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

using namespace std;

const int N = 500000;

int n;
int L[N + 1];
int R[N + 1];
char s[N + 1];

int main() {
	cin >> n;
	cin >> s;
	for(int i = 0; i < n; i++) L[i] = (i < 1 ? 0 : L[i - 1]) + (s[i] == 'W');
	for(int i = n; i; i--) R[i - 1] = R[i] + (s[i - 1] == 'E');
	int res = min(L[n - 1], R[1]);
	for(int i = 1; i < n - 1; i++)
		res = min(res, R[i + 1] + L[i - 1]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
 // 	freopen("input.txt","r",stdin);
 // 	freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a ,b;
		cin >>a >>b;
		string s,t;
		int x = a ,y = b;
		while(x--)s+=char(b+'0');
		while(y--)t+=char(a+'0');
		cout << min(s,t)<<E;
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  if(*min_element(a.begin(), a.end())!=1){
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  int m = 1;
  rep(i,n){
    if(a[i]==m){
      m++;
    }else{
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll X; cin >> X;
    ll a = X/500;
    X %= 500;
    ll b = X/5;
    cout << a*1000 + b*5 << ln;
}


Measured memory_bytes: 256
x = int(input())

if 400 <= x and x <= 599:
    print(8)
elif 600 <= x and x <= 799:
    print(7)
elif 800 <= x and x <= 999:
    print(6)
elif 1000 <= x and x <= 1199:
    print(5)
elif 1200 <= x and x <= 1399:
    print(4)
elif 1400 <= x and x <= 1599:
    print(3)
elif 1600 <= x and x <= 1799:
    print(2)
elif 1800 <= x and x <= 1999:
    print(1)


Measured memory_bytes: 9184
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn zalgo(s: Vec<char>) -> Vec<usize> {
    let n = s.len();
    let mut ans = vec![0; n];
    ans[0] = n;
    let mut i = 1usize;
    let mut j = 0usize;
    while (i < n) {
        while (i + j < n && s[j] == s[i + j]) {
            j += 1;
        }
        ans[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while (i + k < n && k + ans[k] < j) {
            ans[i + k] = ans[k];
            k += 1;
        }
        i += k;
        j -= k;
    }

    ans
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let mut ans = 0;
    for i in 0..n {
        let s_ = &s[i..];
        let acc = zalgo(s_.to_vec());
        for j in 1..acc.len() {
            ans = max(ans, min(j, acc[j]))
        }
    }

    println!("{}", ans);
}


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

int n, W;

//DPtable
void show(vector<vector<ll> >&dp, int i){
    printf("\n");
    printf("   |");
    rep(i, W+1)  printf("%3d", i);
    printf("\n");
    printf("---+");
    rep(i, 10)  printf("---");
    printf("\n");
    rep(i, n+1){
        printf("%3d|", i);
        rep(j, W+1){
            printf("%3lld", dp[i][j]);
        }
        printf("\n");
    }
    sleep(i);
}

int main(){
    cin >> n;
    cin >> W;
    vector<int>w(n);
    vector<ll>v(n);
    rep(i, n)   cin >> w[i] >> v[i];
    //solve
    vector<vector<ll> >dp(1000, vector<ll>(1e5+10));
    rep(i, n){
        for(int j = 0; j <= W; j++){
            if(w[i] <= j){
                dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            }else{
                dp[i+1][j] =  dp[i][j];
            }
            //show(dp, 1);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 785024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int n;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n;
	vector<int> p(n);
	rep(i, 0, n){
		cin >> p[i];
	}
	int ans = 0;
	rep(i,1,n-1){
		//cout << p[i - 1] << " " << p[i] << " " << p[i + 1] << "\n";
		if(p[i-1]<p[i]&&p[i]<p[i+1]){
			ans++;
		}else if(p[i+1]<p[i]&&p[i]<p[i-1]){
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000000000000
using namespace std;
vector<ll> edges[1005];
ll dp[1005][2][2];
ll req[1005];
bool flag = true;
vector< vector<ll> > tdp;
void dfs (int u) {
	vector<pll> blk, wht;
	blk.pb({0, 0}); wht.pb({0, 0});
	for (auto v : edges[u]) {
		dfs(v);
		blk.pb({dp[v][0][0], dp[v][1][0]});
		wht.pb({dp[v][0][1], dp[v][1][1]});
	}
	ll i, j, m, s = edges[u].size();
	bool ok = false;
	tdp.clear();
	tdp.resize(s + 1);
	m = 0;
	for (i = 0; i <= s; i++) {
		tdp[i].resize(req[u] + 5);
		for (j = 0; j <= req[u]; j++) {
			tdp[i][j] = inf;
		}
		if (i == 0) {
			tdp[i][0] = 0;
			continue;
		}
		for (j = 0; j <= req[u]; j++) {
			if (j - blk[i].fi >= 0) {
				tdp[i][j] = min(tdp[i][j], tdp[i - 1][j - blk[i].fi] + wht[i].fi);
			}
			if (j - blk[i].se >= 0) {
				tdp[i][j] = min(tdp[i][j], tdp[i - 1][j - blk[i].se] + wht[i].se);
			}
			if (i == s && tdp[i][j] < inf) m = max(m, j);
		}
	}
	if (tdp[s][m] < inf) {
		dp[u][0][0] = req[u]; dp[u][0][1] = tdp[s][m]; ok = true;
	}
	
	tdp.clear();
	tdp.resize(s + 1);
	m = 0;
	for (i = 0; i <= s; i++) {
		tdp[i].resize(req[u] + 5);
		for (j = 0; j <= req[u]; j++) {
			tdp[i][j] = inf;
		}
		if (i == 0) {
			tdp[i][0] = 0;
			continue;
		}
		for (j = 0; j <= req[u]; j++) {
			if (j - wht[i].fi >= 0) {
				tdp[i][j] = min(tdp[i][j], tdp[i - 1][j - wht[i].fi] + blk[i].fi);
			}
			if (j - wht[i].se >= 0) {
				tdp[i][j] = min(tdp[i][j], tdp[i - 1][j - wht[i].se] + blk[i].se);
			}
			if (i == s && tdp[i][j] < inf) m = max(m, j);
		}
	}
	if (tdp[s][m] < inf) {
		dp[u][1][0] = tdp[s][m]; dp[u][1][1] = req[u]; ok = true;
	}
	if (!ok) flag = false;
	return;
}
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	for (i = 2; i <= a; i++) {
		scanf("%lld", &b);
		edges[b].pb(i);
	}
	for (i = 1; i <= a; i++) {
		scanf("%lld", &req[i]);
		for (j = 0; j <= 1; j++) for (k = 0; k <= 1; k++) dp[i][j][k] = inf;
	}
	dfs(1);
	if (flag) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0; 
}

Measured memory_bytes: 2332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	ll k;
	cin >> k;
	ll ans = 0;
	for (ll i = 1; i <= k; i++) {
		for (ll j = 1; j <= k; j++) {
			for (ll h = 1; h <= k; h++) {
				ans += gcd(i, gcd(j, h));
			}
		}
	}
	cout << ans;
	return 0;
}










Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    int sum = 0;
    for(int i=0; i<M; i++) {
      sum += scan.nextInt();
    }
    scan.close();

    System.out.println(N<sum ? -1 : N-sum);
  }
}

Measured memory_bytes: 39304
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,p,ans=1;
  cin>>n>>p;
  map<ll,ll> mp;
  vector<ll> v;
  if(n==1){
    cout<<p<<endl;
    return 0;
  }
  for(ll i=2;i<=sqrt(p);i++){
    while(p%i==0){
      mp[i]++;
      p/=i;
    }
    if(p==1) break;
  }
  for(auto c:mp){
    if(c.second>=n){
      rep(i,c.second/n) ans*=c.first;
    }
  }
  
  cout<<ans<<endl;

 
  
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    ll c=1000;
    ll k=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    A[N]=0;
    for(int i=0;i<N-1;i++){
        if(A[i]<A[i+1]){
            k = c/A[i];
            c -= A[i]*k;
            c += A[i+1]*k;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3148
# coding: utf-8
# Your code here!
N,X = list(map(int,input().split(" ")))
m = [int(input()) for i in range(N)]

total=0;c=0;flag=True
for i in range(len(m)):
        total+=m[i]
        c+=1
        
while(flag):
    total+=min(m)
    if total<=X:
        c+=1
    else:
        flag=False
    

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n, m; cin >> n >> m;
		priority_queue<int64> a;
		rep (i, n) {
			int64 tmp; cin >> tmp;
			a.push(tmp);
		}
		rep (i, m) {
			int64 target = a.top();
			a.pop();
			target /= 2;
			a.push(target);
		}
		int64 ans = 0;
		while(!a.empty()) {
			ans += a.top();
			a.pop();
		}
		cout << ans << endl;
    return;
}

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



Measured memory_bytes: 1400
from itertools import accumulate
def resolve():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(K):
        imos_table = [0]*(N+1)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = list(accumulate(imos_table))[:-1]
        if all([True if a == N else False for a in A]):
            print(*A)
            return
    else:
        print(*A)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 184216