akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

template<ll MOD>
class rolloing_hash {
public:
    int n;
    ll b;
    vector<ll> pow, hash;

    rolloing_hash() {}

    rolloing_hash(const string &s, ll b_ = 10007) { set(s, b_); }

    void set(const string &s, ll b_ = 10007) {
        n = s.size();
        b = b_;
        calc(s.c_str());
    }

    ll get() const { return get(n); }

    ll get(int i) const { return hash[i]; }

    ll get(int i, int j) const {
        return (get(j) - get(i) * pow[j - i] % MOD + MOD) % MOD;
    }

private:
    void calc(const char *s) {
        pow.resize(n + 1); pow[0] = 1;
        hash.resize(n + 1); hash[0] = 0;
        for (int i = 0; i < n; ++i) {
            pow[i + 1] = pow[i] * b % MOD;
            hash[i + 1] = (s[i] + hash[i] * b) % MOD;
        }
    }
};

// 1000000007, 1000000009, 1000000021, ...
using RH1 = rolloing_hash<1000000007>;
using RH2 = rolloing_hash<1000000021>;

string s;
string x[200010], y[200010];
ll hx[200010], hy[200010];
map<ll, int> shx, shy;
set<int> sx, sy;

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

    cin >> s;
    int n;
    cin >> n;
    RH1 rh1;
    RH2 rh2;

    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];

        rh1.set(x[i]);
        rh2.set(x[i]);
        ll h = rh1.get() << 32 | rh2.get();
        hx[i] = h;
        shx[h] = -1;
        sx.insert(x[i].size());

        rh1.set(y[i]);
        rh2.set(y[i]);
        h = rh1.get() << 32 | rh2.get();
        hy[i] = h;
        shy[h] = -1;
        sy.insert(y[i].size());
    }
    
    rh1.set(s);
    rh2.set(s);
    for (auto &e : sx) {
        for (int i = 0; i + e <= (int)s.size(); ++i) {
            ll h = rh1.get(i, i + e) << 32 | rh2.get(i, i + e);
            auto it = shx.find(h);
            if (it != shx.end() && it->second == -1) it->second = i;
        }
    }
    for (auto &e : sy) {
        for (int i = (int)s.size() - e; i >= 0; --i) {
            ll h = rh1.get(i, i + e) << 32 | rh2.get(i, i + e);
            auto it = shy.find(h);
            if (it != shy.end() && it->second == -1) it->second = i;
        }
    }

    for (int i = 0; i < n; i++) {
        int l = shx[hx[i]];
        int r = shy[hy[i]];
        if (l != -1 && r != -1 && l <= r && l + x[i].size() <= r + y[i].size()) {
            cout << r - l + (int)y[i].size();
        } else {
            cout << 0;
        }
        cout << '\n';
    }
}

Measured memory_bytes: 23360
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    R string
    |>String.map(fun c-> 'x')
    |>outl
    0
    

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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int A[9];
	FOR(i,0,9) cin >> A[i];
 
	int N,B;
	cin >> N;
	FOR(i,0,N){
		cin >> B;
		FOR(i,0,9){
		if(B==A[i]){
			A[i]=0;
			break;
	}
        }
}

 	if((A[0]==0)&&(A[1]==0)&&(A[2]==0)) cout << "Yes" <<endl;
	else if((A[3]==0)&&(A[4]==0)&&(A[5]==0)) cout << "Yes" <<endl;
	else if((A[6]==0)&&(A[7]==0)&&(A[8]==0)) cout << "Yes" <<endl;
	else if((A[0]==0)&&(A[3]==0)&&(A[6]==0)) cout << "Yes" <<endl;
	else if((A[1]==0)&&(A[4]==0)&&(A[7]==0)) cout << "Yes" <<endl;
	else if((A[2]==0)&&(A[5]==0)&&(A[8]==0)) cout << "Yes" <<endl;
	else if((A[0]==0)&&(A[4]==0)&&(A[8]==0)) cout << "Yes" <<endl;
	else if((A[2]==0)&&(A[4]==0)&&(A[6]==0)) cout << "Yes" <<endl;
	else cout << "No" <<endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int MAX = 10000;
        static readonly int sqrt = 100;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            var memo = Enumerable.Range(0, MAX + 1).ToArray();
            memo[0] = memo[1] = -1;

            for (int i = 2; i <= sqrt; i++)
            {
                if (memo[i] == -1) continue;

                for (int j = i + i; j <= MAX; j += i)
                {
                    memo[j] = -1;
                }
            }

            var primes = memo.Where(a => a != -1).ToArray();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int idx = UpperBound(primes, n) - 1;

                for (int i = idx; i > 0; i--)
                {
                    int p = primes[i - 1];
                    int q = primes[i];

                    if (q - p == 2)
                    {
                        sb.AppendLine(p + " " + q);
                        break;
                    }
                }
            }
            Console.Write(sb);
        }

        static int UpperBound(int[] arr, int value)
        {
            int low = 0, high = arr.Length;

            while (low < high)
            {
                int mid = ((high - low) >> 1) + low;

                if (arr[mid] <= value) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

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

int main(){
	int x,N,K;
	x = 1;
	cin >> N >> K;
	
	for(int i = N; i>0 ;i--){
		if(K>x)
			x = x*2;
		else
			x = x+K;
	}
	
	cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
     string S;
     cin>>S;
    int  ans=10000;
    for(int i=0; i<S.size()-2; i++){
        if(abs((S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0')-753)<ans){
            ans=abs((S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0')-753);
        }
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
import sys

N=int(input())

S=input()

if len(S)==1:
    print(3)
    sys.exit()

if S[0]==S[1]:
    before=2
    S=S[2::]
    pattern=6
else:
    before=1
    S=S[1::]
    pattern=3
while len(S)>1:
    if before==2:
        if S[0]==S[1]:
            pattern=pattern*3
            S=S[2::]
        else:
            before=1
            S=S[1::]
    else:
        if S[0]==S[1]:
            S=S[2::]
            before=2
        else:
            S=S[1::]
        pattern=pattern*2



if len(S)==1 and before==1:
    pattern=pattern*2
print (pattern%1000000007)


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    map<pair<int, int>, int> m;
    vector<int> dh = {0, -1, -2}, dw = {0, -1, -2};
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                int left_up_h = a + dh.at(i), left_up_w = b + dw.at(j);
                if (1 <= left_up_h && left_up_h <= h - 2 && 
                    1 <= left_up_w && left_up_w <= w - 2) {
                        m[pair<int, int>(left_up_h, left_up_w)]++;
                }
            }
        }
    }
    
    vector<int> ans(10);
    long long sum = 0;
    for (auto p: m) {
        ans.at(p.second)++;
        sum++;
    }
    cout << (long long)(h - 2) * (w - 2) - sum << endl;
    for (int i = 1; i < 10; i++) {
        cout << ans.at(i) << endl;
    }
}   

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

//Compiler version g++ 6.3.0

int main()
{
    int a,i,j;
    cin>>a;
    for(i=9;i>=1;i--){
      if(a%i==0) break;
    }
    if(i==0) {
      cout<<"No"<<endl;
      return 0;
    }
    j=a/i;
    
    
    if(j<=9) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int d;
    cin >> d;
  vector<int> c(26);
  for ( int i = 0 ; i < 26; i++  ) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> data(d,vector<int>(26));
  for ( int i = 0 ; i < d ; i++ ) {
    for ( int j = 0 ; j < 26 ; j++ ) {
      cin >> data.at(i).at(j);
    }
  }
  
  vector<int> contest(d);
  for ( int i = 0 ; i < d ; i++ ) {
   cin >> contest.at(i);
  }
  
  vector<int> memo(26,0);
  int score =0;
  for ( int i = 0 ; i < d ; i++ ) {
    
    int con=contest.at(i)-1;
   
    score += data.at(i).at(con);
 
    memo.at(con)=i+1;
    //cout << score << data.at(con).at(i) << endl;
    for ( int j = 0 ; j < 26 ; j++ ) {
      score -= c.at(j)*(i+1-memo.at(j));
    }
    cout << score << endl;
  }
  
}

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

int main() {

    long N;
    string S;

    cin >> N >> S ;

    //　文字列長 N の 文字列 S から、左から3文字取り出す組み合わせ

    string a1 = "";
    string a2 = "";
    string a3 = "";

    //map<string, string> key;
    int cnt = 0;

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {

                bool hit1 = false;
                bool hit2 = false;
                bool hit3 = false;

                for (int n = 0; n < S.size(); n++) {

                    if(hit1 == false && i == S[n] - 48){
                        //cout << "hit1" <<  endl;
                        hit1 = true;
                        continue;
                    }
                    if(hit1){
                        if(hit2 == false && j == S[n]- 48){
                            //cout << "hit2" <<  endl;
                            hit2 = true;
                            continue;
                        }
                    }
                    if(hit2){
                        if(k == S[n] - 48){
                            //cout << "hit3" <<  endl;
                            hit3 = true;
                            cnt++;
                            break;

                        }
                    }
                }
            }
        }
    }

    cout << cnt <<  endl;

    return 0;

}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int X,Y,h,m,s;
  scanf("%d",&X);
  h=X/3600;
  Y=X%3600;
  m=Y/60;
  s=Y%60;
  printf("%d:%d:%d\n",h,m,s);

     return 0;
}

Measured memory_bytes: 2704
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[8]={0,1,0,-1,-1,-1,1,1},dy[8]={1,0,-1,0,-1,1,-1,1};

string s;

int main(){
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
}

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

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int flag = 1;
    rep(i,n){
    	if (a[i]%2 == 0) {
    		if ((a[i]%3 == 0) || (a[i]%5 == 0)) flag = 1;
    		else {
    			flag = 0;
    			break;
    		}
    	}
    }
    if (flag == 1) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
A,B = map(int, input().split())

if A > B:
    if A-1 >B:
        print(A+(A-1))
    else:
        print(A+B)
elif A == B:
    print(A+B)
else:
    if B-1 >A:
        print(B+(B-1))
    else:
        print(A+B)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    int K,X;
    cin >> K >> X;
    if (K==1){
        cout << X;
    }
    else if (K>1){
        for (int i=X-K+1; i<X+K-1; i++){
            cout << i << " ";
        }
        cout << X+K-1;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
        String out = "";
        if(s.equals("Sunny"))
          out = "Cloudy";
        else if(s.equals("Cloudy"))
          out = "Rainy";
        else if(s.equals("Rainy"))
          out = "Sunny";
          // 出力
		System.out.println(out);
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pii pair<int, int>
#define ll long long
#define INF 1000000000
#define MAXN 200020
#define MAXL 22

using namespace std;


int main(int argc, char const *argv[])
{
	optimize;

	int N;
	string S;

	cin >> N >> S;

	int r = 0;

	char ult = '&';

	for(int i = 0; i < N; i++)
		if(S[i] != ult) r++, ult = S[i];

	cout << r << endl;

	return 0;	
} 	

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  ll x, y;
  cin >> x >> y;
  ll cnt =0;
  
  for(ll i=x; i<=y; i*=2) cnt++;

  cout << cnt << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define function function2
#define mod 1000000007
int memo[22][1<<21];
int function(vector<int> vec[],int initial,int final,int left)
{
	if(initial>final)
	  return 1;
	if(memo[initial][left]!=-1)
	   return memo[initial][left];
	else
	{
		int answer=0;
		for(int x:vec[initial])
		{
			if((left&x)!=0)
			{
				answer+=function(vec,initial+1,final,left-x);
				answer%=mod;
			}
		}
		memo[initial][left]=answer;
		return answer;
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int i,j;
	int val=1<<n;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<val;j++)
		{
			memo[i][j]=-1;
		}
	}
	vector<int> vec[n];
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			int x;
			cin>>x;
			if(x==1)
			{
				int temp=1<<j;
				vec[i].push_back(temp);
			}
		}
	}
	int answer=function(vec,0,n-1,val-1);
	cout<<answer<<endl;
}


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

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

Measured memory_bytes: 3592
#include "iostream"
#include "vector"
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i+1 < a.size(); i++) {
		cout << a[a.size()-i-1] << " ";
	}
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b){
        cout<<"delicious"<<endl;
    }else if(x+a>=b){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	float t_5[] = {35.5, 37.5, 40, 43, 50, 55, 70};
	float t_10[] = {71, 77, 83, 89, 105, 116, 148};
	float t1, t2;
	
	while (scanf("%f %f", &t1, &t2) != EOF){
		for (i = 0; i < 7; i++){
			if (t1 < t_5[i] && t2 < t_10[i]){
				break;
			}
		}
		
		if (i == 7){
			printf("NA\n");
		}
		else {
			if (i < 3){
				for (j = 0; j < 3 - i; j++){
					printf("%c", 'A');
				}
				printf("\n");
			}
			else {
				printf("%c\n", i - 2 + 'A');
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 632
<?php
$line = readline();
readline_add_history($line);
$inputs = explode(" ", $line);
$a = intval($inputs[0]);
$b = intval($inputs[1]);
$s = $a * $b;
$r = $a + $a + $b + $b;
exit($s . " " . $r . "\n");
?>

Measured memory_bytes: 6568
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
using LD = long double;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	vector<PII> pts(n);
	REP(i, n) cin >> pts[i].ST >> pts[i].ND;
	vector<int> ord(n);
	REP(i, n) ord[i] = i;
	int s = 1;
	FOR(i, 1, n) s *= i;
	LD tot = 0;
	auto sq = [&](LD x) {
		return x * x;
	};
	auto get_dist = [&](int i, int j) {
		LD ds = sq(pts[i].ST - pts[j].ST) + sq(pts[i].ND - pts[j].ND);
		return sqrt(ds);
	};
	do {
		LD dist = 0;	
		FOR(i, 1, n - 1) {
			int a = ord[i];
			int b = ord[i - 1];
			dist += get_dist(a, b);
		}
		tot += dist;
	} 
	while(next_permutation(ord.begin(), ord.end()));
	tot /= s;
	cout.precision(10);
	cout << fixed;
	cout << tot << "\n";
}


Measured memory_bytes: 256
import math
n,a,b = map(int,input().split())
mod = 10**9+7
k = 2
def Base_10_to_n(X,k):
  if (int(X/k)):
    return Base_10_to_n(int(X/k),k)+str(X%k)
  return str(X%k)
STR = Base_10_to_n(n,k)
ans = 1
cur = 2
for i in range(len(STR)):
    if STR[len(STR)-1-i] == '1':
        ans *= cur
        ans = ans%mod
    cur *= cur
    cur %= mod
    
ans -= 1
ans = ans%mod
L = [a,b]
cur = n
cur2 = n
for i in range(1,a):
    cur *= (n-i)*(pow(i+1, mod-2, mod))
    cur %= mod
for i in range(1,b):
    cur2 *= (n-i)*(pow(i+1, mod-2, mod))
    cur2 %= mod
cur %= mod
cur2 %= mod
ans -= cur
ans -= cur2
if ans < 0:
    while ans < 0:
        ans += mod
print(ans)

Measured memory_bytes: 40428
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
string k;int d;
int dp[11111][111][2];
int dfs(int i,int amari,bool ok){
    if(i<0)return amari%d==0;
    int e=ok?k[i]-'0':9;
    int &ret=dp[i][amari][ok];
    if(~ret)return ret;
    ret=0;
    //cout<<"k["<<i<<"]="<<k[i]<<" 余りは"<<amari<<" "<<ok<<" "<<e<<endl;
    for(int s=0;s<=e;s++){
        (ret+=dfs(i-1,(amari+s)%d,s==e&&ok))%=mod;
    }
    return ret;
}
signed main(){
    cin>>k>>d;
    reverse(k.begin(),k.end());
    memset(dp,-1,sizeof(dp));
    cout<<(dfs(k.size()-1,0,1)+mod-1)%mod<<endl;return 0;
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }
  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    cout << n / 2 + (n % 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	int a,b,c,d;
	int max,s,w,best;
	int i,j,temp;
	int k[1000]={0};
	cin>>N>>a>>b>>c;
	for(i=0;i<N;i++){
		cin>>d;
		k[i]=d;
	}
	for(i=0;i<N;i++){
		for(j=N-1;j>i;j--){
			if(k[i]<k[j]){
				temp=k[i];
				k[i]=k[j];
				k[j]=temp;
			}
		}
	}
	max=c/a;
	s=c;
	w=a;
	for(i=0;i<N;i++){
		s=s+k[i];
		w=w+b;
		best=s/w;
		if(max<best){
			max=best;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

typedef struct a
{
	int x; 
	int y;
}coordin;

int h,w,c;
int res = 0;
int maze [8][8];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

void changeColor(int tmp[8][8],int color)
{
	int originColor = tmp[0][0];
	queue <coordin> q;
	coordin cc;
	cc.x = 0; cc.y = 0;

	q.push(cc);
	tmp[0][0] = color;
	
	while (!q.empty())
	{
		cc = q.front();
		q.pop();

		for (int i=0;i<4;++i)
		{
			int tmp_x = cc.x + dx[i];
			int tmp_y = cc.y + dy[i];
			
			if (0<= tmp_x && tmp_x < w && 0<= tmp_y && tmp_y < h)
			{
				if (tmp[tmp_x][tmp_y] == originColor)
				{	
					coordin tmp_cc;
					tmp_cc.x = tmp_x;
					tmp_cc.y = tmp_y;
					if (color != originColor) q.push(tmp_cc);
					tmp[tmp_x][tmp_y] = color;
				}
				
			}
		}
	}
	
	return;
	
}

int cnt(int m[8][8], int x, int y)
{
    int count=1;
    int oc = m[x][y];
    m[x][y] = 0;
    for(int i=0; i<4; i++)
    {
        int tmp_x = x+dx[i];
        int tmp_y = y+dy[i];
        if(0<=tmp_x && tmp_x<w && 0<=tmp_y && tmp_y<h)
        {
            if(m[tmp_x][tmp_y]==oc) count+=cnt(m, tmp_x, tmp_y);
        }
    }
    return count;
}

int dfs(int m[8][8],int depth)
{
	if (depth == 4)
	{
		if(m[0][0]!=c) changeColor(m,c);
		return cnt(m,0,0);
	}
	
	for (int i=1;i<=6;++i)
	{
		int tmp_m[8][8];
		memcpy(tmp_m,m,sizeof(tmp_m));
		
		if (tmp_m[0][0] != i) changeColor(tmp_m,i);
		res = max(res,dfs(tmp_m,depth+1));
	}
	
	return res;
}

int main()
{
	cin>>h>>w>>c;
	
	while (h!=0)
	{
		for (int i=0;i<h;++i)
			for (int j=0;j<w;++j)
				cin>>maze[j][i];
		
		cout<<dfs(maze,0)<<endl;
		res = 0;
		cin>>h>>w>>c;
	}
	
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    long long b,r,g,c,s,t;
    cin>>b>>r>>g>>c>>s>>t;
    if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0) break;
    t-=s;
    long long medal=100;
    medal+=g*7+c*2-(g+c)*3;
    t-=(c+g);
    long long bonus=b*5+r*3;
    medal+=(b+r)*15+bonus*13-(b+r)*3;
    t-=(b+r+bonus);
    medal-=t*3;
    cout<<medal<<endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n+1);
    vector<long long> num(n,0);
    for(int i=0;i<n;i++) {
        cin >> a[i].first;
        a[i].second=i;
    }
    a[n]={0,-1};
    sort(a.rbegin(),a.rend());
    priority_queue<int,vector<int>,greater<int>> que;
    for(int i=0;i<n+1;i++){
        if(i>0 && a[i].first<a[i-1].first){
            num[que.top()] += (a[i-1].first-a[i].first) * que.size();
        }
        que.push(a[i].second);
    }
    for(int i=0;i<n;i++) cout << num[i] << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_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())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string a,b;
  cin >> a >> b;
  if(a.size() > b.size())
    cout << "GREATER" << endl;
  else if(a.size()<b.size())
    cout << "LESS" << endl;
  else{
    if(a>b)
      cout << "GREATER" << endl;
    else if(a<b)
      cout << "LESS" << endl;
    else
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
using namespace std;

int main(){
    int N; cin>>N;
    vector<vector<long>> times(N,vector<long>(2));
    for(int i=0;i<N;i++){
        cin>>times.at(i).at(1);
        cin>>times.at(i).at(0);
    }

    sort(times.begin(),times.end());
    long time=0;
    for(int i=0;i<N;i++){
        time+=times.at(i).at(1);
        if(time>times.at(i).at(0)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
const int N=300010,lim=3e5,base=1e5+5;
int s[N],n,a[N],sum[N];
int lowbit(int k){return k&-k;}
void add(int x){for(int i=x;i<=lim;i+=lowbit(i))s[i]++;}
int query(int x){int res=0;for(int i=x;i;i-=lowbit(i))res+=s[i];return res;}
bool check(int x)
{
	for(int i=1;i<=n;i++)
		if(a[i]<x)
			sum[i]=sum[i-1]+1;
		else
			sum[i]=sum[i-1]-1;
	for(int i=1;i<=lim;i++)
		s[i]=0;
	long long res=0;
	add(base);
	for(int i=1;i<=n;i++)
	{
		res+=query(sum[i]+base-1);
		add(sum[i]+base);
	}
	return res<(1ll*n*(n+1)/2)/2+1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int l=1,r=1e9,res=0,mid;
	while(l<=r)
	{
		mid=l+r>>1;
		if(check(mid))res=mid,l=mid+1;
		else
			r=mid-1;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 2176
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int k; cin >> k;
    set<string> ss;
    for(size_t i = 0; i < s.size(); i++){
        for(int j = 0; j < 5; j++){
            ss.insert(s.substr(i, j + 1));
        }
    }
    int cnt = 0;
    for(auto& e : ss){
        if(++cnt == k){
            cout << e << '\n';
            return 0;
        }
    }
    // char mini = 'z';
    // vector<string> ss;
    // for(size_t i = 0; i < s.size(); i++){
    //     auto c = s[i];
    //     mini = min(mini, c);
    //     ss.push_back(s.substr(i, 5));
    // }
    // if(k == 1){
    //     cout << mini << '\n';
    //     return 0;
    // }
    // sort(ss.begin(), ss.end());
    // if(k <= ss[0].size()){
    //     ss[0][k - 1];
    //     return 0;
    // }else{
    //     k -= ss.size();
    // }
    // for(size_t i = 0; i < ss.size(); i++){
    //     auto& s = ss[i];
    //     if(k <= (int)s.size()){
    //         cout << s[k - 1] << '\n';
    //         return 0;
    //     }else{
    //         k -= s.size();
    //     }
    // }
}


Measured memory_bytes: 1664
include Math

gets.to_i.times {
	xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f)
	
	d = sqrt((xb - xa)**2 + (yb - ya)**2)

	if ra + rb < d then
		rt = 0
	elsif (ra - rb).abs <= d then
		rt = 1
	elsif ra - rb > d then
		rt = 2
	else
		rt = -2
	end

	puts rt
}

Measured memory_bytes: 6132
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;




int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, i, j, k, ans, x, s;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));

	for (i = 0; i < n; i++) {
		cin >> c[i];
		for (j = 0; j < m; j++) cin >> a[i][j];
	}

	ans = 1000000000;

	for (i = 0; i < (1 << n); i++) {
		vector<int> sum(m, 0);
		s = 0;
		for (j = 0; j < n; j++) {
			if ((1 << j) & i) {
				s += c[j];
				for (k = 0; k < m; k++) sum[k] += a[j][k];
			}
		}
		bool valid = true;
		for (auto p : sum) {
			if (p < x) valid = false;
		}
		if (valid) ans = min(ans, s); 
	}

	if (ans == 1000000000) ans = -1;
	cout << ans << "\n";		

	return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> l(n);
  for (int &x : l) {
    cin >> x;
  }

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int sum = 0;

  for (int i = 0; i < k; i++) {
    sum += l.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long C(long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(M);
  vector<P>job(N);
  rep(i,N){
    cin>>job.at(i).first>>job.at(i).second;
  }
  
  priority_queue<ll> q;
  
  ll res=0;
  
  sort(all(job));
  
  ll j=0;
  rep(i,M){
    while(j<N && job.at(j).first==i+1){
      q.push(job.at(j).second);
      //cout<<job[j].second<<endl;
      j++;
    }
    if(q.size()>0){
      res+=q.top();
      q.pop();
    }
    //cout<<j<<endl;
  }
  
  cout<<res;
}

Measured memory_bytes: 2936
n = int(input())
p = list(map(int,input().split()))
var = 0
for k in range(n-2):
  if (p[k+1] > p[k]) and (p[k+1] < p[k+2]):
    var = var + 1
  elif (p[k+1] < p[k]) and (p[k+1] > p[k+2]):
    var = var + 1
print(var)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_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())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

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

	string s;
  cin>>s;
  if(s.size()<4)
    cout<<"No"<<endl;
  else{
    if(s.substr(0,4)=="YAKI")
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int D,E,i;
double r,t;
int main()
{
	for(;scanf("%d%d",&D,&E),D;)
	{
		r=10000000;
		for(i=0;i<=D/2;i++)
		{
			t=sqrt(1.0*i*i+(D-i)*(D-i))-E;
			if(t<0)t*=-1;
			r=r-t>=0.001?t:r;
		}
		printf("%lf\n",r);
	}
	return 0;
}

Measured memory_bytes: 636
import java .util.ArrayList;
import java.util.Collections;
import java .util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	ArrayList<Integer> inA = new ArrayList<>();

	int inputN = sc.nextInt();
	Boolean boo = true;

	for(int i = 0; i < inputN; i++) {
		inA.add(sc.nextInt());
	}

	Collections.sort(inA, Collections.reverseOrder());

	for(int i = 0; i < inputN-1; i++) {
		int n = inA.get(i);
			if(n == inA.get(i + 1)) {
				boo = false;
				break;

		}

	}

	if(boo == true) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}

}
}


Measured memory_bytes: 66184
from collections import defaultdict
import sys
rline = sys.stdin.readline


def solve():
    N = int(rline())
    counter = defaultdict(int)
    for _ in range(N):
        counter[int(rline())] += 1
    
    ans = 0
    for val in counter.values():
        if val % 2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 15456
#include<stdio.h>
int main(void){
  int i,n;
  scanf("%d",&n);
  int r[n];
  for(i=0;i<n;i++){
    scanf("%d",&r[i]);
  }
  int max=-2147483647;
  int min=r[0];
  for(i=1;i<n;i++){
    if(r[i]-min>max){
      max=r[i]-min;
    }
    if(r[i]<min){
      min=r[i];
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 2560
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-6-16 21:02:12
# Powered by Visual Studio Code
#

d, n = gets.chomp.split(" ").map{|i| i.to_i}

ans = 1
cnt = 0

while cnt < n
  c = 0
  t = ans
  while t % 100 == 0
    t /= 100
    c += 1
  end
  if c == d
    cnt += 1
  end
  ans += 1
end

puts ans - 1


Measured memory_bytes: 1788
import java.util.*;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int count = 0;
		for (int i = a; i <= b; i++)
			if (c % i == 0)
				count++;
		System.out.println(count);
	}
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n;
  cin >> n;
  
  ll total = 0;
  ll current = 0;
  ll a;
  for(ll i=0;i<n;i++){
    cin >> a;
    if(0==i) current = a;
    if(a<current){
      total += current-a;
    }
    else{
      current = a;
    }
  }
  
  cout << total << endl;
  return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K; cin >> N >> K;
	vll A(N); cin >> A;
	vll sum(N+1, 0);
	for (int i = 0; i < N; i++) {
		sum[i+1] = sum[i] + A[i];
	}
	vll B;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j <= N; j++) {
			B.push_back(sum[j]-sum[i]);
		}
	}
	ll ans = 0;
	for (ll b = 62; b >= 0; b--) { 
		ll M = B.size();
		vll tmp;
		ll cnt = 0;
		for (int i = 0; i < M; i++) {
			if ((B[i]>>b)&1ll) cnt++;
		}
		if (cnt >= K) {
			ans |= (1ll<<b);
			for (int i = 0; i < M; i++) {
				if ((B[i]>>b)&1ll) {
					tmp.push_back(B[i]);
				}
			}
			B = tmp;
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int A[110];
  for (auto i = 0; i < M; i++) {
    cin >> A[i];
  }
  if (M == 1) {
    cout << A[0] << endl;
    if (A[0] > 1) {
      cout << 2 << endl;
      cout << A[0]-1 << " " << 1 << endl;
    } else {
      cout << 1 << endl;
      cout << 1 << endl;
    }
    return 0;
  }
  vector<int> odd;
  deque<int> even;
  for (auto i = 0; i < M; i++) {
    if (A[i]%2 != 0) {
      odd.push_back(A[i]);
    } else {
      even.push_back(A[i]);
    }
  }
  if (odd.size() >= 3) {
    cout << "Impossible" << endl;
    return 0;
  } else if (odd.size() == 2) {
    even.push_back(odd[0]);
    even.push_front(odd[1]);
  } else if (odd.size() == 1) {
    even.push_back(odd[0]);
  }
  vector<int> ans;
  for (auto it = even.begin(); it != even.end(); it++) {
    if (it == even.begin() && (*it != 1)) {
      ans.push_back((*it)-1);
    } else if (it != even.begin()) {
      ans.push_back(*it);
    }
  }
  ans[ans.size()-1]++;
  for (auto i = 0; i < (int)even.size(); i++) {
    cout << even[i];
    if (i != (int)even.size()-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  cout << ans.size() << endl;
  for (auto i = 0; i < (int)ans.size(); i++) {
    cout << ans[i];
    if (i != (int)ans.size()-1) {
      cout << " ";
    } else {
      cout << endl;
    }    
  }
}


Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
n_root = prime_factorize(N)
n_set = list(set(n_root))

ans = 0
for num in n_set:
    item = n_root.count(num)
    i = 1
    while item >= i:
        item -= i
        ans += 1
        i += 1

print(ans)

Measured memory_bytes: 9216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> p = new ArrayList<>();
        for (int i=0;i<n;i++){
            p.add(scanner.nextInt());
        }
        int count = 0;
        int min = Collections.max(p);
        for (int i=0;i<n;i++){
            if (p.get(i)<=min){
                min = p.get(i);
                count++;
            }
        }

        System.out.println(count);
    }

}

Measured memory_bytes: 88768
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=110000;
const int D=11;
vi adj[N];
int c[N][D], t[N][D];

int main() {
    int n, m, i, u, v, d, color;
    scanf("%d%d", &n, &m);
    for(u=1; u<=n; u++) adj[u].pb(u);
    while(m--) {
        scanf("%d%d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    scanf("%d", &m);
    for(i=1; i<=m; i++) {
        scanf("%d%d%d", &u, &d, &color);
        c[u][d]=color;
        t[u][d]=i;
    }
    for(d=10; d>0; d--) for(u=1; u<=n; u++) {
        for(int v:adj[u]) if(t[v][d-1]<t[u][d]) {
            t[v][d-1]=t[u][d];
            c[v][d-1]=c[u][d];
        }
    }
    for(i=1; i<=n; i++) printf("%d\n", c[i][0]);
    return 0;
}

Measured memory_bytes: 16384
import java.util.Scanner


import scala.io.StdIn._

object Main extends App {

  val s = readLine()


  def solve() = {
    val n = s.length
    val c2 = s.take((n-1)/2)
    val c3 = s.drop((n+3)/2 -1)
    if(f(s) && f(c2) && f(c3)) "Yes" else "No"
  }

  def f(c: String): Boolean = c == c.reverse

  println(solve())

}



Measured memory_bytes: 54636
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void)
{
    unsigned long long L, R;

    cin >> L >> R;

    unsigned long long modL = L % 2019ULL;
    unsigned long long modR = R % 2019ULL;

    unsigned long long min = 2018;
    unsigned long long xl = std::min(modL, modR);
    unsigned long long xr = std::max(modL, modR);

    if ((R - L >= 2019) || (modL >= modR)) min = 0;
    else
    {
        for (unsigned long long i = xl; i <= xr; ++i)
        {
            for (unsigned long long j = i+1; j <= xr; ++j)
            {
                min = std::min(min, (i * j) % 2019);
            }
        }
    }
    cout << min;

    return 0;
}


Measured memory_bytes: 256