akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
set<int> st;

bool f(int x){
	return st.find(x)==st.end();
}	

int main(){
	cin>>m>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		st.insert(x);
	}
	if(f(m)) cout<<m<<endl;
	else{
		for(int i=1;;i++){
			if(f(m-i)){
				cout<<m-i<<endl;
				break;
			}
			if(f(m+i)){
				cout<<m+i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3608
import heapq
T=int(input())

for _ in range(T):
  N=int(input())
  
  llist=[]
  rlist=[]
  base=0
  for _ in range(N):
    K,L,R=map(int,input().split())    
    if L>R:
      llist.append((K,L-R))
      base+=R
    elif L<R:
      rlist.append((N-K,R-L))
      base+=L
    else:
      base+=L
      
  llist.sort()
  rlist.sort()      
  #print(base)
  #print(llist)
  #print(rlist)
  
  hq_left=[]
  for i,l in llist:
    heapq.heappush(hq_left,l)
    if len(hq_left)>i:
      heapq.heappop(hq_left)
  hq_right=[]
  for i,r in rlist:
    heapq.heappush(hq_right,r)
    if len(hq_right)>i:
      heapq.heappop(hq_right)
      
  answer=base
  while hq_left:
    answer+=heapq.heappop(hq_left)
  while hq_right:
    answer+=heapq.heappop(hq_right)
    
  print(answer)

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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define REVPTR(it, x) for(auto it=x.rbegin();it!=x.rend();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 2e6 + 5;

int s,w;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s>>w;
	if(w >= s)
		cout<<"unsafe";
	else
		cout<<"safe";
	return 0;
}

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

signed main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(int i = n; i >= 0; i--){
        if(s.substr(n - i) == t.substr(0, i)){
            cout << 2 * n - i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import bisect
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

asum, bsum = [0], [0]
for i in range(n):
  if k < a[i] + asum[i]:
    break
  asum.append(a[i] + asum[i])
for i in range(m):
  if k < b[i] + bsum[i]:
    break
  bsum.append(b[i] + bsum[i])

ans = 0
for i in range(len(asum)):
  tmp = i + bisect.bisect(bsum, k-asum[i]) - 1
  if ans < tmp:
    ans = tmp
print(ans)


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

int main(){
    int a, b;
    cin >> a >> b;
    int _a, _b;
    for (int i = 1; i < 1001; ++i) {
        _a = i * 0.08;
        _b = i * 0.1;
        if (_a == a && _b == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

long long dp[65][4] = {};
long long geko[65] = {};
int main() {
	long long n;
	cin >> n;
	for (long long i = 63; i >= 0; --i) {
		if ((n & (1LL << i)) != 0) {
			geko[63 - i] = 1;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < 64; ++i) {
		for (int q = 0; q <= 2; ++q) {
			int now = q * 2;
			now += geko[i];
			dp[i + 1][min(now, 2)] += dp[i][q];
			dp[i + 1][min(now, 2)] %= MAX_MOD;
			if (now >= 1) {
				dp[i + 1][min(now - 1, 2)] += dp[i][q];
				dp[i + 1][min(now - 1, 2)] %= MAX_MOD;
			}
			if (now >= 2) {
				dp[i + 1][min(now - 2, 2)] += dp[i][q];
				dp[i + 1][min(now - 2, 2)] %= MAX_MOD;
			}
		}
	}
	long long ans = dp[64][0] + dp[64][1] + dp[64][2];
	ans %= MAX_MOD;
	cout << ans << endl;
}

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

w = list(map(int, input().split()))

s1 = []
for t in range(n):
    s1.append(sum(w[:t+1]))

total = sum(w)
abs_min = total
for t in range(n):
    s2 = total - s1[t]
    if abs(s1[t]-s2) < abs_min:
        abs_min = abs(s1[t]-s2)

print(abs_min)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	vs <- readInts
	cs <- readInts
	print $ sum $ filter ( 0 < ) $ zipWith (-) vs cs

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


int main() {

    int n;
    cin >> n;
    int sum = 0;
    int tmp = n;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0

if k % 2 == 1:
    p = n // k
    ans += pow(p, 3)
else:
    p = n//k
    q = (n + (k//2))//k
    ans += pow(p, 3) + pow(q, 3)

print(ans)

Measured memory_bytes: 3060
using System;

namespace A____Children_and_Candies__ABC_Edit_
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = 0;
            for (var i=1; i<=n; i++)
            {
                a += i;
            }
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=305;
int n,m,P,C[N][N],f[N][N],s[N][N];
int Mod(int x){return x>=P?x-P:x;}
void Pre(int n){
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]);
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),P=read(),Pre(300);
	for(int j=0;j<=m;j++)f[1][j]=1,s[1][j]=m-j+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=m;j++)
		for(int k=1;k<i;k++)f[i][j]=Mod(f[i][j]+1ll*f[k][j]*s[i-k][j+1]%P*C[i-2][k-1]%P);
		for(int j=m;j>=0;j--)s[i][j]=Mod(s[i][j+1]+f[i][j]);
	}printf("%d",f[n+1][0]);
	return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

int n, a[MAX_N];

bool possible(int cri)
{
    map<int,int> mp;
    int prv = 0;
    rep(i,n){
        if(a[i] <= prv){
            mp.erase(mp.upper_bound(a[i]), mp.end());
            rrep(j,a[i]+1){
                if(j == 0){
                    return false;
                }
                if(mp[j] < cri-1){
                    mp[j]++;
                    break;
                }else{
                    mp.erase(j);
                }
            }
        }
        prv = a[i];
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int flag = -1;
    rep(i,n){
        cin >> a[i];
        if(flag >= a[i]){
            flag = INF;
        }
        cmx(flag, a[i]);
    }
    if(flag != INF){
        cout << "1\n";
        return 0;
    }
    int l = 1, r = n;
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<string> s(n);
    vector<pair<ll, ll>> cnt(n, {0, 0}), a;
    rep(i, n)cin >> s[i];
    ll cnt1 = 0, cnt2 = 0;
    rep(i, n){
        rep(j, s[i].size()){
            if(s[i][j] == '(')cnt[i].first++;
            else{
                if(cnt[i].first)cnt[i].first--;
                else cnt[i].second++;
            }
        }
    }
    ll now = 0;
    rep(i, n){
        if(!cnt[i].second)now += cnt[i].first;
    }
    rep(i, n){
        if(cnt[i].first && cnt[i].second){
            a.push_back({cnt[i].second, cnt[i].first-cnt[i].second});
        }
    }
    sort(all(a));
    ll j = 0, ma = 0;
    priority_queue<pair<ll, ll>> que;
    rep(i, a.size()){
        while(j < a.size() && a[j].first <= now){
            que.push({a[j].second, j}); j++;
        }
        if(que.empty()){cout << "No" << endl; return 0;}
        if(a[que.top().second].first > now){cout << "No" << endl; return 0;}
        now += que.top().first; que.pop();
    }
    rep(i, n){
        if(!cnt[i].first)now -= cnt[i].second;
    }
    cout << (now == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 50248
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll a;
 long double b;
 cin >> a >> b;
 ll ib=100*b+0.5;
 a*=ib;
 cout << a/100 << endl; 
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3740
package main

import "fmt"

func main() {
	var A, B, C, X int
	fmt.Scan(&A, &B, &C, &X)
	count := 0
	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				total := 500*a + 100*b + 50*c
				if total == X {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) P(0);
  else P(n - k);
  return 0;
}



Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)

def main():
    a, b = map( int ,input().split())
    g = gcd(a, b)
    print(a*b//g)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using V = vector<T>;


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

template <typename T, typename E>
struct SegmentTree {
private:
    typedef function<T(T, T)> F;
    typedef function<T(T, E)> G;
    int n;
    F f;
    G g;
    T d1;
    vector<T> nodes;

public:
    SegmentTree(int n_, F f, G g, T d1, const vector<T>& v=vector<T>()) {
        this->f = f;
        this->g = g;
        this->d1 = d1;
        nodes_init(n_);
        if (n_ == (int)v.size()) build(n_, v);
    }

    void nodes_init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        nodes.clear();
        nodes.resize(2 * n - 1, d1);
    }

    void build(int n_, const vector<T>& v) {
        for (int i = 0; i < n_; i++) {
            nodes.at(i + n - 1) = v.at(i);
        }
        for (int i = n - 2; i >= 0; i--) {
            nodes.at(i) = f(nodes.at(i * 2 + 1), nodes.at(i * 2 + 2));
        }
    }

    void update(int idx, E value) {
        int node_idx = idx + n - 1;
        nodes.at(node_idx) = g(nodes.at(node_idx), value);
        int current_idx = node_idx;
        while (current_idx) {
            current_idx = (current_idx - 1) / 2;
            nodes.at(current_idx) = f(nodes.at(2 * current_idx + 1), nodes.at(2 * current_idx + 2));
        }
    }

    T query(int query_left, int query_right, int cur_idx, int cur_left, int cur_right) {
        if (cur_right <= query_left || query_right <= cur_left) return d1;
        if (query_left <= cur_left && cur_right <= query_right) return nodes.at(cur_idx);
        T value_from_left = query(query_left, query_right, 2 * cur_idx + 1, cur_left, (cur_left + cur_right) / 2);
        T value_from_right = query(query_left, query_right, 2 * cur_idx + 2, (cur_left + cur_right) / 2, cur_right);
        return f(value_from_left, value_from_right);
    }

    T query(int query_left, int query_right) {
        return query(query_left, query_right, 0, 0, n);
    }
};


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

    int N;
    cin >> N;
    V<int> A_list;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A_list.emplace_back(tmp);
    }
    SegmentTree<int, int> range_gcd(
        N,
        [](int a, int b) {return gcd(a, b);},
        [](int a, int b) {return b;},
        0,
        A_list);

    int max_gcd = range_gcd.query(0, N - 1);
    for (int ignore_idx = 0; ignore_idx < N - 1; ignore_idx++) {
        max_gcd = max(
            max_gcd,
            gcd(range_gcd.query(0, ignore_idx), range_gcd.query(ignore_idx + 1, N))
        );
    }
    cout << max_gcd << "\n";
}


Measured memory_bytes: 1784
#include<stdio.h>

int main(){
  int i,j,k;
  
  int N;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)
    scanf("%d ",&A[i]);
  int kisuu=0,two=0,four=0;
  
  for(i=0;i<N;i++){
    if(A[i] %4 ==0)
      four++;
    else if(A[i] % 4 != 0 && A[i] %2 == 0)
      two++;
    else
      kisuu++;
  }
  if(kisuu - four  > 1){
    puts("No");
    return 0;
  }
  four -= kisuu-1;
  if(two %2 == 1 && four <= 0){
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string w;
    cin >> w;

    map<char, int> num;
    for(int i = 0; i < w.length(); i++) num[w[i]]++;

    string ans = "Yes";
    for(auto x : num) if(x.second % 2) ans = "No";

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define forn(i0, n0) for (int i0 = 0; i0 < n0; i0++)
#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvl (v) for (ll x : v) cout << x << ' '; cout << '\n'
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define Sort(a) sort(all(a))
#define Reverse reverse (all(a))

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long gcd(long a, long b);
long lcd(long a, long b);
int main(){
    long x,y; cin >> x >> y;
    if(x < y){
        long w = x; x = y; y = w;
    }
    cout << lcd(x,y) << endl;
}

long gcd(long a, long b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
long lcd(long a, long b){
    return a*b/gcd(a,b);
}

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

int main(){

    int k, s;
    scanf("%d%d", &k, &s);

    int cnt=0;
    for(int x=0; x<=k; ++x){
        for(int y=0; y<=k; ++y){
            int z=s-(x+y);
            if(z>=0&&z<=k)
                ++cnt;
        }
    }


    printf("%d", cnt);



    return 0;
}


Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define debug(x) cout<<#x<<": "<<x<<" "
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
int main()
{
    IO;
    int x;
    cin>>x;
    if(x<=599) cout<<'8'<<endl;
    else if(x<=799) cout<<'7'<<endl;
    else if(x<=999)cout<<'6'<<endl;
    else if(x<=1199) cout<<'5'<<endl;
    else if(x<=1399) cout<<'4'<<endl;
    else if(x<=1599) cout<<'3'<<endl;
    else if(x<=1799)cout<<'2'<<endl;
    else cout<<'1'<<endl;
    return 0;
}

Measured memory_bytes: 3636
// by Balloons
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 29;
const int maxn=5005;

int n;
int a[maxn];
vector<int>g[maxn];
int dp[maxn];

void dfs(int x,int fat=-1){
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(u==fat)continue;
		if(a[x]>a[u]){
			dfs(u,x);
			if(!dp[u]){
				dp[x]=1;
				return ;
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n-1;i++){
		int u,v;scanf("%d%d",&u,&v);
		g[u].push_back(v);g[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		memset(dp,0,sizeof dp);
		dfs(i);
		if(dp[i])printf("%d ",i);
	}
	puts("");

	return 0;
}


Measured memory_bytes: 512
nyukyo = [[[0 for i in range(10)] for m in range(3)] for n in range(4)]
num = int(input())
for i in range(num):
    handan = input().split()
    handan = list(map(int, handan))
    nyukyo[handan[0]-1][handan[1]-1][handan[2]-1] += handan[3]

for m in nyukyo[0]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[1]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[2]:
    t = list(map(str, m))
    print(" "+" ".join(t))
print("#"*20)
for m in nyukyo[3]:
    t = list(map(str, m))
    print(" "+" ".join(t))

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

int main() {
  ll n, T;
  cin >> n >> T;
  ll t[n];
  rep(i, n) cin >> t[i];
  ll ans = T;
  rep(i, n-1) {
    if (t[i+1]-t[i] < T) ans += t[i+1]-t[i];
    else ans += T;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,k,l,a[1005][1005];
int main()
{
	scanf("%lld",&n);
	if (n==1)
	{
		puts("1\n1");
		return 0;
	}
	m=(n+1)/2;
	if (m&1) m++;
	for (i=1;i<=n;i++)
	{
		k=(i-1)%m+1;
		for (j=1;j<=m;)
		{
			a[j][k]=i;
			for (l=0;l<=(i-1)/m;l++)
			{
				k--;j++;
				if (k==0) k=m;
			}
		}
	}
	cout<<m<<endl;
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=m;j++)
		{
			cout<<a[i][j];
			if (j!=m) cout<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)
    cin>>s.at(i);
  vector<vector<vector<int>>> b(h+1,vector<vector<int>>(w+1,vector<int>(2,h*w)));
  b[0][1][0]=0;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s.at(i-1).at(j-1)=='#')
        b[i][j][1]=min({b[i-1][j][0]+1,b[i][j-1][0]+1,b[i-1][j][1],b[i][j-1][1]});
      else
        b[i][j][0]=min({b[i-1][j][0],b[i][j-1][0],b[i-1][j][1],b[i][j-1][1]});
    }
  }
  cout<<min(b[h][w][0],b[h][w][1])<<endl;
}

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

vector<ll> to[100010];

int main(){
    ll n,k;cin>>n>>k;
    rep(i,0,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<ll> q;
    q.push(0);
    vector<ll> oya(n,-1);
    vector<ll> col(n,-1);
    ll K=k-1;
    col[0]=k;
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        ll nK=k-2;
        for(auto nx:to[now]){
           if(col[nx]!=-1)continue;
           if(now==0){
               oya[nx]=now;
               col[nx]=K;
               K--;
           }
           else{
               oya[nx]=now;
               col[nx]=nK;
               nK--;
           }
           q.push(nx);
        }
    }
    ll an=1;
    rep(i,0,n){
        an*=col[i];
        an%=1000000007;
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 8948
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())
      
ans = num2alpha(n).lower()
print(ans)

Measured memory_bytes: 9136
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val A=readLine()!!.split(" ").map {it.toInt()}

    val Odd=A.filter {it % 2==1}
    // println(N)
    // println(A)
    println(if(Odd.size % 2 == 0) {"YES"} else {"NO"}) 
  }
}


Measured memory_bytes: 41240
def main():
    n = int(input())
    a, b = n // 15, n % 15

    fbeg = [i for i in range(1, 16) if i % 3 != 0 and i % 5 != 0]
    fend = [i for i in range(a * 15, n + 1) if i % 3 != 0 and i % 5 != 0]

    ne = len(fbeg)
    fbs = sum(fbeg) # sum of first terms in [1, 15]
    fes = sum(fend)
    step = 15 * ne
    first = fbs
    last = fbs + (a-1) * step

    tot = (first + last) * a // 2 + fes

    print(tot)

main()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n, t;
    cin >> n >> t;
    vint a(n);
    rep(i, n) cin >> a[i];

    int smallest = 1e9 + 5, gap = 0, count = 1;
    rep(i, n)
    {
        chmin(smallest, a[i]);
        bool change_gap = chmax(gap, a[i] - smallest);
        if (change_gap)
        {
            count = 1;
        }
        else if (a[i] - smallest == gap)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl1;

int main()
{ ll i, k, n, val, tmp, sum;

  cin>>n;
  vl1 veka(n+1), dp(n+1);
  for(i=1;i<=n;i++) cin>>veka[i];

  dp[1]=0;
  dp[2]=veka[2]-veka[1];
  if(dp[2]<0) dp[2]=-dp[2];

  for(i=3;i<=n;i++)
    { val=veka[i]-veka[i-1];
      if(val<0) val=-val;
      tmp=veka[i]-veka[i-2];
      if(tmp<0) tmp=-tmp;
      if(dp[i-1]+val<dp[i-2]+tmp)
      dp[i]=dp[i-1]+val; else dp[i]=dp[i-2]+tmp;
    }
    cout << dp[n] << endl;
    return 0;
}
/*
4
10 30 40 20
*/


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  string S;
  cin >>S;
 bool count=true;
  rep(i,S.size()-1) {
if (S.at(i)==S.at(i+1)) {
count=false;
  break;
}
  }
if (count) {
cout <<"Good" << endl;
}
else {
 cout << "Bad" << endl;
}
}


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

sys.setrecursionlimit(10000)


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, K, A):
    A.sort()

    s = 0
    ans = N
    for i in range(N-1, -1, -1):
        if s + A[i] < K:
            s += A[i]
        else:
            ans = min(ans, i)
    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


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

void print_flags(const std::array<int, 4>& num, int flag) {
  std::cout << num[0];
  for (int j = 0; j < 3; ++j) {
    if ((flag >> j) & 1) {
      std::cout << "+";
    } else {
      std::cout << "-";
    }
    std::cout << num[j + 1];
  }
  std::cout << "=7" << std::endl;
}

int main() {
  std::string s;
  std::cin >> s;
  std::array<int, 4> num;
  for (int i = 0; i < 4; ++i) {
    num[i] = s[i] - '0';
  }
  for (int i = 0; i < 8; ++i) {
    int sum = num[0];
    for (int j = 0; j < 3; ++j) {
      if ((i >> j) & 1) {
        sum += num[j + 1];
      } else {
        sum -= num[j + 1];
      }
    }
    if (sum == 7) {
      print_flags(num, i);
      return 0;
    }
  }
  std::cout << "Error" << std::endl;
  return -1;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char ch;
  
  ch = getchar();
  
  if(ch<0x60)
  {
    printf("A\n");
  }
  
  else if(ch>0x60)
  {
    printf("a\n");
  }
  
  return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main(){
    int D,L;cin>>D>>L;
    cout<<D/L+D%L<<endl;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long n, k;
    long long ans=0;
    long long tmp=0;
    
    cin >> n >> k;
    
    if(k==0){
        
        cout << n*n << endl;
        
        return 0;
        
    }
    
    ans += (n-k) * (n-k+1) / 2;
    
    for(int i=1; i<=n; i++){
        
        tmp = n - i + 1;
        tmp /= i;
        tmp *= max(0LL, i-k);
        tmp += max(0LL, (n-i+1)%i-k);
        ans += tmp;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()
	s := 0
	mx := A[0]
	for i := 1; i < N; i++ {
		if mx > A[i] {
			s += mx - A[i]
		} else {
			mx = A[i]
		}

	}
	fmt.Println(s)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 12288
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=101;
int a[MAXN];
inline bool CMP(int x,int y)
{
	return x<y;
}
int main()
{
	int n,ans=1;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	sort(a,a+n+1,CMP);
	for(int i=2;i<=n;++i)
		if(a[i]!=a[i-1]) ++ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] data = new int[6];
        Arrays.fill(data, 0);

        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            double height = Double.parseDouble(br.readLine());
            if (height < 165)
                data[0]++;
            else if (height < 170)
                data[1]++;
            else if (height < 175)
                data[2]++;
            else if (height < 180)
                data[3]++;
            else if (height < 185)
                data[4]++;
            else
                data[5]++;
        }

        for (int i = 0; i < 6; i++) {
            System.out.print((i + 1) + ":");
            for (int j = 0; j < data[i]; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}


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

int main() {
  int A, B, C;
  int a;
  cin >> A >> B >> C;
  if (C - (A - B) < 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << C - (A - B) << endl;
  }
}

Measured memory_bytes: 3620
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
bool flag[19999990];
int _prime[19999990];
void get_prime(int maxn)
{
    int i,j;
    for(i=2;i<=maxn;i++)
        if(!flag[i])
        {
            _prime[++_prime[0]]=i;
            for(j=i*i;j<=maxn;j+=i)
                flag[j]=true;
        }
}
int main()
{
	int n;
	cin>>n;
	int i,j,k;
	int s=0;
	for(i=1;i<n;i++){
		s+=n/i;
		if(n%i==0) s--;
	}
	cout<<s<<endl; 
	return 0;
}


Measured memory_bytes: 3648
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad (replicateM)
import           Data.Int      (Int64)

main :: IO ()
main = do
  q <- readLn
  abs <- replicateM q readInt2
  putStr . unlines . map show $ solve abs

solve :: [(Int64, Int64)] -> [Int64]
solve = map solve'

solve' :: (Int64, Int64) -> Int64
solve' (a, b)
  | a == b || a + 1 == b = 2 * a - 2
  | c * (c + 1) >= a * b = 2 * c - 2
  | otherwise            = 2 * c - 1
  where c = calcC a b

calcC :: Int64 -> Int64 -> Int64
calcC a b = if c * c == a * b then c - 1 else c
  where c = floor . sqrt . fromIntegral $ a * b

readInt2 :: IO (Int64, Int64)
readInt2 = do
  [a, b] <- map read . words <$> getLine
  return (a, b)


Measured memory_bytes: 1020
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


char b;

int main(){
	cin >> b;
	if(b == 'A') cout << 'T' << endl;
	if(b == 'T') cout << 'A' << endl;
	if(b == 'G') cout << 'C' << endl;
	if(b == 'C') cout << 'G' << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using univ= pair<int64_t, int64_t>;

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

  vector<univ> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i).first;
  }
  for(int i=0; i<N; i++){
    cin >> data.at(i).second;
  }

  auto comp= [](univ a, univ b){
    return a.second- a.first > b.second- b.first;
  };
  sort(data.begin(), data.end(), comp);

  int64_t shortage= 0;
  int cnt_short= 0;
  while(data.at(cnt_short).second- data.at(cnt_short).first > 0){
    shortage+= data.at(cnt_short).second- data.at(cnt_short).first;
    cnt_short++;
  }

  int cnt_surplus= 0;
  while(shortage > 0 && cnt_surplus < N){
    cnt_surplus++;
    int id_surplus= N- cnt_surplus;
    shortage-= data.at(id_surplus).first- data.at(id_surplus).second;
  }

  int ans= (shortage > 0) ? -1
                          : cnt_short+ cnt_surplus;

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int stack[1000];
	int car, p = 0;
	
	while(scanf("%d\n", &car) == 1) {
		if(car == 0) {
			if(p > 0) {
				printf("%d\n", stack[p-1]);
				p--;
			}
		} else {
			stack[p] = car;
			p++;
		}
	}
	return 0;
}

Measured memory_bytes: 604
fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1] // 'this' corresponds to the list
    this[index1] = this[index2]
    this[index2] = tmp
}

fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var A = readLine()!!.split(' ').map { it.toInt() }.toMutableList()

    var res = 0
    for (i in 0 until N-1) {
        if (A[i] == i+1) {
            res++
            A.swap(i, i+1)
        }
    }

    if (A[N-2] == N-1 || A[N-1] == N) res++

    println(res)
}

Measured memory_bytes: 53768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {	
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
		}
		for (int i = num.length - 1; i >= 0; i = i - 2) {
			if (i != num.length - 1) {
				System.out.print(" ");
			}
			System.out.print(num[i]);
		}
		if (num.length == 1) {
			
		} else if (num.length % 2 == 0) {
			for (int i = 0; i < num.length; i = i + 2) {
				System.out.print(" ");
				System.out.print(num[i]);
			}
		} else {
			for (int i = 1; i < num.length; i = i + 2) {
				System.out.print(" ");
				System.out.print(num[i]);
			}
		}
		System.out.println();
		scanner.close();
	}
}


Measured memory_bytes: 93740
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

template <typename T>
using vec = vector<T>;

template <typename T>
using vec2 = vector<vector<T>>;

template <typename T>
using vec3 = vector<vector<vector<T>>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int W, H, N;
    cin >> W >> H >> N;
    vec2<int> f(H + 1, vec<int>(W + 1, 0));
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1) {
            f[0][0]++;
            f[0][x]--;
            f[H][0]--;
            f[H][x]++;
        } else if (a == 2) {
            f[0][x]++;
            f[H][x]--;
            f[0][W]--;
            f[H][W]++;
        } else if (a == 3) {
            f[0][0]++;
            f[0][W]--;
            f[y][0]--;
            f[y][W]++;
        } else {
            f[y][0]++;
            f[y][W]--;
            f[H][0]--;
            f[H][W]++;
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 1; w < W; w++) {
            f[h][w] += f[h][w - 1];
        }
    }
    for (int h = 1; h < H; h++) {
        for (int w = 0; w < W; w++) {
            f[h][w] += f[h - 1][w];
        }
    }

    int ans = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (f[h][w] == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int K;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        A = sc.nextIntArray(N);
        System.out.println( solve() );
    }

    static int solve() {
        if( N == K ) return 1;

        int N1 = N - K;
        int q = N1 / (K-1);
        int r = N1 % (K-1);
        return q + (r != 0 ? 1 : 0) + 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 998244353;


void solve_case() {
	string s, t;
	cin >> s >> t;
	
	ll n, m;
	n = s.size(), m = t.size() + 1;
	ll dp[n + 1][m + 1];
	pair<int, int> path[n + 1][m + 1];
	
	for (int i = 0; i <= n; i++) {
		dp[i][0] = 0;
	}
	for (int j = 0; j <= m; j++) {
		dp[0][j] = 0;
	}
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
				path[i][j] = make_pair(i - 1, j - 1);
			}
			else {
				dp[i][j] =  max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] == dp[i][j]) {
					path[i][j] = make_pair(i - 1, j);
				}
				else {
					path[i][j] = make_pair(i, j - 1);
				}
			}
		}
	}
	
	int i = n, j = m;
	stack<char> stk;
	while(dp[i][j]) {
		if (s[i - 1] == t[j - 1]) {
			stk.push(s[i - 1]);
		}
		auto p = path[i][j];
		i = p.first, j = p.second;
	}
	
	while(!stk.empty()) {
		cout << stk.top();
		stk.pop();
	}
	cout << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


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

int main(){
    int n,x;
    cin >> n >> x;
    int m,sum=0,min_n=1001;;
    for(int i=0;i<n;i++){
        cin >> m;
        sum += m;
        min_n = min(min_n,m);
    }
    int ans = ((x-sum)/min_n)+n;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

int main() {
    int N, n=(int)1e8, d=0;
    scanf("%d", &N);
    int dp[10][2][8] = {{{0}}}; //less, {3?, 5?, 7?}(2)
    int j5[] = {0,1,4,5};
    bool zero = true, tookoff = false;
    for (int i=0; i<9; i++) {
        d = d*10 + N/n;
        N = N%n;
        n /= 10;
        for (int j=0; j<8; j+=2) {
            if (d > 3)
                dp[i+1][1][j+1] += dp[i][0][j] + dp[i][0][j+1];
            else if (d == 3)
                dp[i+1][0][j+1] += dp[i][0][j] + dp[i][0][j+1] + ((zero && j==0) ? 1 : 0);
            dp[i+1][1][j+1] += dp[i][1][j] + dp[i][1][j+1] + ((d > 3 || !zero) && j == 0 ? 1 : 0);
        }
        for (int k = 0; k < 4; k++) {
            if (d > 5)
                dp[i+1][1][j5[k]+2] += dp[i][0][j5[k]] + dp[i][0][j5[k]+2];
            else if (d == 5)
                dp[i+1][0][j5[k]+2] += dp[i][0][j5[k]] + dp[i][0][j5[k]+2] + ((zero && k==0) ? 1 : 0);
            dp[i+1][1][j5[k]+2] += dp[i][1][j5[k]] + dp[i][1][j5[k]+2] + ((d > 5 || !zero) && k == 0 ? 1 : 0);
        }
        for (int j = 0; j < 4; j++) {
            if (d > 7)
                dp[i+1][1][j+4] += dp[i][0][j] + dp[i][0][j+4];
            else if (d == 7)
                dp[i+1][0][j+4] += dp[i][0][j] + dp[i][0][j+4] + ((zero && j==0) ? 1 : 0);
            dp[i+1][1][j+4] += dp[i][1][j] + dp[i][1][j+4] + ((d > 7 || !zero) && j == 0 ? 1 : 0);
        }
        if (zero && d != 0) zero = false;
        if (!tookoff && d >= 3) tookoff = true;
        if (tookoff) d = 0;
    }
    printf("%d\n", dp[9][0][7] + dp[9][1][7]);
    return 0;
}

Measured memory_bytes: 128