akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N, cur;
vll C,S,F;

ll calc(int n){
    cur = 0;

    for(int i = n; i < N-1; i++){
        //printf("Station %d: %lld\n",i,cur);
        cur = max(cur, S[i]);
        if((cur - S[i])%F[i] > 0)
            cur += F[i] - (cur - S[i])%F[i];
        cur += C[i];
    }

    return cur;
}

void solve(){
    rep(i,N)
        cout << calc(i) << endl;
}

int main(){
    cin >> N;
    C.resize(N-1), S.resize(N-1), F.resize(N-1);
    rep(i,N-1)
        cin >> C[i] >> S[i] >> F[i];

    solve();
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solve(L, R int) int {
	ans := 2019
	for i := L; i < R; i++ {
		for j := L + 1; j <= R; j++ {
			mod := (i * j) % 2019
			if mod < ans {
				ans = mod
				if ans == 0 {
					return ans
				}
			}
		}
	}
	return ans
}

func main() {
	var L, R int
	fmt.Scan(&L, &R)
	ans := solve(L, R)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main() {
 
char ch[2000] = {0};
char W[15] = {0};
int i,j,k,l,m,n,o,p; 
 
m=0; /* ??????W?????\??? */
while(1) {
 
scanf("%c" , &W[m]);
/* printf("W[%d]???%c ",m,W[m]); /*W[m]????¢????*/
if(W[m] == '\n') {
break;
}
m = m+1;
}
 
n=0; /* ?????????T?????\??? */
while(1) {
 
scanf("%c",&ch[n]);
 
 /*printf("ch[%d]???%c ",n ,ch[n]); /*  ch[n]????¢???? */
  
 
if(ch[n] =='T' && ch[n-1] == 'X' && ch[n-2] == 'E' && ch[n-3] == 'T' && ch[n-4] == '_' && ch [n-5] == 'F' && ch[n-6] == 'O' && ch[n-7] == '_' && ch[n-8] == 'D' && ch[n-9] == 'N' && ch[n-10] == 'E') {
/* printf("break??????\n"); */
break;
}
n +=1;
} /*while??\????????????*/
 
 
/*??????????????¨?????????????¢????*/
p=0;
for(i=0; i<n; i++){
if(W[0] == ch[i] || W[0] == ch[i]+32 || W[0] == ch[i]-32) {
/* printf("????????????????¢????ch[%d]\n",i); /**/
if(ch[i+m] == ' ' || ch[i+m] == '\n' || W[0] == ch[0]  ) { 
if(ch[i-1] == ' ' || ch[i-1] == '\n' ||  W[0] == ch[0]+32 || W[0] == ch[0]-32){
o=o+1;
/*printf("ch[%d]???%c?????????\n",i,ch[i]); /*??????????¢????*/
 
for(j=0;j<m; j++) {
if(W[j] == ch[i+j] || W[j] == ch[i+j]+32 || W[j] == ch[i+j]-32){
/*printf("W[%d]???%c ch[%d]???%c\n",j,W[j],i+j,ch[i+j]); /*???= ????¢???????*/
o=o+1;
}
}
}
}
 
if(o==m+1){
p=p+1;
}
o=0;
}
}
 
printf("%d\n",p);
 
return 0;
 
}


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

int main() {
    int n, sum=0;
    cin >> n;
    vector<int> t(n);
    rep(i,n) {
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    rep(i,m) {
        int p, x;
        cin >> p >> x; p--;
        cout << sum-t[p]+x << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    string a, b, s;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        s += a[i];
        s += b[i];
    }
    cout << s << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(ll i = 0;i<n;++i)
#define repc(bit,k,n) for (ll bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using pll=pair<ll,ll>;
vector<vector<pll> >path(100001);
ll dp[100001];

void depth(int i, int parent){
  repi(itr, path[i]){
    if((*itr).first != parent){
      dp[(*itr).first] = dp[i] + (*itr).second;
      depth((*itr).first, i);
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;cin>>n;
  rep(i,n-1){
    int a,b;cin>>a>>b;a--;b--;
    ll c;cin>>c;
    path[a].push_back(make_pair(b,c));
    path[b].push_back(make_pair(a,c));
  }
  int q,k;cin>>q>>k;k--;
  dp[k] = 0;depth(k,k);
  vector<ll> ans;
  rep(i,q){
    int a,b;cin>>a>>b;a--;b--;
    ans.push_back(dp[a]+dp[b]);
  }
  repi(itr,ans)cout<<*itr<<endl;

  return 0;
}

Measured memory_bytes: 18336
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, K;
        cin >> N >> K;

        if (N % K == 0)
        {
                cout << 0 << endl;
        }
        else
        {
                cout << 1 << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL fen(LL n,int x)
{
	if(x>0)
	{
		return fen(n*2+1,x-1);
	}
	return n;
}
int main()
{
	int x;
	cin>>x;
	cout<<fen(1,x+1)-1;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int a[n][m],b[m],c[n]={};
    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
    }
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include "stdio.h"
using namespace std;

/** Problem0080 : Third Root **/
int main()
{
	double x, oldX, in;
	
	while (cin >> in) {
		if (in == -1) break;
		
		oldX = in/2.0;
		for (;;) {
			x = oldX - (oldX*oldX*oldX-in)/(3*oldX*oldX);
			
			if (x*x*x > in) {
				if (x*x*x - in < 0.00001*in)
					break;
				else
					oldX = x;
			} else {
				if (in - x*x*x < 0.00001*in)
					break;
				else
					oldX = x;
			}
		}
		printf("%.6lf\n", x);
	}
	
	return 0;
}

Measured memory_bytes: 1236
_input = [i for i in open(0).read().split('\n') if i]
n = int(_input[0])
a_list = [int(i) for i in _input[1].split()]
a_double_list = [i * 2 for i in a_list]

switch = 1
total = 0
for i in range(n):
    if (switch % 2) == 1:
        total += a_double_list[i]
    else:
        total -= a_double_list[i]
    switch += 1
b1 = total // 2

ans = [b1]
for i in range(n-1):
    b = a_double_list[i] - ans[i]
    ans.append(b)
print(' '.join(str(i) for i in ans))


Measured memory_bytes: 24204
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}



int main() {
	int a, b;
	cin >> a >> b;
	rep(i, 10000) {
		if (a <= i * 0.08 && i * 0.08 < a + 1 &&
			b <= i * 0.1 && i * 0.1 < b + 1) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int MAX = (int)10e5;
    int digit;
    int n = N;
    REP(i,6) {
        n /= 10;
        if (n == 0) {
            digit = i+1;
            break;
        }
    }

    int ans = 0;
    REP(i,digit-1) {
        if (i%2 == 0) ans += 9*pow(10,i);
    }
    if (digit%2 == 1) ans += N - pow(10,digit-1) + 1;
    

    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define fora(i, a, n) for(int i = a; i < n; i++)
#define forb(i, a, n) for (int i = a; i >= (n); --i)
#define PI 3.1415926535897932384626433832795
#define INF 1e9

int main(){ 
ios::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
/////////////////////////////////
string s;
cin >> s;
bool ans = false;
if(s[2] == s[3] && s[4] == s[5]) ans = true;

if(ans) cout << "Yes" << endl;
else cout << "No" << endl;  

return 0;
}


Measured memory_bytes: 256
NIL = -1


class Node:
    parent = NIL
    left = NIL
    right = NIL


def getDepth(u):
    d = 0
    while T[u].parent != NIL:
        u = T[u].parent
        d += 1
    return d


def getChildren(u):
    c = T[u].left
    result = []
    while c != NIL:
        result.append(c)
        c = T[c].right
    return result


n = int(input())
T = [0] * n
for i in range(n):
    T[i] = Node()

for i in range(n):
    tmp = list(map(int, input().split()))
    id = tmp.pop(0)
    k = tmp.pop(0)
    c = tmp
    if k != 0:
        for j in range(len(c)):
            T[c[j]].parent = id
        T[id].left = c[0]
        for j in range(len(c) - 1):
            T[c[j]].right = c[j + 1]

for i in range(n):
    d = getDepth(i)
    c = getChildren(i)
    if d == 0:
        t = 'root'
    elif c == []:
        t = 'leaf'
    else:
        t = 'internal node'
    print('node ', i, ': ', 'parent = ', T[i].parent, ', depth = ', d, ', ', t, ', ', c, sep='')

Measured memory_bytes: 30712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    int k;cin>>k;
    set<ll> s;
    int i,j;
    for(i=1;i<=9;i++) s.insert(i);

    
    ll ans = (k<=9) ? k:-1;
    while(k > s.size()){
         set<ll> a; 
         k-=s.size();
         j = 0;
         for(auto el : s){
            ll td = el%10;
            if(td>0) a.insert(el*10+(td-1)),j++;
            if(j==k){
                ans = *--a.end(); 
                break;
            }
            a.insert(el*10+(td)),j++;
            if(j==k){
                ans = *--a.end(); 
                break;
            }
            if(td<9) a.insert(el*10+(td+1)),j++;
            if(j==k){
                ans = *--a.end(); 
                break;
            }
         }
         swap(s,a);
    }
    cout<<ans<<"\n";
    
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() { 
  ll n;
  int ans=0;
  double d;
  cin>>n>>d;
  for(int i=0;i<n;i++) { 
    double x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
    } cout<<ans<<endl;
  return 0;
  }



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

const int N_MAX = 110;
const int W_MAX = 10010;
int dp[N_MAX][W_MAX]; // dp[i][j] i個目まで選んだ時の重さjを超えない最大の価値の合計

const int INF = 1e9;

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

    int n, w;
    cin >> n >> w;

    vector<int> V(n), W(n);
    for(int i = 0; i < n; i++){
        cin >> V[i] >> W[i];
    }

    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - W[i] >= 0){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - W[i]]) + V[i];
            }
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= w; i++){
        if(ans < dp[n][i]) ans = dp[n][i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7056
N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P = gets.chomp.split(" ").map(&:to_i)
Ary1 = gets.chomp.split("")
Ary2 = []

Ary1.each do |i|
    if i == "r"
        Ary2 << "p"
    elsif i == "p"
        Ary2 << "s"
    else
        Ary2 << "r"
    end
end

for i in (0..(Ary1.length - K))
    if Ary2[i] == Ary2[i + K]
        Ary2[i + K] = 0
    end
end

sum = R * Ary2.count("r") + S * Ary2.count("s") + P * Ary2.count("p") 

puts sum


Measured memory_bytes: 16124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

#define inf                  1e9   // this is double value
#define ms(a,b)              memset(a,b,sizeof a)
#define CLR(a)               memset(a,0,sizeof a)
#define input_file           freopen("in.txt","r",stdin)
#define output_file          freopen("out.txt","w",stdout)
#define N                    100000008
#define LL                   long long
#define nl                   printf("\n")
#define spc                  printf(" ")
#define isValid(x,y,dx,dy)   ((0<=dx&&dx<x) && (0<=dy&&dy<y)) 

int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		if(a%3==0 || b%3==0 || (a+b)%3==0)
			cout<<"Possible"<<endl;
		else 
			cout<<"Impossible"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n == 25)
    printf("Christmas");
    else if(n == 24)
    printf("Christmas Eve");
    else if(n == 23)
    printf("Christmas Eve Eve");
    else
    printf("Christmas Eve Eve Eve");
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
//============================================================================
// Name        : AOJCpp.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace(int A[], int n) {
	for (int j = 0; j < n-1; j++) {
		cout << A[j] << " ";
	}

	cout << A[n-1] << endl;
}

int main() {


	int n;
	int A[MAX];

	cin >> n;

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

	for(int i = 1; i < n; i++) {
		int v = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A, n);
	}
}





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

int main()
{
	std::vector<long long> A;
	std::vector<long long> B;
	int N = 0, M = 0, K = 0;

	std::cin >> N >> M >> K;;

	A.resize(N + 1);
	B.resize(M + 1);

	int readingTime = 0;

	// A.at(index)にはindex冊目までの合計時間を記録する
	for (size_t index = 1; index < A.size(); ++index)
	{
		std::cin >> readingTime;
		A.at(index) = A.at(index - 1) + readingTime;
	}

	// B.at(index)もAと同様
	for (size_t index = 1; index < B.size(); ++index)
	{
		std::cin >> readingTime;
		B.at(index) = B.at(index - 1) + readingTime;
	}

	// 答えを表す変数answer
	size_t answer = 0;

	// Aを0番目のコンテナからKを超える値があるコンテナの直前まで走査する。
	// B.at(j) <= K - A.at(index)が成り立つような整数jの最大値を探す。
	// index + j の最大値が求める値となる。
	for (size_t index = 0; index < A.size(); ++index)
	{
		if (A.at(index) > K)
		{
			break;
		}

		while (B.at(M) > K - A.at(index))
		{
			--M;
		}

		answer = std::max(answer, index + M);
	}
	
	std::cout << answer << std::endl;
}



Measured memory_bytes: 6060
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m;
char a[maxn],b[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s%s",a+1,b+1);
	int g=__gcd(n,m);
	bool flag=1;
	for(int i=1,j=1;i<=n;i+=n/g,j+=m/g)
	{
		if(a[i]!=b[j])
			flag=0;
	}
	long long ans=1LL*n*m/g;
	if(flag==0)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p aa
  p bb
end

if (aa + bb) % 2 == 0
  puts (aa + bb) / 2
else
  puts "IMPOSSIBLE"
end


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, k, t;
    cin>> n>> k;

    n--;
    k--;

    cout << ( n+k-1)/k;
    nl;

    return 0;
}




Measured memory_bytes: 3600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    int N,M,i;
    cin>>N>>M;
    vector<int> data(M);
    rep(i,0,M)cin>>data.at(i);
    rep(i,0,M)N-=data.at(i);
    if(N>=0)cout<<N<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

const int MOD = 1000000007;

int main(int argc, const char * argv[]) {
     
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    map<int, int> mp;
    for (int m = 2; m <= n; m++) {
        int p = m;
        bool update = true;
        while (update) {
            update = false;
            for (int i = 2; i <= sqrt(p) + 0.5; i++) {
                if (p % i == 0) {
                    update = true;
                    mp[i]++;
                    p /= i;
                    break;
                }
            }
            if (!update) mp[p]++;
        }
    }
    
    int64_t ans = 1;
    for (auto &iter : mp) {
        ans = ans * (iter.second + 1) % MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();


		int cnt = 0;
		int max = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'G' || s.charAt(i) == 'C') {
				cnt++;
			} else {
				cnt = 0;
			}
			max = Math.max(max, cnt);
		}

		System.out.println(max);
	}

}

Measured memory_bytes: 23380
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, a, b; readV(n, a, b);
  long[] v; readA(n, v);

  v.sort!"a>b";

  writefln("%.7f", v[0..a].sum.to!real/a);
  auto pt = pascalTriangle!long(n);

  if (v[0] > v[a-1]) {
    auto x = v.countUntil!(vi => vi == v[a-1]);
    auto y = v[x..$].count!(vi => vi == v[a-1]);
    writeln(pt[y][a-x]);
  } else {
    auto k = v.count!(vi => vi == v[0]);
    auto ans = 0L;
    foreach (i; a..min(k, b)+1) ans += pt[k][i];
    writeln(ans);
  }
}

pure T[][] pascalTriangle(T)(size_t n)
{
  auto t = new T[][](n+1);
  t[0] = new T[](1);
  t[0][0] = 1;
  foreach (i; 1..n+1) {
    t[i] = new T[](i+1);
    t[i][0] = t[i][$-1] = 1;
    foreach (j; 1..i)
      t[i][j] = t[i-1][j-1] + t[i-1][j];
  }
  return t;
}


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

bool t[1000000] = {};

int is_prime(int n) {
  int i;
 
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
 
  return true;
}

int main() {
  int n, i, r;
  n = 999999;

  for (i = 0; i < n; i++) {
    t[i] = is_prime(i);
  }

  while (cin >> n) {
    r = 0;
    for (i = 2; i <= n; i++) {
      if (t[i]) {
        r++;
      }
    }
    cout << r << endl;
  }

  return 0;
}

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

using namespace std;

const int MaxN = 2e5 + 25;
const int MOD = 1e9 + 7;

int dp[MaxN];
int n, a[MaxN];

int sumDP[MaxN];

void add(int & x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

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

    dp[0] = 1;
    for(int i = 1; i <= n; ++i)
    {
        dp[i] = dp[i - 1];

        if(a[i] != a[i - 1])
            add(dp[i], sumDP[a[i]]);

        if(a[i] != a[i - 1])
            add(sumDP[a[i]], dp[i - 1]);
    }

    cout << dp[n] << '\n';

    return 0;
}


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

using namespace std;

int 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 sum = -A[0];
  for(int i = 1; i < N - 1; i++){
    sum += abs(A[i]);
  }
  sum += A[N - 1];
  
  cout << sum << endl;
  
  int k = 0;
  for(int i = N - 2; i > 0 && A[i] >= 0; i--){
    cout << A[0] << ' ' << A[i] << endl;
    A[0] -= A[i];
    k++;
  }
  
  for(int i = 0; k < N - 1; i++){
    cout << A[N - 1] << ' ' << A[i] << endl;
    A[N - 1] -= A[i];
    k++;
  }
  
  return 0;
}

Measured memory_bytes: 2304
hw = list(map(int, input().split()))

if hw[0] == 1 or hw[1] == 1:
    count = 1
elif hw[0] % 2 == 0 and hw[1] % 2 == 0:
    count = (hw[0] * hw[1]) // 2
elif hw[0] % 2 != 0 and hw[1] % 2 == 0:
    count = ((hw[0] + 1) * hw[1] // 2) - (hw[1] // 2)
elif hw[0] % 2 == 0 and hw[1] % 2 != 0:
    count = ((hw[1] + 1) * hw[0] // 2) - (hw[0] // 2)
else:
    count = ((hw[0] + 1) * (hw[1] + 1) // 2) - ((hw[0] // 2 + 1) + (hw[1] // 2 + 1) - 1)
print(count)


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}


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

int main()
{


	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;

	for (int div = a; div <= b; div++)
	{
		if (!(c%div))
			count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1164
import scala.io.StdIn

object Main extends App {
  
  val a = StdIn.readLine().trim.split(' ').map(_.toInt)
  val t = a(2)
  /*
  val result = (a(0) to a(1)).foldLeft(0) { (acc, i) =>
    if(t % i == 0) acc + 1 else acc
  }*/

  /*
   ref
   http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2388634#1
   */
  //val result = (a(0) to a(1)).filter(p => t % p == 0).size
  val result = (a(0) to a(1)).count(p => t % p == 0)
  println(result)

}


Measured memory_bytes: 44228
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    if (N < A + B - 1 || A * B < N) {
        cout << -1 << endl;
        return 0;
    }

    ll arr[A];
    fill(arr, arr + A, 1);
    arr[0] = B;
    N -= A + B - 1;

    for (ll i = 1; i < A; ++i) {
        arr[i] += min(N, B - 1);
        N -= min(N, B - 1);
    }

    ll used = 0;
    for (ll i = 0; i < A; ++i) {
        used += arr[i];
        for (ll j = 0; j < arr[i]; ++j) {
            cout << used - j << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#include <deque> 
#define DBL_MIN 0.000000000000001

#include <iostream>
using namespace std;


int main(void){
    long N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    long min_p = min(A,min(B,min(C,min(D,E))));
    long bottle = N / min_p + ( N % min_p > 0);
    cout << bottle + 4 << endl;
}



Measured memory_bytes: 3628
#include<stdio.h>




int main(){
    char A[11]={};
    scanf("%s",A);
    int max = 0;
    for(int i=0;i<10;i++){
        int basho=i;
        int counter=0;
        while(basho<10){
            if(A[basho]=='A' || A[basho]=='C' || A[basho]=='G'||A[basho]=='T'){
                counter++;
                basho++;
            }
            else{
                basho=1000;
            }
        }
        if(max<counter){
            max=counter;
        }
    }
printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int pointCard = 2 * N;
		int M = sc.nextInt();

		int[][] cards = new int[M][2];
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < 2; j++) {
				cards[i][j] = sc.nextInt();
			}
		}

		int count = 0;
		int money = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();

		for (int i = 0; i < M; i++) {
			if (cards[i][0] >= cards[i][1]) {
				count++;
			} else {
				list.add(cards[i][1] - cards[i][0]);
			}
		}
      Collections.sort(list);
      int index=0;
     while(count<M-1) {
    	 int check=0;
    	 if(list.get(index)%2==0) {
    		 check=list.get(index)/2;
    	 }
    	 else {
    		 check=list.get(index)/2+1;
    	 }
    	 money+=check;
    	 count++;
    	 index++;
     }
     System.out.println(money);




	}
}



Measured memory_bytes: 33028
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector<int> ptr(n, 0);
    vector<vector<int>> state(n, vector<int>(n, 0)); // not yet
    queue<int> ready;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
        ready.push(i);
    }


    int ans = 0;
    while (true) {
        queue<int> next_ready;
        bool matched = false;

        while (!ready.empty()) {
            int q = ready.front();
            ready.pop();

            if (ptr[q] < n - 1) {
                int peer = A[q][ptr[q]];
                state[q][peer] = 1;

                if (state[peer][q] == 1) {
                    state[q][peer] = 2;
                    state[peer][q] = 2;
                    ptr[q]++;
                    ptr[peer]++;
                    next_ready.push(q);
                    next_ready.push(peer);
                    matched = true;
                }
            }
        }

        if (next_ready.empty()) break;

        while (!next_ready.empty()) {
            ready.push(next_ready.front());
            next_ready.pop();
        }

        ans++;
    }

    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (ptr[i] != n-1) {
            ok = false;
        }
    }

    if (ok) {
        cout << ans << '\n';
    } else {
        cout << -1 << '\n';
    }

    return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  const int64 divide_by = 1e9 + 7;
  int64 N, K;
  cin >> N >> K;
  int64 tmp = K;
  int64 ans = 0;
  while (tmp <= N + 1) {
    int64 sm = (-1) * pow(tmp, 2) + tmp * (N + 1) + 1;
    int64 amari = sm % divide_by;
    ans += amari;
    tmp++;
  }
  cout << ans % divide_by << endl;
  return 0;
}

Measured memory_bytes: 3536
import sys
t1,t2=[0]*1001,[0]*1001
lines=sys.stdin.readlines()
mid=lines.index("\n")
for line in lines[:mid]:
    i,d=map(int,line.strip().split(","))
    t1[i]+=1
for line in lines[mid+1:]:
    i,d=map(int,line.strip().split(","))
    t2[i]+=1
for i in xrange(1001):
    if t1[i]>0 and t2[i]>0:
        print i,t1[i]+t2[i]

Measured memory_bytes: 4248
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine().Split(' ');
            string S = s[0];
            var t = ReadLine().Split(' ');
            string T = t[0];
            int ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

    }

}

Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
double x[20][20];
int n,m,ans;
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			cin>>x[i][j];
	for (int i=0;i<n;i++)
		for (int j=i+1;j<n;j++){
			double num=0;
			for (int k=0;k<m;k++) num+=abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
			num=sqrt(num);
			if ((int)num==num) ans++;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?(テァツクツョテ・ツーツ湘ァツ可?

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, C[20], x[20010];
int dp[2][300];

signed main() {
    while(cin >> N >> M, N || M) {
        rep(i,0,M) cin >> C[i];
        rep(i,0,N) cin >> x[i];
        rep(i,0,2) rep(j,0,300) dp[i][j] = INF;
        dp[0][128] = 0;

        rep(i,0,N) {
            int mo = i%2;
            rep(j,0,256) {
                if(dp[mo][j] == INF) continue;
                rep(k,0,M) {
                    int nx = max(0LL, min(255LL, j + C[k]));
                    int diff = (x[i] - nx) * (x[i] - nx);
                    chmin(dp[mo^1][nx], dp[mo][j] + diff);
                }
                dp[mo][j] = INF;
            }
        }

        int ans = INF;
        rep(i,0,256) chmin(ans, dp[N%2][i]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int wa(int a){
	if(a==0) return 0;
	else return wa((a-a%10)/10)+a%10;
}

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

	int min = 10000;
	int count =1;
	int tempa=0;
	int tempb=0;
	int tempwa=0;
	while(count!=NNN){
		tempa = count;
		tempb = NNN-count;
		tempwa = wa(tempa)+wa(tempb);
		if(tempwa < min) {
			min = tempwa;
		}
		count ++;
	}


	cout << min <<endl;

    return 0;
}


Measured memory_bytes: 256
N, H = map(int, input().split())
a = []
b = []
for _ in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
    
a.sort(reverse = True)
b.sort(reverse = True)

for i in range(N):
    if b[i] <= a[0]:
        b = b[:i]
        break
s = 0
if H <= sum(b):
    for i in range(len(b)):
        s += b[i]
        if s >= H:
            ans = i+1
            break
else:
    H -= sum(b)
    ans = len(b) + H // a[0]
    if H  % a[0] != 0:
        ans += 1

print(ans)

Measured memory_bytes: 11356
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, i = 0, Ans = 1, p = 1000000007;cin >> N;
bool C = 0;
string A, B;cin >> A >> B;
vector<string> S;
S.push_back(A);S.push_back(B);

while(i < N){

  if(i == 0){

    if(S[0][i] == S[1][i]){Ans *= 3;i++;C = 1;continue;}

    else{Ans *= 6;i += 2;C = 0;continue;}

  }

  if(S[0][i] == S[1][i]){

    if(C){Ans *= 2;i++;Ans %= p;C = 1;continue;}

    else{i++;Ans %= p;C = 1;continue;}

  }

  else{

    if(C){Ans *= 2;Ans %= p;i += 2;C = 0;continue;}
    else{Ans *= 3;Ans %= p;i += 2;C = 0;continue;}

  }

}

cout << Ans;

}

Measured memory_bytes: 3632
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		Double W = sc.nextDouble();
		Double H = sc.nextDouble();
		Double x = sc.nextDouble();
		Double y = sc.nextDouble();

		System.out.println(W*H/2);

		if(Math.pow((2*x - W),2) < 0.001 && Math.pow((2*y - H),2)<0.001){
			System.out.println(1);
		}else{
			System.out.println(0);
		}

		sc.close();
	}
};

Measured memory_bytes: 24660
N = int(input())
A = [int(a) for a in input().split()]

S = N * (N+1) // 2

A_sum = sum(A)

if A_sum % S != 0:
	print("NO")
	exit(0)
T = A_sum // S

diff = [A[(i+1)%N] - A[i%N] for i in range(N)]
zure = 0
for i in range(N):
	d = diff[i]
	if T - d >= 0 and (T - d) % N == 0:
		zure += (T - d) // N

if zure == T:
	print("YES")
else:
	print("NO")

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

int main() {
    int n;
    ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    ll ans;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') cnt1++;
        else if (s[i] == 'G') cnt2++;
        else cnt3++;
    }
    ans = cnt1 * cnt2 * cnt3;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            if (i - j < 0 || i + j >= n) continue;
            else {
                if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j]) ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int N = 2 * 123456;
	boolean p[];
	
	void run() {
		Scanner sc = new Scanner(System.in);
		p = new boolean[2*N+1];
		prime();
		for(;;) {
			int n = sc.nextInt();
			if(n==0) break;
			int cnt = 0;
			for(int i=n+1;i<=2*n;i++) {
				if( !p[i]) cnt++;
			}
			System.out.println(cnt);
		}
	}
	
	void prime() {
		p[0] = p[1] = true;
		for(int i=2;i<=N;i++) {
			if( !p[i] ) for(int j=2*i;j<=N;j+=i) {
				p[j] = true;
			}
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
    	cout<<k<<endl;
    }
    else if(k<=(a+b) and k>a){
    	cout<<a<<endl;
    }
    else{
    	cout<<a - min(k-(a+b),c)<<endl;
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> a(N,0);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }

    long long a_max = *max_element(a.begin(), a.end());
    long long ans = 0;
    
    for(int i=0;i<N;i++){
        ans += a[i] - 1;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define int ll

int32_t main(){
    FAST
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j*i < n; j++){
            if(n - j*i > 0)ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans = 10000;
    rep(i, 0, S.size() - 1){
        int x = stoi(S.substr(i, 3));
        ans = min(ans, abs(x - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

// int max: 2147483647

using namespace std;

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

  int maxL = 0;
  int minR = N;

  int l, r;
  for (int i = 0; i < M; i++) {
    cin >> l >> r;

    maxL = max(maxL, l);
    minR = min(minR, r);
  }

  int answer = max(minR - maxL + 1, 0);
  cout << answer << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

int groupNum[43];

void makeGroup(){
  int curMax = 0;
  int cur    = 1;
  for(int i=1; i<43; i++){
    if (curMax + 1 == cur){
      curMax = cur;
      cur = 1;
    }else{
      ++cur;
    }
    groupNum[i] = curMax;
  }
}

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  makeGroup();
  auto f = prime_factor(N);
  int ret = 0;
  for(auto &p : f){
    ret += groupNum[p.second];
  }

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3592
n, m = (int(i) for i in input().split())  
gate = []
for i in range(m):
  line =  [int(i) for i in input().split()] 
  gate.append(line)
L = []
R = []
for i in range(m):
  L.append(gate[i][0])
  R.append(gate[i][1])
R_min = min(R)
L_max = max(L)
n = R_min - L_max
if n < 0:
  print(0)
else:
  print(n+1)

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

int main() {
	long n;
	cin>>n;
	long a[n];
	long s[n];
	for(long i=0;i<n;i++)
	{
		cin>>a[i];
	}
	s[0]=0;
	s[1]=abs(a[1]-a[0]);
	for(long i=2;i<n;i++)
	{
		s[i]=min(s[i-1]+abs(a[i]-a[i-1]),s[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<s[n-1]<<endl;
	return 0;
}

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

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int sum = 0;
            for (int k = 0; k < D; k++) {
                sum += pow(X[i][k] - X[j][k], 2);
            }
            int tmp = sqrt(sum);
            if (pow(tmp, 2) == sum) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[20010], b[20010];
    int p[20010];
    rep(i, N) cin >> p[i];
    rep(i, N) p[i]--;
    rep(i, N) {
        a[i] = (i + 1) * 45000;
        b[i] = (N - i) * 45000;
    }
    rep(i, N) {
        a[p[i]] += i;
    }
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << b[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let t: Vec<usize> = sc.vec(5);
    for i in 0..5 {
        if t[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
    unreachable!();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static long cnt = 0;
	public static ArrayList<Integer> G = new ArrayList<>();
	public static void insertitionSort(int[] A, int n, int g) {
		for(int i = g; i < n; i++) {
			int v = A[i];
			int j = i - g;
			while(j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}
			A[j + g] = v;
		}
	}
	public static void shellSort(int[] A, int n) {
		for(int h = 1; h <= n;h = h*3 + 1) G.add(h);
		for(int i = G.size()-1; i >= 0; i--) {
			insertitionSort(A,n,G.get(i));
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(buffer.readLine());
		int[] array = new int[n];
		for(int i = 0; i < n; i++) array[i] = Integer.parseInt(buffer.readLine());

		shellSort(array,n);
		System.out.println(G.size());
		for(int i=G.size()-1;i >=0;i--) {
			System.out.printf("%d", G.get(i));
			if(i!=0) System.out.printf(" ");
		}
		System.out.printf("\n");
		System.out.printf("%d\n", cnt);
		StringBuilder output = new StringBuilder();
		output.append(array[0]);
		for(int i=1;i<n;i++) output.append("\n").append(array[i]);
		System.out.println(output.toString());
	}
}


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

int const N=3e3+5, M=1e5+5, OO = 0x3f3f3f3f;

int n;
int arr[N];

long long mem[N][N][2];
long long solve(int s, int e, int last)
{
    if(s>e)
        return 0;
    if(mem[s][e][last]!=-1)
        return mem[s][e][last];
    long long ret=0;
    if(last)
        ret=max(solve(s+1,e,0)+arr[s],solve(s,e-1,0)+arr[e]);
    else
        ret=min(solve(s+1,e,1)-arr[s],solve(s,e-1,1)-arr[e]);
    return mem[s][e][last]=ret;
}


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",arr+i);
    memset(mem, -1, sizeof mem);
    printf("%lld\n",solve(0,n-1,1));


}


Measured memory_bytes: 141568