akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int partition(int a[], int p, int r){
    int i = p - 1;
    int x = a[r];
    for(int j = p; j <= r-1; j++){
        if(a[j] <= x){
            i++;
            int temp = a[i];
            a[i] = a[j];
            a[j] = temp;
        }
    }
    int t = a[i+1];
    a[i+1] = a[r];
    a[r] = t;
    return i+1;
}
int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);

    int q = partition(a, 0, n-1);
    for(int i = 0; i < n; i++){
        if(i == n-1) {
            if (i == q){
                printf("[%d]\n", a[i]);
            }
            else{
                printf("%d\n", a[i]);
            }

        }
        else{
            if(i == q){
                printf("[%d] ", a[i]);
            } else{
                printf("%d ", a[i]);
            }

        }
    }
    return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A.at(i);
    int counter = 0, std_counter = 0;
    int town = 1;
    vector<int> town_list(n, 0);
    int std_town = 0;
    
    
    do{
        counter += 1;
        town_list.at(town-1) += 1;
        town = A.at(town-1);
        if(town_list.at(town-1) == 1){
            std_town = town;
            break;
        }
    }while(1);
    
    do{
       std_counter += 1;
       town = A.at(town-1);
    }while(town != std_town);
    
    if(counter > k){
        town = 1;
        for(int i = 0; i < k; i++){
            town = A.at(town-1);
        }
        cout << town << endl;
    }else{
        int amari = (k-counter)%std_counter;
        if(amari == 0){
            cout << std_town << endl;
        }else{
            town = std_town;
            for(int i = 0; i < amari; i++){
                town = A.at(town-1);
            }
            cout << town << endl;
        }
    }
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, T;
  cin >> A >> B >> T;

  /*
  * We can get B cookies after every A sec.
  * How many cookies we can get after T + 0.5 sec?
  */

  int ans = (T+0.5) / A;
  ans *= B;
  cout << std::setprecision(20);
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var s, t string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s %s", &s, &t)
	sRune := []rune(s)
	tRune := []rune(t)
	result := ""
	for i := 0; i < n; i++ {
		result = result + string(sRune[i]) + string(tRune[i])
	}

	fmt.Printf("%s\n", result)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    long long a[n],sum=1;
    for(i=0;i<n;i++) scanf("%lld",&a[i]);
    for(i=0;i<n;i++){
        if(a[i]==0){
            printf("0");
            return 0;
        }
    }
    for(i=0;i<n;i++){
        if(a[i]>1000000000000000000/sum){
            printf("-1");
            return 0;
        }
        else sum*=a[i];
    }
    printf("%lld",sum);
}


Measured memory_bytes: 2484
// :)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	stack <int> A;
	int n;
	cin >> n;
	ll a[n], d[n][2];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		while (!A.empty() && a[i] < a[A.top()]) {
			int v = A.top();
			d[v][0] = i - v;
			A.pop();
		}
		A.push(i);
	}
	while (!A.empty()) {
		int v = A.top();
		d[v][0] = n - A.top();
		A.pop();
	}
	for (int i = n; i >= 0; i--) {
		while (!A.empty() && a[i] < a[A.top()]) {
			int v = A.top();
			d[v][1] = v - i;
			A.pop();
		}
		A.push(i);
	}
	while (!A.empty()) {
		int v = A.top();
		d[v][1] = v + 1;
		A.pop();
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
		res += d[i][0] * d[i][1] * a[i];
	cout << res << "\n";
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b ;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a < 10 && b < 10 ){
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
    //*/
    
    cout << max(a - 2 * b, 0) << endl;

    return 0; 
}


Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");
		
		int n = scn.nextInt(), min = n;
		for(int i = 1; i <= n / 2; i++) {
			min = Math.min(min, getS(i) + getS(n - i));
		}
		out.println(min);
		out.flush();
	}

	public static int getS(int n) {
		int rv = 0;
		while(n != 0) {
			rv += n % 10;
			n /= 10;
		}
		return rv;
	}
	
	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
}


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

int main() {

    string s;
    int n;
    cin >> s >> n;

    int now = 0;
    string front = "";
    string back = "";
    rep(i, n){
        int t;
        cin >> t;
        if(t == 1){
            now ^= 1;
        }
        else{
            int f; string c;
            cin >> f >> c;
            if(now){
                if(f == 1){
                    back += c;
                }
                else{
                    front = c + front;
                }
            }
            else{
                if(f == 1){
                    front = c + front;
                }
                else{
                    back += c;
                }
            }
        }
    }
    
    string ans = front + s + back;
    if(now & 1){
        reverse(all(ans));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1360
import math
def merge(a, left, mid, right):
    global c
    n1 = mid - left
    n2 = right - mid
    l = a[left:left + n1]
    r = a[mid:mid + n2]
    l.append(10e10)
    r.append(10e10)
    i = 0
    j = 0
    for k in range(left, right):
        if l[i] < r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            c += n1 - i
            j += 1

def mergeSort(a, left, right):
    if left + 1 < right:
        mid = math.ceil((left + right) / 2)
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)

n = int(input())
a = list(map(int,input().split()))
c = 0
mergeSort(a, 0, n)
print(c)


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


int main() {

    long n;
    cin >> n;
    int arr[n], min = INT_MAX, max = INT_MIN;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if(arr[i] < min)
            min = arr[i];
        if(arr[i] > max)
            max = arr[i];
    }
    long long ans = (long long)1e12, temp= 0;
    for(; min <= max; min++)
    {
        temp = 0;
        for(int i = 0; i < n; i++)
            temp += (min - arr[i])*(min - arr[i]);
        if(temp < ans)
            ans = temp;
    }
    cout << ans;


}


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

typedef long long ll;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
    ll N;
    cin >> N;
    ll A[N+1],min,count;
    rep(i,0,N) cin >> A[i];
    min = 1000000;
    count = 0;
    for(int i =0 ;i <N ; i++){
        if(A[i] <= min){
            min = A[i];
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int a,b,v,w; cin >> a >> v >> b >> w;
   int t; cin >> t;
   int delta = abs(b-a), deltav = v - w;
   if(a == b) {
      cout << "YES\n";
      return 0;
   }
   if(deltav <= 0) {
      cout << "NO\n";
   }
   else {
      // cout << deltav * t << "\n";
      if (deltav * t >= delta) {
         cout << "YES\n";
      }
      else cout << "NO\n";
   }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    if(n&1)
        cout<<fixed<<setprecision(6)<<double((n/2)+1)/double(n)<<endl;
    else
        cout<<setprecision(6)<<double(n/2)/double(n)<<endl;
    return 0;
}


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

using namespace std;

vector<int> ans;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		
		int change = 1000 - n;
		int coin[] = {500,100,50,10,5,1};
		
		int tans = 0;
		for(int i = 0;i < 6;i++){
			int maisu = change / coin[i];
			if(maisu != 0){
				tans += maisu;
				change -= coin[i] * maisu;
			}
		}
		ans.push_back(tans);
	}
	
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

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

int N,A,B;

int sumd(int n){
	int m = 0;
	while(n > 0){
		m += n%10;
		n /= 10;
	}
	return m;
}

int main(){
	while(cin >> N >> A >> B){
		int ans = 0;
		for(int i=1;i<=N;i++){
			if(sumd(i)>=A && sumd(i) <= B){
				ans += i;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A2s = [2*A[i] for i in range(N)]
    M1 = 0
    sign = 1
    for i in range(len(A2s)):
        M1 += sign * A2s[i]
        sign *= -1
    prev = M1//2
    resultS = str(prev)
    for i in range(N-1):
        current = A2s[i] - prev
        prev = current
        resultS += " " + str(current)
    print(resultS)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23044
#include<cstdio>
using namespace std;
int main() {

    int a, b;
    scanf("%d %d", &a, &b);

    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> arr(n);
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}
	bool flag = true;
	for(int i = 0; i < n; i++) {
		flag &= ((sum-arr[i])>arr[i]);
	}

	cout << ((flag)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: x[1])
A.sort()
i = 0
for b, c in BC[::-1]:
    for _ in range(b):
        if i == N:
            break
        if c > A[i]:
            A[i] = c
            i += 1
        else:
            break

print(sum(A))


Measured memory_bytes: 33736
#python3
INF = int(1e6)
def main():
    a, b, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    cp = []
    ans1 = INF
    for _ in range(m):
        x, y, c = map(int, input().split())
        x -= 1
        y -= 1
        ans1 = min(a[x]+b[y]-c, ans1)
    a_cost = min(a)
    b_cost = min(b)
    ans2 = a_cost + b_cost
    ans = min(ans1, ans2) 
    print(ans)
main()


Measured memory_bytes: 18488
#include <bits/stdc++.h>
#include <stdlib.h>
#define dbgi(x) cout << #x << " = " << (x) << "\n";
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
#define mrk() cout << "HERE\n"
#define int long long
#define vi vector < int >
#define vs vector < string >
#define vii vector < vi >
#define viii vector < vii >
#define viiii vector < viii >
#define pii pair < int, int >
#define vpii vector < pii >
#define foru(i, a, b) for(int i = a; i < b; ++i)
#define ford(i, b, a) for(int i = b; i > a; --i)
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ld long double
using namespace std;

const int inf = (int)1e13;
const int mxn = 2000 + 10;
int sm = 0;

signed main(){
    int n;
    cin >> n;
    vi a(n);
    foru(i, 0, n){
        cin >> a[i];
        sm += a[i];
    }
    bitset< mxn * mxn > dp;
    dp[0] = 1;
    foru(i, 0, n){
        dp |= (dp << a[i]);
    }
    foru(i, (sm + 1) / 2, sm + 1){
        if(dp[i]){
            cout << i << " ";
            return 0;
        }
    }



}


Measured memory_bytes: 1792
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		int K = Integer.parseInt(in.readLine());
		int val = 1;
		for (int i = 0; i < N; ++i) {
			val = Math.min(val * 2, val + K);
		}
		System.out.println(val);
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 21844
n,m = map(int,input().split())
AB = [[int(i) for i in input().split()] for j in range(n)]
AB.sort()
res = 0
for a,b in AB:
	m -= b
	if m >= 0:
		res += a*b
	else:
		m += b
		res += a*m
		break
print(res)


Measured memory_bytes: 60760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();

        int[][] a = new int[n][3];

        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
            a[i][2] = sc.nextInt();
        }

        int[][] dp = new int[n][3];
        dp[0][0] = a[0][0];
        dp[0][1] = a[0][1];
        dp[0][2] = a[0][2];

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }

        int res = 0;
        for (int i = 0; i < 3; i++) {
            res = Math.max(dp[n - 1][i], res);
        }
        out.println(res);

        out.flush();

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 49736
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
map<int, int> used;
deque<ll> divisor;
ll GCD(ll x, ll y)
{
    return x ? GCD(y % x, x) : y;
}
bool IsPrime(ll num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    for (ll i = 3; i <= sqrt(num) + 1; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
ll findFactors(ll num)
{
    ll i;
    ll cnt = 1;
    ll tmp = num;
    //printf("%d =", num);
    while (num % 2 == 0)
    { // 偶数の素数は2のみ
        //printf("2 *");
        if (!used[2])
        {
            used[2]++;
            cnt++;
            //divisor.push_back(2);
        }
        num /= 2;
    }
    for (i = 3; i <= sqrt(tmp) + 1; i += 2)
    { // 他の素数で割っていく

        while (num % i == 0)
        {
            //printf("%d *", i);
            if (!used[i])
            {
                used[i]++;
                cnt++;
                // divisor.push_back(i);
            }
            num /= i;
        }
        //  cout << num << endl;
    }
    if (IsPrime(num))
    {
        if (!used[num])
        {
            used[num]++;
            cnt++;
        }
    }
    //printf("%b %n");
    return cnt;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll n = GCD(a, b);
    // cout << n << endl;
    ll ans = 0;
    if (IsPrime(n))
    {
        ans = 2;
    }
    else
    {
        ans = findFactors(GCD(a, b));

        /*if (n == 1)
        {
            ans = 1;
        }*/
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
poti=list(input().split())
poti= [ int(s) for s in poti ]
poti=sorted(poti)
sa=[]
if N>=M:
    print(0)
else:
    for i in range(0,M-1):
        a=poti[i+1]-poti[i]
        sa.append(a)


    if len(sa)!=0:  
        sa=sorted(sa)
        sa=sa[0:(M-1)-(N-1)]
        print(sum(sa))
    else:
        print(0)

Measured memory_bytes: 13192
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
ll A[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = 0;
    for(int i = 1; i < N; i++){
        if(A[i] < A[i-1]){
            ans += (A[i-1]-A[i]);
            A[i] = A[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

int main()
{

	unsigned long long int a = 1, b = 0, c = 100, d = 0, e = 0, maxy = 0, max = 0, ans = 1, count = 0;

	int yoko = 0, tate = 0;
	int array[1001] = {0};
	std::string output, output2, output3, input = {};
	bool okada = false;


	cin >> d;
	for (int j = d; j >= 2; j--) {
		b = j;

		for (int i = 2; i <= b; i++) {
			while (b%i == 0) {

				b /= i;
			
				array[i]++;

			}
		}
	}

	for (int i = 0; i <= d; i++) {

		if (array[i] != 0) {

			ans *= array[i] + 1;
		
		}
		ans %= 1000000007;

	}
	cout << ans << endl;
}







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

string n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n;
    
    ll sum = 0;
    for (ll i=0; i<n.size(); i++){
        sum += (n[i]-48);
    }
    
    if (sum%9==0 || sum==0){
        cout<<"Yes";
    }
    else cout<<"No";
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        ll tmp;
        cin >> tmp;
        if(i==0){
            a[i] = tmp;
        }else{
            a[i] = a[i-1] + tmp;
        }
    }
    ll mid = a[n-1]/2;
    auto itr = lower_bound(a.begin(), a.end(), mid);
    if(*itr == mid and a[n-1] % 2 == 0){
        cout << 0 << endl;
    }else{
        vector<ll> b(3);
        int index = itr - a.begin();
        if(index != 0){
            b[0] = a[index-1];
            b[1] = a[index] - a[index-1];
            b[2] = a[n-1] - a[index];
        }else{
            b[0] = a[index];
            b[1] = 0;
            b[2] = a[n-1] - a[index];
        }
        ll ans = min(abs(b[0]+b[1]-b[2]), abs(b[1]+b[2]-b[0]));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[305];
ll dp[55][2][2];

int main(void){
	scanf("%d",&n);
	ll xo=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(i>=2){
			xo^=a[i];
		}
	}
	if(xo==0LL){
		if(a[0]>=a[1] && (a[0]-a[1])%2LL==0){
			printf("%lld\n",(a[0]-a[1])/2LL);
		}else{
			printf("-1\n");
		}
		return 0;
	}
	for(int i=0;i<55;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				dp[i][j][k]=(1LL<<55);
			}
		}
	}
	dp[0][0][0]=0;
	for(int i=0;i<50;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				if(dp[i][j][k]==(1LL<<55))continue;
				ll aa0=a[0]-(1LL<<i)*j;
				ll aa1=a[1]+(1LL<<i)*k;
				if(aa0<0)continue;
				ll a0=(aa0>>i)&1LL;
				ll a1=(aa1>>i)&1LL;
				if((a0^a1)!=((xo>>i)&1LL))continue;
				for(ll u=0;u<2;u++){
					int nj=0;
					int nk=0;
					if(((a[0]>>i)&1LL)<j+u){
						nj=1;
					}
					if(((a[1]>>i)&1LL)+k+u>=2){
						nk=1;
					}
					dp[i+1][nj][nk]=min(dp[i+1][nj][nk],dp[i][j][k]+(1LL<<i)*u);
				}
			}
		}
	}
	printf("%lld\n",dp[50][0][0]>=a[0]?-1:dp[50][0][0]);
	return 0;
}


Measured memory_bytes: 3812
#include <utility>
#include <algorithm>
#include <iostream>

using namespace std;

int N,W;
int val[100+10];
int wei[100+10];
int vmax[100+10][10000+10] = {0};


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


  for (int i=1;i<=N;++i){
    cin >> val[i];
    cin >> wei[i];
    //cout << val[i] << " " << wei[i] << endl;
  }

  for (int i=0;i<=N;++i){
    for (int c=0;c<=W;++c){
      if(i <= 0 || c <= 0)vmax[i][c] = 0;
      else if(c - wei[i] < 0)vmax[i][c] = vmax[i-1][c];
      else vmax[i][c] = max((val[i] + vmax[i-1][c-wei[i]]), vmax[i-1][c]);
      //cout << vmax[i][c];
    }
    //cout << endl;
  }
  cout << vmax[N][W] << endl;
}
  

Measured memory_bytes: 7024
#include <sstream>
#include <string>
#include<iostream>
using namespace std;

int intcat(int i, int j)
{
	int k;

	stringstream s;

	s << i;
	s << j;

	s >> k;
	return(k);
}

int main() {
	int a, b;
	cin >> a >> b;
	int k = intcat(a, b);

	bool isPower=false;
	for (int i = 1; i <= k; i++) {
		if (k/(double)i == (double)i) {
			isPower = true;
			break;
		}
	}

	if (isPower) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------

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

  prt(min(n%k, (k-n%k)));

}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u64,
        y: u64,
    }
    let mut x = x;
    let mut cnt = 0;
    while x <= y {
        x *= 2;
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int main() {
	LL A, B, C; cin >> A >> B >> C;
	cout << max(0ll, (C - (A - B)));
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
a = list(map(int, input().split()))

m = 20

ans = n
index = 0
cs = [[0 for i in range(m)] for i in range(n+1)]
bit = [0 for i in range(m)]
for i in range(n):
    for j in range(m):
        cs[i+1][j] = cs[i][j] + ((a[i]>>j)&1)

    bit = [cs[i+1][j] - cs[index][j] for j in range(m)]
    if max(bit) >= 2:
        while max(bit) >= 2:
            k = max(i - index - 1, 0)
            ans += k
            index += 1
            bit = [cs[i+1][j] - cs[index][j] for j in range(m)]

    # print("{:2d} {:2d}".format(i, index), ans, "".join([str((a[i]>>j)&1) for j in reversed(range(m))]))

k = max(n - index - 1, 0)
ans += k * (k+1) // 2
# print(cs)
print(ans)



Measured memory_bytes: 128076
import math
n = int(input())
A = list(map(int, input().split()))
A = [A[i]-(i+1) for i in range(n)]
#print(A)
A.sort()
i = n/2
a = A[math.floor(i)]
b = A[math.ceil(i)] if i>1 else a
ans,ans1=0,0
for i in A:
    ans += abs(i-a)
    ans1 += abs(i-b)
print(min(ans,ans1))

Measured memory_bytes: 26836
#include<iostream>
 
using namespace std;
 
int main() {
	long long a;
	double b;  
	cin >> a >> b;
    long long b1 = b*100 + 0.5;
	long long res = a * b1;
    long long res1 = res/100;
	cout << res1;
	return 0;
 
}

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

ll x[10], y[10];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    sum *= 2/(double)n;
    printf("%.7f\n", sum);
    return 0;
}

Measured memory_bytes: 3756
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import qualified Data.ByteString.Char8 as BS
import Debug.Trace
import qualified Data.IntMap.Strict as IntMap
import Data.List

takeLT :: Int -> IntMap.IntMap Int -> Maybe (Int, IntMap.IntMap Int)
takeLT k m = case IntMap.lookupLT k m of
               Just (l, a) | a == 1 -> Just (l, IntMap.delete l m)
                           | otherwise -> Just (l, IntMap.update (const $! Just $! a-1) l m)
               Nothing -> Nothing

check :: IntMap.IntMap Int -> IntMap.IntMap Int -> Bool
check m m' | IntMap.null m' = True
           | otherwise = case IntMap.foldrWithKey (\ !k !a acc -> case acc of Just (_,_) -> iterate (f k) acc !! a; Nothing -> Nothing) (Just (m, m')) m of
                           Just (m2, m'2) -> check m2 m'2
                           Nothing -> False
  where f :: Int -> Maybe (IntMap.IntMap Int, IntMap.IntMap Int) -> Maybe (IntMap.IntMap Int, IntMap.IntMap Int)
        f !k (Just (!m, !m')) = case takeLT k m' of
                                  Just (l, !m'2) -> let !m2 = IntMap.insertWith (+) l 1 m
                                                    in Just (m2, m'2)
                                  Nothing -> Nothing
        f k Nothing = Nothing

main = do
  n <- readLn :: IO Int -- 1 <= n <= 18
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = foldl' (\m x -> IntMap.insertWith (+) x 1 m) IntMap.empty xs
  let result = case IntMap.deleteFindMax m of
                 ((x, a), m') | a == 1 -> check (IntMap.singleton x 1) m'
                              | otherwise -> False
  if result
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 55164
import java.util.Scanner;

public class Main
{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        String[][] a = new String[n][n];
        String[][] b = new String[m][m];
        for (int i = 0 ; i < n ; i++) {
            String c  = sc.next();
            for (int j = 0 ; j < n ; j++) {
                a[i][j] = c.substring(j, j + 1);
            }
        }

        for (int i = 0 ; i < m ; i++) {
            String c  = sc.next();
            for (int j = 0 ; j < m ; j++) {
                b[i][j] = c.substring(j, j + 1);
            }
        }

        boolean exist = false;
        for (int i = 0 ; i < n - m + 1 ; i++ ) {
            for (int j = 0 ; j < n - m + 1 ; j++ ) {
                boolean match = true;
                for (int k = 0 ; k < m ; k++ ) {
                    for (int l = 0 ; l < m ; l++ ) {
                        if (!a[k + i][l + j].equals(b[k][l])) {
                           match = false;
                        }
                    }
                }
                if (match) {
                    exist = true;
                }

            }
        }
        if (exist) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

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

using namespace std;

using ll = long long;

class LazySegmentTree{
    public:
    ll size;
    vector<ll> dat, lazy;

    LazySegmentTree(ll n){
        size = 1;
        while(size < n) size *= 2;

        dat = vector<ll>(2*size - 1, 0LL);
        lazy = vector<ll>(2*size - 1, 0LL);
    }

    void eval(ll k, ll l, ll r){
        if(lazy[k] != 0){
            dat[k] += lazy[k];

            // if not bottom of the tree
            if(r - l > 1){
                lazy[k*2+1] += lazy[k] / 2; 
                lazy[k*2+2] += lazy[k] / 2;
            }

            lazy[k] = 0;
        }
    }

    // Add x to [l, r)
    void add(ll a, ll b, ll x, ll k=0, ll l=0, ll r=-1){
        if(r < 0) r = size;

        eval(k, l, r);

        if(b <= l || r <= a) return;

        if(a <= l && r <= b){
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }else{
            add(a, b, x, k * 2 + 1, l, (l + r) / 2);
            add(a, b, x, k * 2 + 2, (l + r) / 2, r);
            dat[k] = dat[k*2+1] + dat[k*2+2];
        }
    }

    // Get sum of [l, r)
    ll getSum(ll a, ll b, ll k=0, ll l=0, ll r=-1){
        if(r < 0) r = size;
        if(b <= l || r <= a) return 0;

        eval(k, l, r);
        if(a <= l && r <= b) return dat[k];
        else{
            ll vl = getSum(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = getSum(a, b, k * 2 + 2, (l + r) / 2, r);
            return vl + vr;
        }
    }
};

// DSL_2_G: verified
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, q; cin >> n >> q;
    LazySegmentTree lsg(n);
    vector<ll> ans;
    for(ll i=0;i<q;i++){
        ll com; cin >> com;
        if(com == 0){
            ll s, t, x; cin >> s >> t >> x;
            lsg.add(s - 1, t, x);
        }else{
            ll s, t; cin >> s >> t;
            ans.push_back(lsg.getSum(s - 1, t));
        }
    }
    for(ll a: ans) cout << a << endl;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#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++)

int main() {
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  REP(i, N) {
    REP(j, 10) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  REP(i, N) {
    REP(j, 11) {
      cin >> P[i][j];
    }
  }
  vector<int> ans;
  for(int b = 1; b < (1 << 10); b++) {
    int cc = 0;
    REP(i, N) {
      int c = 0;
      REP(j, 10) {
        if(b >> j & 1 && F[i][j] == 1) {
          c++;
        }
      }
      cc += P[i][c];
    }
    ans.push_back(cc);
  }
  int a = *max_element(ans.begin(), ans.end());
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && a!=c) cout<<c<<endl;
    else if(a==c && a!=b) cout<<b<<endl;
    else cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
good_tower =[1]*n

for i in range(m):
  a,b = map(int, input().split())
  high_a = h[a-1]
  high_b = h[b-1]
  if high_a > high_b:
    good_tower[b-1] = 0
  elif high_b > high_a:
    good_tower[a-1] = 0
  elif high_a == high_b:
    good_tower[b-1] = 0
    good_tower[a-1] = 0
    
print(sum(good_tower))

Measured memory_bytes: 19936
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


signed main(){
    int h;
    int w;

    while(1){
        std::cin >> h;
        std::cin >> w;

        if (h == 0 & w == 0){
            break;
        }

        for(auto i = 0; i < h; i++){
            for(auto j = 0; j < w; j++){
                if(i % 2 == 0){
                    if(j % 2 == 0){
                        std::cout << "#";
                    }
                    else{
                        std::cout << ".";
                    }
                }
                else if(i % 2 == 1){
                    if(j % 2 == 1){
                        std::cout << "#";
                    }
                    else{
                        std::cout << ".";
                    }
                }
            }
            std::cout << "" << std::endl;
        }
        std::cout << "" << std::endl;
    }

    return 0;
}


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

int findSumOfDigits(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

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

  int min_sum = 1000000;
  for (int a = 1; a <= n -1; a++) {
    min_sum = min(min_sum, findSumOfDigits(a) + findSumOfDigits(n-a));
  }
  cout << min_sum << endl;
}


Measured memory_bytes: 256
s = input()
plus_len = len(s) - 1
num_search = 2 ** plus_len
result = 0
for i in range(num_search):
  x = ''
  for index,value in enumerate(s):
    x += value
    if (i >> index) & 1:
      x += '+'
  
  #print(x)
  #print(eval(x))
  result += eval(x)
print(result)

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace ABC154_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Trim().Split(' ').Select(a => int.Parse(a)).ToArray();
            Array.Sort(A);
            for (int i = 0; i < N - 1; i++)
            {
                if (A[i] == A[i + 1])
                {
                    Console.WriteLine("NO");
                    Environment.Exit(0);
                }
            }
            Console.WriteLine("YES");
        }
    }
}

Measured memory_bytes: 34268
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int ans[10004];
void solve() {
    for (int i=1;i<=100;++i) {
        for (int j=1;j<=100;++j) {
            for (int k=1;k<=100;++k) {
                int go = i * i + j * j + k * k + i * j + k * j + i * k; 
                if (go > 10000) continue;
                ans[go]++;
            }
        }
    }
    int n;
    cin >> n;
    for (int i=1;i<=n;++i) cout << ans[i] << "\n";
} 

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

Measured memory_bytes: 3580
#include<stdio.h>

int main(void) {
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	int ax, bx;
	if (a > x) ax = a - x;
	else ax = x - a;
	if (b > x) bx = b - x;
	else bx = x - b;
	if (ax > bx) printf("B");
	else printf("A");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))
cnt = 0
lis = [0]
for i in range(n-1):
    if h[i] >= h[i+1]:
        cnt += 1
    else:
        lis.append(cnt)
        cnt = 0
lis.append(cnt)
print(max(lis))

Measured memory_bytes: 20320
<?php
$stdin = trim(fgets(STDIN));
$stdin = trim(fgets(STDIN));
$array = explode(" ", $stdin);

$alh = count($array);

$wa = 0;
$sa = 0;

for($i = 0; $i < $alh -1; $i++){
    $sa = (int) $array[$i +1] - (int) $array[$i];
    if($sa < 0){
      $wa = $wa + (int) $sa * -1;
      $array[$i + 1] = $array[$i];
    }
}

echo $wa;
?>

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, K;
	cin >>N >>K;
	vector<vector<int>> C(K+2, vector<int> (K+2, 0));
	int S0=0;
	for (int i=0; i<N; i++) {
		int x, y;
		char c;
		cin >>x >>y >>c;
		if (0==(x/K+y/K)%2)
			if ('B'==c) {
				C.at(x%K+1).at(y%K+1)++;
				S0++;
			} else
				C.at(x%K+1).at(y%K+1)--;
		else
			if ('B'!=c) {
				C.at(x%K+1).at(y%K+1)++;
				S0++;
			} else
				C.at(x%K+1).at(y%K+1)--;
	}
	vector<vector<int>> C0(K+2, vector<int> (K+2, 0));
	for (int i=1; i<=K; i++)
		for (int j=1; j<=K; j++)
			C0.at(i).at(j)=C0.at(i-1).at(j)+C0.at(i).at(j-1)-C0.at(i-1).at(j-1)-C.at(i).at(j);
	vector<vector<int>> C1(K+2, vector<int> (K+2, 0));
	for (int i=K; i>0; i--)
		for (int j=K; j>0; j--)
			C1.at(i).at(j)=C1.at(i+1).at(j)+C1.at(i).at(j+1)-C1.at(i+1).at(j+1)-C.at(i).at(j);
	vector<vector<int>> C2(K+2, vector<int> (K+2, 0));
	for (int i=1; i<=K; i++)
		for (int j=K; j>0; j--)
			C2.at(i).at(j)=C2.at(i-1).at(j)+C2.at(i).at(j+1)-C2.at(i-1).at(j+1)-C.at(i).at(j);
	vector<vector<int>> C3(K+2, vector<int> (K+2, 0));
	for (int i=K; i>0; i--)
		for (int j=1; j<=K; j++)
			C3.at(i).at(j)=C3.at(i+1).at(j)+C3.at(i).at(j-1)-C3.at(i+1).at(j-1)-C.at(i).at(j);
	int S=-INF;
	for (int i=0; i<=K; i++)
		for (int j=0; j<=K; j++)
			S=max(S, C0.at(i).at(j)+C1.at(i+1).at(j+1));
	for (int i=0; i<=K; i++)
		for (int j=K+1; j>0; j--)
			S=max(S, C2.at(i).at(j)+C3.at(i+1).at(j-1));
	cout <<S+S0 <<endl;
	return 0;
}



Measured memory_bytes: 19968
n=int(input())
import sys
import math

ALPHABET = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

print(alphabet_decimal(n))

Measured memory_bytes: 9228
#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
#include<vector>
int main(){
  std::stack<int> S1;
  std::stack<std::pair<int, int> > S2;
  char c;
  int sum=0;
  for(int i=0; std::cin>>c; i++){
    if(c == '\\') S1.push(i);
    else if(c == '/' && S1.size() > 0){
      int tmp1 = S1.top(); S1.pop();
      sum += i - tmp1;
      int tmp2 = i - tmp1;
      while(S2.size() > 0 && S2.top().first > tmp1) tmp2 += S2.top().second, S2.pop();
      S2.push(std::make_pair(tmp1,tmp2));
    }
  }
  std::vector<int> out;
  std::cout << sum << std::endl;
  sum = 0;
  while(S2.size() > 0) out.push_back(S2.top().second), S2.pop();
  std::reverse(out.begin(),out.end());
  std::cout << out.size();
  for(int i=0; i<out.size(); i++){
    sum += out[i];
    std::cout << " " << out[i];
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
ll sum=0;
ll max_ele=a[0];
for(int i=1;i<n;i++)
{
if(a[i]<max_ele)
{
sum=sum+max_ele-a[i];
}
max_ele=max(max_ele,a[i]);
}
cout<<sum;
}

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

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

    int ans = 0;

    int first = 0, last = s.size() - 1;
    while (first <= last) {
        if (s[first] != s[last]) ans++;
        first++;
        last--;
    }

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


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

using namespace std;

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

    int i,n;
    cin >> n;
    int a[n+2],mx=0;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++)
    {
        if(mx-a[i] > 1)
        {
            cout << "No";
            return 0;
        }
        mx=max(mx,a[i]);
    }
    cout << "Yes";
    return 0;
}


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

int main( void )
{
    int n;
    cin >> n;
    
    ll ans = n * 800 - n / 15 * 200;
    
    cout << ans << endl;
}


Measured memory_bytes: 256