akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ll n,q;
	cin>>n>>q;
	string s;
	ll l[q],r[q];
	cin>>s;
	for(ll i=0;i<q;i++)cin>>l[i]>>r[i];
	ll cnt=0,plc[n];
	for(ll i=0;i<n;i++)plc[i]=0;
	for(ll i=0;i<n-1;i++){
		plc[i+1]=plc[i];
		if(s[i]=='A'&&s[i+1]=='C'){
			cnt++;
			plc[i+1]++;
		}
		//cout<<"i:"<<i<<" olc:"<<plc[i]<<endl;
	}
	//cout<<cnt<<endl;
	ll res =0;
	for(ll i=0;i<q;i++){
		res = 0;
		res = (plc[r[i]-1])-(plc[l[i]-1]);
		cout<<res<<endl;
	}

}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f;

string s;
bool ok(int k)
{
    if(k<(int)s.size()/2)return 0;
    int one=0,zero=0;
    for(int i=s.size()-k;i<k;i++)
    {
        if(s[i]=='0')zero++;
        else one++;
    }
    if(zero==2*k-s.size()||one==2*k-s.size())return 1;
    else return 0;
}
int main()
{
    fio;
    cin>>s;
    int l=0,r=s.size()+1;
    while(l<r-1)
    {
        int m=(l+r)>>1;
        if(ok(m))l=m;
        else r=m;
    }
    cout<<l<<"\n";
    return 0;
}
/********************

********************/


Measured memory_bytes: 512
#include<cctype>
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int decode(string s){
	int a=1,ans=0;
	for(int i=0;i<s.length();i++){
		if(isdigit(s[i]))	a=s[i]-'0';
		if(s[i]=='m')		ans+=a*1000,a=1;
		if(s[i]=='c')		ans+=a*100,a=1;
		if(s[i]=='x')		ans+=a*10,a=1;
		if(s[i]=='i')		ans+=a*1,a=1;
	}
	return ans;
}

string encode(int a){
	char v[5],*b="mcxi";
	sprintf(v,"%04d",a);
	string s;
	for(int i=0;i<4;i++){
		if(v[i]>'1')	s+=v[i];
		if(v[i]>'0')	s+=b[i];
	}
	return s;
}

int main(){
	int n;	cin>>n;
	while(n--){
		int ans=0;
		for(int i=0;i<2;i++){
			string s;	cin>>s;
			ans+=decode(s);
		}
		cout<<encode(ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main
import (
    "fmt"
)

func main(){
  var L int
  fmt.Scan(&L)
  A := make([]int,L)
  DP := make([][]int,L)
  for i:=0;i<L;i++{
    DP[i] = make([]int,5)
  }
  for i:=0;i<L;i++{
    fmt.Scan(&A[i])
    kisuuflag := A[i]%2
    if A[i] == 0{
      kisuuflag = 2
    }
    guusuuflag := (A[i] + 1 )%2
    if i==0{
      DP[i][0] = A[i]
      DP[i][1] = kisuuflag
      DP[i][2] = guusuuflag
      DP[i][3] = kisuuflag
      DP[i][4] = A[i]
      continue
    }
    DP[i][0] = DP[i-1][0] + A[i]
    var min int
    if DP[i-1][0] < DP[i-1][1]{
      min = DP[i-1][0]
    }else{
      min = DP[i-1][1]
    }
    DP[i][1] = min + kisuuflag
    if DP[i-1][2] < min{
      min = DP[i-1][2]
    }
    DP[i][2] = min+guusuuflag
    if DP[i-1][3] < min{
      min = DP[i-1][3]
    }
    DP[i][3] = min+kisuuflag
    if DP[i-1][4] < min{
      min = DP[i-1][4]
    }
    DP[i][4] = min+A[i]
  }
  var min int
  if DP[L-1][0] < DP[L-1][1]{
    min = DP[L-1][0]
  }else{
    min = DP[L-1][1]
  }
  if DP[L-1][2] < min{
    min = DP[L-1][2]
  }
  if DP[L-1][3] < min{
    min = DP[L-1][3]
  }
  if DP[L-1][4] < min{
    min = DP[L-1][4]
  }
  fmt.Println(min)
  return
}


Measured memory_bytes: 27136
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = getLine >> readLine >>= print . solve

solve :: [Int] -> Int
solve hs
    | all (== 0) hs = 0
    | otherwise = edit0 . dropWhile (== 0) . map head $ group hs
    where
        edit0 (x : y : zs) = count0 $ x : edit x (y : zs)
        edit0 [x] = x

        edit p (x : y : zs)
            | (p < x && x > y) || (p > x && x < y) = x : edit x (y : zs)
            | otherwise = edit x $ y : zs
        edit _ xs = xs

        count0 (x : y : zs)
            | x > y = x + count (y : zs)
            | otherwise = x + count (x : y : zs)
        
        count (x : y : zs) = y - x + count zs
        count _ = 0

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b

def main():
    X, Y = map(int, input().split())
    print(X + Y // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S.at(S.size() - 1) == 's'){
    S += "es";
  }else{
    S += 's';
  }
  
  cout << S;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;

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

	int ans=0;

	for (int i = 1;i <= n;i++) {
		ans += n / i;
		if (n % i == 0)ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 2019;
ll pow_mod(ll x,ll y){
    if(y==0){
        return 1; 
    }
    else if(y&1){
        return (x*pow_mod(x,y-1))%mod;
    }
    else{
        return (ll)powl(pow_mod(x,y/2),2)%mod;
    }
}

int main(){
string S;
cin>>S;
ll table[S.size()];
repr(i,S.size()){
    table[i]=((S[i]-'0')*pow_mod(10,S.size()-1-i))%mod;
    
}
ll count=0;
ll sum=0;
map<ll,int> m;
m[0]++;
rep(i,S.size()){
    sum+=table[i];
    sum%=mod;
    count+=m[sum];
    m[sum]++;

}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 5312
from collections import deque

s = deque(input())
q = int(input())
counter = 1
lista = [list(input().split()) for i in range(q)]

def rever(i):
    if i == '1':
        return 1
    else:
        return -1
for i in lista:
    if i[0] == '1':
        counter = -1 * counter
    else:
        if counter * rever(i[1]) > 0:
            s.appendleft(i[2])
        else:
            s.append(i[2])
s = "".join(list(s))
if counter > 0:
    print(s)
else:
    print(s[::-1])

Measured memory_bytes: 115288
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int n;

int main(){
	cin >> n;
	printf("%.7lf\n", 1.0 * ((n + 1) / 2) / (1.0 * n));
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    
    int x, y, z;
    map<long long, long long> ans;
    for (x = 1; x <= 100; x++)
    {
        for (y = 1; y <= 100; y++)
        {
            for (z = 1; z <= 100; z++)
            {
                long long a = x*x + y*y + z*z + x*y + y*z + z*x;
                ans[a]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 6084
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, D, X[10][10] = {}, ANS = 0;
	cin >> N >> D;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) cin >> X[i][j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int COUNT = 0;
			for (int k = 0; k < D; k++) {
				COUNT += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			if (COUNT == (int)sqrt(COUNT) * (int)sqrt(COUNT)) ANS++;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    ull A=0,B=0;
    cin >> A >> B;
    if((A+B)%2) cout << "IMPOSSIBLE" << endl;
    else cout << (A+B)/2 << endl;
}

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

int main(){
  std::string s;
  std::cin >> s;

  int a=0, b=0;
  char x;
  for(int i = 0; i < s.size(); i++){
    if(i%2 == 0) x = '0';
    else x = '1';
    if(s[i] == x) a++;
  }
  for(int i = 0; i < s.size(); i++){
    if(i%2 == 0) x = '1';
    else x = '0';
    if(s[i] == x) b++;
  }
  std::cout << std::min(a, b) << std::endl;

 return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<vi> a(n, vi(m));
	cin >> a;
	for (auto &v : a)
	{
		for (auto &i : v) i--;
	}
	set<int> unuse;
	int ans = n;
	while (unuse.size() < m)
	{
		vi cnt(m);
		REP(i, n)
		{
			REP(j, m)
			{
				if (unuse.count(a[i][j]) == 0)
				{
					cnt[a[i][j]]++;
					break;
				}
			}
		}
		chmin(ans, *max_element(ALL(cnt)));
		unuse.insert(max_element(ALL(cnt)) - cnt.begin());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int n = saori.saori_hayami();
		int m = saori.saori_hayami();
		double nn = n%12*30 + 0.5*m;
		double mm = 6*m;
		double ans = Math.abs(nn-mm);
		if(ans > 180){
			ans = 360 - ans;
		}
		if(ans < 0){
			ans *= -1;
		}
		
		ans = Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(ans));
		System.out.println(Math.sqrt(ans));

		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 33168
/*
  B問題
*/

#include<stdio.h>

int main() {
    //変数の宣言
    int n; //木の本数
    int d; //範囲的なやつ
    int num; //カウンタ変数
    int range;

    scanf("%d %d",&n,&d);

    range = d * 2 +1;
    
    num = n / range;
    
    if(n%range != 0){
        num++;
    }
    
    printf("%d\n",num);

    return 0;
}


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

typedef long long ll;

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

    ll a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

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

  int ans = 0;
  for (int i = 0; i < N; i++) ans += abs(A[i]);
  if (A[0] > 0) ans -= A[0] * 2;
  if (A[N - 1] < 0) ans += A[N - 1] * 2;
  cout << ans << endl;

  int now = A[0];

  for (int i = 1; i < N - 1; i++) {
    if (A[i] >= 0) {
      cout << now << " " << A[i] << endl;
      now -= A[i];
    }
  }

  cout << A[N - 1] << " " << now << endl;
  now = A[N - 1] - now;

  for (int i = 1; i < N - 1; i++) {
    if (A[i] < 0) {
      cout << now << " " << A[i] << endl;
      now -= A[i];
    }
  }
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

int pedras[100100];
int dp[100100]; ///Guardo os valores da funcao frog;

int n,k;
const int inf =1e9;

int main(){

    ///memset(dp,inf,sizeof(dp));
    cin >>n>>k;

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

    ///Comeca aki a bagaca
    dp[n-1]=0;

    for(int i=n-2;i>=0;i--){

        int menor=inf;

        for(int j=1;j<=k;j++){
            if(i+j<=n-1){
                int cost = abs(pedras[i]-pedras[i+j]);
                ///dp[i]=min(dp[i],dp[i+j]+cost);
                menor = min(menor,dp[i+j]+cost);
            }
        }

        dp[i]=menor;
    }

    cout<<dp[0];

}



Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

ll gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int n;string s;
    cin>>n>>s;
    ll a[404]={},ans=0;
    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R'){
            r++;
            ans+=b*g;
        }
        if(s[i]=='B'){
            b++;
            ans+=r*g;
        }
        if(s[i]=='G'){
            g++;
            ans+=b*r;
        }
        int q=2,w=1;
        while(i-q>=0){
            if(s[i-q]!=s[i]&&s[i-w]!=s[i]&&s[i-q]!=s[i-w]){
                ans--;
            }
            q+=2;w+=1;
        }
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<P> p(n);
	vector<bool> used(m);
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	sort(p.begin(), p.end());
	priority_queue<ll> que;
	int now = 0;
	ll ans  = 0;
	for (int i = m - 1; i >= 0; i--) {
		while (now < n && i + p[now].first <= m) {
			que.push(p[now].second);
			now++;
		}
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  int ans=0;
  int flag=0;
  int n=S.size();
  for(int i=1;i<n;i++){
    if(S[i]-'0'!=9){
    flag=1;
    }
  }
  if(flag==1){
    ans=S[0]-'0'-1+(n-1)*9;
    cout << ans << endl;
    return 0;
  }
  ans=9*(n-1)+S[0]-'0';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using vll = vector<long long>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using vpi = vector<pair<int, int> >;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i=(a); i <=(b); i++)
#define F0R(i, a) for (int i=0; i < (a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    int n = s[s.length() -1] - 48;
    if (n == 1 || n == 6 || n == 8 || n == 0) {
        cout << "pon" << nl;
    }
    else if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << nl;
    }
    else {
        cout << "bon" << nl;
    }

    return 0;

}



Measured memory_bytes: 3620
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    account = 1000
    stock = 0

    inc_list = [1 if (A[i] < A[i+1]) else 0 for i in range(n-1)]
    for i in range(n):
        if(i < n-1 and inc_list[i] == 1):
            if(stock == 0):
                stock = int(account / A[i])
                account %= A[i]
        else:
            if(stock != 0):
                account += stock * A[i]
                stock = 0
    print(account)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9172
n, k, l = map(int, input().split())
load = [-1] * (n + 1)
train = [-1] * (n + 1)

def find_load(x, u = load):
    if u[x] < 0 :
        return x
    else:
        u[x] = find_load(u[x])
        return u[x]

def find_train(x, u = train):
    if u[x] < 0 :
        return x
    else:
        u[x] = find_train(u[x])
        return u[x]

for i in range(k):

    p, q = map(int, input().split())
    p, q = map(find_load, [p, q])
    p, q = sorted((p, q))
    if p != q:
        load[q] = p

load = [i if x < 0 else x for i, x in enumerate(load)]

for i in range(l):
    r, s = map(int, input().split())
    r, s = map(find_train, [r, s])
    r, s = sorted((r, s))
    if r != s:
        train[s] = r
train = [i if x < 0 else x for i, x in enumerate(train)]

keys = []
dic  = {}

for node in range(n):
    key = (find_load(load[node + 1]), find_train(train[node + 1]))
    keys.append(key)
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1

ans = [str(dic[key]) for key in keys]
print(" ".join(ans))

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

int main() {
int m1,d1,m2,d2;
cin>>m1>>d1;
cin>>m2>>d2;
if(m2==m1+1 || m2==1 && m1==12){
    cout<<1<<endl;
}
else
cout<<0<<endl;

return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    string S;
    cin >> S;

    ll s = S.size();

    ll r = 0, g = 0, b = 0;
    REP(i,s) if(S[i]=='R') r++;
    REP(i,s) if(S[i]=='G') g++;
    REP(i,s) if(S[i]=='B') b++;

    ll ans = r * g * b;
    ll cnt = 0;

    for(int i =0; i < N-2;i++){
      for(int k =0; i+k+k<N;k++){
        if(S[i]!=S[i+k]&&S[i+k]!=S[i+k+k]&&S[i]!=S[i+k+k]) ans --;
      }      
    }
    //本文
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    ll ans=0;
    if(n==1){
        if(a==b)
            ans=1;
        else
            ans=0;
    }
    else if(b<a)
        ans=0;
    else
        ans=(n-2)*(b-a)+1;
    printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, M;
ll a[100000];

ll gcd(ll x, ll y) {
	if (y)return gcd(y, x%y);
	return x;
}

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

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] & 1) {
			cout << 0 << endl;
			return 0;
		}
		a[i] /= 2;
	}
	ll t = a[0];
	for (int i = 1; i < N; i++) {
		t = lcm(t, a[i]);
		if (t > M) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (!((t / a[i]) & 1)) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << M / t - M / (t + t) << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int x,a,b,r,s;
    while(scanf("%d %d %d",&x,&a,&b)==3)
    {
        r=abs(x-a);
        s=abs(x-b);
        if(r<s)printf("A\n");
        else
            printf("B\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	long int x;
	cin >> x;
	unsigned long long int i,y,z,w;
	vector<unsigned long long int> aaa(x);
	for (i = 0; i < x; i++) {
		cin >> aaa[i];
		if (aaa[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	y = 1;
	for (i = 0; i < x; i++) {
		z = aaa[i];
		w = 1000000000000000000 / y;
		if (w >= z) {
			
			y*= z;
			
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

int k;
struct edge { int to, cost; };
typedef pair<int, int> P;
int V;
vector<edge> G[100000];
int d[100000];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	REP(i,k) 
		d[i] = 100000000;
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	cin >> k;

	REP(i,k) {
		int next = i + 1;
		next %= k;
		if(i == next) 
			continue;
		G[i].pb((edge){next,1});
	}
	REP(i,k) {
		int next = i * 10;
		next %= k;
		if(i == next) 
			continue;
		G[i].pb((edge){next,0});
	}

	dijkstra(1);
	cout << d[0] + 1 << endl;
	return 0;
}


Measured memory_bytes: 6780
#include<stdio.h>
main(){
  int i,n=0,q=0,c[512],a=0,b=0;
  char s[1024],t[512][32],*p;
  fgets(s,1024,stdin);
  for(;;){
    p=strchr(s+q,' ');
    if(!p)
      p=s+strlen(s)-1;
    strncpy(t[n],s+q,p-s-q);
    for(i=0;i<n;i++)
      if(strcmp(t[i],t[n])==0){
    c[i]++;
    break;
      }
    if(i==n){
      c[i]=1;
      n++;
    }
    q=p-s+1;
    if(p==s+strlen(s)-1)
      break;
  }
  for(i=1;i<n;i++){
    if(c[i]>c[a])
      a=i;
    if(strlen(t[i])>strlen(t[b]))
      b=i;
}
printf("%s %s\n",t[a],t[b]);
return 0;
}

Measured memory_bytes: 552
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <bits/stdc++.h>

using namespace std;

class CManyFormulas {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        long long ans = 0;
        for (int i = 0; i < pow(2, s.size() - 1); ++i) {
            vector<char> vec(10, '=');
            bitset<10> bits(i);
            for (int j = 0; j < 10; ++j) {
                if (bits[j] == 1) {
                    vec[j] = '+';
                }
            }
            long long digit = 1;
            for (int k = 0; k < s.size(); k++) {
                long long tmp = (s[k] - '0');
                tmp *= digit;
//                long tmp = ('1') * digit;
                ans += tmp;
                if (vec[k] == '=') {
                    digit *= 10;
                } else {
                    digit = 1;
                }
            }
        }
        cout << ans << endl;
    }
};


int main() {
	CManyFormulas solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>


//# define __TRR__

# define lint  long long int



using namespace std;


lint n, m, q, h, s, d, sum, sum1;


int main ()
{
# ifdef __TRR__
   freopen ("A.TXT", "r", stdin);
   freopen ("A.OUT", "w", stdout);
# endif

   cin >> q >> h >> s >> d >> n;

   m = n / 2;
   sum = m * 8 * q;
   if ( m * 4 * h < sum )
      sum = m * 4 * h;

   if ( m * 2 * s < sum )
      sum = m * 2 * s;

   if ( m * d < sum )
      sum = m * d;

   m = n % 2;

   if ( m * 4 * q < m * 2 * h )
      sum1 = m * 4 * q;
   else
      sum1 = m * 2 * h;

   if ( m * s < sum1 )
      sum1 = m * s;

# ifdef __TRR__
   cout << q << " " << h << " " << s << " " << d << " " << n << endl;
   cout << sum << endl;
   cout << sum1 << endl;
# endif

   sum += sum1;

   cout << sum;

//system ("pause");
   return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;

fn main() {
    input!(mut A: i32, B: i32, mut C: i32, D: i32);
    let mut t = 0;
    loop {
        if t == 0 {
            C -= B;
            if C <= 0 {
                println!("Yes");
                break
            }
        } else {
            A -= D;
            if A <= 0 {
                println!("No");
                break
            }
        }
        t = 1 - t
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 114514191945;

vector<ll > dist;
vector<bool > seen;

void dfs(vector<vector<ll >> G, ll idx, ll from = -1){
    if(seen[idx] == true) return;
    seen[idx] = true;
    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i];
        dfs(G, to, idx);
    }
}

//ベルマンフォード
bool bellman(vector<vector<pi > > G, ll start, ll N){
    //初期化
    dist[start] = 0;
    
    for(ll i = 0; i < N; i++){
        for(ll from = 0; from < N; from++){
            for(ll j = 0; j < G[from].size(); j++){
                ll to = G[from][j].first;
                ll cost = G[from][j].second;
                if(dist[from] != INF && dist[to] > dist[from] + cost){
                    dist[to] = dist[from] + cost;
                    if(i == N - 1){
                        //負の経路が会って頂点の数以上にループが回ってしまう
                        return false;
                    }
                }
            }       
        }
    }

   return true;

}

int main() {
    //探査開始点
    ll N, M, P; 
    cin >> N >> M >> P;

    vector<vector<ll > > front(N);
    vector<vector<ll > > back(N);
    vector<vector<pi> > tmpG(N);
    dist.assign(N, INF);

    for(ll i = 0; i < M; i++){   
        ll u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        //
        ll t_w = P - w;
        front[u].push_back(v);
        back[v].push_back(u);
        //今回は有向グラフ
        tmpG[u].push_back(make_pair(v, t_w));
    }

    //ゴール地点から辿ってスタート地点までに経由する頂点を列挙
    vector<bool > tmpSeen;
    seen.assign(N, false);
    dfs(front, 0);

    tmpSeen = seen;

    seen.assign(N, false);
    dfs(back, N - 1);

    //グラフを再構築する
    for(ll i = 0; i < N; i++){
        seen[i] = seen[i] & tmpSeen[i]; 
    }

    vector<vector<pi> > newG(N);
    for(ll i = 0; i < N; i++){   
        if(seen[i] == false) continue;
        for(ll j = 0; j < tmpG[i].size(); j++){
            if(seen[tmpG[i][j].first] == false) continue;
            newG[i].push_back(tmpG[i][j]);
        }
    }

    //cout << newG.size() << endl;
    
    if(bellman(newG, 0, newG.size()) == false){
        cout << "-1" << endl;
    }else{
        cout << max(-1 * dist[newG.size()-1], ll(0)) << endl;
    }

    /*
    for(ll i = 0; i < N; i++){
        cout << dist[i] << endl;
    }
    */

}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int a, b, c;
    cin>>a>>b>>c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << "\n";
    return 0;
}



Measured memory_bytes: 764
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        l: u32,
        r: u32,
    }

    let mut ans = 2020;
    'outer: for i in l..r.min(l + 2019) {
        for j in l + 1..(r + 1).min(l + 2019) {
            ans = ans.min(((i % 2019) * (j % 2019)) % 2019);
            if ans == 0 {
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;
        
    int n;
    cin >> n;
    vi L;
    FOR(i, 0, n) {int x; cin >> x; L.pb(x);}
    int size = L.size();
    // FOR(i, 0, size) {
    //     FOR(j, i+1, size) {
    //         if (L[i] == L[j]) {L.erase(L.begin() + j, L.begin()+j+1); size--;}
    //     }
    // }
    int answer = 0;
    FOR(i, 0, size) {
        FOR(j, i+1, size) {
            FOR(k, j+1, size) {
                if (!(L[i] == L[j] || L[j] == L[k] || L[i] == L[k])) {
                    if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[i] + L[k] > L[j]) {
                        cerr << i << " " << j << " " << k << "\n";
                        answer++;
                    }
                }
            }
        }
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 3548
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

x = input_numbers()

ans = (x[0] - 1) * (x[1] - 1)

print(ans)

Measured memory_bytes: 12500
#include<stdio.h>
int main(){
  int a,b;
  int s,c=0;
  while(scanf("%d %d",&a,&b)!=EOF){
    s=a+b;
    c=0;
    while(s!=0){
      s/=10;
      c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long ans = a[0];
        for (int i = 0; i < n; i++)
        {
            ans = Gcd(ans, a[i]);
        }
        Console.WriteLine(ans);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
        {
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        }
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}


Measured memory_bytes: 20832
import sys
import math

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    minv = 10
    sumv = 0
    for i in range(5):
        tmp = INT()
        if tmp % 10 > 0:
            minv = min(minv, tmp%10)
        sumv += math.ceil(tmp/10) * 10
    print(sumv - 10 + minv)



if __name__ == '__main__':
    main()


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

/* macros */
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vt vector
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define tc int t;cin>>t;while (t--){solve();}
#define notc solve();
#define newline cout << "\n";
#define mod 1000000007
#define ret return 0;
#define sz(x) (int)x.size();
#define rep(i,a,b) for(int i=a;i<b;i++)
#define srt(x) sort(x.begin(), x.end())
#define rsrt(x) sort(x.rbegin(), x.rend())

void solve(){
    int n;
    cin>>n;
    vi nums(n);
    rep(i,0,n) cin>>nums[i];
    int last = nums[0];
    int ans = 0;
    rep(i,1,n) {
        if (last > nums[i]){
            ans += last - nums[i];
        }else{
            last = nums[i];
        }
    }
    cout << ans << "\n";
}

int32_t main(){
    fastio
    notc
    ret
}


Measured memory_bytes: 4772
// includes {{{
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

string operator*(string a, int t) {
  string r;
  while(t) {
    if(t&1) r += a;
    a += a;
    t >>= 1;
  }
  return r;
}

string sol(int x, int y, int z, string a, string b, string c) {
  if(y + z == 0) return a * x;
  if(x == 0) return sol(y, z, 0, b, c, "");
  int p = x / (y + z);
  int q = x % (y + z);
  string t = a * p;
  if(q < z) {
    // aa...ac, aa...b, aa...c
    return sol(q, y, z - q, t + a + c, t + b, t + c);
  } else {
    // aa...ac, aa...ab, aa...b
    return sol(q - z, z, y - (q - z), t + a + b, t + a + c, t + b);
  }
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int x, y, z;
  cin >> x >> y >> z;
  cout << sol(x, y, z, "a", "b", "c") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;

int main(){
    /*B
    int n;
    cin>>n;
    int p=n%10;
    if(p==2||p==4||p==5||p==7||p==9) cout<<"hon"<<endl;
    else if (p==0||p==1||p==6||p==8) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
    */
   /*C
   int k;
   string s;
   cin>>k>>s;
   int l=s.length();
   if (l<=k) cout<<s<<endl;
   else cout<<s.substr(0,k)+"..."<<endl;
   */
  //C
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double pi=M_PI;
  long double rad = abs(pi/30*m-(pi/360*m+h*pi/6));
  //cout<<rad<<endl;
  if(rad>pi) rad=2*pi-rad;
  long double ans=a*a+b*b-2*a*b*cos(rad);
  printf("%20.20Lf\n",sqrt(ans));
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
using namespace std;
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

int main(void) {
	LL N;
	cin >> N;
	VI A(N),xor_acc(N);
	REP(i,N) cin >> A[i];
	xor_acc[0] = A[0];
	REP(i,N-1) {
		xor_acc[i+1] = xor_acc[i] ^ A[i+1];
		A[i+1] += A[i];
	}
	LL ans = 0;
	LL l,r,mid,k;
	REP(i,N) {
		l = i;
		r = N-1;
		k = i;
		while (l <= r) {
			mid = (l + r)/2;
			if (i == 0) {
				if (xor_acc[mid] == A[mid]) {
					l = mid + 1;
					k = mid;
				}
				else r = mid - 1;
			}
			else {
				if ((xor_acc[mid] ^ xor_acc[i-1]) == (A[mid] - A[i-1])) {
					l = mid + 1;
					k = mid;
				}
				else r = mid - 1;
			}
		}
		ans += (k - i + 1);
	}
	cout << ans << endl;

}

Measured memory_bytes: 3328
export class Main {
  static main(input): string {
    const [one, ...list]: string[] = input.split("\n");
    const [n, m]: number[] = one.split(" ").map(Number);
    const ablist: number[][] = list.slice(0, n).map(l => l.split(" ").slice(0, 2).map(Number));
    ablist.sort(([a, b], [a2, b2]) => a - a2);
    let money: number = 0;
    let drink: number = 0;
    for (let i: number = 0, len: number = ablist.length; i < len; i++) {
      const [a, b]: number[] = ablist[i];
      if (drink + b >= m) {
        money += a * (m - drink);
        break;
      }
      money += a * b;
      drink += b;
    }
    return `${money}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 53404
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  x,y,z = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  print(z,x,y)

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: u64
    };

    let mut a = 100u64;
    for i in 1.. {
        a = (a as f64 * 1.01) as u64;
        if a >= x {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int a[200010]={0};
  string s,t;
  cin >> s;
  cin >> t;
  n = s.size();
  m = t.size();
  result = 9999;
  for(i=0;i<n-m+1;i++){
    k=0;
    for(j=0;j<m;j++){
      if(s[i+j]!=t[j]) k++;
    }
    result = min(result,k);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3640