akhauriyash/Code-Regression huggingface dataset:
package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() 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 printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve
const INFTY = (1 << 21)
const MAX = 100
const WHITE = 0
const GRAY = 1
const BLACK = 2

var time, n int

//隣接行列
var M [MAX][MAX]int

//d[i]: 頂点1から頂点iまでの距離
var color, d [MAX]int

func bfs(s int) {
	var q []int
	q = append(q, s)
	for i := 0; i < n; i++ {
		d[i] = INFTY
	}
	//sは開始点なので、0をいれる
	d[s] = 0

	//キューが空になるまで、以下を繰り返す
	for len(q) > 0 {
		u := q[0]
		q = q[1:]
		for v := 0; v < n; v++ {
			if M[u][v] == 0 {
				continue
			}
			if d[v] != INFTY {
				continue
			}
			d[v] = d[u] + 1
			q = append(q, v)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d ", i+1)
		if d[i] == INFTY {
			fmt.Printf("%d\n", -1)
		} else {
			fmt.Printf("%d\n", d[i])
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		M[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				M[u-1][v-1] = 1

			}
		}

	}

	bfs(0)

}



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

int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> g(n);
	for(int i = 0;i<m;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		g[x]++;
		g[y]++;
	}
	int a = 0;
	for(int i = 0;i<n;i++)
	{
		a+=g[i];
		if(g[i]%2)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	//if(a)cout<<"NO"<<endl;
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=3010;
int mod;
int Pow(int x,int y) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
int Pow(int x,int y,int mod) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
int C[N][N],n;
int pw[N*N];
int f[N][N];
int main() {
    rd(n),rd(mod);
    for(int i=0;i<=n;++i) for(int j=0;j<=i;++j) C[i][j]=j?(C[i-1][j-1]+C[i-1][j])%mod:1;
    pw[0]=1; for(int i=1;i<=n*n;++i) pw[i]=pw[i-1]*2ll%mod;

    f[0][0]=1;
    for(int i=1;i<=n;++i)
        for(int j=0;j<=i;++j)
            f[i][j]=(f[i-1][j]*(ll)(j+1)+f[i-1][j-1])%mod;
    int ans=0;
    for(int i=0;i<=n;++i) {
        int tot=0;
        for(int j=0;j<=i;++j) tot=(tot+f[i][j]*(ll)pw[(n-i)*j]%mod)%mod;
        tot=tot*(ll)Pow(2,Pow(2,n-i,mod-1))%mod;
        ans=(ans+C[n][i]*(ll)tot*((i&1)?-1:1))%mod;
    }
    printf("%d",(ans+mod)%mod);
    return 0;
}

Measured memory_bytes: 104960
/*input
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

priority_queue<pii,vector<pii>,greater<pii>> q; 
int ans[maxn];

int main()
{
	int n;
	cin>>n;
	REP(i,n) ans[i]=INF;
	q.push(MP(1,1));
	ans[1]=1;
		
	while(SZ(q)){
		pii cur=q.top();
		q.pop();
		//cout<<cur.S<<' '<<cur.F<<'\n';
		if(cur.F!=ans[cur.S]) continue;
		if(ans[cur.S*10%n]>cur.F){
			q.push(MP(cur.F,cur.S*10%n));
			ans[cur.S*10%n]=cur.F;
		}
		if(ans[(cur.S+1)%n]>cur.F+1){
			q.push(MP(cur.F+1,(cur.S+1)%n));
			ans[(cur.S+1)%n]=cur.F+1;
		}
	}
	cout<<ans[0]<<'\n';

	return 0;
}



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

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

  int sum = 0;
  for(int i=0; i<N ; i++){
    int x;
    cin >> x;

    if(x<K-x){
      sum += 2*x;
    }
    else{
      sum += 2*(K-x);
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    string S;
    cin >> S;
    if(S.size()%2==1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < S.size();i+=2){
        if(S.at(i)!='h'||S.at(i+1)!='i'){
            cout << "No" << endl;
        return 0;
        }
    }
    cout << "Yes" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long merge(int a[],int left,int mid,int right){
    int n1,n2,i,j,k;
    int l[250002],r[250002];
    long cccc = 0;
    n1 = mid-left; n2 = right-mid;
    for(i=0;i<n1;i++){
        l[i] =a[i+left];
    }
    for(i=0;i<n2;i++){
        r[i] =a[i+mid];
    }
    l[n1]=1000000001;r[n2]=1000000001;
    i=0;j=0;
    for(k=left;k<right;k++){
        if(l[i]<=r[j]){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            j++;
            cccc+=n1-i;
        }
    }
    return cccc;
}

long mergesort(int a[],int left,int right){
    int mid;
    long c1=0,c2=0,c3=0;
    if(left+1<right){
        mid = (left+right)/2;
        c1=mergesort(a,left,mid);
        c2=mergesort(a,mid,right);
        c3=merge(a,left,mid,right);
    }
    return c1+c2+c3;
}

int main(void){
    int n,i;
    int a[200000];
    long cccc=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    cccc = mergesort(a,0,n);
    printf("%ld\n",cccc);
}



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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


inline ll iter(ll x, ll y, ll z){
    return llabs(y-x) + llabs(z-y);
}
void solve(int A,int B,int Q,vll& s,vll& t,vll& x) {
    rep(i,Q){
        int al = lower_bound(ALL(s), x[i]) - s.begin();
        int bl = lower_bound(ALL(t), x[i]) - t.begin();
        ll a0=s[al-1], a1=s[al], b0=t[bl-1], b1=t[bl];
        ll best = LLONG_MAX;
        amin(best, iter(x[i], a0, b0));
        amin(best, iter(x[i], a0, b1));
        amin(best, iter(x[i], a1, b0));
        amin(best, iter(x[i], a1, b1));
        amin(best, iter(x[i], b0, a0));
        amin(best, iter(x[i], b0, a1));
        amin(best, iter(x[i], b1, a0));
        amin(best, iter(x[i], b1, a1));
        printf("%lld\n", best);
    }
}

int main() {
    int A,B,Q; scanf("%d%d%d", &A,&B,&Q);
    vll s(A+2), t(B+2), x(Q);
    s[0]=t[0]=-100000000000LL, s[A+1]=t[B+1]=100000000000LL;
    rep1(i,A) scanf("%lld", &s[i]);
    rep1(i,B) scanf("%lld", &t[i]);
    rep(i,Q) scanf("%lld", &x[i]);
    solve(A,B,Q,s,t,x);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------
int R, C;
int mat[3001][3001];
int dp[3001][3001][4];

int solve(int x, int y, int curr)
{
    if (x > R || y > C)
    {
        return 0;
    }
    
    if (dp[x][y][curr] != -1)
    {
        return dp[x][y][curr];
    }
    if (mat[x][y] == 0)
    {
        dp[x][y][curr] = max(solve(x, y + 1, curr), solve(x + 1, y, 0));
        return dp[x][y][curr];
    }
    else
    {
        if (curr < 3)
        {
            int op1 = mat[x][y] + solve(x, y + 1, curr + 1);
            int op2 = solve(x, y + 1, curr);
            int op3 = mat[x][y] + solve(x + 1, y, 0);
            int op4 = solve(x + 1, y, 0);
            dp[x][y][curr] = max({op1, op2, op3, op4});
            return dp[x][y][curr];
        }
        else
        {
            dp[x][y][curr] = max(solve(x + 1, y, 0),solve(x,y+1,curr));
            return dp[x][y][curr];
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int K;
    cin >> R >> C >> K;
    memset(mat, 0, sizeof(mat));
    memset(dp, -1, sizeof(dp));
    while (K--)
    {
        int r, c, val;
        cin >> r >> c >> val;
        mat[r][c] = val;
    }
    cout << solve(1, 1, 0) << endl;
}


Measured memory_bytes: 356064
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

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

  ll n,p;
  std::cin>>n>>p;

  std::string s;
  std::cin>>s;

  if(p!=2&&p!=5){
    std::vector<ll> num(n+1,0);
    std::vector<ll> cnt(p,0);

    cnt[0]++;

    ll ans=0;

    for(ll i=n-1;i>=0;i--){
      num[i]=num[i+1]+pow_mod(10,n-1-i,p)*((ll)(s[i]-'0'))%p;
      num[i]%=p;
      ans+=cnt[num[i]];
      cnt[num[i]]++;
    }

    debug(num);

    std::cout<<ans<<"\n";
    return 0;
  }

  if(p==2){
    ll ans=0;
    rep(i,0,n){
      if((s[i]-'0')%2==0)ans+=i+1;
    }

    std::cout<<ans<<"\n";
  }

  if(p==5){
    ll ans=0;
    rep(i,0,n){
      if((s[i]-'0')%5==0)ans+=i+1;
    }

    std::cout<<ans<<"\n";
  }

  return 0;
}



Measured memory_bytes: 5268
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;

ll INF = 1145141919454519;

int main() {
 
  ll A, B, C;
  cin >> A >> B >> C;
  
  if(A + B + C <= 21 ){
    cout << "win" << endl;
  }else{
    cout << "bust" << endl;
  } 
  
}

Measured memory_bytes: 256
n=gets.to_i

arr=gets.split.map(&:to_i)
arr2=gets.split.map(&:to_i)

arr3=[]
i=0
n.times{
  arr3<<arr[i]-arr2[i]  
  i+=1  
}

arr4=0
arr5=0
arr6=0

i=0
n.times{
    if arr3[i]>0
    arr4+=arr3[i]
    
    elsif arr3[i]%2==0 && arr3[i]<0
    arr5-=arr3[i]
    
elsif  arr3[i]<0
    
    arr6+=arr3[i]*(-1)-1
  end 
 i+=1 
  
  
 
}

arr5=arr5/2
arr6=arr6/2

if arr4-arr5-arr6<=0
puts  "Yes"
else puts "No"
end





Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

auto dp = vector<ll>(10010, 1000000000000);
int main() {
  int H, N;
  cin >> H >> N;

  vector<pair<int, int>> magic = vector<pair<int, int>>(N);
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    magic[i] = {A, B};
  }
  dp[0] = 0;
  REP(i, H + 1) {
    REP(j, N) {
      auto p = magic[j];
      auto a = i + p.first;
      if(i + p.first >= H) {
        a = H;
      }
      dp[a] = min(dp[a], dp[i] + p.second);
    }
  }
  // dump(dp);
  cout << dp[H] << endl;
}


Measured memory_bytes: 512
from itertools import permutations

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

base = [A, B, C, D, E]
ans = 10e9
for orders in permutations(base, 5):
    wait = orders[0]
    for order in orders[1:]:
        for i in range(0, 11):
            if (wait + i) % 10 == 0:
                wait = wait + i + order
                break
    ans = min(ans, wait)

print(ans)


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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> H(N+1);
	vector<int> AB(N+1);
	
	for (int i = 1; i <= N; i++){
		cin >> H.at(i);
		AB.at(i) = 0;
	}

	for (int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		AB.at(a) = max(AB.at(a), H.at(b));
		AB.at(b) = max(AB.at(b), H.at(a));
	}

	int ans = 0;
	for (int i = 1; i <= N; i++){
		if(H.at(i) > AB.at(i)){
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3996
#include<stdio.h>
#define MAX 100000

int Parent(int n){
  return n/2;
}

int Left(int n){
  return 2*n;
}

int Right(int n){
  return 2*n+1;
}
int main()
{
  int n,i,A[MAX];

  scanf("%d",&n);

  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
  }

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(Parent(i) >=1)printf("parent key = %d, ",A[Parent(i)]);
    if(Left(i)<=n) printf("left key = %d, ",A[Left(i)]);
    if(Right(i)<=n) printf("right key = %d, ",A[Right(i)]);
    printf("\n");
  }
  return 0;
}
      



Measured memory_bytes: 2036
def pdw(n):
    i=2
    t=[]
    ta = t.append
    while i*i<=n:
        while n%i==0:
            n//=i
            ta(i)
        i+=1
    if n>1:ta(n)
    return t.count(2)
N = int(input())
print(min([pdw(c) for c in list(map(int,input().split()))]))

Measured memory_bytes: 3064
s = int(input())
a = set()
a.add(s)
c = 1
while True:
	c += 1
	if s % 2 == 0:
		if s // 2 in a:
			print(c)
			break
		else:
			a.add(s//2)
			s = s//2
	else:
		if s * 3 + 1 in a:
			print(c)
			break
		else:
			a.add(s * 3 + 1)
			s = s * 3 + 1

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    String[] words = {"dream", "dreamer", "erase", "eraser"};

    if (dfs(s, 0, words)) {
      os.println("YES");
    } else {
      os.println("NO");
    }
  }

  private static boolean dfs(String s, int index, String[] words) {
    if (index == s.length()) return true;
    boolean res = false;
    for (String w : words) {
      String t = s.substring(index, Math.min(index + w.length(), s.length()));
      if (t.equals(w)) {
        res |= dfs(s, index + w.length(), words);
      }
    }
    return res;
 }
}


Measured memory_bytes: 34916
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k, x;
    ll ans = 0;
    cin >> n >> k;
    while (n--) {
        cin >> x;
        ans += 2*min(x, abs(x-k));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define NILL 2000000010
using namespace std;
struct node{
  node *p, *l,*r;
  int key;
};
node *root;
 
node * mk_node(int key,node *l,node *r,node *p){
  node *n=(node *)malloc(sizeof(node));
  n->key=key;
  n->r=r;
  n->l=l;
  n->p=p;
  return n;
}
 
void insert(node *z){
  node *y=mk_node(NILL,NULL,NULL,NULL);
  node *x=root;

  while(x!=NULL){
    y=x;
    if((z->key)<(x->key)) x=x->l;
    else x=x->r;
  }
  z->p = y;

  if(y->key==NILL)root = z;
  else if(z->key < y->key) y->l=z;
  else y->r=z;
}

void In(node *pos){
  if(pos->l!=NULL)In(pos->l);
  cout <<" "<<pos->key;
  if(pos->r!=NULL)In(pos->r);
}

void Pre(node *pos){
  cout <<" "<<pos->key;
  if(pos->l!=NULL)Pre(pos->l);
  if(pos->r!=NULL)Pre(pos->r);
  
}
 
 
char str[1000];
int main(){
  root=mk_node(NILL,NULL,NULL,NULL);
  int n;
  cin>>n;

  while(n--){
    node *x=mk_node(NILL,NULL,NULL,NULL);
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&x->key);
      insert(x);
    }
    else if(str[0]=='p'){
      In(root);cout <<endl;
      Pre(root);cout <<endl;
    }
   
  }
  return 0;
}

Measured memory_bytes: 48120
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int a,b;
    cin >> a >>b;
    if(a <= 9 && b <= 9)cout << a*b << endl;
    else cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <map>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;

int main(){
  double d,t,s;
  cin >> d >> t >> s;
  if(d/s<=t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
}

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

int main()
{
  int N, total = 0;
  cin >> N;
  vector<double> T(N), V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> T.at(i);
    total += T.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> V.at(i);
  }
  vector<double> maxV(total * 2 + 1, 10000);
  maxV[0] = 0, maxV[total * 2] = 0;
  int l = 0;
  for (int i = 0; i < N; i++)
  {
    for (int t = l; t <= l + T.at(i) * 2; t++)
    {
      maxV[t] = min(maxV[t], V.at(i));
    }
    l += T.at(i) * 2;
  }
  for (int t = 1; t <= total * 2; t++)
  {
    maxV[t] = min(maxV[t], maxV[t - 1] + 0.5);
  }
  for (int t = total * 2 - 1; t >= 0; t--)
  {
    maxV[t] = min(maxV[t], maxV[t + 1] + 0.5);
  }
  double ans = 0.0;
  for (int t = 0; t <= total * 2; t++)
  {
    ans += maxV[t] * 0.5;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3832
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

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

	long long int dp[N+1][W+1];
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=W;j++) dp[i][j]=0;
	}

	for(int i=1;i<=N;i++){
		for(int j=1;j<W+1;j++){
			if(j>=w[i]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			else dp[i][j]=dp[i-1][j];
		}
	}

	cout<<dp[N][W]<<endl;
	
	return 0;
} 

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    ll a;
    map<ll, ll> m;
    m[0]++;
    ll sum = 0;
    REP(i, n) {
        cin >> a;
        sum += a;
        m[sum]++;
    }
    ll ans = 0;
    for (auto x : m) {
        ll z = x.second;
        ans += z * (z - 1) / 2;
    }
    cout << ans << EOL;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define MOD 1000000007
#define N 20000
long long fac[N],finv[N],inv[N];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long COM(int n,int k)
{
    if (n < k || n < 0 || k < 0){
        return 0;
    }
    else if (k == 0 || n == k){
        return 1;
    }
    else {
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
}
int main()
{
    int n,k;
    cin >> n >> k;
    
    COMinit();
    
    for (int i = 1;i <= k;i++){
        cout << (COM(n-k+1,i)*COM(k-1,i-1))%MOD << endl;
    }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    map<int,int>mp;
    ll sum=0;
    for (int i=0;i<x;i++){
        cin>>y[i];
        sum+=y[i]-1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#17D8104026C 宮地拓海 Air_conditioner123 Python

n = int(input())
List = [int(i) for i in input().split()]
q = int(input())
List2 = [int(i) for i in input().split()]
count = 0
for i in range(q):
    count += list(set(List)).count(List2[i])
print(count)


Measured memory_bytes: 6552
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-8;
const int MAXN=60;
struct Vector {
	Vector () {x=y=0.0;}
	Vector (double a,double b) {x=a,y=b;}
	double x,y;
}v[MAXN],tmp;
int n;
double ans;
double dis (Vector a,Vector b) {return (b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y);}
double chk (Vector t) {
	double res=-1e18;
	for (int i=1;i<=n;i++) {res=max(res,dis(t,v[i]));}
	return res;
}
int main () {
	scanf("%d",&n);
	ans=1e18;
	for (int i=1;i<=n;i++) {scanf("%lf%lf",&v[i].x,&v[i].y);
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<i;j++) {
			tmp=Vector((v[i].x+v[j].x)/2.0,(v[i].y+v[j].y)/2.0);
			ans=min(ans,chk(tmp));
		}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<i;j++) {
			for (int k=1;k<j;k++) {
				double k1=(v[i].x-v[j].x)/(v[j].y-v[i].y);
				double k2=(v[i].x-v[k].x)/(v[k].y-v[i].y);
				k1=min(k1,1e8),k1=max(k1,-1e8);
				k2=min(k2,1e8),k2=max(k2,-1e8);
				tmp=Vector((v[i].x+v[j].x)/2,(v[i].y+v[j].y)/2);
				double b1=tmp.y-tmp.x*k1;
				tmp=Vector((v[i].x+v[k].x)/2,(v[i].y+v[k].y)/2);
				double b2=tmp.y-tmp.x*k2;
				if (fabs(k1-k2)<eps) {continue;}
				tmp.x=(b2-b1)/(k1-k2);
				tmp.y=tmp.x*k1+b1;
				ans=min(ans,chk(tmp));
			}
		}
	}
	printf("%.9f\n",sqrt(ans));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	
        // 入力
        int n = sc.nextInt();
      	int count=0;
      
      	for(int i=1;i<n;i++){
          double up=Math.sqrt(n-i);
          if(up%1==0){
            count+=1;//平方数の部分
          }
          if((n-i)%2==0){//2の倍数で計算量削減
            for(int j=1;j<up;j++){
              if((n-i)%j==0){
                count+=2;
              }
            }
          }else{
            for(int j=0;j<up/2-0.5;j++){
              if( (n-i)%(2*j+1)==0 ){
                count+=2;
              }
            }
          }
          
        }

      System.out.println(count);
      
    }
}








Measured memory_bytes: 35836
import java.util.*;

public class Main {

    static final int MOD=1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h=sc.nextInt();
        long w = sc.nextInt();
        
        if(h==1||w==1){
            System.out.println(1);
            return;
        }

        long ans=0;
        ans = (h*w)/2;
        if(h%2==1&&w%2==1)ans++;
        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim a As Integer = NextInt()
        Dim b As Integer = NextInt()
        Dim c As Integer = NextInt()
        Dim ans As Integer
        Dim dic As New List(Of Integer())
        Dim flg As Boolean

        Do
            Dim abc As Integer() = New Integer() {a, b, c}
            Array.Sort(abc)
            If Contains(dic, abc) Then ans = -1
            For Each v As Integer In abc
                If v Mod 2 <> 0 Then flg = True
            Next
            If flg OrElse ans < 0 Then Exit Do
            ans += 1
            dic.Add(abc)
            Dim x As Integer = b \ 2 + c \ 2
            Dim y As Integer = c \ 2 + a \ 2
            Dim z As Integer = a \ 2 + b \ 2
            a = x
            b = y
            c = z
        Loop
        WriteLine(ans)
    End Sub

    Function Contains(dic As List(Of Integer()), abc As Integer()) As Boolean
        For Each dic_i As Integer() In dic
            Dim flg As Boolean = False
            Dim j As Integer = 0
            For Each dic_ij As Integer In dic_i
                If dic_ij <> abc(j) Then
                    flg = True
                End If
                j += 1
            Next
            If Not flg Then Return True
        Next
        Return False
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define dbg(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define dbg(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

int main() {
  ll h,n; cin>>h>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) cin>>a[i]>>b[i];

  vector<ll> dp(h+1, LINF);
  dp[0] = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<=h; j++) {
      dp[j] = min(dp[j], dp[max(0LL, j-a[i])] + b[i]);
    }
  }
  cout << dp[h] << endl;

  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int A[30]={};
    string S;
    cin>>S;

    for(int i=0;i<S.length();i++){
        A[S[i]-'a']++;
    }

    for(int i=0;i<26;i++){
        if(A[i]>1){
            cout<<"no"<<endl;
            return 0;
        }
    }

    cout<<"yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    out((n-1)*(m-1));
    re0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        if x >= i*500 + j*100 and x <= i*500 + j*100 + c*50:
            count += 1
print(count)

Measured memory_bytes: 3064
#include <cstdio>
int a[20];
int n;
int dfs(int m,int sum,int i)
{
	if (i >= n)return 0;
	if (sum + a[i] == m)return 1;

	return dfs(m, sum + a[i], i + 1) + dfs(m, sum, i + 1);
}

void A()
{
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		int m;
		scanf("%d", &m);
		if (dfs(m,0, 0)> 0)
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
}

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

Measured memory_bytes: 992
#include <stdio.h>

int main(void)
{
	int n, t, e;
	int x[100];
	int i;
	int ans;
	int time;
	
	scanf("%d %d %d", &n, &t, &e);
	
	for (i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	
	ans = -1;
	time = t - e;
	while (time <= t + e){
		for (i = 0; i < n; i++){
			if (time % x[i] == 0){
				ans = i + 1;
				break;
			}
		}
		time++;
	}
	printf("%d\n", ans);
	
	return (0);
}

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

int numb(long long x, long long y){
  if (x % y == 0) { return x/y+1; }
  return x/y;
}

int main(){
  long long a, b, c, d;
  long long cnt = 0;
  cin >> a >> b >> c >> d;

  long long c_t, d_t, r;
  c_t = c;
  d_t = d;

  if(c_t < d_t){
    swap(c_t, d_t);
  }

  r = c_t % d_t;

  while(r!=0){
    c_t = d_t;
    d_t = r;
    r = c_t % d_t;
  }
  long long x = (c * d)/d_t;

  long long A, B, C;
  A = (b/c - (a - 1)/c);
  B = (b/d - (a - 1)/d);
  C = (b/x - (a - 1)/x);


  cout << (b-a+1) - (A + B - C) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> A(N, 0);

	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	long long ans = 0;
	long long v_max = A[0];

	for (long long i = 1; i < N; i++) {
		if (A[i] > v_max) {
			v_max = A[i];
		}
		else {
			ans += v_max - A[i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int number;
  cin >> number;
  cout<<endl;
  vector<int> people(number);
  for(int i=0; i<number; i++){
    cin >> people[i];
    cout<<" ";
  }
  cout<<endl;
  int maxp = people[0];
  int minp = people[0];
    for (auto val: people) {
        if (maxp < val)
            maxp = val;
    }
    for (auto val: people) {
        if (minp > val)
            minp = val;
    }
  int smallP=0;
  for(int i=0; i<people.size(); i++){
    smallP+=(people[i]-minp)*(people[i]-minp);
  }
  for(int i=minp+1; i<=maxp; i++){
    int comV=0;
    for(int j=0; j<people.size(); j++){
      comV+=(people[j]-i)*(people[j]-i);
    }
    if(smallP>comV){
      smallP=comV;
    }
  }
  cout<< smallP <<endl;
}

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

#define newl "\n"
#define pb push_back
#define mp make_pair
#define foru(i,n) for (int i = 0;i < n;++i)
#define ford(i,n) for (int i = n - 1;i >= 0;--i)
#define forr(i,n1,n2) for (int i = n1;i < n2;++i)

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using db = double;
using pii = pair<int,int>;
using pll = pair<lli,lli>;
using vbool = vector<bool>;
using vint = vector<int>;
using vlli = vector<lli>;
using vstring = vector<string>;
using vpii = vector <pii>;
using vvint = vector<vint>;
using vvlli = vector<vlli>;
using vvpii = vector<vpii>;
using cd = complex<double>;
const int inf = 1e9 + 5;
const lli infl = 1e18 + 5;
const double pi = 2.0 * acos(0.0);

void solve(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	int t = h * 60 + m;
	int ta,tb;
	ta = t % (12 * 60);
	tb = t % 60;
	db ya,yb;
	ya = 2 * pi * ta / (12 * 60);
	yb = 2 * pi * tb / (60);
	db y = fabs(ya - yb);
	db out = a * a + b * b - 2 * a * b * cos(y);
	cout << sqrt(out) << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(15);
	#ifdef EXECUTE_LOCALLY
    	   freopen("in.txt","r",stdin);
	#endif
	solve();
	#ifdef EXECUTE_LOCALLY
    	   cerr << newl << "Time taken: " << 1.00 * clock() / CLOCKS_PER_SEC << "s\n";
	#endif
	return 0;
}


Measured memory_bytes: 4212
r, c = gets.split.map(&:to_i)
sheets = []
r.times do
  tmp = gets.split.map(&:to_i)
  tmp.push (tmp.inject(0) {|sum, num| sum += num;})
  sheets.push tmp
end


tmp = []
(c + 1).times do |i|
  sum = 0
  r.times do |j|
    sum += sheets[j][i]
  end
  tmp.push sum
end

sheets.push tmp

sheets.each do |row|
  puts row.join(' ')
end

Measured memory_bytes: 6136
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = int(1e9 + 7)
cnt_a = [0] * 2005
for i in a:
    cnt_a[i] += 1
less = 0
m = 0
for i in cnt_a:
    if i == 0:
        continue
    m += less * i
    less += i
ans = 0
for i in range(n):
    cnt = 0
    for j in range(i):
        if a[j] > a[i]:
            cnt += 1
    ans += cnt * k % mod
ans += m * k * (k - 1) // 2 % mod
print(ans % mod)

Measured memory_bytes: 9228
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int c[][] = new int[2*k][2*k];

		for(int i=0; i<n; i++) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			String s = sc.next();
			boolean isblack = s.equals("B");

			if(!isblack) {
				x += k;
				isblack = !isblack;
			}

			x %= 2*k;
			y %= 2*k;

			c[x][y]++;

		}
		int s[][]=new int[2*k+1][2*k+1];
		for(int i=0; i<2*k; i++) {
			for(int j=0; j<2*k; j++) {
				s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + c[i][j];
			}
		}

		int max = 0;
		for(int i=0; i<k; i++) {
			for(int j=0; j<k; j++) {
				int tmp1 = s[i][j] - s[i][0] - s[0][j] + s[0][0];
				int tmp2 = s[i+k][j+k] - s[i][j+k] - s[i+k][j] + s[i][j];
				int tmp3 = s[2*k][j] - s[i+k][j] - s[2*k][0] + s[i+k][0];
				int tmp4 = s[i][2*k] -s[0][2*k] - s[i][j+k] + s[0][j+k];
				int tmp5 = s[2*k][2*k] - s[i+k][2*k] - s[2*k][j+k] + s[i+k][j+k];
				int tmp = tmp1+tmp2+tmp3+tmp4+tmp5;
				max = Math.max(max, tmp);
				max = Math.max(max, n-tmp);
			}
		}
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 105252
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll a,b;
  cin >> a >> b;
  cout << a+b/2 << endl;

}

Measured memory_bytes: 3588
def myAnswer(N:int,M:int,A:list,B:list) -> int:
   dic ={}
   for i in range(N):
      if(A[i] in dic.keys()):
         dic[A[i]] += B[i]
      else:
         dic[A[i]] = B[i]
   dic2 = sorted(dic.items())
   total = 0
   for key,value in dic2:
      if(M - value < 0):
         total += M * key
         break
      else:
         total += key * value
         M -= value
   return total

def modelAnswer():
   tmp=1
def main():
   N,M = map(int,input().split())
   A = []
   B = []
   for _ in range(N):
      a,b=map(int,input().split())
      A.append(a)
      B.append(b)
   print(myAnswer(N,M,A[:],B[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 26048
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N, K = mi()

print(min(N-(N//K)*K, abs(N-(N//K+1)*K)))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("3 5 2");
            WillReturn.Add("4 5");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("5 6 3 8");
            WillReturn.Add("5 100 8");
            //22
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2");
            WillReturn.Add("100 1 1");
            WillReturn.Add("1 100");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] BArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();

        long Answer = 0;
        for (int I = AArr.GetUpperBound(0); 0 <= I; I--) {
            int DecVal;

            //その添字の勇者で倒す
            if (I <= BArr.GetUpperBound(0)) {
                DecVal = Math.Min(AArr[I], BArr[I]);
                AArr[I] -= DecVal;
                BArr[I] -= DecVal;
                Answer += DecVal;
            }

            //その添字-1の勇者で倒す
            if (0 < I) {
                DecVal = Math.Min(AArr[I], BArr[I - 1]);
                AArr[I] -= DecVal;
                BArr[I - 1] -= DecVal;
                Answer += DecVal;
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 37196
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

ll h[100005],c[100005];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;

	for (int i = 0; i < n; i++)cin >> h[i];
	ll y =0 ;
	for (int i = n-2; i >= 0; i--) {
		if (h[i] >=h[i + 1])c[i] = c[i + 1] + 1;
		y = max(y, c[i]);
	}
	cout <<y << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z), t, o;
    for (int i = 0; i < x; i++)
        cin >> a.at(i);
    for (int i = 0; i < y; i++)
        cin >> b.at(i);
    for (int i = 0; i < z; i++)
        cin >> c.at(i);
    for (int i = 0; i < x; i++)
        for (int j = 0; j < y; j++)
            t.push_back(a.at(i) + b.at(j));
    sort(t.begin(), t.end(), greater<ll>());
    for (int j = 0; j < z; j++)
        for (int i = 0; i < min(x * y, k); i++)
            o.push_back(t.at(i) + c.at(j));
    sort(o.begin(), o.end(), greater<ll>());
    for (int i = 0; i < k; i++)
        cout << o.at(i) << endl;
}

Measured memory_bytes: 43240