akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int a[32];

    signed call_of_Cthulhu( signed datum ) {

        int n, m;
        read n >> m;
        for ( int i = 0; i < n; i++ ) {
            int k;
            read k;
            for ( int j = 0; j < k; j++ ) {
                int f;
                read f;
                a[f]++;
            }
        }
        int cnt = 0;
        for ( int i = 0; i < m; i++ ) {
            if ( a[i+1] == n ) cnt++;
        }
        echo cnt fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){

	char W[205],TEMP[205];
	int m,i,j,k,h;
	while(1){
	scanf("%s",W);
	if(strcmp(W,"-")==0)break;
	scanf("%d",&m);
	for(i=0;i<205;i++)TEMP[i]='\0';
	for(i=0;i<m;i++){
		scanf("%d",&h);
		strncpy(TEMP,W,h);
		j=0;
		while(W[h+j]!='\0'){
			W[j]=W[h+j];
			j++;
		}
		for(k=0;k<h;k++){
			W[j+k]=TEMP[k];
		}
	}
	printf("%s\n",W);
	}
	return 0;
}

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n;
  scanf("%d",&n);
  int sum=0;
  int m=n;
  for(int i=0;i<9;i++){
    sum+=n%10;
    n/=10;
  }
  if(m%sum==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int x = GetInt();
		int y = GetInt();

		int ans = 0;
		if(Math.Abs(x) < Math.Abs(y))
		{
			if(x < 0)
				ans++;
			ans += Math.Abs(Math.Abs(x) - Math.Abs(y));
			if(y < 0)
				ans++;
		}
		else
		{
			if(x > 0)
				ans++;
			ans += Math.Abs(Math.Abs(x) - Math.Abs(y));
			if(y > 0)
				ans++;
		}

		Console.WriteLine(ans);		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int cnt=0;
    for(int i=0; i<3; i++){
        int a; cin>>a;
        if(a&1) cnt++;
    }
    if(cnt>=2) cout<<"Hom"<<endl;
    else cout<<"Tem"<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int ans = x;
  rep(i, n) {
    int a;
    cin >> a;
    ans += (d - 1) / a + 1;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception { new Main().run(); }
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println((a*b) + " " + (a*2+b*2));
	}
}



Measured memory_bytes: 26216
import bisect
from operator import itemgetter
import math
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,L = IL()

ans = 0
for i in range(N):
  ans += L + i
  num = L+i

if L < 0:
  if num > 0:
    print(ans)
  else:
    print(ans-num)
else:
  print(ans-L)

Measured memory_bytes: 21212
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  char a[10] ;
  scanf("%s",a);

  if(strcmp(a,"ABC") == 0 ){
    puts("ARC");
  }

  if(strcmp(a,"ARC") == 0 ){
    puts("ABC");
  }


    return 0;

}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  string S;
  cin >> S;
  bool ans = false;
  REP(i,2) {
    if(S[i]!=S[i+1]) ans = true;
  }
  if(ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

int main() {
    ll N,M;
    cin>>N>>M;
    vector<int> arr;
    arr.pb(1);
    REP(i,M-1){
        int n=arr.back()+2;
        if (N%2==0&&(n==N/2||N/2+1==n))++n;
        arr.pb(n);
    }
    REP(i,M) {
        cout << N/2 -i << " " << N/2-i + arr[i]<<endl;
    }
}


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

public class AtCoderD
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int x = sc.NextInt();
        int y = sc.NextInt();

        int[] answers = new int[n];

        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                int dist = 0;
                if (j <= x || y <= i)
                {
                    dist = j - i;
                }
                else if (i <= x && x <= j && j <= y)
                {
                    dist += x - i;
                    dist += Math.Min(1 + y - j, j - x);
                }
                else if (x <= i && i <= y && y <= j)
                {
                    dist += Math.Min(1 + i - x, y - i);
                    dist += j - y;
                }
                else if (i <= x && x <= y && y <= j)
                {
                    dist = x - i + 1 + j - y;
                }
                else
                {
                    dist += Math.Min(j - i, y - j + i - x + 1);
                }
                answers[dist]++;
            }
        }

        for (int i = 1; i <= n - 1; i++)
        {
            Console.WriteLine(answers[i]);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
#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 R;
    cin >> R;
    double leng;

    leng = 2 * 3.141 * R;

    cout << leng << endl;
    return 0;
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    long long ans = 0;
    std::vector< int > bit_exists(21, -1);
    int max = -1;
    for(int i=0; i<N; i++){
        for(int j=0; j<21; j++){
            
            int mask = 1 << j;
            if(A[i] & mask){
                if(max < bit_exists[j]){
                    max = bit_exists[j];
                }
                bit_exists[j] = i;
            }
        }
        ans = ans + i - max;
    }
    
    
    std::cout << ans << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

/*ll a[2000000];
int main() {
	ll n; scanf("%d", &n);
	ll Min = LLONG_MAX;
	rep(i, n) {
		scanf("%lld", &a[i]);

	}
	
}*/
char s[2000000];
bool flag[2000000];
int main() {
	scanf("%s", s);
	priority_queue<P, vector<P>, greater<P>>que;
	ll len = (ll)strlen(s);
	ll ans = len;
	rep(i, len - 1) {
		if (s[i] == 'S'&&s[i + 1] == 'T') {
			que.push(P(i, i + 1));
			ans -= 2;
		}
	}
	while (!que.empty()) {
		P i = que.top(); que.pop();
		if (flag[i.first] || flag[i.second])continue;
		flag[i.first] = flag[i.second] = true;
		for (; i.first >= 0 && flag[i.first]; i.first--);
		for (; i.second < len&&flag[i.second]; i.second++);
		if (i.first >= 0 && i.second < len&&s[i.first] == 'S'&&s[i.second] == 'T' && !flag[i.first] && !flag[i.second]) {
			que.push(P(i.first, i.second));
			ans -= 2;
		}
	}
	printf("%lld\n", max(0LL, ans));
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    vector<P> v;
    for(int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        v.push_back(P(c, b));
    }
    sort(all(v));
    reverse(all(v));
    int id = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(id < m && v[id].first > a[i]) {
            ans += v[id].first;
            v[id].second--;
        } else {
            ans += a[i];
        }
        if(id < m && v[id].second == 0) {
            id++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4084
package main

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

var (
	N, x, y, t int
	dx, dy, dt int
	answer     string
)

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	answer = "Yes"
	for i := 0; i < N; i++ {
		next()
		// fmt.Println(i, ok(dx, dy, dt), dt, dx, dy)
		if !ok(dx, dy, dt) {
			answer = "No"
		}
	}
	fmt.Println(answer)
}

func ok(dx, dy, dt int) bool {
	delta := AbsInt(dx) + AbsInt(dy)
	if (delta-dt)%2 != 0 {
		return false
	}
	if delta > dt {
		return false
	}
	return true
}

func next() {
	dt, dx, dy = nextInt(), nextInt(), nextInt()
	dx -= x
	dy -= y
	dt -= t
	x += dx
	y += dy
	t += dt
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

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


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

int n, k;

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

  if (n >= 10)
  {
    printf("%d\n", k);
  }
  else
  {
    printf("%d\n", k + 100 * (10 - n));
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
    int N;
    cin >> N;
    int A[220];
    rep(i, N) {
        cin >> A[i];
    }
    int coudim[220] = {};
    rep(i, N) {
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            coudim[i]++;
        }
    }
    cout << *min_element(coudim, coudim + N) << endl;
}

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

bool keta_check ( int a, vector<int> &s, vector<int> &c, int m) {
    vector<int> keta_num;
    while(1) {
        if ( a == 0 ) break;
        keta_num.push_back( a % 10 );
        a /= 10;
    }
    if ( keta_num.empty()) keta_num.push_back(0);
    reverse(keta_num.begin(), keta_num.end());
    rep(i, m) {
        if ( keta_num[s[i]] == c[i] ) {
            continue;
        }
        return false;
    } 
    return true;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<int> c(m);
    rep(i, m) {
        int tmp_s;
        cin >> tmp_s >> c[i];
        --tmp_s;
        s[i] = tmp_s;
    }
    int min_num = 1;
    rep(i, n-1) {
        min_num *= 10;
    }
    if ( n == 1 ) {
        min_num = 0;
    }
    int max_num = 1;
    rep(i, n) {
        max_num *= 10;
    }
    for ( int i = min_num; i < max_num; ++i ) {
        if ( keta_check ( i, s, c, m ) ) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  print_endline @@
  if List.for_all (fun a -> a mod 2 = 1 || a mod 3 = 0 || a mod 5 = 0) @@ Array.to_list as_
  then "APPROVED" else "DENIED"

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

int main() {
  int n;
  cin >> n;
  vector<int> vn;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    vn.push_back(tmp);
  }
  int m;
  cin >> m;
  vector<int> vm;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    vm.push_back(tmp);
  }

  if (includes(vn.begin(), vn.end(), vm.begin(), vm.end()))
  cout << 1 << endl;
  else
  cout << 0 << endl;
}


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

int main (void) {
    int n;
    
    cin >> n;
    vector<int> a(n); 
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(),a.end());
    double half = (double)a[n - 1] / 2;
    int mn = INT_MAX;
    int ans = 0; 
    for (int i = 0; i < n - 1; i++) {
        if (abs(a[i] - half) < mn) {
            mn = abs(a[i] - half);
            ans = i;
        }
    }
    cout << a[n - 1] << " " << a[ans] << endl;
    
    return 0;
}



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

using namespace std;

long long int N, M;

// 1  4  5  5  7  8 13 33 52 100
// 30 30 30 30 10 10
// 1 4
// 3 10
// 4 30

struct Cmd{
    Cmd(long long int b, long long int c)
        : B(b), C(c)
    {
    }

    long long int B;
    long long int C;
};

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

    std::vector<long long int> A;
    A.reserve(N);

    for(long long int i=0;i<N;i++){
        long long int tmp;
        cin >> tmp;
        A.emplace_back(tmp);
    }

    std::vector<Cmd> cmd;

    for(long long int i=0;i<M;i++){
        long long int b, c;
        cin >> b >> c;
        cmd.emplace_back(Cmd(b, c));
    }

    std::sort(A.begin(), A.end());

    std::sort(cmd.begin(), cmd.end(), [](Cmd lhs, Cmd rhs){ return lhs.C > rhs.C; });

    // for(long long int i=0;i<N;i++){
    //     cout << A[i] << endl;
    // }
    // for(long long int i=0;i<M;i++){
    //     Cmd& c = cmd[i];
    //     cout << c.B << "," << c.C << endl;
    // }

    long long int idx = 0;
    for(long long int i=0;i<M && idx < N;i++){
        Cmd& c = cmd[i];
        for(long long int j=0;j < c.B && idx < N; j++){
            if(A[idx] < c.C){
                A[idx] = c.C;
                idx++;
            }else{
                goto exit;
            }
        }
    }
exit:

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

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<deque>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef deque<int> di;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int i,j;
    string a,b,c;
    while(cin >> a, a != "0"){
        cin >> b;
        cin >> c;
        reverse(all(a));
        reverse(all(b));
        reverse(all(c));
        int n = a.size();
        vector<vi> dp(n+1,vi(2,0));
        dp[0][0]++;
        rep(i,n)rep(j,2)if(dp[i][j]){
            rep(x,10)rep(y,10){
                if(i == n-1 && (!x || !y))continue;
                if(a[i] != '?' && a[i] - '0' != x)continue;
                if(b[i] != '?' && b[i] - '0' != y)continue;
                if(c[i] != '?' && c[i] - '0' != (x + y + j)%10)continue;
                (dp[i+1][(x+y+j)/10] += dp[i][j]) %= MOD;
            }
        }

        cout << dp[n][0] << endl;
    }
}



Measured memory_bytes: 3204
import java.util.Scanner;

public class Main{
	static long mod = 1000000000 + 7;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int N = sc.nextInt(), K = sc.nextInt();
			int[] a = new int[N];
			for(int i = 0; i < N; i++) a[i] = sc.nextInt();
			long[][] dp = new long[N][K + 1];
			for(int i = 0; i <= a[N - 1]; i++) dp[N - 1][i] = 1;
			for(int i = N - 2; i >= 0; i--) {
				for(int j = 0; j <= K; j++) {
					if(j == 0) {
						dp[i][j] = dp[i + 1][j];
						continue;
					}
					dp[i][j] = dp[i + 1][j] + dp[i][j - 1];
					if(j - a[i] - 1 >= 0) {
						dp[i][j] -= dp[i + 1][j - a[i] - 1];
						dp[i][j] = (mod + dp[i][j]) % mod;
					}
					dp[i][j] %= mod;
				}
			}
			System.out.println(dp[0][K] % mod);
		}
	}
}

Measured memory_bytes: 127312
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n, x;

void solve() {
	cin >> n;
	int maxtill = 0, ans = 0;

	cin >> maxtill;
	for (int i = 0; i < n - 1; i++) {
		cin >> x;
		maxtill = max(maxtill, x);
		ans += abs(x - maxtill);
		// deb(ans);
	}


	cout << ans << endl;

}

int32_t main() {
	IOS;



	solve();

	return 0;
}




Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int n,m,i,j;
    char bef[100000];
    char aft[100000];
    char out[100000];
    while(scanf("%d",&n)!=EOF && n!=0){
        for(i=0;i<n;i++){
            scanf("%s %s",&bef[i],&aft[i]);
        }
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf("%s",&out[i]);
            for(j=0;j<n;j++){
                if(out[i]==bef[j]){
                    out[i]=aft[j];
                    break;
                }
            }
        }
        for(i=0;i<m;i++){
            printf("%c",out[i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e3+10;
int n;
int num[maxx];
int main() {
	scanf("%d",&n);
	rep(i,1,n+1){
		scanf("%d",&num[i]);
	}
	int cnt=0;
	rep(i,1,n+1){
		if(i&1){
			if(num[i]&1){
				cnt++;
			}
		}
	}
	cout<<cnt;
} 

Measured memory_bytes: 3804
/* god is with you dont worry */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define input() ios_base::sync_with_stdio(false);cin.tie(0);
const ll mod=1e9+7;
/*ll power(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1){
			res=res*x;
		}
		x=x*x;
		y=y/2;
	}
	return res;
}*/
void solve(){
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    int c=a+k-a%k;
    if(a%k==0 or b%k==0 or(c>=a and c<=b )){
    	cout<<"OK";
    }
    else
    cout<<"NG";
}
int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int>> c(100100,vector<int> (0));
int N;

//既に探索した部分をboolの配列で表現したところREとなった
//上記boolをやめて，一つ前のpositionをppで把握→ppを飛ばすとしても提出結果に変わりなし
void DFS(int p,int ans,int pp,vector<int> &d){
  d.at(p)=ans;
  for(int i:c.at(p)){
    if(i==pp){continue;}
    DFS(i,ans+1,p,d);
  }
  return;
}

vector<int> dist(int p){
  vector<int> d(N);
  DFS(p,0,-1,d);
  return d;
}

int main(){
  int T,A,ans=0;
  
  cin>>N>>T>>A;
  T--;A--;
  
  int s,t;
  for(int i=0;i<N-1;i++){
    cin>>s>>t;
    s--;t--;
    c.at(s).push_back(t);
    c.at(t).push_back(s);
  }
  
  vector<int> Td(N),Ad(N);
  Td=dist(T);
  Ad=dist(A);
  
  for(int i=0;i<N;i++){
    if(Td[i]<Ad[i]){ans=max(ans,Ad[i]-1);}
  }
  cout<<ans;
}

Measured memory_bytes: 12024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main(){
  ll N,K; cin>>N>>K;
  vi a(N); REP(i,N) cin>>a[i];
  ll appearingNum=0; vi times(K+1);
  ll l=0,r=0;
  ll ans=INF;
  while(r<N){
    while(appearingNum<K&&r<N){
      if(a[r]<=K){
        if(times[a[r]]==0) appearingNum+=1;
        times[a[r]]+=1;
      }
      r++;
    }
    while(appearingNum==K){
      ans=min(ans,r-l);
      if(a[l]<=K){
        if(times[a[l]]==1) appearingNum-=1;
        times[a[l]]-=1;
      }
      l++;
    }
  }
  if(ans==INF) ans=0;
  cout<<ans<<endl;
}

Measured memory_bytes: 4416
import java.util.Scanner;
import java.util.Stack;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().start();
	}
	final int L = 0;
	final int R = 1;
	void start(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String ss = in.next();
		Stack<Integer> s = new Stack<Integer>();
		for(int i = 0; i < n; i++){
			if(ss.charAt(i) == '(') s.push(L);
			if(ss.charAt(i) == ')'){
				if(!s.isEmpty()){
					int a = s.pop();
					if(a != L){
						s.push(R);
						s.push(R);
					}
				}else{
					s.push(R);
				}
			}
		}

		while(!s.isEmpty()){
			if(s.pop() == L) ss += ")";
			else ss = "(" + ss;
		}
		System.out.println(ss);
		in.close();
	}
}


Measured memory_bytes: 21844
import itertools
S = input()

ans = 0
for ptn in itertools.combinations(range(1,len(S)), 3):
    ai,bi,ci = ptn
    a = S[:ai]
    b = S[ai:bi]
    c = S[bi:ci]
    d = S[ci:]
    if a[0] == '0' and a != '0': continue
    if b[0] == '0' and b != '0': continue
    if c[0] == '0' and c != '0': continue
    if d[0] == '0' and d != '0': continue
    if not 0 <= int(a) <= 255: continue
    if not 0 <= int(b) <= 255: continue
    if not 0 <= int(c) <= 255: continue
    if not 0 <= int(d) <= 255: continue

    ans += 1
print(ans)



Measured memory_bytes: 5636
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons;
import core.bitop, std.datetime, std.range;

void main(){
    auto rd = readln.split.to!(int[]);
    auto n = rd[0], q = rd[1];
    auto ds = new int[][](n, 1);
    auto n2s = iota(n).array;

    foreach(i ; 0 .. n){
        ds[i][0] = i;
    }

    foreach(lp ; 0 .. q){
        rd = readln.split.to!(int[]);
        auto c = rd[0], x = rd[1], y = rd[2];

        if(c == 0){
            merge(ds, n2s, x, y);
        } else{
            writeln(n2s[x] == n2s[y] ? 1 : 0);
        }
    }

    //writefln("%(%s\n%)", ds);
}

void merge(int[][] ds, int[] n2s, int x, int y){
    auto u = n2s[x];
    auto v = n2s[y];

    if(u == v) return;

    if(u > v) swap(u, v);

    ds[v].length += ds[u].length;
    ds[v][$ - ds[u].length .. $] = ds[u];
    foreach(z ; ds[u]){
        n2s[z] = v;
    }
    delete ds[u];
}

Measured memory_bytes: 11096
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	int subA[4],subB[2];

	for(int i=0; i < 4; i++)scanf("%d",&subA[i]);
	for(int i=0; i < 2; i++)scanf("%d",&subB[i]);

	for(int i = 1; i <= 3; i++){
		for(int k = 3; k >= i; k--){
			if(subA[k] > subA[k-1]){
				swap(subA[k],subA[k-1]);
			}
		}
	}
	if(subB[1] > subB[0])swap(subB[1],subB[0]);

	printf("%d\n",subA[0]+subA[1]+subA[2]+subB[0]);

    return 0;
}

Measured memory_bytes: 2664
// 2011/05/25 Tazoe

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int mag[15][15];
		for(int i=0; i<n; i++)
			for(int j=0; j<n; j++)
				mag[i][j] = 0;

		int i = n/2+1;
		int j = n/2;
		mag[i][j] = 1;

		for(int k=2; k<=n*n; k++){
			i++;
			if(i==n)
				i = 0;
			j++;
			if(j==n)
				j = 0;

			if(mag[i][j]==0){
				mag[i][j] = k;
			}
			else{
				while(mag[i][j]!=0){
					i++;
					if(i==n)
						i = 0;
					j--;
					if(j==-1)
						j = n-1;
				}
				mag[i][j] = k;
			}
		}

		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++)
				cout << setw(4) << mag[i][j];
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 101

int A[N][N],x;



int main(){

  int i,j,v,g,u;

  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    for(j=0;j<x;j++){
      A[i][j]=0;
    }
  }
  
  for(i=0;i<x;i++){
    scanf("%d",&u);
    scanf("%d",&v);
    for(j=0;j<v;j++){
      scanf("%d",&g);
      A[u-1][g-1]=1;
    }
  }
  for(i=0;i<x;i++){
    for(j=0;j<x;j++){
      if(j==x-1)printf("%d\n",A[i][j]);
      else printf("%d ",A[i][j]);
      
    }
  }
  return 0;
}



Measured memory_bytes: 2112
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 100 * 1000 + 9;
const string FILENAME = "sample";

string s;

void read(){
	cin >> s;
}

void solv(){
	int k = s.size();
	int cnt = 0;
	for(int i = 0; i < k; i++){
		cnt += (s[i] == 'o');
	}

	if(15 - k + cnt >= 8){
		cout << "YES\n";
		return;
	}

	cout << "NO\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string S;
	cin >> S;
	int N = S.size();
	char c = S[0];
	int i = 1;
	int res = 0;
	while (i < N) {
		while (i < N && S[i] == c) i++;
		if (i < N) {
			res++;
			c = S[i++];
		}
	}
	cout << res << "\n";

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin>>n>>k;
  vector<int> p(n);
  rep(i,n) cin>>p.at(i);
  int summ = 0, sum = 0;
  rep(i, n){
    if(i<k){
      sum+=p.at(i);
      summ=sum;
    }
    else{
      sum=sum + p.at(i) - p.at(i-k);
      if(summ<sum) summ = sum;
    }
  }
  double ans = 0.5*(summ+k);
  cout<<fixed<<setprecision(2);
  cout<<ans<<endl;
}

Measured memory_bytes: 3960
if __name__ == '__main__':
    maxL = 0
    maxF = 0
    strlst = list(map(str, input().split()))
    for s in strlst:
        if strlst.count(s) > maxF:
            maxF = strlst.count(s)
            maxFans = s
        if len(s) > maxL:
            maxL = len(s)
            maxLans = s
    print(maxFans, maxLans)


Measured memory_bytes: 5548
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<lint> a(n);
    REP(i,n) cin >> a[i];
    lint sum = 0;
    lint h = a[0];
    FOR(i,1,n){
        if(h > a[i]){
            sum += h - a[i];
        }else{
            h = a[i];
        }
    }
    println(sum);
    return 0;
}

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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

ll max3(ll a, ll b, ll c) {
  return max(a, max(b, c));
}

ll min3(ll a, ll b, ll c) {
  return min(a, min(b, c));
}

const int maxn = 1e6 + 10;
const ll INF = 1e16 * -1;
int n;
ll sum[maxn], rig[maxn];
ll a[maxn];
ll dp[maxn];
ll dp2[maxn];

void solve() {
  cin >> n;
  a[0] = sum[0] = 0;
  for (int i = 1; i <= 3 * n; ++i) {
    cin >> a[i];
    sum[i] = a[i] + sum[i - 1];
  }
  rig[3 * n + 1] = 0;
  for (int i = 3 * n; i >= 1; --i) {
    rig[i] = a[i] + rig[i + 1];
  }

//  for (int i = 1; i <= 3 * n; ++i) {
//    printf("%d %d %d\n", a[i], sum[i], rig[i]);
//  }

  priority_queue<ll, vector<ll>, greater<ll> > q;
  dp[0] = INF;
  for (int i = 1; i <= n; ++i) {
    dp[i] = INF;
    q.push(a[i]);
  }

  dp[n] = sum[n];
  for (int i = n + 1; i <= 2 * n; ++i) {
    int mini = q.top();
    if (mini < a[i]) {
      dp[i] = dp[i - 1] - mini + a[i];
      if (!q.empty()) {
        q.pop();
      }
      q.push(a[i]);
    } else {
      dp[i] = dp[i - 1];
    }
  }

  priority_queue<ll> q2;
  dp2[3 * n] = INF * -1; //できるだけ最小に
  for (int i = 3 * n; i >= 2 * n + 1; --i) {
    dp2[i] = INF * -1;
    q2.push(a[i]);
  }
  dp2[2 * n + 1] = rig[2 * n + 1];
  for (int i = 2 * n; i >= n + 1; --i) {
    int maxi = q2.top();
    if (maxi > a[i]) {
      dp2[i] = dp2[i + 1] - maxi + a[i];
      if (!q2.empty()) {
        q2.pop();
      }
      q2.push(a[i]);
    } else {
      dp2[i] = dp2[i + 1];
    }
//    printf("dp2[%2d] = %2d\n", i, dp2[i]);
  }
  ll ans = INF;
  for (int i = n; i <= 2 * n; ++i) {
//    printf("%3d\t%3d\t%3d\n", a[i], dp[i], dp2[i + 1]);
    ans = max(ans, dp[i] - dp2[i + 1]);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 21620
#include<bits/stdc++.h>
using namespace std;
int f[3005][3005][2],ms=1e9+7;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	f[0][0][1]=1;
	for (int i=1;i<=n;i++)
	f[0][i][0]=1;
	for (int i=0;i<=m;i++)
	for (int j=0;j<=n;j++)
	for (int k=0;k<=1;k++){
		if (j) (f[i+1][j-1][!(j-1)|k]+=f[i][j][k])%=ms;
		if (n-j) (f[i+1][j+1][k]+=f[i][j][k])%=ms;
		if (j) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=ms;
		if (n-j) (f[i+1][j][k]+=f[i][j][k])%=ms;
	}
	int ans=0;
	for (int i=0;i<=n;i++)
	(ans+=f[m][i][1])%=ms;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  string S;
  int N,Z=0;
  cin>>S>>N;
  vector<char> p(S.size());
for (int i=0;i<S.size();i++) {
  p.at(i)=S.at(i);
}
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a==1){
      Z++;
    }
    else{
      int b;
      char x;
      cin>>b>>x;
      if((b+Z-1)%2==0){
        p.insert(p.begin(),x);
      }
      else{
        p.push_back(x);
      }
    }
  }
  if(Z%2==1){
        reverse(p.begin(), p.end());
      }
  for(int i=0;i<p.size();i++){
    cout<<p.at(i);
  }
  cout<<endl;
    
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


vector< LL > divisor(LL n) {
  vector< LL > ret;
  for(LL i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main(){
    int N;cin >> N;
    int ans = 0;
    for(int i = 1;i <= N;i++){
        if(i % 2 == 0)continue;
        auto v = divisor(i);
        if(v.size() == 8)ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
int mx = 102;
int main()
{
    ll n, w, wi[mx], vi[mx], sum = 0;
    cin >> n >> w;
    for(ll i = 0; i < n; i++)
    {
        cin >> wi[i] >> vi[i];
        sum += vi[i];
    }
    vector<ll> dp(sum + 1, INF);
    dp[0] = 0;
    for(ll i = 0; i < n; i++)
    {
        for(ll j = sum; j >= 0; j--)        
        {
            if(j - vi[i] >= 0)
            {
                dp[j] = min(dp[j],  wi[i] + dp[j - vi[i]]);
            }
        }
    }
    for(ll j = sum; j >= 0 ; j--)
        if(dp[j] <= w)
        {
            cout << j << '\n';
            break;
        }
}


Measured memory_bytes: 1024
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n = int(input())
if n == 1:
    print(1)
    exit()
cnt = [0] * (n+1)
for i in range(1, n+1):
    val = 1
    arr = factorization(i)
    for j in arr:
        cnt[j[0]] += j[1]
ans = 1
for i in range(2, n+1):
    ans *= cnt[i] + 1
    if ans >= 10**9+7:
        ans %= 10**9+7
print(ans)


Measured memory_bytes: 3064