akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const int MAX_N=1e5;
ll N;
typedef pair<ll,ll> P;
ll par[MAX_N*2-1],sz[MAX_N*2-1];
void inituf(ll n){
	REP(i,n){
		par[i]=i;
		sz[i]=i<=n/2;
	}
}
ll fndpar(ll v){
	if(v==par[v]){
		return v;
	}
	return par[v]=fndpar(par[v]);
}
struct edge{
	ll u,v,cst,inx;
};
bool operator < (const edge &a,const edge &b){
	return a.cst<b.cst;
}
edge E[MAX_N-1];
vector<P> G[MAX_N*2-1];
ll dst[MAX_N*2-1];
void dfs(ll v,ll p,ll d){
	dst[v]=d;
	for(auto e:G[v]){
		if(e.first!=p){
			dfs(e.first,v,d+e.second);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N-1){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		E[i]=(edge){a,b,c,i};
	}
	sort(E,E+N-1);
	inituf(N*2-1);
	REP(i,N-1){
		edge e=E[N-2-i];
		e.u=fndpar(e.u);
		e.v=fndpar(e.v);
		par[e.u]=e.inx+N;
		par[e.v]=e.inx+N;
		sz[e.inx+N]=sz[e.u]+sz[e.v];
		G[e.inx+N].push_back(P(e.u,sz[e.v]*e.cst));
		G[e.inx+N].push_back(P(e.v,sz[e.u]*e.cst));
	}
	ll rt=fndpar(0);
	dfs(rt,-1,0);
	REP(i,N){
		cout<<dst[i]<<endl;
	}
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+10;
const int mod=1e9+7;

int dp[5010];




int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int j=1;j<=5005;j++)
        dp[j]=1e9;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        int sum=0;
        for(int j=1;j<=b;j++)
        {
            int c;
            cin>>c;
            int x=1<<(c-1);
            sum|=x;
        }
        for(int j=0;j<=(1<<n)-1;j++)
        {
            int temp=0;
            for(int x=0;x<=12;x++)
            {
                if(((j>>x)&1)==1&&((sum>>x)&1)==0)
                    temp+=1<<x;
            }
            dp[j]=min(dp[j],dp[temp]+a);
        }
    }
    if(dp[(1<<n)-1]==1e9)
        dp[(1<<n)-1]=-1;
    cout<<dp[(1<<n)-1]<<'\n';

}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c;
    for (int i = 1; i <= c; ++i)
    {
        if (b < i * a)
        {
            ans = i - 1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
int A[3000], B[3000];
int m[3010][3010];
int solve(int k, int t) {
    if (k < 0) return 0;
    if (m[k][t] != -1) return m[k][t];
    int res = solve(k-1, t);
    if (t >= A[k]) {
        res = max(res, solve(k-1, t-A[k]) + B[k]);
    }
    return m[k][t] = res;
}
vector<pair<int, int>> C;
int main () {
    for (int i = 0; i < 3010; i++) {
        for (int j = 0; j < 3010; j++) {
            m[i][j] = -1;
        }
    }
    int T;
    cin >> N >> T;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        C.push_back(make_pair(a, b));
    }
    sort(C.begin(), C.end());
    for (int i = 0 ; i < N; i++) {
        A[i] = C[i].first, B[i] = C[i].second;
        ans = max(ans, B[i]);
    }
    for (int i = 1; i < N; i++) {
        ans = max(ans, solve(i-1, T-1) + B[i]);
    }
    cout << ans << endl;
}

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

if x == 2:
    print(2)
    exit()
if x == 3:
    print(3)
    exit()
if x == 5:
    print(5)
    exit()


def check_prime(n):
    if n % 2 == 0:
        return False

    for i in range(3, n // 2, 2):
        if n % i == 0:
            return False

    return True

if x % 2 ==0:
    x += 1

while True:
    if check_prime(x):
        print(x)
        exit()
        break

    x += 2

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int k = stdIn.nextInt();
		int x = stdIn.nextInt();
		
		for(int i = x-k+1; i < x + k; i++){
			System.out.print(i+" ");
		}
	}

}


Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int X;
	cin >> X;
	int M = 100;
	int ans = 0;
	while (M < X) {
		M += M / 100;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;
signed main(void)
{
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B,a,b;
    int i=0;
    cin>>A>>B;
    bool ans=false;
    while(ans==false&&i<1010){
        i++;
        a=i*8/100;
        b=i/10;
        if(a==A&&b==B){
            ans=true;
        }
    }
    if(ans==true)cout<<i<<endl;
    if(ans==false)cout<<-1<<endl;
    return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;

    string st;

    while (n) {
        int x = n % (-2);
        bool flag = false;
        if (x < 0) {
            x += 2;
            flag = true;
        }
        st += to_string(x);
        if (flag) n -= 2;
        n /= (-2);
    }

    reverse(all(st));
    print(st.length() ? st : "0");

    return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
hp = gets.chomp.split(" ").map(&:to_i).sort
hp_sum = 0

if n > k
  (0...n-k).each do |i|
    hp_sum += hp[i]
  end
  puts hp_sum
else
  puts 0
end

Measured memory_bytes: 21360
#include <iostream>
#include <vector>
#include <string>
//#include "./libb/lib.hpp"

using namespace std;

int main()
{
    uint32_t ss;
    uint32_t ww;
    cin >> ss >> ww;

    if(ww >= ss){
        cout << "unsafe" << endl;
        return 0;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>

int main(){
  std::string s;
  std::cin >> s;

  std::array<long, 2> ansArr = {0, 0};

  for(unsigned long i = 0; i < s.size(); ++i){
    if(i%2 == 0){
      if(s[i] == '1')
        ++ansArr[0];
      else
        ++ansArr[1];
    }else{
      if(s[i] == '1')
        ++ansArr[1];
      else
        ++ansArr[0];
    }
  }

  std::cout << (ansArr[0] < ansArr[1] ? ansArr[0] : ansArr[1]) << std::endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
typedef tuple<ll,ll,ll> tl;
typedef tuple<ll,ll,ll,ll> ql;

#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ld r;
    cin >> r;
    cout << setprecision(10) << (ld)2*r*PI;
}

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

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

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

//----------------------------------------------------------------
// decayed bridge

class UnionFind{

public:
  vector<int> parents;

  UnionFind(int n){
    parents.assign(n, -1);
  }
  ~UnionFind(){}

  int find(int x){
    if(parents[x]<0){
      return x;
    } else {
      return find(parents[x]);
    }
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y){return;}

    if(parents[x]>parents[y]){
      int tmp = x;
      x = y;
      y = tmp;
    }

    parents[x] += parents[y];
    parents[y] = x;
  }

  int size(int x){
    return -parents[find(x)];
  }

  int count_roots(){
    int ct=0;
    for(int i=0; i<parents.size(); i++){
      if(parents[i]<0){ct++;}
    }
    return ct;
  }

  bool is_same(int x, int y){
    return find(x) == find(y);
  }
};

int main(void) {
  int n, m;
  cin >> n >> m;

  UnionFind uf(n);

  int a[m], b[m];
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  vecll ans;
  ll cnt = (ll) n*(n-1)/2;
  rep(i,m){
    ans.push_back(cnt);
    if(uf.is_same(a[m-i-1], b[m-i-1])){
      //uf.unite(a[m-1-i], b[m-i-1]);
      continue;
    } else {
      ll n_1 = uf.size(a[m-i-1]);
      ll n_2 = uf.size(b[m-i-1]);
      cnt -= n_1*n_2;
      uf.unite(a[m-1-i], b[m-i-1]);
    }
  }

  rep(i,m){
    prt(ans[m-i-1]);
  }

}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ldb long double
const int MAXN = 307;
ldb dp[MAXN][MAXN][MAXN];
int cnt[4], n;
int main()
{
    scanf("%d", &n);
    for (int i = 1, a; i <= n; i++) scanf("%d", &a), cnt[a]++;
    dp[0][0][0] = 0;
    for (int k = 0; k <= cnt[3]; k++)
        for (int j = 0; j <= cnt[2] + cnt[3]; j++)
            for (int i = 0; i <= cnt[1] + cnt[2] + cnt[3]; i++)
            {
                if (!i && !j && !k) continue;
                dp[i][j][k] = (ldb)(n - i - j - k) / (i + j + k);
                if (i) dp[i][j][k] += (ldb)i / (i + j + k) * (dp[i - 1][j][k] + 1);
                if (j) dp[i][j][k] += (ldb)j / (i + j + k) * (dp[i + 1][j - 1][k] + 1); 
                if (k) dp[i][j][k] += (ldb)k / (i + j + k) * (dp[i][j + 1][k - 1] + 1);
            }
    printf("%.15lf\n", (double)dp[cnt[1]][cnt[2]][cnt[3]]);
    return 0;
}

Measured memory_bytes: 444672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int a=cin.nextInt();
        int b=cin.nextInt();
        if(a>b)
        {
          for(int i=0;i<a;i++)Console.Write(b);
          Console.WriteLine();
        }
       else
        {
          for(int i=0;i<b;i++)Console.Write(a);
          Console.WriteLine();
        }
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11092
'use strict'

const INF = 900719925474099; // Number.MAX_SAFE_INTEGER / 10;

//ユークリッド互除法(a,bの大小は気にしなくてOK,最大公約数が返る。)
function gcd(a,b){return b?gcd(b,a%b):a;}


function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let a = temp[1].split(' ').map((v)=>parseInt(v));	

	let all = gcd(a[0],a[1]);

	let s = new Set([all,a[0],a[1]]);

	for(let i = 2;i<n;i++){
		let t = new Set();
		//スキップ済みのものと今回のをgcd
		for(let v of s){
			v = gcd(v,a[i]);
			if(v>1) t.add(v);
		}
		if(all>1){
			//今回スキップの場合
			t.add(all);
			//全部gcdとった場合
			all = gcd(all,a[i]);
			if(all>1) t.add(all);
		}
		s = t;
	}
	let max = 1;
	for(let v of s){
		if(v>max) max = v;
	}
	//回答出力
	console.log(max);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29960
def main():
    import sys
    input = sys.stdin.readline
    mod = 998244353
    A, B, C, D = map(int, input().split())
    dp = [[1] * (D+1) for _ in range(C+1)]
    a = A
    for i, w in enumerate(range(B+1, D+1)):
        dp[A][w] = a
        a *= A
        a %= mod
    b = B
    for i, h in enumerate(range(A+1, C+1)):
        dp[h][B] = b
        b *= B
        b %= mod
    for h in range(A+1, C+1):
        for w in range(B+1, D+1):
            dp[h][w] = (dp[h-1][w]*w%mod + dp[h][w-1]*h%mod - dp[h-1][w-1]*(h-1)*(w-1)%mod) % mod
    print(dp[C][D])

if __name__ == '__main__':
    main()

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000000

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

int ce(int a, int b){
    return (a+b-1)/b;
}

int n, m, l, r;

int main(){
    scanf("%d %d", &n, &m);

    int mal = -1, mir = 100100;
    for (int i = 0; i < m; ++i){
       	scanf("%d %d", &l, &r);

       	mal = max(l, mal);
       	mir = min(r, mir);
    } 

    printf("%d\n", max(mir-mal+1, 0));

    return 0;       
}

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

int main(){
    long long int a;
    string b;
    cin >> a >> b;

    int bb = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    long long int ans = a * bb / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define jyldam ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(NULL);

#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define sz size()
#define fi first
#define se second
 
#define cmp_all(x) (x).begin(), (x).end(), cmp
#define batr ONLINE_JUDGE
#define all(x) (x).begin(),(x).end()
#define skip continue
 
using namespace std;

typedef long long ll;
typedef long double ld;
 
const int N = 1e6 + 17, maxN = 4 * N, D = 1e3 + 17, mod = 1e9 + 7;

ll a, b, c;

int main () {
	jyldam;
	cin >> a >> b >> c;
	if (a + b + 1 >= c) {
		cout << b + c;
	}
	else {
		cout << b + (a + b + 1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int ans = 0;
    for (int i=1; i <= n; i++){
        int tmp = i;
        int sum = 0;
        sum += tmp%10;
        tmp /= 10;
        sum += tmp%10;
        tmp /= 10;
        sum += tmp%10;
        tmp /= 10;
        sum += tmp%10;
        tmp /= 10;
        sum += tmp%10;
        if (a <= sum && sum <= b) ans+=i;
    }


    

    printf("%d\n", ans);    


    return 0;
} 



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

using namespace std;

void print(const vector<int>& A) {
    for (int i = 0; i < A.size(); i++) {
        if (i == 0) {
            cout << A[i];
        } else {
            cout << ' ' << A[i];
        }
    }
    cout << endl;
}

void selectionSort(vector<int>& A) {
    int swaps = 0;
    for (int i = 0; i < A.size(); i++) {
        int minj = i;
        for (int j = i; j < A.size(); j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            swaps++;
        }
    }
    print(A);
    cout << swaps << endl;
}

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

    vector<int> a;
    a.reserve(n);

    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        a.push_back(val);
    }

    selectionSort(a);

    return 0;
}

Measured memory_bytes: 3040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
int main() {
	ll X, Y;
	cin >> X >> Y;
	if (X%Y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << X << endl;
	}
}

Measured memory_bytes: 256
N = gets.chomp.to_i
S = gets.chomp.split('')
ans = []

alf = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
S.each do |s|
  i = alf.find_index(s) + N
  ans << alf[i % 26]
end
puts ans.join('')

Measured memory_bytes: 2300
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

boin = ["a", "e", "i", "o", "u"]
c = input()

print("vowel" if c in boin else "consonant")

Measured memory_bytes: 14500
let () =
  Scanf.scanf "%d %d %d" @@ fun a b k ->
  let rec f c i =
    if c = k then i+1
    else if a mod i = 0 && b mod i = 0 then f (c+1) (i-1)
    else f c (i-1)
  in f 0 (min a b) |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
   double w,h,x,y;
  cin>>w>>h>>x>>y;
  int mul=0;
  if(x==w/2&&y==h/2) mul=1;
  double ans=w*h/2;
  cout<<ans<<" "<<mul<<endl;
}

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

int main(void){

	int n;
	int m;

	scanf("%d",&n);

	m = n % 10;

	switch(m){
	case 3:
		printf("bon\n");
		break;
	case 1:
		printf("pon\n");
		break;
	case 0:
		printf("pon\n");
		
		break;
	case 6:
		printf("pon\n");

		break;
	case 8:
		printf("pon\n");
		break;

	default :
		printf("hon\n");
		break;

	}

	
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());

    float ans = v[0];
    for(int i = 1; i < N; i++) {
        ans += v[i];
        ans /= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	int a,b;
	string c;
	cin>>s>>t>>a>>b>>c;
	if(c==s)
	cout<<a-1<<' '<<b;
	else
	cout<<a<<' '<<b-1;
	return 0; 
 } 

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

const int N = 40000 + 7;

int a[N], b[N];



int32_t main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, a, b; cin >> n >> a >> b;
    if(a == 0) cout << 0 << endl;
    else {
        int k = (n / (a + b)) * a, l = n % (a + b);
        k += min(a, l);
        cout << k << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int keisan(int x,int y){
	int r;
 if (x < y)
        swap(x, y);
    while (y > 0){
        r = x % y;
        x = y;
		y = r;
	}
    return x;
}

int main(){
  int a;
  int b;
  cin >> a >> b;
  cout<<keisan(a,b)<<endl;
  return 0;
 }


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		string ans="second";
		for(int i=0;i<n;i++){
			int q=int.Parse(Console.ReadLine());
			if(q%2==1){
				ans="first";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 15184
(* --------------Encoder-------------- *)
(* -----function----- *)
(*
let encoder = 0
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
(*
let decoder ans = ""
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(*
let processor dat = 0
*)

(* -------test------- *)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*
let () = print_endline (decoder (processor encoder))
*)
(* ------------------------------------ *)
let () = Scanf.scanf "%d %d" (fun s w -> 
        if s <= w then
                "unsafe"
        else
                "safe"
) |> Printf.printf "%s\n"



Measured memory_bytes: 3700
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
int H,W,A,B;
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}
ll divmod(ll a,ll b){
    return ((a%MOD) * (powmod(b,MOD-2)%MOD)) % MOD;
}
ll combi(ll n,ll r){
    ll num = 1;
    for(ll i = 1;i <= n;i++){
        num = divmod((n-i+1)*num,i);
    }
    return num;
}
void make_table(ll n,ll r,ll *table){
    //rCr ~ nCr
    table[0] = 1;
    for(int i = 1;i < W;i++){
        table[i] = divmod(table[i-1]*(r+i),i); 
    }
}
main(){
    cin >> H >> W >> A >> B;
    ll t1[W] = {},t2[W] = {};
    make_table(H+W-A-B,H-A-1,t1);
    make_table(W,A-1,t2);
    /*
    for(int i = 0;i < W;i++){
        cout << t1[i] << endl;
    }cout << endl;
    for(int i = 0;i < W;i++){
        cout << t2[i] << endl;
    }
    */
    ll ans = 0;
    for(int i = 0;i < W-B;i++){
//        cout << t1[W-i-1] << " " << t2[i] << endl;
        (ans += t1[W-i-1] * t2[i]) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(2 * 10 ** 5)

N = int(input())
colors = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for i in range(N - 1)]
graph = [[] for i in range(N + 1)]
for u, v in edges:
    graph[u].append(v)
    graph[v].append(u)
parent = {1: None}
children = {}


def rootTree(node):
    children[node] = []
    for nbr in graph[node]:
        if nbr not in parent:
            parent[nbr] = node
            children[node].append(nbr)
            rootTree(nbr)


rootTree(1)


# Count the paths that don't contain a particular color
# If we can find a max c-less component (in the sense that the nodes are either leaves or bordered by color c) of size s, then there are (s * s + 1 / 2) c-less paths in that component
colorlessCount = [0 for c in range(N + 1)]
# In our DFS we want to increment the size of each component except for the one matching current color all at once but that will TLE
# Instead implicitly increment them by tracking current size as dfs time `t` minus some offset. Then we can increment all just by adding to t or subtract from one by fiddling with the offset
colorlessTime = [0 for c in range(N + 1)]
t = 0


def buildComps(node):
    global t
    currColor = colors[node - 1]
    # Increment all by 1 except currColor
    t += 1
    colorlessTime[currColor] += 1
    for child in children[node]:
        # Each child forms a new currColor-less component so we need to save the old count
        oldCount = t - colorlessTime[currColor]
        # Start new comp
        colorlessTime[currColor] = t
        buildComps(child)
        # Done with child comp, count the paths and discard comp
        s = t - colorlessTime[currColor]
        colorlessCount[currColor] += s * (s + 1) // 2
        # Restore old count
        colorlessTime[currColor] = t - oldCount


buildComps(1)

# Count the colorless components path from root too
for c in range(1, N + 1):
    s = t - colorlessTime[c]
    colorlessCount[c] += s * (s + 1) // 2

# We counted colorless but want colored paths so take complement
maxPairs = N * (N + 1) // 2
for c in range(1, N + 1):
    print(maxPairs - colorlessCount[c])


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(rall(a));
    int sum = 0;
    rep(i, k) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }
    print!("{}", s);
    let mut vs: Vec<char> = s.chars().collect();
    if vs[(vs.len() - 1) as usize] == 's' {
        println!("es");
    } else {
        println!("s");
    }
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(time(NULL));

const int D = 365, N = 26;
int d;
ll c[N+1];
ll s[D+1][N+1];
ll last[N];
int contest[D];

ll calc(int idx, int x) {
	ll ans = 0;
	ll l = idx-1, r = idx+1;
	ll len, len2;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans -= s[idx][contest[idx]];
	ans -= c[contest[idx]] * len * len2;
	ll tmp = contest[idx];
	contest[idx] = x;

	l = idx-1, r = idx+1;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans += s[idx][x];
	ans += c[x] * len * len2;
	contest[idx] = tmp;
	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> d;
	for(int i = 1; i <= N; i++)
		cin >> c[i];
	for(int i = 1; i <= d; i++) {
		for(int j = 1; j <= N; j++)
			cin >> s[i][j];
	}
	memset(last, 0, sizeof last);
	ll ans = 0;
	for(int i = 1; i <= d; i++) {
		ll penalty = 0;
		for(int j = 1; j <= 26; j++)
			penalty += c[j] * (last[j] - i);
		ll best = -1, idx = -1;
		for(int j = 1; j <= 26; j++) {
			ll cur = s[i][j] - penalty + c[j] * (i - last[j]);
			if(best < cur)
				best = cur, idx = j;
		}
		last[idx] = i;
		ans += best;
		contest[i] = idx;
	}

	for(int i = 0; i < 120000; i++) {
		int idx = rng() % d + 1;
		for(int to = 1; to <= 26; to++) if(to != contest[idx]) {
			ll change = calc(idx, to);
			if(change > 0) {
				contest[idx] = to;
				ans += change;
			}
		}
	}

	for(int i = 1; i <= d; i++)
		cout << contest[i] << '\n';

	return 0;
}

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

int main() {
	int N; cin >> N;
	map<string, int> mp;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}

	long long int ans = 0;
	for (auto& p : mp) {
		int s = p.second;
		ans += (long long)s * (s - 1) / 2;
	}

	cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll count = 0;
    map<string, ll> S;
    cin >> N;
    rep(i, N) {
        string temp;
        cin >> temp;
        sort(temp.begin(), temp.end());
        S[temp]++;
    }
    iter(i, S) count += i.second * (i.second - 1) / 2;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=min(b,d)-max(a,c);
    if(ans<0){
        ans=0;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int X[4]={1,0,-1,0};
int Y[4]={0,1,0,-1};
const int m=501;
int n;
int near[m][m];
int visited[m][m];
void dfs(int x_val, int y_val, int visited[][501], int near[][501]){
	if(x_val>=0 and y_val>=0 and x_val<=n and y_val<=n){
		int z=visited[x_val][y_val]+near[x_val][y_val];
		f(i,0,4){
			int x=X[i]+x_val;
			int y=Y[i]+y_val;
			if(x>=0 and y>=0 and x<=n and y<=n and z<near[x][y]){
				near[x][y]=z;
				dfs(x,y,visited,near);
			}
		}
	}
}
int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    // vector<vector<int>> near(n+1,vector<int> (n+1,0));
    // vector<vector<int>> visited(n+1,vector<int> (n+1,1));
    f(i,1,n+1){
    	f(j,1,n+1){
    		near[i][j]=min(min(i,n-i+1),min(j,n-j+1))-1;
    		visited[i][j]=1;
    	}
    }
    int ans=0;
    for (int it = 0; it < n*n; it++){
        int id;
        cin >> id;
        int x = (id+n-1)/n;
        int y = id % n;
        if (y == 0) y += n;
        ans += near[x][y];
        visited[x][y] = 0;
        dfs(x, y, visited, near);
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 24880
import java.util.*;

public class Main{
	public static void main(String[] args){
		//new Main().printHelloWorld();
		System.out.println(new Main().ITP1_1_B(Integer.parseInt(new Scanner(System.in).next())));
	}

	public void printHelloWorld(){
		System.out.println("Hello World");
	}

	public int ITP1_1_B(int x){
		return x*x*x;
	}
}

Measured memory_bytes: 26068
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define bql 2147483647
#define ll long long
#define ull unsigned long long
using namespace std::tr1;
using namespace std;
const int N=2e5+5;
const int mod=998244353;
const int fx[5]={0,-1,0,1,0};
const int fy[5]={0,0,-1,0,1};
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0' && ch<='9'){x=(x<<3)+(x<<1);x+=(ch-'0');ch=getchar();}
    return x*f;
}

void write(int x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>10) write(x/10);
    putchar(x%10+'0');
}

ll n,k,a[N];
ll f(ll mid)
{
	ll ret=0;
	for (int i=0;i<n;i++)
  {
		if (a[i]==0)
    {
			if (mid>=0)
          ret+=n-1;
			continue;
		}
		if (a[i]<0)
    {
			ll target=mid/a[i];
			if (target*a[i]>mid)
          target++;
			int idx=lower_bound(a,a+n,target)-a;
			ret+=n-idx;
			if (idx<=i)
          ret-=1;
		}
		else
    {
			ll target=mid/a[i];
			if (target*a[i]>mid)
          target--;
			int idx=upper_bound(a,a+n,target)-a-1;
			if (idx<0)
          continue;
			ret+=idx+1;
			if (idx>=i)
          ret-=1;
		}
	}
	return ret/2;
}

int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++)
      cin>>a[i];
	sort(a,a+n);
	ll lo=-1e18,hi=1e18;
	while (lo<hi)
  {
		ll mid=lo+(hi-lo)/2;
		if (f(mid)>=k)
        hi=mid;
		else
        lo=mid+1;
	}
	cout<<lo<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int N;
    int a[100];
    scanf("%d", &N);
    int i, j, tunc, counter = 0;
    for (i = 0; i < N;i++){
        scanf("%d", &a[i]);
    }
    for (i = N - 1; i != 0;i--){
        for (j = N - 1; j != N - i - 1;j--)
            if (a[j - 1] > a[j])
            {
                //printf("%d %d\n", a[j - 1], a[j]);
                tunc = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tunc;
                counter++;
            }
    }
    for (i = 0; i < N-1;i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[N - 1]);
    printf("%d\n", counter);
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{ int k;
    cin>>n>>k;
    int h[n];
    for(i=0;i<n;i++)
        cin>>h[i];
    int dp[n];
    for(i=0;i<n;i++)
        dp[i]=0;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(i=2;i<n;i++)
    {
      int ans=INT_MAX;
      for(j=i-1;j>=i-k&&j>=0;j--)
        ans=min(dp[j]+abs(h[j]-h[i]),ans);
      dp[i]=ans;
      
    }

    cout<<dp[n-1];
}

}


Measured memory_bytes: 5172
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

let rec solve maxVal ans list =
    match list with
    | x :: xx -> if x >= maxVal then solve x (ans + 1) xx else solve maxVal ans xx
    | [] -> ans

stdin.ReadLine()

()
|> readIntArray
|> Array.toList
|> solve 0 0
|> printfn "%d"


Measured memory_bytes: 30132
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  vector<ll> v(n), dp(n+1, 0);
  rep(i, n) cin >> v[i];
  dp[0] = 0; dp[1] = abs(v[0]-v[1]);
  for(int i = 2; i < n; i++){
    dp[i]  =  min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout << dp[n-1] << endl;
  system("pause");
}

Measured memory_bytes: 2040
#include <stdio.h>

int A[2000],m[2000],b;

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=b) return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){
  int a,i;
  scanf("%d",&b);
  for(i=0; i<b; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&a);
  for(i=0; i<a; i++){
    scanf("%d",&m[i]);
  }
  for(i=0; i<a; i++){
    if(solve(0, m[i]) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2108
// AUTHOR : Kishan Srivastav
	#include<bits/stdc++.h>
	using namespace std;
	#define ll long long
	#define mod 1000000007
	#define in freopen("input.txt", "r", stdin)
	#define out freopen("output.txt", "w", stdout)
	#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


	int main() {
		ios
	#ifndef ONLINE_JUDGE
		in;
		out;
	#endif
		string s;
		cin>>s;
		if(s == "Sunny"){
			cout<<"Cloudy"<<endl;
		}else if (s == "Cloudy"){
			cout<<"Rainy"<<endl;
		}else{
			cout<<"Sunny"<<endl;
		}

	}

Measured memory_bytes: 3624
#include<iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

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

// 入力
int N;
int W;
long long w[110];
long long v[110];
int f;

// DP テーブル
long long dp[110][100010] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    // ループ
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j <= W; ++j){
        if(j - w[i] >= 0){
          chmax(dp[i+1][j],dp[i][j-w[i]] + v[i]);
          }
        chmax(dp[i+1][j],dp[i][j]);

      }
    }

    // 答え
    cout << dp[N][W] << endl;

}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

signed main() {
  string S, T;
  cin >> S >> T;
  REP (i, S.size()) {
    if (S.substr(i) + S.substr(0, i) == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//???????????????????¢??°???Euler's totient function???
//n??¨??????????´??????°[1,n]????????°
//http://mathtrain.jp/phi
int eulerTotient(int n) {
	int ret = n;
	for (int x = 2; x*x <= n; x++) {
		if (n%x)continue;
		ret -= ret / x;
		while (n%x == 0)n /= x;
	}
	if (n != 1)ret -= ret / n;
	return ret;
}

signed main() {
	int n; cin >> n;
	cout << eulerTotient(n) << endl;
	return 0;
}

Measured memory_bytes: 3100
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int A = sc.nextInt();
 
   int tmp = N%500;
   if(tmp<=A) System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    std::string S; std::cin >> S;
    std::vector<int> a(4);
    for(int i(0); i < 4; ++i) a[i] = S[i] - '0';
    for(int i(0), i_len(1 << 3); i < i_len; ++i){
        int sum(a[0]);
        std::string ans(1, S[0]);
        for(int j(0); j < 3; ++j){
            if((i >> j) & 1){
                sum += a[j+1];
                ans += '+';
            }else{
                sum -= a[j+1];
                ans += '-';
            }
            ans += S[j+1];
        }
        if(sum == 7){
            std::cout << ans << "=7" << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc119a()
}

fun abc119a() {
    val (y, m, d) = readLine()!!.split("/").map { it.toInt() }
    
    if (y <= 2019 && m <= 4 && d <= 30) println("Heisei") else println("TBD")
}


Measured memory_bytes: 36204