akhauriyash/Code-Regression huggingface dataset:
using System;
//using System.Collections.Generic;
class Untitled
{
	static void Main(string[] args)
	{
		bool parsed = false;
		string s;
		int index = 1;
		// List <int> list = new List <int> ();
		while (!String.IsNullOrEmpty (s = Console.ReadLine())) {
			int i = 0;
			parsed = Int32.TryParse (s, out i);
			if (parsed && i != 0) {
			//  	list.Add (i);
			Console.WriteLine ("Case " + index + ": " + i); 
			} else {
				break;
			}
			index++;
		}
//		for (int i = 0; i < list.Count; i++) {
		//	Console.WriteLine ("Case " + i + ": " + list [i]); 
//		}
	}
}

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

using namespace std;

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int answer = 0;
    for (int i = 0; i <= n / r; ++i) {
        for (int j = 0; j <= n / g; ++j) {
            if (n >= i * r + j * g && (n - i * r - j * g) % b == 0) {
                ++answer;
            }
        }
    }
    cout << answer << endl;
}


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

// int a = 97

int main() {
	char x;	cin >> x;
  	char out = (char)((int)x + 1);
  	cout << out << endl;
}

Measured memory_bytes: 256
import sys
n, m, q = map(int, input().split())
alis, blis, clis, dlis = [], [], [], []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    alis.append(a)
    blis.append(b)
    clis.append(c)
    dlis.append(d)
sys.setrecursionlimit(10**9)
Alist = [] 
def dfs(A):
    if len(A)==(n+1):
        Alist.append(A)
        return
    for i in range(A[-1], m+1):
        dfs(A+[i])

dfs([1])

ans = 0
for A in Alist:
    score = 0
    for i in range(q):
        if A[blis[i]] - A[alis[i]] == clis[i]:
            score += dlis[i]
    ans = max(ans, score)

print(ans)

Measured memory_bytes: 24300
int main(){
    int n,array[50],array2[100];
    int difference[20];
    int sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&array[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&array2[i]);
        difference[i]= array[i] - array2[i];
    }
    for(int i=0;i<n;i++){
        if(difference[i]>0){
            sum+=difference[i];
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 53

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

struct edge{
  int to,cost;
};

int A[NMAX],B,C,N,K,W,H,ans = 0,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
vector<int > v;

void solve(){
	for (int i = 0; i < N; ++i)
	{
		v.push_back(A[i]);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < K; ++i)
	{
		ans += v[N-1-i];
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

using namespace std;

int main()
{
	int n;
	int data[10];
	int a[11],b[11];
	int ai,bi;
	int k;
	int flag;
	cin>>n;
	while(n--){
		for(int i=0;i<10;i++) cin>>data[i];
		a[0]=b[0]=0;
		ai=bi=0;
		flag=0;
		for(k=0;k<10;k++){
			if(a[ai]<data[k]){
				a[ai+1]=data[k];
				ai++;
			}
			else if(b[bi]<data[k]){
				b[bi+1]=data[k];
				bi++;
			}
			if(data[k]<a[ai] && b[bi]>data[k])
				flag=1;
		}
		if(flag==1) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int[] inp = IntLine();
        int H = inp[0], W = inp[1];
        string[] g = new string[H];
        for (int i = 0; i < H; i++) g[i] = Console.ReadLine();

        long[,] dp = new long[1010, 1010];
        for (int i = 0; i <= 1000; i++) for (int j = 0; j <= 1000; j++) dp[i, j] = 0;
        dp[0, 0] = 1;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                dp[i, j] %= INF;
                if (g[i][j] == '#') continue;
                if (j + 1 != W)
                {
                    if (g[i][j + 1] == '.') dp[i, j + 1] += dp[i, j];
                }
                if (i + 1 != H)
                {
                    if (g[i + 1][j] == '.') dp[i + 1, j] += dp[i, j];
                }
            }
        }
        Console.WriteLine(dp[H - 1, W - 1]);
    }
}



public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 29148
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {
	const int len = 10;
	int arr[len];

	for (int i = 0; i < len; i++)
		cin >> arr[i];

	for (int i = 0; i < len; i++)
		for (int j = 0; j < len; j++)
			if (arr[i] < arr[j])
				swap(arr[i], arr[j]);

	for (int i = len - 1; len - 4 < i; i--)
		cout << arr[i] << endl;

	return 0;
}

Measured memory_bytes: 1164
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri(), a = ri(), b = ri();
	std::cout << std::min(n * a, b) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC target ("avx")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b) {
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if(a<b){a=b;return true;}
	return false;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	int sum=0;
	REP(i,N+1){
		if(i%3&&i%5)sum+=i;
	}
	cout<<sum<<"\n";
}


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

int main(){
    int c[3][3], a[3] = {0}, b[3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j]; // c[i][j] == a[i] + b[j]
            if(i == 0){
                b[j] = c[i][j];
            }
        }
    }
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    int success = 1;
    for(int i = 1; i < 3; i++){
        for(int j = 1; j < 3; j++){
            if(c[i][j] - b[j] != a[i]){
                success = 0;
                break;
            }
        }

        if(success == 0){
            break;
        }
    }

    if(success == 1){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

int main(){
  int N;
  cin>>N;
  lint ans;
  cin>>ans;
  FOR(i,1,N){
    lint T;
    cin>>T;
    ans=ans/gcd(ans,T)*T;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	string s;
      	int x=0,a[100]={};
      	cin>>s;
      	for(int i=0;i<s.size();i++){
          if(a[s[i]-'a']==0)
            a[s[i]-'a']++;
          else{
          	cout<<"no"<<endl;
            return(0);
          }
        }
      cout<<"yes"<<endl;
      return(0);
    }

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

const int MAX = 510000;
const int MOD = 1000000007;

vector<int64_t> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

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

  map<int64_t,int> prime=prime_list(M);
  COMinit();

  int64_t ans=1;
  for(auto p:prime){
    ans=(ans*COM(N+p.second-1,p.second))%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   string s,t;
   cin>>s>>t;
   for(long long int i=0;i<s.size();i++)
   {
      if(s[i]!=t[i])
      {
         cout<<"No"<<endl;
         return 0;
      }
   }
   cout<<"Yes"<<endl;
   return 0;
}


Measured memory_bytes: 3628
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n = ii()
    h = li()
    dp = [0 for i in range(n+5)]
    dp[1] = abs(h[1]-h[0])
    for i in range(2,n):
        dp[i] = min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1])

    print(dp[n-1])







main()




Measured memory_bytes: 15124
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    boost;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    string s2 = s;
    sort(s2.begin(),s2.end());
    ll cnt1 =0, cnt2 =0;
    for(ll i=0;i<s2.length(); i++)
    {
        // cout<<s2[i]<<" "<<s[i]<<"\n";
        if(s2[i] == 'R' && s[i] == 'W')
        cnt1++;
        if(s2[i] == 'W' && s[i] == 'R')
        cnt2++; 
    }
    ll ans = min(cnt1,cnt2) + abs(cnt1-cnt2);
     cout<<ans<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3868
//Distance2
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int n, x[1000], y[1000];
	double sum1 = 0, sum2 = 0, sum3 = 0, sum4 = -1;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> x[i];
	for(int i = 0; i < n; i++){
		cin >> y[i];
		sum1 += fabs((double)(x[i] - y[i]));
		sum2 += pow(fabs((double)(x[i] - y[i])),2);
		sum3 += pow(fabs((double)(x[i] - y[i])),3);
		sum4 = max(fabs(x[i]-y[i]), sum4);
	}
	cout << fixed << setprecision(6) << sum1 << endl;
	cout << pow(sum2, (double)1/2) << endl;
	cout << pow(sum3, (double)1/3) << endl;
	cout << sum4 << endl;
	


	return 0;
}


Measured memory_bytes: 3428
def yymm(S):
    return 1 <= int(S[2:]) <= 12


def mmyy(S):
    return 1 <= int(S[:2]) <= 12


def main():
    S = input()
    y = yymm(S)
    m = mmyy(S)
    if y and m:
        print("AMBIGUOUS")
    elif y:
        print("YYMM")
    elif m:
        print("MMYY")
    else:
        print("NA")


if __name__ == "__main__":
    main()


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

int main(){
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  stack<int> ans;
  while(true){
    int rem=-1;
    if(b.empty()){
      break;
    }
    for(int i=0;i<b.size();i++){
      if(b.at(i)==i+1){
        rem=i;
      }
    }
    if(rem==-1){
      cout << -1 << endl;
      return 0;
    }
    ans.push(b.at(rem));
    b.erase(b.begin()+rem);
  }
  while(!ans.empty()){
    cout << ans.top() << endl;
    ans.pop();
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
using namespace std;
typedef long long ll;
int main() {
	int n, k;
	cin >> n >> k;
	if (n%k) {
		cout << 1 << endl;
		return 0;
	}
	else cout << 0 << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,d;
  int b[1000000],c[1000000];
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
    c[i]=b[i];
  }
  sort(b,b+a,greater<int>());
  for(int i=0;i<a;i++){
    d=0;
    if(b[0]!=c[i]){
      cout<<b[0]<<"\n";
      d=1;
    }
    if(b[0]==c[i]&&d==0||b[0]==c[i]){
      cout<<b[1]<<"\n";
    }
  }
  return(0);
}



Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));    // lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<int>fv;
    vector<int>sv;
    for(int i=0; i<m; i++){
        int tf, ts;
        cin >> tf >> ts;
        fv.push_back(tf);
        sv.push_back(ts);
    }

    int min = *max_element(fv.begin(), fv.end());
    int max = *min_element(sv.begin(), sv.end());
    int count = (max - min) >= 0 ? (max - min + 1) : 0;
    cout << count << endl;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

const ll MOD = 1e9+7;

ll dp[60][2];
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string A,B,C;
    
    while(cin >> A){
        if(A == "0") break;
        cin >> B >> C;
        
        reverse(A.begin(),A.end());
        reverse(B.begin(),B.end());
        reverse(C.begin(),C.end());
        
        fill(*dp,*dp+60*2,0);
        dp[0][0] = 1;
        int len = (int)A.length();
        for(int i = 0; i < len;i++){
            for(int j = 0; j < 2;j++){
                if(dp[i][j] == 0) continue;
                
                int Al,Ar,Bl,Br,Cl,Cr;
                Al = Bl = Cl = 0;
                Ar = Br = Cr = 9;
                
                
                if(A[i] != '?'){
                    Al = Ar = A[i] - '0';
                }
                if(B[i] != '?'){
                    Bl = Br = B[i] - '0';
                }
                if(C[i] != '?'){
                    Cl = Cr = C[i] - '0';
                }
                
//                cout << " ======" << endl;
//                cout << i << " " << j <<  endl;
//                cout << Al << " " << Ar << " " << Bl << " " << Br << " " << Cl << " " << Cr << endl;
                for(int a = Al; a <= Ar; a++){
                    if(i+1 == len && a == 0) continue;
                    for(int b = Bl; b <= Br; b++){
                        if(i+1 == len && b == 0) continue;
                        for(int c = Cl; c <= Cr;c++){
                            if(i+1 == len && c == 0) continue;
                            if(a+b+j==c){
                                (dp[i+1][0] += dp[i][j])%=MOD;
                            }
                            if(a+b+j==10+c){
                                (dp[i+1][1] += dp[i][j])%=MOD;
                            }
                        }
                    }
                }
            }
//            cout << dp[i][0] << " " << dp[i][1] << endl;
//            cout << dp[i+1][0] << " " << dp[i+1][1] << endl;
//            cout << " ====== " << endl;
        }
//        cout << dp[len][0] << " " << dp[len][1] << endl;
        cout << dp[len][0] << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a) for(int i=0;i<(a).size();i++) cin>>(a)[i];

int main()
{
    char c;
    cin >> c;
    cout << (char)(c + 1);
    return 0;
}

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

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && A == C && B == C)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s<t) cout << "Yes";
	else cout << "No";
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

ll a[100010], b[100010];

int  main() {
	
	int n;
	ll ans = 0;
	cin >> n;

	rep(i, n) cin >> a[i] >> b[i];
	
	for (int i = n - 1; i >= 0; i--) {
		a[i] += ans;
		if(a[i] % b[i] != 0)ans += b[i] - (a[i] % b[i]);
	}

	pr(ans);

	return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"Bad"<<endl;return 0;}
//template

//main
signed main(){
  int a,b,c,d,l,h;cin>>a>>b>>c>>d;
  int ans=b-a+1;

  h=(b/c);
  l=((a-1)/c);
  ans-=(h-l);

  swap(c,d);

  h=(b/c);
  l=((a-1)/c);
  ans-=(h-l);

  c*=d/__gcd(c,d);

  h=(b/c);
  l=((a-1)/c);
  ans+=(h-l);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll myxor(ll a)
{
    if(a % 4 == 1)
    {
        return 1;
    }
    else if(a % 4 == 2)
    {
        return a + 1;
    }
    else if(a % 4 == 3)
    {
        return 0;
    }
    else
    {
        return a;
    }
}

int main()
{
    ll a, b;
    cin>>a>>b;
    if(a == 0 && b == 0)
        cout<<0<<endl;
    else if(a == 0 && b != 0)
    {
        a = a + 1;
        cout<<((myxor(b))^(myxor(a-1)))<<endl;
    }
    else
        cout<<((myxor(b))^(myxor(a-1)))<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - HSI
	var N, M float64
	fmt.Scanf("%f %f", &N, &M)

	sum := M*1900 + (N-M)*100
	rate := math.Pow(2, M)
	fmt.Println(int(sum * rate))
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  int a,b,c;
  ci(a>>b>>c);
  cout<<max(0,b+c-a)<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
typedef tuple<ll,ll,ll> tl;
typedef tuple<ll,ll,ll,ll> ql;

#define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
#define ROF(i, a, b) for(ll i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 10+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll s, w;
    cin >> s >> w;
    if (w>=s) cout << "unsafe";
    else cout <<"safe";
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

// abc075
int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];

	sort(ALL(A));

	int flag = true;

	for(int i=(N%2?1:0);i<N;i+=2){
		if(A[i]!=A[i+1]){
			flag = false;
			break;
		}
	}

	if(flag){
		cout << mpow(2,(ll)N/2) << endl;
	}
	else{
		cout << 0 << endl;
	}


	return 0;
}




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



int main() 
{
    int a, b;
    cin >> a >> b;
    if(a-2*b<0)
    {
    cout << 0 << endl;
    }
    else
    {
    cout << a - 2 * b << endl;
    }

    return 0;
}

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

int main(){
    long long A, B, C,D;
    cin >> A >> B >> C >>D;
    while(A>0&&C>0){
        C = C-B;
        if(C<=0) break;
        A = A-D;
    }
    if(A>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

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

int main() {
	int n,k,d,o,count=0;

	cin >> n >> k;
  	vector<int> a(n,0);
	for(int i=0;i<k;i++)
	{   
		cin >> d;
		for(int j=0;j<d;j++)
		{
			cin >> o;
			a.at(o-1) += 1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a.at(i)==0)
		{
			count++;
		}
	}
	cout << count;
  
}


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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

/* -------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------*/

void A(){
 	int n,h,w; cin>>n>>h>>w; 
 	cout<<(n-h+1)*(n-w+1);  
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    A(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
function main()
  
  S = chomp(readline())
  
  check1 = false
  check2 = false
  
  for i in S
    if i == 'C'
      check1 = true
    elseif check1 && i == 'F'
      check2 = true
    end
  end
  
  if check1 && check2
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 167172
import sys
input = sys.stdin.readline


n, c = map(int, input().split())

TABLE = [[0] * 10**5 for _ in range(c)]
for _ in range(n):
    s, t, i = [int(x) - 1 for x in input().split()]
    for j in range(s, t + 1):
        TABLE[i][j] = 1

answer = 0
for j in range(10**5):
    temporary = sum(TABLE[i][j] for i in range(c))
    answer = max(answer, temporary)

print(answer)


Measured memory_bytes: 66268
x,n=map(int,input().split())
if n!=0:
  li=list(map(int,input().split()))
  si=list(range(-10,130))

  for k in li:
    si.remove(k)
  li=si  
  li=sorted(li,reverse=True)
  sa=150
  ans=0
  for i in li:
    mi=abs(i-x)
    sa=min(mi,sa)
    if mi==sa:
      ans=i

  print(ans)
else:
  print(x)

Measured memory_bytes: 9132
n,x=map(int,input().split());s,f,M=sorted(list(map(int,input().split())))[::-1],[1,1],10**9+7
for i in range(2,n):f+=[f[-1]*i%M]
D={x:f[n-1]}
for i, k in enumerate(s):
 m,inv=dict(),pow(n-i-1,M-2,M)
 for j,a in D.items():m[j%k]=(m.get(j%k,0)+a)
 for j,a in m.items():D[j]=(D.get(j,0)+a*inv)%M
print(sum([i*j for i, j in m.items()])%M)

Measured memory_bytes: 5160
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                ans+=1
print(ans)

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

int main()
{
    char c;
    cin >> c;
    switch (c)
    {
    case 'A':
        cout << 'T' << endl;
        break;
    case 'T':
        cout << 'A' << endl;
        break;
    case 'G':
        cout << 'C' << endl;
        break;
    case 'C':
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int t;
		scanf("%d", &t);
		n -= t;
	}
	printf("%d\n", n<0?-1:n);
	return 0;
}

Measured memory_bytes: 3828
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int now, next;
    cin >> now >> next;
    cout << next * 2 - now << endl;
    return 0;
}


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

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

ll n,a[300000];

ll calc(ll b) {
    ll ret = 0;
    rep(i,n) {
        ret += abs(a[i] - (b + i + 1));
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];

    ll l = -2000000010,r = 2000000010;

    while(r - l > 1) {
        int mid = (l + r) / 2;
        //(calc(mid) - calc(mid - 1) > 0) ? l : r = mid;
        if(calc(mid) - calc(mid-1) > 0) r = mid;
        else l = mid;
        //cerr << l << " " << r << endl;
    }
    cout << calc(l) << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    public class Solver
    {
        public void Solve()
        {
            int[] input = ria();
            int A = input[0];
            int B = input[1];

            int taps = 1;
            int count = 0;

            while(taps < B)
            {
                taps = taps - 1 + A;
                count++;
            }

            Console.WriteLine(count);

        }

        int ri() { return int.Parse(Console.ReadLine()); }
        long rl() { return long.Parse(Console.ReadLine()); }
        double rd() { return double.Parse(Console.ReadLine()); }
        string rs() { return Console.ReadLine(); }

        int[] ria() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        long[] rla() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        double[] rda() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        string[] rsa() { return Console.ReadLine().Split(' '); }

    }

    public class Program
    {
        static void Main()
        {
            var solver = new Solver();
            solver.Solve();
        }
    }
}

Measured memory_bytes: 13268
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a % 2 == b % 2){
        cout << (b - a) / 2 << '\n';
        return 0;
    }
    cout << min(a + ((b - a) - 1) / 2, (n - b + 1) + (n - (a + n - b + 1)) / 2) << '\n';
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

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

    string name;
    while(N){
        N--;
        name += 'a' + N%26;
        N /= 26;
    }

    rvs(name);
    cout << name << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int


int cmpfunc (const void * a, const void * b)
{
    return ( *(int*)a - *(int*)b );
}


int main()
{
    int N , K;
    scanf("%d %d",&N,&K);

    int array[N];

    for (int i = 0; i<N; i++)
        scanf("%d",&array[i]);


    qsort(array,N,sizeof(int),cmpfunc);


    int min = INT_MAX;
    int res = 0;
    for (int  j = 0; j<N; j++)
    {
       if (j+K-1<N)
        res=array[j+K-1]-array[j];

       if (min>res)min=res;
    }

    printf("%d",min);

    return 0;
}


Measured memory_bytes: 892
N,K = map(int, input().split())
X = [int(i) for i in input().split()]

ans = float("inf")

for left in range(N-K+1):
    right = left + K - 1

    if X[left] <=0 and X[right] <= 0:
        cur = abs(X[left])
    elif X[left] >= 0 and X[right] >= 0:
        cur = abs(X[right])
    else:
        if abs(X[left]) >= abs(X[right]):
            cur = abs(X[right]) * 2 + abs(X[left])
        else:
            cur = abs(X[left]) * 2 + abs(X[right])
    ans = min(ans, cur)

print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
 
using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
typedef pair <lli,lli> pll;
 
 
lli countGreater(lli arr[], lli n, lli k) 
{ 
    lli l = 0; 
    lli r = n - 1; 
  
    // Stores the index of the left most element 
    // from the array which is greater than k 
    lli leftGreater = n; 
  
    // Finds number of elements greater than k 
    while (l <= r) { 
        lli m = l + (r - l) / 2; 
  
        // If mid element is greater than 
        // k update leftGreater and r 
        if (arr[m] > k) { 
            leftGreater = m; 
            r = m - 1; 
        } 
  
        // If mid element is less than 
        // or equal to k update l 
        else
            l = m + 1; 
    } 
  
    // Return the count of elements greater than k 
    return (n - leftGreater); 
}
 
bool is_palin(string input)
{
if (input == string(input.rbegin(), input.rend())) 
    return true;
return false;
}
void solve()
{
    lli r;cin>>r;
    cout<<(2*r*(3.14159265359));
}
 
int main()
{
    kira; 
 
    lli t=1; //cin>>t;
    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3804
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		sc.close();

		for (int i = n; i >= 0; i--) {
			if (s.endsWith(t.substring(0, i))) {
				System.out.println(i + (n - i) * 2);
				return;
			}
		}
	}
}


Measured memory_bytes: 21716
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 1000000+1
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
vector<bool>Isprime(MAX+1,true);
vi dp(MAX+1,0);
int main(){
    int n;
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(Isprime[i]){
            for(int j = 2;i*j<MAX;j++)
                Isprime[i*j] = false;//テァツエツ?ヲツ閉ーテ」ツ?ェテ」ツつ臼rimearrayテ」ツ?ォテヲツ?シテァツエツ催」ツ?療」ツ?ヲテ」ツ?敕」ツ?ョテ・ツ?催ヲツ閉ーテ」ツつ津・ツ?ィテ」ツ?ヲfalseテ」ツ?ォ
            Primecounter++;
        }
    }
    int x;
    while(cin>>n>>x,n+x){
        rep(i,x+1)dp[i]=0;
        vi tiya;
        rep(i,n){
            int gotiusa_is_a_god_anime;
            cin>>gotiusa_is_a_god_anime;
            tiya.push_back(gotiusa_is_a_god_anime);
            dp[gotiusa_is_a_god_anime]=1;
        }
        rep(j,n)rep(i,x+1){
            if(dp[i]){
                if(i+tiya[j]<=x) dp[i+tiya[j]]=1;
            }
        }
        int maxi=-INF;
        for(int i=1; i<=x;i++)if(Isprime[i]&&dp[i])cmax(maxi,i);
        if(maxi!=-INF&&maxi!=1)cout<<maxi<<endl;
        else cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 6532
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

dp = [float('inf')]*n 
dp[0] = 0
for i in range(n-1):
    dp[i+1] = dp[i] + min((x[i+1] - x[i])*a, b)

print(dp[-1])

Measured memory_bytes: 84960
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  
  if(a + b == 15) {
    cout << "+\n";
  } else if(a * b == 15) {
    cout << "*\n";
  } else {
    cout << "x\n";
  }
  
  return 0;
}


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

int main(void){
    int N;
    char s[50][100];
    int t[50];
    char X[100];

    int i;
    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%s %d", s[i], &t[i]);    
    }
    scanf("%s", X);
    
    for(i=0;i<N;i++){
        if(strcmp(X,s[i])==0){
            break;
        }
    }
    int ans=0;
    for(i=i+1;i<N;i++){
        ans+=t[i];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;

const int MAXN = 234567;
int A[MAXN];
int cnt[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        cnt[A[i]]++;
    }
    LL ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += (LL)cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        int cur = A[i];
        LL cur_ans = ans - cnt[cur] + 1;
        printf("%lld\n", cur_ans);
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)

using namespace std;

int main(){
	char S[55];
	scanf("%s", S);
	int n = strlen(S) - 1;
	S[n - 7] = '\0';
	printf("%s", S);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX = 100000;
int n,U[MAX];
void init()
{
	for (int i = 0; i < n; i++)
		U[i] = i;
}
int getAncestor(int v)
{
	if (U[v] == v)
		return v;
	else
	{
		U[v] = getAncestor(U[v]);
		return U[v];
	}
}
void unite(int s, int t)
{
	int a1 = getAncestor(s);
	int a2 = getAncestor(t);
	if (a1 != a2)
		U[a2] = a1;
}
int same(int s, int t)
{
	return getAncestor(s) == getAncestor(t);
}
int main()
{
	int q;
	cin >> n >> q;
	init();
	for (int i = 0; i < q; i++)
	{
		int com, s, t;
		cin >> com >> s >> t;
		if (com == 0)
			unite(s, t);
		else if (com == 1)
			cout << same(s, t) << endl;
	}
}


Measured memory_bytes: 3104
#include<stdio.h>
int main() {
	int n=0,i;
	char s[5];
	scanf("%s", &s);
	for (i = 0;i < 4;i++) {
		if (s[i] == '+') {
			n++;
		}
		else if (s[i] == '-') {
			n--;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;

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

template <typename T, typename E>
struct SegmentTree {
private:
    typedef function<T(T, T)> F;
    typedef function<T(T, E)> G;
    int n;
    F merge_func;
    G update_func;
    T identity_item;
    vector<T> nodes;

public:
    SegmentTree(int n_, F merge_func, G update_func, T identity_item, const vec<T>& v=vector<T>()) {
        this->merge_func = merge_func;
        this->update_func = update_func;
        this->identity_item = identity_item;
        nodes_init(n_);
        if (n_ == (int)v.size()) build(n_, v);
    }

    void nodes_init(int n_) {
        n = 1;
        while (n <= n_) n *= 2;
        nodes.clear();
        nodes.resize(2 * n - 1, identity_item);
    }

    void build(int n_, const vector<T>& v) {
        for (int i = 0; i < n_; i++) {
            nodes.at(i + n - 1) = v.at(i);
        }
        for (int i = n - 2; i >= 0; i--) {
            nodes.at(i) = merge_func(nodes.at(i * 2 + 1), nodes.at(i * 2 + 2));
        }
    }

    void update(int idx, E value) {
        int node_idx = idx + n - 1;
        nodes.at(node_idx) = update_func(nodes.at(node_idx), value);
        int current_idx = node_idx;
        while (current_idx) {
            current_idx = (current_idx - 1) / 2;
            nodes.at(current_idx) = merge_func(nodes.at(2 * current_idx + 1), nodes.at(2 * current_idx + 2));
        }
    }

    T query(int query_left, int query_right, int cur_idx, int cur_left, int cur_right) {
        if (cur_right <= query_left || query_right <= cur_left) return identity_item;
        if (query_left <= cur_left && cur_right <= query_right) return nodes.at(cur_idx);
        T value_from_left = query(query_left, query_right, 2 * cur_idx + 1, cur_left, (cur_left + cur_right) / 2);
        T value_from_right = query(query_left, query_right, 2 * cur_idx + 2, (cur_left + cur_right) / 2, cur_right);
        return merge_func(value_from_left, value_from_right);
    }

    T query(int query_left, int query_right) {
        return query(query_left, query_right, 0, 0, n);
    }
};

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;

    SegmentTree<lint, lint> segtree(
        n,
        [](lint a, lint b) {return a + b;},
        [](lint a, lint b) {return a + b;},
        0
    );

    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) segtree.update(x - 1, y);
        else {
            cout << segtree.query(x - 1, y) << "\n";
        }
    }
}


Measured memory_bytes: 4764