akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define  ff     first
#define  ss     second
#define  pb     push_back
#define  all(x) (x).begin(), (x).end()
#define  rep(i,a,b) for(int i=a ; i<b ; ++i)
#define  deb(x) cout << #x << " - " << x << "\n";
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D2(x)  { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  ps(x,y) fixed<<setprecision(y)<<x
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000;
const ll MAX_N = 1e5 + 2;

int main() {
    IOS;
    int x,n; cin>>x>>n;
    vi v(n);
    map<int,int>mp;
    rep(i,0,n){
        cin>>v[i];
        mp[v[i]]++;
    }
    
    int res = MAX_N,ans;
    for(int i=0;i<=101;++i){
        if(!mp[i]&&res>abs(x-i)){
            res = abs(x-i);
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n){
    Int res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
    Int g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

void owari(){
    cout << "No" << endl;
    exit(0);
}

int cnt[26];

int main(){
    cin.tie(0);

    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            char ch;
            cin >> ch;
            cnt[ch-'a']++;
        }
    }
    for (int i = 0; i < H/2; i++){
        for (int j = 0; j < W/2; j++){
            int flag = 0;
            for (int k = 0; k < 26; k++){
                if (cnt[k] >= 4){
                    cnt[k] -= 4;
                    flag = 1;
                    break;
                }
            }
            if (!flag) owari();
        }
    }
    for (int i = 0; i < H/2; i++){
        if (W%2){
            int flag = 0;
            for (int j = 0; j < 26; j++){
                if (cnt[j] >= 2){
                    cnt[j] -= 2;
                    flag = 1;
                    break;
                }
            }
            if (!flag) owari();
        }
    }
    for (int i = 0; i < W/2; i++){
        if (H%2){
            int flag = 0;
            for (int j = 0; j < 26; j++){
                if (cnt[j] >= 2){
                    cnt[j] -= 2;
                    flag = 1;
                    break;
                }
            }
            if (!flag) owari();
        }
    }
    if (H%2 && W%2){
        int flag = 0;
        for (int i = 0; i < 26; i++){
            if (cnt[i]){
                cnt[i] -= 1;
                flag = 1;
                break;
            }
        }
        if (!flag) owari();
    }
    cout << "Yes" << endl;
    return 0;
} 


Measured memory_bytes: 504
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int N;
	cin >> N;
	vector<int>h(N);
	rep(i, N)cin >> h[i];
	vector<int>dp(N, 0);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < N; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[N - 1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

//local変数のサイズ
int dp1[3010][3010] = {0};
int dp2[3010][3010] = {0};
int main()
{
    int n,t;
    cin >> n >> t;
    vector<P> ab;
    ab.push_back(P(0, 0)); //ラベル調整
    rep(i, n){ int tmp, tmp2; cin >> tmp >> tmp2; ab.push_back(P(tmp, tmp2));}

    //dp1 dp[i][j]: i番目の荷物までを用いて時間jまでに抑える
    sort(ab.begin(), ab.end());
    rep1(i, n)rep1(j, t){
        if (j >= ab[i].first){
            dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j - ab[i].first] + ab[i].second);
        } else {
            dp1[i][j] = dp1[i-1][j];
        }
    }

    //dp2 dp[i][j]: i~N番目の荷物までを用いて時間jまでに抑える

    for (int i = n; i >= 1; i--)
    {
        for (int j = 1; j <= t; j++)
        {
            if (j >= ab[i].first){
                dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j - ab[i].first] + ab[i].second);
            } else {
                dp2[i][j] = dp2[i+1][j];
            }
        }
    }
    int ans = 0;
    rep1(i, n)rep1(j, t-1){
        //cout << dp1[i-1][j] << ":" << dp2[i+1][t-1-j] << ":" << ab[i].second << "::";
        //cout << dp1[i-1][j] + dp2[i+1][t-1-j] + ab[i].second << ":" << i <<":" <<j<<endl;
        ans = max(ans, dp1[i-1][j] + ab[i].second);
    }
    cout << ans << endl;
}



Measured memory_bytes: 70912
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);


const myMax = (a: number, b: number) => a > b ? a : b;
const myMin = (a: number, b: number) => a < b ? a : b;

const N = +input[0];

const INF = Infinity;
let dp: number[] = [];

dp.fill(INF, 0, 100010);
dp[0] = 0;

for(let i=0; i<+input[0]; i++) {
  dp[i+1] = myMin(dp[i+1], dp[i] + Math.abs(+input[i+1] - +input[i+2]));
  dp[i+2] = myMin(dp[i+2], dp[i] + Math.abs(+input[i+1] - +input[i+3]));
}

console.log(dp[N-1]);

Measured memory_bytes: 25420
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int A, B, Q;
vector<ll> s;
vector<ll> t;

int main () {
  cin >> A >> B >> Q;

  Rep(i, A) {
    ll tmp;
    cin >> tmp;
    s.push_back(tmp);
  } 

  Rep(i, B) {
    ll tmp;
    cin >> tmp;
    t.push_back(tmp);
  }

  sort(All(s)); sort(All(t));

  Rep(i, Q) {
    ll s_a, s_b, t_a, t_b;
    ll tmp;
    cin >> tmp;

    auto iter_s = lower_bound(All(s), tmp);
    if (iter_s - s.begin() == A) {
      s_a = -1;
    } else {
      s_a = *iter_s - tmp;
    }

    if (iter_s - s.begin() == 0) {
      s_b = -1;
    } else {
      iter_s--;
      s_b = tmp - *iter_s;
    }

    auto iter_t = lower_bound(All(t), tmp);
    if (iter_t - t.begin() == B) {
      t_a = -1;
    } else {
      t_a = *iter_t - tmp;
    }

    if (iter_t - t.begin() == 0) {
      t_b = -1;
    } else {
      iter_t--;
      t_b = tmp - *iter_t;
    }

    ll ans = INFLL;

    if (s_a != -1 && t_a != -1) {
      ans = min(ans, max(s_a, t_a));
    }
    if (s_b != -1 && t_b != -1) {
      ans = min(ans, max(s_b, t_b));
    }
    if (s_a != -1 && t_b != -1) {
      ans = min(ans, (s_a * 2 + t_b));
    }
    if (s_b != -1 && t_a != -1) {
      ans = min(ans, (s_b * 2 + t_a));
    }
    if (t_a != -1 && s_b != -1) {
      ans = min(ans, (t_a * 2 + s_b));
    }
    if (t_b != -1 && s_a != -1) {
      ans = min(ans, (t_b * 2 + s_a));
    }

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

Measured memory_bytes: 3060
N, K, Q = map(int, input().split())

import sys
input = sys.stdin.readline
A = [None] * Q
for i in range(Q):
    A[i] = int(input().rstrip())
    
peoples = [0] * N

for a in A:
    peoples[a-1] += 1
#print(peoples)

for p in peoples:
    if K-Q+p > 0:
        print('Yes')
    else:
        print('No')

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

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    switch (N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
    return 0;
}



Measured memory_bytes: 3632
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)

n = int(raw_input())
sm = 0;
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      sm += gcd(gcd(i,j),k)
      
print(sm)


Measured memory_bytes: 80484
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  int N;
  cin>>N;
  
  vector<vector<int>> vec(N,vector<int>(2));
  for(int i=0;i<N;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  
  vector<int> root(N);
  for(int i=0;i<N;i++){
    root[i]=i;
  }
  
  double sum=0;
  
  
  do{
    double d=0;
    for(int i=0;i<N-1;i++){
      double a=pow((vec[root[i]][0]-vec[root[i+1]][0]),2);
      double b=pow((vec[root[i]][1]-vec[root[i+1]][1]),2);
      d+=pow(a+b,0.5);
    }
    sum+=d;
  }
  while(next_permutation(root.begin(),root.end()));
  
  
  int x=1;
  for(int i=2;i<=N;i++){
    x*=i;
  }
  
  
  cout<<fixed<<setprecision(10)<<sum/x<<endl;
}

Measured memory_bytes: 4172
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if(a <= 9 && b <= 9)
                Console.WriteLine(a * b);
            else
                Console.WriteLine("-1");
                
        }
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC150();
void ABC151();
void ABC152();
void ABC153();
void ABC155();
void ABC156();
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC151();
}

void ABC151(){
    int n,m;
    cin>>n>>m;
    set<int> ac;
    map<int,int> wa;
    int p,sum=0;
    string s;
    for(i=0;i<m;i++){
        cin>>p>>s;
        if(s=="AC"){
            ac.insert(p);
        }else {
            if(!(ac.count(p))){
                if(wa.count(p)){
                    wa[p]++;
                }else{
                    wa[p]=1;
                }
            }
        }
    }
    p=ac.size();
    cout<<ac.size()<<" ";
    for(i=0;i<p;i++){
        //cerr<<"enter"<<endl;
        //cerr<<*begin(ac)<<endl;
        sum+=wa[*begin(ac)];
        ac.erase(*begin(ac));
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
	int i, n, min, max, score, total;
	
	while(1)
	{
		scanf("%d", &n);
		
		if(n == 0) break;
		
		total = 0;
		max = 0;
		min = 1000;
		
		for(i = 0; i < n; i++)
		{
			scanf("%d", &score);
			
			if(score > max)
				max = score;
			
			if(score < min)
				min = score;
			
			total += score;
		}
		
		total -= (max + min);
		
		printf("%d\n", total / (n - 2));
	}
	
	return 0;
}

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

//0.～ * 2^m --> 1.～ * 2^m
void convert(int &sisu, int &kasu) {
	sisu--;
	kasu %= (1LL << 52);
}

void solve(int n, int a) {
	a += (1LL << 52);
	int sisu = 1;
	int kasu = a;
	int i;
	
	for (i = 0; i < n;) {
		if (a == 0) break;
		int m = (((1LL << 53) - kasu) + (a - 1)) / a;
		m = min(m, n - i);
		kasu += a * m;
		if (kasu >= (1LL << 53)) {
			kasu >>= 1;
			sisu++;
			a >>= 1;
		}
		i = i + m;
	}

	convert(sisu, kasu);
	rep(i, 12) cout << (sisu >> (12 - 1 - i)) % 2;
	rep(i, 52) cout << (kasu >> (52 - 1 - i)) % 2;
	cout << endl;
}

signed main() {
	int n;
	while (cin >> n) {
		if (!n) break;
		string s;
		cin >> s;
		int i;
		
		int a = 0;
		rep(i, 52) {
			a += (1LL << i) * (s[52 - 1 - i] - '0');
		}
		solve(n, a);
	}
	return 0;
}


Measured memory_bytes: 3100
main = do
  getLine
  as<-map read.words<$>getLine
  putStr.solve $ as

solve as
  | point >= -1 = "Yes"
  | otherwise = "No"
  where
    point = sum ps - if 0 `elem` ps then 1 else 0
    ps = map f as
    f n
      | n `mod` 4 == 0 = 1
      | even n = 0
      | otherwise = -1

Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long int> vec(n);
  for (int i = 0; i < n; i++){
    long int a;
    cin >> a;
    vec.at(i) = a;
    if(vec.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  long int ans = 1;
  for (int i = 0; i < n; i++){
    if (vec.at(i) > 1000000000000000000/ans){
      cout << -1 << endl;
      return 0;
    }else{
      ans *= vec.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <cstring>

#define test(t) while(t--)
#define fo(i,k,n) for(int i=k;i<n;i++)
#define refl(a,x) for(auto& a:x)
#define MIN(a,b)  (a>b?b:a)
#define ll  long long int
#define MOD 1e9 + 7
#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define fi first
#define se second
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
//typedef pair<int,int> pai;
//typedef pair<char,int> pac;



/*bool f(int x,int y){

return x>y;
}*/


using namespace std;


void solve()
{ ll n;
  in n;
  ll tot = (n*(n+1))/2;
  ll nt=n/3;
  ll nf=n/5;
  ll nfif=n/15;
  ll st =(nt*(6+(nt-1)*3))/2;
  ll sf= (nf*(10+(nf-1)*5))/2;
  ll sfif=(nfif*(30+(nfif-1)*15))/2;
  ll ans = (sfif+tot)-(st+sf);
  out ans<<en;
}


int main(){ fast()
             //freopen("input.txt","r",stdin);
	         //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }

return 0;}


Measured memory_bytes: 3640
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;

int main() {
    long long x, y;
    long long cnt=1;
    vector<long long> X;
    vector<long long> Y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }
        X.push_back(x);
        Y.push_back(y);
    }
    for(int i=0; i<X.size(); i++){
        if(X.at(i) < Y.at(i)){
            cout << X.at(i) << " " << Y.at(i) << endl;
        }else{
            cout << Y.at(i) << " " << X.at(i) << endl;     
        }
    }
    return 0;
}




Measured memory_bytes: 3220
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    string t;cin>>t;
    for(int i=0;i<s.length();i++){
        reverse(all(s));
        reverse(s.begin()+1,s.end());
        if(s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int
main()
{
  int H, W;
  string s;
  const string snuke = "snuke";
  cin >> H >> W;
  for (int j = 0; j < H; ++j) {
    for (int i = 0; i < W; ++i) {
      cin >> s;
      if (s == snuke) {
	cout << char('A' + i) << j + 1 << "\n";
	return 0;
      }
    }
  }
  return 0;
}


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

#define int long long 

signed main(){
    int n;
    cin >> n;
    vector<double> a(n);
    double x = 0;
    for(int i =0 ; i < n; ++i) {
        cin >> a[i];
        a[i] = (1.0/a[i]);
        x += a[i];
    }
    
    
    cout << fixed << setprecision(12) << (1.0/x);
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	l := make([]int, n)

	evencnt := 0
	quadcnt := 0
	oddcnt := 0
	for i := 0; i < n; i++ {
		l[i] = nextInt()

		if l[i]%4 == 0 {
			quadcnt++
		} else if l[i]%2 == 0 {
			evencnt++
		} else {
			oddcnt++
		}
	}

	adjf := false
	if evencnt == 0 {
		if oddcnt <= quadcnt+1 {
			adjf = true
		}
	} else {
		if oddcnt <= quadcnt {
			adjf = true
		}
	}

	if adjf == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main()
{
  ll n, k;
  cin >> n >> k;
  int ans = floor(log(n) / log(k))+1;
  cout << ans << endl;
  return 0;
}

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

int main()
{
  ll N, M;
  cin >> N >> M;
  ll ac = 0;
  ll wa = 0;
  ll temp = 0;
  vector<pair<ll, ll>> ans(N, {0, 0});
  for (ll i = 0; i < M; ++i)
  {
    string s;
    ll p;
    cin >> p >> s;
    if (ans.at(p - 1).first)
    {
      continue;
    }
    if (s == "AC")
    {
      ac += 1;
      wa += ans.at(p - 1).second;
      ans.at(p - 1).first = 1;
    }
    else
    {
      ans.at(p - 1).second += 1;
    }
  }
  cout << ac << ' ' << wa << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i,1, n + 1)
		ret = (ret *i)%MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n) , (factorial(r) * (factorial(n - r)))%MODU, MODU);
}
signed main() {
	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}

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

using namespace std;

int main(void){
    int a,b;
    
    cin >> a >> b;
    
    int d,r;
    double f;
    
    d = a / b;
    r = a % b;
    f = (double)a /  b;
    
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
    
    return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int n, k;
	cin >> n >> k;
	int a[n + 1];
	ld sum[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + (ld)((a[i] + 1) / 2.0);
	}
	ld ans = 0;
	for(int i = k; i <= n; i++) {
		ans = max(ans, sum[i] - sum[i - k]);
	}
	cout << fixed << setprecision(10) << ans;

	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);

    int ansAs[20000];
    int ansBs[20000];

    for(int i=0; i<=20000; i++){
        int ansA = (int)(i * 1.08) -i;
        int ansB = (int)(i * 1.1) -i;
        if(ansA == A && ansB == B){
            printf("%d\n", i);
            return 0;
        }
    }

    printf("%d\n", -1);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,i,n=0;
    cin>>a>>b>>c;
    for(i=100;i>=1;i--)
    {
        if(i%c==0&&i>=a&&i<=b)
        {
            n=n+1;
        }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;


int main(){
    int a[6];
    int ans = 0;
    int maxx = 0;
    int mod;
    for(int i = 0;i < 5;i++){
        scanf("%d",a + i);
        mod = a[i] %10;
        maxx = max(mod?10 - mod:0,maxx);
        if(mod){
            ans += a[i] + 10 - mod;
        }
        else ans += a[i];
        //printf("a[%d] = %d,ans= %d\n",i,a[i],ans);
    }
    printf("%d\n",ans -maxx);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>


#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
typedef complex<double> Point;


struct Circle {
    Point c;
    double r;
    int color;
    Circle(Point c=Point(), double r=0.0,int color=0) :
        c(c),r(r),color(color){}
};
double getDistance(Point a,Point b) {
    return abs(a-b);
}

bool intersect(Circle c1, Circle c2) {
    double d=getDistance(c1.c,c2.c);
    return d<c1.r+c2.r;
}
int n;
bool same_color[30][30];
bool is_intersect[30][30];
bool ok(int n,int S) {
    rep(i,n) {
        if(!(S>>i&1)&&is_intersect[i][n]) return false;
    }

    return true;
}
short dp[1<<24];
int dfs(int S) {
    if(dp[S]!=-1) return dp[S];
    int ret=0;
    rep(i,n) rep(j,n) if(i!=j) {
        if(((S>>i)&1)) continue;
        if(((S>>j)&1)) continue;
        if(!same_color[i][j]) continue;
        //if(!ok(i,S)) continue;
        //if(!ok(j,S)) continue;
        bool ok=true;
        rep(k,n) {
            if(((S>>k)&1)) continue;
            if(k<i&&is_intersect[i][k]) ok=false;
            if(k<j&&is_intersect[j][k]) ok=false;
        }
        if(!ok) continue;

        //printf("remove %d %d\n",i,j);
        ret=max(ret,dfs(S|(1<<i)|(1<<j))+2);
    }

    return dp[S]=ret;
}
void solve() {
    memset(dp,-1,sizeof(dp));
    rep(i,30) rep(j,30) is_intersect[i][j]=false;
    rep(i,30) rep(j,30) same_color[i][j]=false;
    vector<Circle> circles;
    rep(i,n) {
        double x,y,r;
        int c;
        cin>>x>>y>>r>>c;
        circles.push_back(Circle(Point{x,y},r,c));
    }
    rep(i,circles.size()) rep(j,circles.size()) {
        if(intersect(circles[i],circles[j])) is_intersect[i][j]=true;
        if(circles[i].color==circles[j].color) same_color[i][j]=true;
    }
    cout<<dfs(0)<<endl;
}
int main() {
    while(cin>>n) {
        if(!n) break;
        solve();
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#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 SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


ll n, a, b,sum=0;

ll digit_sum(ll n) {
	if (n < 10)  return n;
	return digit_sum(n / 10) + n % 10;
}


int main() {
	cin >>n>>a>>b;
	for (ll i = 1; i <= n; i++) {
		ll tmp = digit_sum(i);
		if (tmp >= a && tmp <= b) sum += i;
	}

	cout << sum << endl;

	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
ll n;
ll dp[3010][3010]={};
vector<ll>ho(3010);
ll dfs(int fr,int to,int now){
  if(fr==to){
    ///cout<<"!"<<endl;
    if(now==0)
      return dp[fr][to]=ho[to];
    else
      return dp[fr][to]=-ho[to];
  }
  if(dp[fr][to]!=-llINF)return dp[fr][to];
  // cout<<fr<<" "<<to<<" "<<now<<endl;
  if(now==0){
    return dp[fr][to]=max(dfs(fr+1,to,1)+ho[fr],dfs(fr,to-1,1)+ho[to]);
  }else{
    return dp[fr][to]=min(dfs(fr+1,to,0)-ho[fr],dfs(fr,to-1,0)-ho[to]);
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n+1;i++)
    for(int j=0;j<n+1;j++)
      dp[i][j]=-llINF;
  for(int i=0;i<n;i++)cin>>ho[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    }
  }
  dfs(0,n-1,0);
  cout<<dp[0][n-1]<<endl;
  return 0;
}


Measured memory_bytes: 71040
from collections import Counter


if __name__ == "__main__":
    N, V = map(lambda x: int(x), input().split())
    bags = [list(map(lambda x: int(x), input().split())) for _ in range(4)]

    merged_0_1 = Counter(v1 + v2 for v1 in bags[0] for v2 in bags[1])
    merged_2_3 = Counter(v1 + v2 for v1 in bags[2] for v2 in bags[3])

    ans = sum(merged_0_1[V - val] * num
              for val, num in merged_2_3.items() if V - val in merged_0_1)
    print(ans)



Measured memory_bytes: 203952
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d) cout<<"Yes";
	else cout<<"No";
	return 0; 
	
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

int main()
{
    int n, k;
    cin >> n >> k;
    string s; 
    cin >> s;
    int num = 0;
    for(int i = 0; i < n-1; i++) if(s[i] != s[i+1]) num++;
    cout << n-1-max(num - 2*k, 0) << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  int n; cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int m; cin>>m;
  vector<ll>b(m);
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  if(includes(a.begin(),a.end(),b.begin(),b.end())){
    cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


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

using namespace std;

struct solve {
    int ans[1000][1000];
    
    constexpr solve() : ans() {
        for (int i = 0; i < 1000; i++) {
            for (int j = 0; j < 1000; j++) {
                int N = i, A = j - 100;
                
                int L = A;
                int R = A + N - 1;
    
                int eat = 0;
                if (R <= 0)eat = R;
                else if (L >= 0)eat = L;
                
                int answer = (R + L) * (R - L + 1) / 2 - eat;
                
                ans[i][j] = answer;
            }
        }
    }
};

int main() {
    int N, L;
    cin >> N >> L;
    solve s;
    cout << s.ans[N][L+100] << endl;
}


Measured memory_bytes: 4220
while w_s = gets
	w = w_s.to_i
	price = 0
	if w == -1
		break
	end
	
	if w <=10
		price = 4280 - 1150
		puts price
	elsif 10 < w && w <= 20
		price = 4280 - (1150 + 125 * (w - 10))
		puts price
	elsif 20 < w && w <= 30
		price = 4280 - (2400 + 140 * (w - 20))
		puts price
	elsif 30 < w
		price = 4280 - (3800 + 160 * (w - 30))
		puts price
	end
end

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int r0, w0, c, r;
    while(cin >> r0 >> w0 >> c >> r && r0 && w0 && c && r){
        int need = w0 * c - r0;
        if(need < 0){
            cout << 0 << "\n";
            continue;
        }
        cout << max(0, (need / r) + !!(need % r)) << "\n";
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <cmath>
#define MAX 100000
using namespace std;
typedef long long ll;
ll n, k, a, lar, g;
ll fun(ll x, ll y) {
    if(y==0)
        return x;
    else
        return fun(y, x%y);
}

int main(void) {
    cin >> n >> k;
    for(ll i=0; i<n; i++) {
        cin >> a;
        lar = max(lar, a);
        g = fun(g, a);
    }
    cout << (k%g || k>lar ? "IMPOSSIBLE" : "POSSIBLE");
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  double T, A;
  cin >> T >> A;
  int h[N];
  for (int i = 0; i < N; i++) cin >> h[i];

  double diff = INF;
  int ans;
  for (int i = 0; i < N; i++) {
    double tmp = T - (h[i] * 0.006);
    if (abs(A - tmp) < diff) {
      diff = abs(A - tmp);
      ans = i + 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			UnionFindTree uft = new UnionFindTree(n);
			IntStream.range(0, m).forEach(i -> {
				int a = scanner.nextInt() - 1, b = scanner.nextInt() - 1;
				uft.union(a, b);
			});
			// Union Fid Treeでグルーピングしたグループの要素数の最大値
			System.out.println(IntStream.range(0, n).map(i -> uft.count(i)).max().getAsInt());
		}
	}

	/**
	 * Union Find Treeの実装<br/>
	 * https://atcoder.jp/contests/abc040/submissions/4708654 を参考に作成
	 */
	private static class UnionFindTree {
		int[] parent;
		int[] count;

		UnionFindTree(int size) {
			parent = new int[size];
			IntStream.range(0, size).forEach(i -> parent[i] = i);
			count = new int[size];
			Arrays.fill(count, 1);
		}

		int find(int x) {
			if (parent[x] == x) {
				return x;
			} else {
				int v = find(parent[x]);
				parent[x] = v;
				return v;
			}
		}

		/**
		 * @param x
		 * @param y
		 * @return xとyがつながっているかどうか
		 */
		@SuppressWarnings("unused")
		boolean same(int x, int y) {
			return find(x) == find(y);
		}

		/**
		 * xとyを結合する
		 * 
		 * @param x
		 * @param y
		 */
		void union(int x, int y) {
			int rootX = find(x);
			int rootY = find(y);
			if (rootX == rootY) {
				return;
			}
			parent[rootX] = rootY;
			parent[x] = rootY;
			count[rootY] += count[rootX];
		}

		/**
		 * @param x
		 * @return xと結ぶ都市の数
		 */
		public int count(int x) {
			return count[find(x)];
		}
	}
}


Measured memory_bytes: 72968
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[]) throws Exception
    {
        FastReader sc=new FastReader();
         PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
           int n=sc.nextInt();long a[]=new long[n];long ans=0;
           for(int i=0;i<n;i++) a[i]=sc.nextLong();
           for(int i=1;i<n;i++)
           {
               if(a[i-1]>a[i]) {ans+=(a[i-1]-a[i]);a[i]+=(a[i-1]-a[i]);}
           }//for(int w:a) pw.println(w);
           pw.println(ans);
        }
           pw.close();
    }
}
  

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int vis[100111];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m;
	cin >> n >> m;
	int ca = 0, pe = 0;
	int p; string s;
	for(int i = 0; i < m; i++){
		cin >> p >> s;
		if(s=="WA"&&vis[p]>=0){
			vis[p]++;
		}else if(s=="AC"&&vis[p]>=0){
			pe += vis[p];
			vis[p]=-1;
			ca++;
		}
	}
	cout << ca << ' ' << pe << endl;
}	


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

typedef long long ll;



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

	ll C[N],S[N],F[N];
	for(int i=0;i<N;i++) cin>>C[i]>>S[i]>>F[i];
	
	
	for(int i=0;i<N-1;i++){
	    int t=S[i];
	    for(int j=i;j<N-1;j++){
	        if(t<=S[j])t=S[j];
	        while(t%F[j]!=0)t++;
	        t+=C[j];
	        
	    }
	    cout<<t<<endl;
	}
	
	cout<<0<<endl;
}

Measured memory_bytes: 256
package main

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

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

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

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

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

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

	return mp
}

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	for i := 0; i < len(S); i++ {
		if S[i] == 'C' {
			for j := i + 1; j < len(S); j++ {
				if S[j] == 'F' {
					fmt.Println("Yes")
					return
				}
			}
			fmt.Println("No")
			return
		}
	}
	fmt.Println("No")
	return

}



Measured memory_bytes: 640
#include<iostream>
#include<cctype>
#include<stdio.h>
using namespace std;
 string S;
    char ch;
int main(){
   
    while(1){
        scanf("%c",&ch);
        if(islower(ch)) ch = toupper(ch);
        else if(isupper(ch)) ch = tolower(ch);
        cout<< ch;
        if(ch == '\n')break;
    }
}


Measured memory_bytes: 3176
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	 Scanner sc = new Scanner(System.in);
	 String a = sc.next();
	 String year="2018";
	 String month = a.substring(4);
	 System.out.println(year+month);
             
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, t;
  cin >> a >> b >> t;

  cout << (t/a)*b << endl;
  return 0;
}

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

//
void core(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == 7 && c == 5){
		a = 5;
		c = 7;
	}
	if (b == 7 && c == 5){
		b = 5;
		c = 7;
	}
	printf((a == 5 && b == 5 && c == 7) ? "YES" : "NO");
}
//

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    int m=INF;
    int sum=0;
    int cou=0;
    rep(i,N) {
        cin>>A[i];
        if(A[i]<0) cou++;
        sum+=abs(A[i]);
        m=min(m,abs(A[i]));
    }
    if(cou%2==0) cout << sum << endl;
    else cout << sum-2*m << endl;




}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }




    }

}

Measured memory_bytes: 22868