akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef vector < vector<int> > vvi;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
#define deb(x) cout << #x << " : " << x << endl
#define debv(x) for(auto i=x.begin();i!=x.end();i++) cout<<*i<<' ';cout<<endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define s(n) cin >> n
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) ((b)+((a) - (b))/2)
#define INF (1e9 + 7)
#define endl '\n'

void solve() {
	int n,w;
	cin>>n>>w;
	vector<vector<ll>> dp(n,vll(w+1,-1));
  	ll mx=0;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		if(i==0){
			dp[i][0]=0;
          	if(a<=w){
              dp[i][a]=b;
              mx=max(mx,b);
            }
		}
		else{
			for(int j=0;j<w+1;j++){
				if(dp[i-1][j]!=-1){
					dp[i][j]=max(dp[i][j],dp[i-1][j]);
					if(j+a<=w){
						dp[i][j+a]=max(dp[i][j+a],dp[i-1][j]+b);
					}
				}
				mx=max(mx,dp[i][j]);
              	//deb(dp[i][j]);
			}
		}
	}
	cout<<mx;
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



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

const int MAX = 50;

int main(){
    int n, d;
    cin >> n >> d;
    int vision = 2*d + 1;

    int monitor = 0;
    while(n > 0){
        n -= vision;
        monitor++;
    }

    cout << monitor << endl;
}

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let br=new Array(n)
  for(let i=0;i<n;i++){
    br[ar[i]-1]=i+1
  }
  to(br.join(' '))
}
main()


Measured memory_bytes: 32972
#include <stdio.h>

int main(void){
    
    int i,j=0;
    
    for (i=1; i<10; i++) {
        for (j=1; j<10; j++) {
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <set>
#include <tuple>
#include <queue>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a;
    vector<vector<int>> b;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> s;
    for (int i=0;i<n;i++) {
        vector<int> aa;
        for (int j=0;j<n;j++) {
            int aaa;
            cin >> aaa;
            aa.push_back(aaa);
            s.push(make_tuple(aaa, i, j));
        }
        a.push_back(aa);
    }
    b = a;
    for (int k=0;k<n;k++) {
        for (int i=0;i<n;i++) {
            for (int j=0;j<n;j++) {
                if (b[i][j] > b[i][k] + b[k][j]) {
                    b[i][j] = b[i][k] + b[k][j];
                }
            }
        }
    }

    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) {
            if (a[i][j] != b[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    long long result = 0;
    while (!s.empty()) {
        auto x = s.top();
        s.pop();
        int i = get<1>(x);
        int j = get<2>(x);
        bool shortcut = false;
        for (int k=0;k<n;k++) {
            if (k == i || k == j) {
                continue;
            }
            if (b[i][j] == b[i][k] + b[k][j]) {
                shortcut = true;
            }
        }
        if (!shortcut) {
            result += b[i][j];
        }
    }

    std::cout << result / 2 << std::endl;
    return 0;
}


Measured memory_bytes: 2076
local S = io.read("*l")
local SS = S .. S
local T = io.read("*l")

local cur = 0
local ans = 0
local find = string.find
local sub = string.sub
for i=1,#T do
    local c = sub(T, i, i)
    local pos = find(SS, c, cur+1)
    if pos then
        local step = pos - cur
        ans = ans + step
        cur = cur + step
        if cur > #S then
            cur = cur - #S
        end
    else
        print("-1")
        return
    end
end
print(ans)

Measured memory_bytes: 788
while 1:
        x,y,s = map(int,input().split())
        if x == 0 and y == 0 and s == 0:
            break
        Max = -9999999999
        py = (y / 100) + 1
        for p1 in range(1,s):
            for p2 in range(p1,s):
                p1_tax = p1*(100+x) // 100
                p2_tax = p2*(100+x) // 100
                if (p1_tax+p2_tax) == s:
                    p1_tax_y = p1*(100+y) // 100
                    p2_tax_y = p2*(100+y) // 100
                    Max = max(Max,p1_tax_y+p2_tax_y)
        print(Max)      
        


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
    
  int main(){
    int h,w;
    cin>>h>>w;
    int x[h][w];
    rep(i,h){
        rep(j,w){
            cin>>x[i][j];
        }
    }
    vector<tuple<lint,lint,lint,lint>>ans;
        rep(i,h){
            rep(j,w){
                if(x[i][j]%2==1){
                    if(i!=(h-1)&&j!=(w-1)){
                        if(x[i][j+1]%2==1){
                            x[i][j]--;
                            x[i][j+1]++;
                            ans.push_back(make_tuple(i,j,i,j+1));
                        }else {
                              x[i][j]--;
                            x[i+1][j]++;
                            ans.push_back(make_tuple(i,j,i+1,j));
                        }
                    }else if(i==(h-1)&&j==(w-1));
                    else if(i==(h-1)){
                          x[i][j]--;
                            x[i][j+1]++;
                            ans.push_back(make_tuple(i,j,i,j+1));
                    }else{
                        x[i][j]--;
                            x[i+1][j]++;
                            ans.push_back(make_tuple(i,j,i+1,j));
                    }
                }
            }
        }
        cout<<ans.size()<<endl;
       rep(i,ans.size()){
           lint a,b,c,d;
           tie(a,b,c,d)=ans[i];
           cout<<a+1<<" "<<b+1<<" "<<c+1<<" "<<d+1<<endl;
       }
     }
  
      
      
    

  
          
  

Measured memory_bytes: 7408
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextUInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextUInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] buffer = new byte[BUF_SIZE];
    static int ptr = 0;

    private static void Read() { Stream.Read(buffer, 0, BUF_SIZE); }

    private static byte Next { get { if (ptr >= buffer.Length) { Read(); ptr = 0; } return buffer[ptr++]; } }

    public static int NextUInt
    {
        get
        {
            int res = 0; byte next; do { next = Next; } while (next < 48);
            do { res = res * 10 + (next ^ 48); next = Next; } while (48 <= next);
            return res;
        }
    }

    public static long NextULong
    {
        get
        {
            long res = 0; byte next; do { next = Next; } while (next < 48);
            do { res = res * 10 + next - 48; next = Next; } while (48 <= next);
            return res;
        }
    }
}


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

string str;
stack<long long> S;
long long a,b;


int main(){
  while(cin >> str){
    if(str=="+"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b+a);
    }
    else if(str=="-"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b-a);
    }
    else if(str=="*"){
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(b*a);
    }
    else{
      S.push(stoll(str));
    }
    if(getchar()=='\n'){
      cout << S.top() << endl;
      return 0;
    }
  }


}



Measured memory_bytes: 3172
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> can(n, vector<int>(n));
  rep(n) {
    rep(j, n) { cin >> can[i][j]; }
  }
  int const mod = 1e9 + 7;
  auto addSelf = [](int &a, int b) -> void {
    a += b;
    if (a >= mod) a -= mod;
  };
  vector<vector<int>> mem(n, vector<int>(1 << n, -1));
  function<int(int, int)> f = [&](int i, int mask) -> int {
    if (mask == (1 << n) - 1) return 1;
    if (i == n) return 0;
    if (mem[i][mask] != -1) return mem[i][mask];
    mem[i][mask] = 0;
    rep(j, n) {
      if (can[i][j] && ((mask >> j) & 1) == 0)
        addSelf(mem[i][mask], f(i + 1, mask | (1 << j)));
    }
    return mem[i][mask];
  };
  cout << f(0, 0) << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 180608
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N,W = imn()
wv = [iln() for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w - wv[i][0] >= 0: dp[i+1][w] = max(dp[i+1][wv[i][0]], dp[i][w-wv[i][0]]+wv[i][1])
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])
print(dp[N][W])

Measured memory_bytes: 180032
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int main() {
	char s[101]; int i;
	cin >> s;
	for (i = 0; s[i] != 0; i++) {
		s[i] = 'x';
	}
	s[i] = 0;
	cout <<s<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd( ll a, ll b )
{
  ll t;
  if( a < b ){ t = a; a = b; b = t; }
  while( ( t = a % b ) != 0 ){ a = b; b = t; }
  return b;
}
ll lcm( ll a, ll b )
{
  return (a / gcd(a,b)) * b;
}
ll A[100005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  ll M;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  ll G = A[0];
  for (int i=1; i<N; i++) {
    G = gcd(G, A[i]);
  }
  ll L = 1;
  bool flag = true;
  for (int i=0; i<N; i++) {
    L = lcm(L, A[i]/G);
    if (L*G > 1000000000LL || L % 2 == 0) {
      flag = false;
      L = 1;
    }
  }
  if (flag) {
    cout << (M / (L*G/2) + 1) / 2 << endl;
  } else {
    cout << 0 << endl;
  }
}

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


int main()
{
int s,n,a,b;

scanf("%d",&s);

b = s%100;
a = (s-b)/100; 

if(a==1&&b==0)
{
    printf("MMYY");
    return 0;
}
if(a==0&&b==1)
{
    printf("YYMM");
    return 0;
}


if(a==0||b==0)
{
    printf("NA");
    return 0;
}

if(a<=12)
{
    if(b>=13)
    {
        printf("MMYY");
        return 0;
    }
    if(b<=12)
    {
        printf("AMBIGUOUS");
        return 0;
    }
}
if(a>=13){
    if(b<=12)
    {
        printf("YYMM");
        return 0;
    }
    if(b>=13)
    {
        printf("NA");
        return 0;
    }
}
}

Measured memory_bytes: 128
#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>;
const int INF = 1 << 29;
 
int main() {
	int a,b,c,x,y;
	cin >>a>>b>>c>>x>>y;
	int ans = INF*2;
	int up = max(x,y);
	rep(i, up+1) {
		ans = min(ans, 2*c*i+a*max(0,x-i)+b*max(0,y-i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
static Scanner sc = new Scanner(System.in);
static ArrayList<String> strList = new ArrayList<String>();
static ArrayList<String> intList2 = new ArrayList<String>();
public static void main(String[] args) {

        String str = sc.nextLine();

        for(int i = 0; i < str.length(); i++){

            System.out.print("x");
            }
    }
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
	LLI n, d, x, sum = 0, tmp;
	cin >> n >> d >> x;
	for(int i = 0; i < n; i++)
	{
		cin >> tmp;
		sum += 1 + (d-1)/tmp;
	}
	cout << sum + x;
}

Measured memory_bytes: 3544
#include <stdio.h>

int main(void)
{
	int ka, ki;
	while (1){
		scanf("%d %d", &ka, &ki);
		if (ka == 0 && ki == 0) break;
		if (ka < ki)
			printf("%d %d\n", ka, ki);
		else
			printf("%d %d\n", ki, ka);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi acos(-1)
#define lli long long int
using namespace std;

int main() 
{
    FIO
    lli t,n, b,i,j,d,a;
    cin >> a >> b;
    
    if(a < b) {
        for ( i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
    }

    else
    {
        for ( i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }
    
    return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	cout << n*(n-1)/2+m*(m-1)/2 << endl;
}

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

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


int main() {
  
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }


  int l = 0,r = 0;
  vector<int> L(1),R(1);
  for(int i = 0;i < N;i++) {
    l = gcd(A.at(i),l);
    L.push_back(l);
    r = gcd(A.at(N-i-1),r);
    R.push_back(r);
  }

  L.push_back(0);
  R.push_back(0);

  int ans = 0;
  for(int i = 0;i < N;i++) {
    int GCD = gcd(L.at(i),R.at(N-i-1));
    ans = max(ans,GCD);
  }

  cout << ans << endl;
  
  
}

Measured memory_bytes: 1660
s = input()
s_list = list(s)

#文字ごとの出現頻度を取得
import collections
c = collections.Counter(s_list)

#上位２つの文字を抽出
top2 = c.most_common(2)

if top2[0][1]==2 and top2[1][1]==2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3316
#include <iostream>
#include<math.h>
#include<vector>
#include<string>
using namespace std;
int main() 
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    vector<int>dp(n,1<<30);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1]<<endl;

}


Measured memory_bytes: 1152
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, a, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < 5; ++i) {
    scanf("%lld", &a);
    ans++;
    if(ans < (n + a - 1) / a + i) ans = (n + a - 1) / a + i;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
#include<functional>
#include <cassert>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

bool f[100001];
ll c[100002];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    for(int i=2;i<=100000;i++)if(!f[i])for(int j=2*i;j<=100000;j+=i) f[j]=true;
    for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++;
    for(int i=3;i<=100000;i++)c[i]+=c[i-1];
    ll q;
    cin>>q;
    vec<ll> l(q),r(q);
    rep(i,q) cin>>l[i]>>r[i];
    rep(i,q){
        cout<<c[r[i]]-c[l[i]-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

// template <class Head, class... Tail>
// void print(Head&& head, Tail&&... tail) {
//     cout << head;
//     if (sizeof...(tail) != 0) cout << " ";
//     print(forward<Tail>(tail)...);
// }

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i,k-1)cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    cout << p.first << " " << p.second << "\n";
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<Pll> ans;
    if((n % 2) == 1){
        ll left = 1, right = n-1;

        while(m){
            ans.emplace_back(left, right);
            left++, right--;
            m--;
        }
    }
    else{
        vector<ll> use(n);
        ll left = 1;
        ll even_left = left + m + 1;
        while(m){
            if(m & 1){
                ll right = left + m;
                ans.emplace_back(left, right);
                left++;
            }
            else{
                ll right = even_left + m;
                ans.emplace_back(even_left, right);
                even_left++;
            }
            m--;
        }
    }

    for(auto p : ans){
        print(p);
    }
}

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;

  if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R') cout << 3 << endl;
  else if ((s[0] == s[1] && s[0] == 'R') || (s[1] == s[2] && s[1] == 'R')) cout << 2 << endl;
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << endl;
  else cout << 0 << endl;
  
  return (0);
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

vector<vector<int>> dp(4000, vector<int>(4000, 0));
// 左上1、左2、上3
vector<vector<int>> from(4000, vector<int>(4000, 0));

void print_dp(vector<vector<int>> vv){
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cout << vv[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl;
}

int lcs_size(string s1, string s2){
  int n1 = int(s1.size());
  int n2 = int(s2.size());
  for (int i = 1; i <= n1; i++) {
    for (int j = 1; j <= n2; j++) {
      if(s1[i-1] == s2[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
        from[i][j] = 1;
        continue;
      }
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      from[i][j] = (dp[i][j] == dp[i-1][j]) ? 3 : 2;
    }
  }
  return dp[n1][n2];
}


string lcs(string s1, string s2){
  string res = "";
  int n1 = int(s1.size());
  int n2 = int(s2.size());
  int x = lcs_size(s1, s2);
  while(x > 0){
    if(from[n1][n2] == 1){
      res += s1[n1-1];
      n1--; n2--; x--;
    }else if(from[n1][n2] == 2) n2--;
    else n1--;
  }

  reverse(res.begin(), res.end());
  return res;
}

int main(){
  string s, t;
  cin >> s >> t;
  cout << lcs(s, t) << endl;
}


Measured memory_bytes: 125568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;;i++)
    {
        int x=i*0.08,y=i*0.1;
        if(x==a&&y==b)
        {
            cout<<i;
            break;
        }
        if(x>a||y>b)
        {
            cout<<-1;
            break;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(0) != 'A') {
			System.out.println("WA");
			return;
		}
		int count = 0;
		for (int i = 2; i < s.length() - 1; i++) {
			if (s.charAt(i) == 'C') {
				count++;
			}
		}
		if (count != 1) {
			System.out.println("WA");
			return;
		}
		count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) < 'a' || s.charAt(i) > 'z') {
				count++;
			}
		}
		if (count != 2) {
			System.out.println("WA");
		} else {
			System.out.println("AC");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;





int main()
{
	double v;
	double h;
	int n;
	while (cin >> v) {
		n = 1;
		h = 4.9*(v / 9.8)*(v / 9.8);
		while (h > 5 * (n - 1)) {
			n++;
		}
		cout << n << endl;
	}


	return 0;
}

Measured memory_bytes: 1228
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int r,c,k;
struct uzi{
  int r,c,v;
  bool operator <(const uzi & t)const{
    if(r==t.r)return c<t.c;
    return r<t.r;
  }
}p[N];
int ok[3333];
LL dp[3333][3333];
LL st[3333][4];
int main() {
  ios::sync_with_stdio(false);
  cin>>r>>c>>k;
  for(int i=1;i<=k;i++){
    cin>>p[i].r>>p[i].c>>p[i].v;
  }
  sort(p+1,p+1+k);
 // for(int i=1;i<=k;i++)cout<<p[i].r<<' '<<p[i].c<<' '<<p[i].v<<endl;
  int l=1;
  for(int i=1;i<=r;i++){
    while(l<=k&&p[l].r<i)l++;
    for(int j=1;j<=c;j++){
      dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      for(int ne=0;ne<=3;ne++)st[j][ne]=0;
    }
    if(l>k||p[l].r!=i){
      continue;
    }
    int ra=l;
    for(int j=1;j<=c;j++)ok[j]=0;
    while(ra+1<=k&&p[ra+1].r==i)ra++;
  //  cout<<i<<' '<<l<<' '<<ra<<endl;
    for(int j=l;j<=ra;j++){
      ok[p[j].c]=p[j].v;
     // cout<<i<<' '<<p[j].c<<' '<<p[j].v<<endl;
    }
    for(int j=1;j<=c;j++){
      if(ok[j]){
        st[j][0]=max(st[j-1][0],dp[i-1][j]);
        for(int ne=1;ne<=3;ne++){
          st[j][ne]=max(st[j-1][ne-1]+ok[j],st[j-1][ne]);
          st[j][ne]=max(st[j][ne],dp[i-1][j]+ok[j]);
          st[j][ne]=max(st[j][ne],st[j][ne-1]);
        }
      }else{
        for(int ne=0;ne<=3;ne++){
          st[j][ne]=max(dp[i-1][j],st[j-1][ne]);
          if(ne)st[j][ne]=max(st[j][ne],st[j][ne-1]);
        }
      }
      for(int ne=0;ne<=3;ne++){
        dp[i][j]=max(dp[i][j],st[j][ne]);
      }
      dp[i][j]=max(dp[i][j],dp[i][j-1]);

   //   cout<<"get->"<<i<<' '<<j<<' '<<dp[i][j]<<endl;
    }
    l=ra+1;
  }
  cout<<dp[r][c];
  return 0;
}

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

using namespace std;

int main(){
  int D,N;
  cin>>D>>N;
  int x=100;
  if(N==100){
    if(D==0){
      cout<<101;
    }else if(D==1){
      cout<<10100;
    }else{
      cout<<1010000;
    }
    return 0;
  }
  cout<<pow(x,D)*N<<"\n";
  return 0;
}


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

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

const int MAX = 1000000;

int dp[MAX + 1];
int dp2[MAX + 1];

void solve()
{
  fill(dp, dp + MAX + 1, MAX);
  fill(dp2, dp2 + MAX + 1, MAX);
  dp[0] = dp2[0] = 0;
  vector<int> v;
  for(int i = 0; ; i++){
    int t = i * (i + 1) * (i + 2) / 6;
    if(t <= MAX)
      v.push_back(t);
    else
      break;
  }
  for(int i = 0; i <= MAX; i++){
    for(int j = 0; j < v.size(); j++){
      if(i + v[j] <= MAX){
        if(v[j] & 1)
          dp2[i + v[j]] = min(dp2[i + v[j]], dp2[i] + 1);
        dp[i + v[j]] = min(dp[i + v[j]], dp[i] + 1);
      }
    }
  }
}
    
int main()
{
  solve();
  while(1){
    int n;
    cin >> n;
    if(n == 0)
      break;
    cout << dp[n] << " " << dp2[n] << endl;
  }
}

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

int main() {
    int n, ans = 1;
    cin >> n;
    int a[n];
    
    for(int i = 0 ; i < n; ++i) cin >> a[i];
    int flag = 0; // 1:up, -1:down
    for(int i = 0; i < n-1; ++i) {

        if(a[i] > a[i+1]) { // down
            if(flag == 1) {
                ans++;
                flag = 0;
            } else {
                flag = -1;
            }
        } else if(a[i] < a[i+1]) { // up
            if(flag == -1) {
                ans++;
                flag = 0;
            } else {
                flag = 1;
            }
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
//
//  Problem Name: Knapsack 1

//  Created by Kushal Warke
//  Copyright © 2018 Kushal Warke. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
#include <set>
#include <sstream>
#include <stack>
#include <list>
#include <queue>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector< pair<int,int> > vpi;
typedef vector< pair<long long,long long> > vpll;

double EPS = 1e-9; 
int INF = 1000000005;
const ll N = 101; 
const ll M = 100001;
ll weight[N];
ll value[N];
ll sol[N][M];
ll solve(ll n,ll w) {
    for(ll i=0;i<=n;i++) {
        for(ll j=0;j<=w;j++) {
            if(i==0 or j==0) {
                sol[i][j] = 0;
            }
            else if(weight[i]>j) {
                sol[i][j] = sol[i-1][j];
            }
            else {
                sol[i][j] = MAX(value[i]+sol[i-1][j-weight[i]],sol[i-1][j]);
            }
            //cout<<i<<" "<<j<<" "<<sol[i][j]<<endl;
        }
    }
    return sol[n][w];
}

int main() {
    ll n,w;
    cin>>n>>w;
    for(ll i=1;i<=n;i++) {
        cin>>weight[i]>>value[i];
    }
    ll ans = 0;
    ans = solve(n,w);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include <iostream>

void call(int n);

int main() {
  int n;
  std::cin >> n;

  call(n);

  return 0;
}

void call(int n) {
  int x;

  for(int i = 1; i <= n; ++i) {
    x = i;
    if(x % 3 == 0) {
      std::cout << " " << i;
      continue;
    }
    if(x % 10 == 3) {
      std::cout << " " << i;
      continue;
    }
    while(x) {
      x /= 10;
      if(x % 10 == 3) {
        std::cout << " " << i;
        break;
      }
    }
  }
  std::cout << std::endl;

}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,res=0;
    cin>>n>>x>>t;
    while(n>=x)
    {
        n-=x;
        res+=t;
    }
    if(n)
    res+=t;
    cout<<res;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    // int a[n];
    map<int,int>mp;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        mp[x]++;
    }
    int ans=0;
    for(auto i: mp){
        if(i.first<i.second){
            ans+=(i.second- i.first);
        }
        else if(i.first>i.second){ ans+=i.second;}
        else continue;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4736
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    (q, r) = n `divMod` 2
  print $ if r == 0 then f q else 0

f :: Int -> Int
f = sum . unfoldr next
  where
    next k | q == 0 = Nothing
           | otherwise = Just (q, q)
      where
        q = k `div` 5

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = input()

f = 0
for i in range(len(n)):
    f += int(n[i])

if (int(n) % f == 0):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 9004
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const long long N = 1e10 + 7;
typedef long long ll;
int main()
{
	int n;
	cin >> n;
	cout << 3.14159265359 * 2 * n;
    return 0;
}


Measured memory_bytes: 3792
/*
* @author:  codancer
* @createTime:  2020-09-15, 23:04:07
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
int main(){
	int x;
	cin>>x;
	cout<<(!x)<<endl;
	return 0;
}

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

int main() {
  int64_t A, B, r, x, tmp;
  cin >> A >> B;
  x = A * B;
  if(A < B) {
    tmp = A;
    A = B;
    B = tmp;
  }
  r = A % B;
  while(r != 0) {
    A = B;
    B = r;
    r = A % B;
  }
  cout << x / B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  int a[26]={};
  rep(i,s.size()){
    a[s[i]-97]++;
  }
  rep(i,26){
    if(a[i]>=2){
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;



  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(5000)


def dfs(v, parent, rest, edge):
    ret = 0
    for c in edge[v]:
        if c != parent:
            ret += dfs(c, v, rest - 1, edge)
    return ret + (rest <= 0)


def main(N, K, edge):
    ans = N
    if K % 2 == 0:
        for v in range(N):
            ans = min(ans, sum(dfs(c, v, K // 2, edge) for c in edge[v]))
    else:
        for v in range(N):
            for c in edge[v]:
                ans = min(ans, dfs(v, c, K // 2 + 1, edge) + dfs(c, v, K // 2 + 1, edge))
    print(ans)


if __name__ == '__main__':
    N, K = map(int, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append(v)
        edge[v].append(u)
    main(N, K, edge)


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

int main()
{
  // 整数の入力
  int a,b,c=0;
  cin >> a;
  
  for (int i = 0; i < a; ++i) {
    cin >> b;
    c |= b;
  }
  
  int cnt = 0;
  for (int i = 0;;++cnt,++i) {
    if (c&(1<<i)) {break;}
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a == b && b == c)
    {
        cout << 1;
    } else {
        if (a == b || b == c || c == a) {
            cout << 2;
        } else {
            cout << 3;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v)	((v).begin()), ((v).end())
#define pb	push_back
#define mp	make_pair
#define mod 1000000007
#define debug(x)  cout<<#x<<" = "<<x<<" \n"
typedef long long ll;
void xin(){
	#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

// int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
// inline bool valid(int x, int y, int v) {
//     return x >= 0 && x < n && y >= 0 && y < m && !visited[x][y] && grid[x][y] == v;
// }

int main()
{
  	xin();
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    ll ans = 0;
    for(int i=1;i<n;i++)
    {
        if(a[i] < a[i-1])
        {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout<<ans<<endl;

   
}
    

Measured memory_bytes: 4380
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi t, v;

int main() {
    cin >> N;
    t.resize(N + 1, 0);
    v.resize(N + 1, 0);
    rep(i, N) cin >> t[i];
    rep(i, N) cin >> v[i];

    for (int i = N - 1; i >= 0; --i) {
        if (v[i] - v[i + 1] > t[i]) {
            v[i] = v[i + 1] + t[i];
        }
    }
    //for (int i = 1; i <= N; ++i) {
    //    if (v[i + 1] - v[i] > t[i]) {
    //        v[i + 1] = v[i] + t[i];
    //    }
    //}

    int ans = 0;
    int v0 = 0;
    for (int i = 0; i < N; ++i) {
        if (v[i] <= v[i + 1]) {
            if (v[i] - v0 <= t[i]) {
                ans += 4 * v0 * (v[i] - v0) + 2 * (v[i] - v0) * (v[i] - v0);
                ans += 4 * v[i] * (t[i] - (v[i] - v0));
                v0 = v[i];
            }
            else {
                ans += 4 * v0 * t[i] + 2 * t[i] * t[i];
                v0 = v0 + t[i];
            }
        }
        else {
            if ((v[i] - v0) + (v[i] - v[i + 1]) <= t[i]) {
                ans += 4 * v0 * (v[i] - v0) + 2 * (v[i] - v0) * (v[i] - v0);
                ans += 4 * v[i + 1] * (v[i] - v[i + 1]) + 2 * (v[i] - v[i + 1]) * (v[i] - v[i + 1]);
                ans += 4 * v[i] * (t[i] - (v[i] - v0) - (v[i] - v[i + 1]));
                v0 = v[i + 1];
            }
            else if (abs(v0 - v[i + 1]) <= t[i]) {
                ans += 4 * min(v0, v[i + 1]) * abs(v0 - v[i + 1]) + 2 * (v0 - v[i + 1]) * (v0 - v[i + 1]);
                int t_tmp = t[i] - abs(v0 - v[i + 1]);
                ans += 4 * max(v0, v[i + 1]) * t_tmp + t_tmp * t_tmp;
                v0 = v[i + 1];
            }
            else {
                ans += 4 * v0 * t[i] + 2 * t[i] * t[i];
                v0 = v0 + t[i];
            }
        }
    }

    printf("%f\n", ans / 4.0);
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int a[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010],ans=0,now=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        if(a[i+1]>a[i]){
            if(now!=2){
                now=1;
                continue;
            }
            else{
                now=0;
                ans++;
                continue;
            }
        }
        if(a[i+1]<a[i]){
            if(now!=1){
                now=2;
            }
            else{
                now=0;
                ans++;
                continue;
            }
        }
    }
    cout<<ans+1<<endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

char s[1010];

int main()
{
    scanf("%s",s);
    int N = strlen(s);
    int v1 = 0, v2 = 0;
    for (int i=0;i<N;i++)
    {
        if (s[i] == 'E') v1 |= 1;
        if (s[i] == 'W') v1 |= 2;
        if (s[i] == 'N') v2 |= 1;
        if (s[i] == 'S') v2 |= 2;
    }
    v1 %= 3;
    v2 %= 3;
    puts(v1==0&&v2==0?"Yes":"No");
}  

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if(s.equals("0")) break;
			int ret = 0;
			for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 26128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := nextInt(), nextInt()

	coinWin := func(f int) float64 {
		res := 1.0
		for f < K {
			f <<= 1
			res *= 0.5
		}

		return res
	}

	r := 0.0
	for i := 1; i <= N; i++ {
		r += coinWin(i) / float64(N)
	}

	fmt.Printf("%1.12f\n", r)
}

Measured memory_bytes: 640
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	var list = [input[0]+input[1],input[0],input[1]];	
  if(list[0] % 3 == 0 || list[1] % 3 == 0 || list[2] % 3 == 0){
     console.log("Possible");
     }else{
     console.log("Impossible");
     }
}

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


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    string t = "keyence";
    string s;
    cin >> s;
    int l = 0, r = 0;
    int sl = s.size(), tl = t.size();
    while (true) {
        bool d = false;
        if (s[l] == t[l]) {
            l++;
            d = true;
        }
        if (s[sl-r-1] == t[tl-r-1]) {
            r++;
            d = true;
        }
        if (!d) break;
    }
    cout << (l + r >= tl ? "YES" : "NO") << endl;
    
}

Measured memory_bytes: 256