akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if(a<=3){
		ans += (100000) * (4-a);
	}
	if(b<=3){
		ans += (100000) * (4-b);
	}
	if(a*b==1){
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a[101][3] = {0}, N, X, Y, Z, q, w, e, r, t, y, u,i=0;
	scanf("%d", &N);
	scanf("%d", &X);
	for (q = 0; q < X; q++)
	{
		scanf("%d", &r);
		a[r][0] = 1;
	}
	scanf("%d", &Y);
	for (w = 0; w < Y; w++)
	{
		scanf("%d", &t);
		a[t][1] = 1;
	}
	scanf("%d", &Z);
	for (e = 0; e < Z; e++)
	{
		scanf("%d", &y);
		a[y][2] = 1;
	}
	for (u = 1; u <=N; u++)
	{
		if (a[u][0] == 0 && a[u][2] == 1 || a[u][1] == 1 && a[u][2] == 1)
			i++;
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 600
A, B, C, X = map(int, [input() for i in range(4)])
count = 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:
                count += 1
print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    int n;cin>>n;
    string str;
    cin>>str;
    vi v;
    vi v1;
    for(int i=0;str[i];i++){
        if(str[i]=='W'){
            v.pb(i);
        }
    }

    for(int i=n-1;i>=0;i--){
        if(str[i]=='R'){
            v1.pb(i);
        }
    }
    int idx=0,cnt=0;
    if(v1.size()!=0 && v.size()!=0){
        while(v1[idx]>v[idx]){
            cnt++;
            idx++;
        }

        cout<<cnt<<endl;
    }
    else
        cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 5824
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        if(s=="ABC") cout<<"ARC";
        else cout<<"ABC";
    }
    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 2e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 998244353;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max({ dp[n - 1][0], dp[n - 1][1], dp[n - 1][2] });
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
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; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A.begin(), A.end());
    ll mid = A[N/2];
    ll ans = 0;
    rep(i,N){
        ans += abs(A[i] - mid);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
read(n);
int a[n];
f(i,0,n){
    cin>>a[i];
}

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


   

}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Question
{
    public class QuestionD
    {
        public static void Main(string[] args)
        {
            var (a, b, n) = ReadHelper.ReadValue<long, long, long>();

            if (n < b)
            {
                Console.WriteLine(Calc(a, b, n));
            }
            else
            {
                Console.WriteLine(Calc(a, b, b - 1));
            }
        }

        private static long Calc(long a, long b, long x)
        {
            return (long)Math.Floor((double)a * x / b) - (long)Math.Floor((double)x / b) * a;
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27152
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
using namespace std;

int main() {
  string s;
  cin >> s;
  stack<char> stk;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      stk.push(s[i]);
    } else {
      if (stk.size() && stk.top() == 'S') {
        stk.pop();
        count += 2;
      } else {
        stk.push(s[i]);
      }
    }
  }
  cout << s.size() - count << endl;
  return 0;
}


Measured memory_bytes: 644
#include<iostream>

using namespace std;

int main(){

    while(1){
    int a, b;
    cin>> a>> b;
    if(a==0&&b==0) break;
    int n;
    cin>> n;
    int x[n], y[n];
    for(int i=0; i<n; i++){
        cin>> x[i]>> y[i];
    }

    int dp[b+1][a+1];
    fill(dp[0], dp[b+1], 0);

    dp[b-1][1]=1;
    for(int i=b-1; i>=0; i--){
        for(int j=1; j<a+1; j++){
            if(i==b-1&&j==1) continue;
            bool f=false;
            for(int k=0; k<n ;k++){
                if(i==b-y[k]&&j==x[k]){
                    f=true;
                    break;
                }
            }
            if(f) continue;
            dp[i][j]=dp[i+1][j]+dp[i][j-1];
        }
    }

    cout<< dp[0][a]<< endl;

    }

    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>T chmax(T&a,T b){return a=a>b?a:b;}
template<class T>T chmin(T&a,T b){return a=a<b?a:b;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vd p(n);
	rep(i,n)cin>>p[i];
	vvd dp(n+1,vd(n+1,0));
	dp[0][0]=1;
	rep(i,n)rep(j,n){
		dp[i+1][j]+=dp[i][j]*(1-p[i]);
		dp[i+1][j+1]+=dp[i][j]*(p[i]);
	}
	fcout(10)<<accumulate(dp[n].begin()+(n+1)/2, dp[n].end(), 0.0)<<endl;
	return 0;
}

Measured memory_bytes: 72704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

//------------------------------------------------
int main(){
  double ans,s;
  int n,k;
  vector<double> a;
  cin>>n>>k;
  a.assign(n,0);
  rep(i,0,n) {
    double p;
    cin>>p;
    a.at(i)=(p+1)/2;
  }
 vector<double> sum;
 sum.assign(n,0);
 sum.at(0)=a.at(0);
 rep(i,1,n) sum.at(i)=sum.at(i-1)+a.at(i);
ans=sum.at(k-1);
rep(i,0,n-k){
  s=sum.at(i+k)-sum.at(i);
  if(s>ans) ans=s;
}

cout<<fixed << setprecision(10) <<ans<<endl;
}


Measured memory_bytes: 3328
c = [list(map(int, input().split())) for _ in range(3)]
# print(c)
ians = [c[0][0]-c[0][0], c[0][1]-c[0][0], c[0][2]-c[0][0]]
jans = [c[0][0]-c[0][0], c[1][0]-c[0][0], c[2][0]-c[0][0]]
# print(ians, jans)
ok = True
for i in range(1, 3):
    for j in range(3):
        # print(c[i][j]-c[i][0])
        if ians[j] != c[i][j]-c[i][0]:
            ok = False

for i in range(1, 3):
    for j in range(3):
        # print(c[j][i]-c[i][0])
        if jans[j] != c[j][i]-c[0][i]:
            ok = False

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9256
//y12-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int ans = 0;
    for(int i=0; i<10; i++){
        int tmp;
        cin >> tmp;
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using Long = long long;


int main(){
    int n;
    cin >> n;
    vector<int> v(1e5 + 1);

    Long sum = 0;

    for( int i = 0 ; i < n ; ++i ){
        int x;
        cin >> x;
        sum += 1LL * x;
        v[x]++;
    }

    int q;
    cin >> q;

    for( int i = 0 ;  i < q ; ++i ){
        int b , c;
        cin >> b >> c;
        if( v[b] ){
            sum += 1LL * v[b] * ( c - b );
            v[c] += v[b];
            v[b] = 0;
        }
        cout << sum << '\n';
    }

    return 0;
}

Measured memory_bytes: 3768
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int x,t=1;
		Scanner sc = new Scanner(System.in);
		while(true){
			x=sc.nextInt();
			if(x == 0) break;
			System.out.println("Case "+ t++ +": "+x);
		}
	}
}

Measured memory_bytes: 13000
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)



void read_problem(vector<int>& ws, int& k)
{
    int n;
    scanf("%d %d\n", &n, &k);

    ws.resize(n);
    REP(i, n) {
        scanf("%d\n", &ws[i]);
    }
}

bool attempt(const vector<int>& ws, int k, int p)
{
    int weight = 0;
    for(int w : ws) {
        if(w > p) return false;

        if(weight + w > p) {
            --k;
            if(k == 0) return false;
            weight = w;
        }
        else {
            weight += w;
        }
    }

    return true;
}

int solve(const vector<int>& ws, int k)
{
    int n = ws.size();
    int lower = 1;
    int upper = 10000 * n / k + 1;
    int p = (lower + upper) / 2;

    for(;;) {
        if(attempt(ws, k, p)) {
            upper = p;
            p = (p + lower) / 2;
        }
        else {
            lower = p;
            p = (p + upper) / 2;
        }

        if(upper - lower == 1) {
            if(upper == 2 && attempt(ws, k, 1)) {
                upper = 1;
            }
            return upper;
        }
    }
}

int main()
{
    vector<int> ws;
    int k;
    read_problem(ws, k);
#if 0
    printf("k: %d\n", k);
    REP(i, ws.size()) {
        printf("%d ", ws[i]);
    }
#endif

    int result = solve(ws, k);
    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 2740
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
d = {"r":p, "s":r, "p":s}
ans = 0
for i in range(k):
    pa = ""
    while i < n:
        if t[i] == pa:
            pa = ""
        else:
            ans += d[t[i]]
            pa = t[i]
        i += k
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          #define pb push_back
          #define ll long long
          #define ld long double

          int main()
          {
               tani_nachi_ke  

               

               int n,k,s;
               cin >> n >> k >> s;
               int mx = 1e9,mn = 1;
               for(int i = 0; i < k; i++)
                    cout << s << " ";
               for(int i = k; i < n; i++)
               {
                    if(mx > s)
                         cout << mx << " ";
                    else
                         cout << 1 << " ";
               }
               cout << endl;




         
               return 0;
          }

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, K; cin >> N >> K;
    if (N%K == 0) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    k, x = map(int, input().split())
    for i in range(x - k + 1, x + k - 1):
        print(i, end=' ')
    print(x + k - 1)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int main() {
  int i;
  cin >> i;
  int n[i];
  for (int x=0; x<i; x++) {
    cin >> n[x];
  }
  int tmp, k=0; // kは交換回数
  bool m=true;
  while (true) {
    for (int x=0; x<i-1; x++) {
      if (n[x]>n[x+1]) {
        tmp = n[x];
        n[x] = n[x+1];
        n[x+1] = tmp;
        k++;
        m=false;
      }
    }
    if (m) {
      break;
    } else {
      m = true;
    }
  }
  //処理完了
  for (int x=0; x<i; x++) {
    if (x!=0) {
      cout << ' ';
    }
    cout << n[x];
  }
  cout << endl << k << endl;
  return 0;
}



Measured memory_bytes: 3068
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	s = replace(s,"BC","X")
	n = length(s)
	a = zeros(Int,n)
	k = 0
	for i in 0:n-1
		if s[n-i] == 'A'
			a[n-i] = k
		elseif s[n-i] == 'X'
			k += 1
		else
			k = 0
		end
	end
	println(sum(a))
end

main()

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

int main() {
	int n, d;;
	cin >> n >> d;
	double a[n+1][d+1];
	for(int i = 1; i < n+1; i++)
	{
		for(int j = 1; j < d+1; j++)
		cin >> a[i][j];
	}
	int ans = 0;
	for(int i = 1; i < n+1; i++)
	{
		for(int j = i+1; j < n+1; j++)
		{
			double sum = 0;
			for(int k = 1; k < d+1; k++)
			{
				sum  = sum + pow(a[i][k]-a[j][k], 2);
			}
			double temp = sqrt(sum);
			if( (temp - floor(temp) ) == 0 )
			ans++;

		}
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    
    print("#"*W)
    i=1
    while i<=H-2:
        
        print("#","."*(W-2),"#",sep="")
        i+=1
    print("#"*W)
    print("")


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

int main(){
	int t[1000][3], cnttri, dataset_num, i;
	cin>>dataset_num;
	for(cnttri=0;cnttri<dataset_num;cnttri++){
		cin>> t[cnttri][0] >> t[cnttri][1]>> t[cnttri][2];
		sort(t[cnttri], t[cnttri]+3);
	}
	for(i=0;i<dataset_num;i++){
		if(t[i][2]*t[i][2] == t[i][1]*t[i][1] + t[i][0]*t[i][0]){
			cout << "YES\n";
		}else{
			cout << "NO\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+7;
LL jmp,a,k,n,m,x[N],y[N],p[N],g[N],siz[N],tot,cnt,sum;
bitset <N> vis;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&x[i]),p[i]=i;
	for(int i=1;i<=n;i++)y[i]=x[i]-x[i-1];
	scanf("%lld%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&a);
		swap(p[a],p[a+1]);
	}
	for(int i=1;i<=n;i++)if(!vis[i])
	{
		++cnt;int res=i;
		while(!vis[res])
			g[res]=cnt,vis[res]=1,res=p[res],++siz[cnt];
	}
	for(int i=1;i<=n;i++)
	{
		jmp=k%siz[g[i]];
		int res=i;
		if(jmp)while(jmp--)res=p[res];
		sum+=y[res];
		printf("%lld.0\n",sum);
	}
} 

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAX 1e9


using namespace std;

bool sortinrev(const pair<int,int> &a,  		//for vector of pairs
               const pair<int,int> &b) 
{ 
       return (a.first < b.first); 
}

int binarySearch(int low,int high,int key,int a[]){
    int mid= low + (high-low)/2;
    while(low<=high){
        if(a[mid]<key)
            low=mid+1;
        else if(a[mid]>key)
            high=mid-1;
        else
            return mid+1;
    }
    return -1;
}

int stringToDecimal(string s){
	int ans=0;
	int base=1;
	for(int i=s.length()-1;i>=0;i--){
		ans = ans + (s[i] - '0')*base;
		base = base*2;
	}
	return ans;
}

int main(){
	double h,a;
	cin>>h>>a;
	cout<<ceil(h/a);
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=500+5;
char a[N][N];
int dp[N][N];
int cl[N][N],cr[N][N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	rep(i,1,n)scanf("%s",a[i]+1);
	s64 ans=0;
	per(j,n,1)
	if(isdigit(a[n][j]))
	{
		cl[j][n]=cr[j][n]=j;
		if(isdigit(a[n][j+1]))
		{
			cr[j][n]=cr[j+1][n];
			dp[n][j]=dp[n][j+1];
		}
		ans+=(a[n][j]-'0')*dp[n][j];
		dp[n][j]+=a[n][j]-'0';
	}
	per(i,n-1,1)
	per(j,n,1)
	if(isdigit(a[i][j]))
	{
		bool b1=isdigit(a[i][j+1]),b2=isdigit(a[i+1][j]);
		if(!b1&&!b2)
		{
			cl[j][i]=cr[j][i]=j;
			rep(k,i+1,n){cl[j][k]=n+1;cr[j][k]=0;}
		}else
		if(!b1&&b2)
		{
			dp[i][j]=dp[i+1][j];
			cl[j][i]=cr[j][i]=j;
		}else
		if(b1&&!b2)
		{
			dp[i][j]=dp[i][j+1];
			cl[j][i]=j;cr[j][i]=cr[j+1][i];
			rep(k,i+1,n){cl[j][k]=cl[j+1][k];cr[j][k]=cr[j+1][k];}
		}else
		{
			if(i==1&&j==2)
				int yyx=1;
			int ndp=dp[i+1][j]+dp[i][j+1];
			int last=0;
			cl[j][i]=j;cr[j][i]=cr[j+1][i];
			rep(k,i+1,n)
			{
				if(cr[j][k]>=cl[j+1][k]&&last<cl[j+1][k])
					ndp-=dp[k][cl[j+1][k]];
				last=cr[j][k];
				chmin(cl[j][k],cl[j+1][k]);
				chmax(cr[j][k],cr[j+1][k]);
			}
			dp[i][j]=ndp;
		}
		ans+=(a[i][j]-'0')*dp[i][j];
		dp[i][j]+=a[i][j]-'0';
	}
//	rep(i,1,n)
//rep(j,1,n)printf("%d%c",dp[i][j]," \n"[j==n]);
	cout<<ans;
}


Measured memory_bytes: 3584
x = gets.chomp.to_i

res = []

for i in 1..35 do
  for j in 2..10 do
    n = i ** j
    res << n if n <= x
  end
end

ans = -1
res.sort.reverse.each do |r|
  if r <= x
    ans = r
    break
  end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	string str;
    	cin>>str;
    	int flag=0;
    	for(int i=0;i<str.length();i++)
    	{
            if(str[i]=='7')
            	flag=1;
    	}
    	(flag)?cout<<"Yes":cout<<"No";
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

bool judge(int dt, int dx, int dy);

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

    string S;
    cin >> S;

    S[K-1] += 'a' - 'A';

    cout << S;
    
    
}


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

const int SIZE = 1E5;
pair<int, int> P[SIZE];

bool cmp(pair<int, int> A, pair<int, int> B) {
	if (A.first != B.first)
		return A.first < B.first;
	return A.second < B.second;
}

int main() {
	int L, T; cin >> L >> T;
	for (int pos = 1; pos <= L; pos++)
		cin >> P[pos].first >> P[pos].second;
	sort(P + 1, P + 1 + L, cmp);
	int M = INT_MAX;
	
	for (int pos = 1; pos <= L; pos++) {
		if (P[pos].second <= T)
			M = min(M, P[pos].first);
	}
	if (M == INT_MAX)
		puts("TLE");
	else
		cout << M << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc095/tasks/arc096_a


A, B, C, X, Y = gets.split.map(&:to_i)

Z = [X, Y].min
W = [X, Y].max - Z
D = C * 2
E = [X > Y ? A : B, D].min

ans = (
  if A + B <= D
    X * A + Y * B
  else
    Z * D + W * E
  end
)

puts ans


Measured memory_bytes: 1916
use std::cmp::max;
use std::collections::BTreeSet;

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 solve(s: String, k: usize) {
    let mut substrs: BTreeSet<&str> = BTreeSet::new();

    for p in 1..(k+1) {
        for i in 0..(max(s.len() as i32 - p as i32 + 1, 0) as usize) {
            let sub = &s[i..i+p];
            match substrs.iter().nth(k-1).cloned() {
                Some(last) if sub > last => (),
                _ => {
                    substrs.insert(sub);
                },
            }
        }
    }

    println!("{}", substrs.iter().nth(k-1).unwrap());
}

fn main() {
    input!{
        s: String,
        k: usize,
    }

    solve(s,k);
}



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

const int INF = 1e9;

int d[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int h, w, kk, x1, y1, x2, y2;
	cin >> h >> w >> kk >> x1 >> y1 >> x2 >> y2;
	vector<vector<int>> dp(h+1, vector<int> (w+1, INF));
	vector<string> a(h);
	for(int i = 0; i < h; i++)
		cin >> a[i];

	queue<pair<int, int>> q;
	q.push({x1, y1});
	dp[x1][y1] = 0;
	while(!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for(int k = 0; k < 4; k++) {
			for(int i = 1; i <= kk; i++) {
				int xx = x + i * d[k][0];
				int yy = y + i * d[k][1];

				if (xx <= 0 || xx > h || yy <= 0 || yy > w) break;
				if (a[xx-1][yy-1] == '@') break;

				if (dp[xx][yy] == dp[x][y]) break;
				if (dp[xx][yy] == INF) {
					dp[xx][yy] = dp[x][y] + 1;
					q.push({xx, yy});
				}
			}
		}
	}
	if (dp[x2][y2] == INF) cout << "-1\n";
	else {
		cout << dp[x2][y2] << '\n';
	}

	return 0;
}

Measured memory_bytes: 15060
/*input
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
*/

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

int main() {
    ll n, k, q;
    cin >> n>> k >> q;
    vector<ll> score(n);
    rep(i, q) {
        ll a;
        cin >> a;
        a--;
        score[a]++;
    }
    for (ll x: score) {
        if (k-q+x > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <stdio.h>
#define N 200000

int main()
{
	int n;
	int i=0;
	int R[N];
	int max;
	int min;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);
	}

	for(i=1;i<n;i++){
		if(i==1){
			max = R[1]-R[0];
			min = R[0];
		}
		if(R[i]-min>max)max=R[i]-min;
		if(R[i]<min)min = R[i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 2576
import math
data = input().rstrip().split(" ")
if float(data[1]) == 0.0:
    print(0)
else:
    A = int(data[0])
    B = round(float(data[1])*100)
    calc = A*B
    if calc <100:
        print(0)
    else:
        ans = str(calc)
        k = len(ans)-2
        print(ans[0:k])


Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
    }
  }
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	if (b == 0)
	{
		return a;
	}

	return gcd(b, a % b);
}


int main()
{
	unsigned long long A, B;
	cin >> A >> B;

	cout << A * B / gcd(A, B) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace  std;
int prime[10000];
int ptr = 0;
bool isPrime(int p)
{
	if (p <= 1)return false;
	for (int i = 2; i * i <= p; i++)
	{
		if (p % i == 0)return false;
	}
	return true;
}
void setPrime()
{
	for (int i = 2;;i++)
	{
		if (ptr >= 10000)break;
		if (isPrime(i))prime[ptr++] = i;
	}
}
int main()
{
	int n;
	setPrime();
	while (cin >> n && n != 0)
	{
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			sum += prime[i];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
// AOJ 0207
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct UF {
	vector <int> data;
	int cnt;
	UF(int n) : data(n, -1), cnt(n) {}
	bool merge(int a, int b){
		a = root(a), b = root(b);
		if (a != b){
			cnt--;
			if (data[b] < data[a]) std::swap(a, b);
			data[a] += data[b];
			data[b] = a;
		}
		return a != b;
	}
	bool same(int a, int b){
		return root(a) == root(b);
	}
	int root(int a){
		return data[a] >= 0 ? data[a] = root(data[a]) : a;
	}
	int size(int a){
		return ~data[root(a)];
	}
	int count(){
		return cnt;
	}
};

int main()
{
	int w, h;
	while (cin >> w >> h, w){
		int sx, sy, gx, gy, n;
		cin >> sx >> sy >> gx >> gy;
		cin >> n;

		int field[128][128] = {};
		for (int i = 0; i < n; i++){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			x--; y--;
			for (int j = 0; j < 4; j++){
				for (int k = 0; k < 2; k++){
					int jj = j, kk = k;
					if (d == 0) swap(jj, kk);
					jj += y; kk += x;
					field[jj][kk] = c;
				}
			}
		}

		UF uf(128*128);

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (field[i][j] == 0) continue;
				if (field[i][j] == field[i][j + 1]){
					uf.merge(i * w + j, i * w + j + 1);
				}
				if (field[i][j] == field[i + 1][j]){
					uf.merge(i * w + j, i * w + w + j);
				}
			}
		}

		sy--; sx--; gx--; gy--;
		if (uf.same(sy * w + sx, gy * w + gx)){
			cout << "OK" << endl;
		}
		else {
			cout << "NG" << endl;
		}

	}

	return 0;
}

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

int main(){
    ll a,b,c;
    std::cin >> a>>b>>c;
    if(a-b>= c){
        std::cout << 0 << std::endl;
    }else{
        std::cout << c-(a-b) << std::endl;
    }
}


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

using namespace std;

int main(void)
{
	int n;

	while (scanf("%d", &n) != EOF){
		int c = n % 39;
		if (c == 0){
			cout << "3C39" << endl;
		}
		else if (c < 10){
			cout << "3C0" << c << endl;
		}
		else {
			cout << "3C" << c << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

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

  if (k <= a)
    cout << k << endl;
  else if (k <= a + b)
    cout << a << endl;
  else
    cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (ll i = 0; i < h; i++) cin >> grid[i];
    vector<vector<ll>> left(h, (vector<ll>(w, 0))), right(h, (vector<ll>(w, 0))), up(h, (vector<ll>(w, 0))), down(h, (vector<ll>(w, 0)));
    for (ll i = 0; i < h;i++){
        for (ll j = 0; j < w;j++){
            if (grid[i][j] == '#') left[i][j] = 0;
			else if(j>0)
                left[i][j] = left[i][j - 1] + 1;
			else
                left[i][j] = 1;
        }
    }
    for (ll i = 0; i < h;i++){
        for (ll j = w-1; j >=0;j--){
            if (grid[i][j] == '#') right[i][j] = 0;
            else if(j<w-1)
                right[i][j] = right[i][j + 1] + 1;
            else
                right[i][j] = 1;
        }
    }
    for (ll j = 0; j < w;j++){
        for (ll i = 0; i < h;i++){
			if(grid[i][j]=='#')up[i][j]=0;
			else if(i>0)
                up[i][j] = up[i - 1][j] + 1;
			else
                up[i][j] = 1;
        }
    }
    for (ll j = 0; j < w;j++){
        for (ll i = h-1; i >= 0;i--){
			if(grid[i][j]=='#')down[i][j]=0;
			else if(i<h-1)
                down[i][j] = down[i + 1][j] + 1;
            else
                down[i][j] = 1;
        }
    }
    ll ans = 0;
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w;j++){
            chmax(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j]);
        }
    }
    cout << ans - 3 << endl;
}

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

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

    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3560
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

ll gcd(ll a,ll b){
  if(b==0) return a;

  return gcd(b,a%b);
}

int main(){
  int N;
  cin >> N;
  vector<ll> T(N);
  for(int i=0; i<N; i++){
    cin >> T[i];
  }
  ll ans=1;
  for(int i=0; i<N; i++){
    ans = T[i]/gcd(T[i],ans)*ans;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void solve() {
	int H, W;
	cin >> H >> W;
	char a[100][100] = { { } };
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a[i][j];
		}
	}

	/* calculate */
	bool isNotBlankRow[100] = { };
	bool isNotBlankCol[100] = { };
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (a[i][j] == '#') {
				isNotBlankRow[i] = true;
				isNotBlankCol[j] = true;
			}
		}
	}

	/* print */
	for (int i = 0; i < H; ++i) {
		if (isNotBlankRow[i]) {
			for (int j = 0; j < W; ++j) {
				if (isNotBlankCol[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

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


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

int main(){
	int H,W;
	cin >> H >> W;
	bool arr[H+1][W+1];
	char a;
	ll dp[H+1][W+1];
	memset(dp,0,sizeof(dp));
	memset(arr,0,sizeof(arr));
	dp[1][1] = 1;

	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> a;
			arr[i][j] = a == '.' ? 1 : 0;
		}
	}

	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(arr[i][j]){
				dp[i][j] += (dp[i][j-1] + dp[i-1][j])%MOD;
			}
		}
	}	

	cout << dp[H][W];
}

Measured memory_bytes: 9088
N, M = map(int, input().split())

ans, pre = 0, 0
i = 1
while True:
    pre = ans
    ans += i*(1900*M+100*(N-M))*(((2**M-1)/2**M)**(i-1))/(2**M)
    i += 1
    if ans - pre < 10**(-2):
        break
print(int(round(ans, 0)))


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
ll X[MAX_N];

int main2() {
  int N = nextInt();
  ll A = nextInt();
  ll B = nextInt();
  REP(i, N) X[i] = nextInt();
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    ans += min(B, (X[i]-X[i-1])*A);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1024
# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    A = set(map(int, [input() for _ in range(M)]))
    MOD = 10 ** 9 + 7
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in A else 0
    for i in range(2, N + 1):
        if i not in A:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    print(dp[-1])


if __name__ == "__main__":
    main()

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b)swap(a,b);
  if(a==1&&b==2)cout << 3 << endl;
  else if(a==2)cout << 1 << endl;
  else cout << 2 << endl;
}


Measured memory_bytes: 256
function main(input) {
  var a = input[0].split(" ")[0]-0;
  var b = input[0].split(" ")[1]-0;
  console.log(a*b/gcd(a,b));

}

function gcd(a,b){
  if(a%b==0) return b;
  return gcd(b,a%b);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 9420
#include <cstdio>
#include <cstring>
#include <cctype>
#include <set>
using namespace std;
typedef long long int64;
inline int64 read(int f = 1, int64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f  = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int64 a, b, p, l1, r1, l2, r2, ans;
int lg(int64 s) { return s?lg(s>>1)+1:0; }
int main()
{
    a = read(), b = read(), ans = b-a+1;
    for( ; lg(a) == lg(b)&&a&&b; a ^= (1ll<<(lg(a)-1)), b ^= (1ll<<(lg(b)-1)));
    p = 1ll<<(lg(b)-1);
    l1 = b+1, r1 = p+(1ll<<lg(b-p))-1;
    if(l1 <= r1) ans += r1-l1+1;
    l2 = max(a+p, b+1), r2 = (p<<1)-1;
    if(l2 <= r2) ans += r2-l2+1;
    if(l1 <= r1&&l2 <= r2&&max(l1, l2) <= min(r1, r2)) ans -= min(r1, r2)-max(l1, l2)+1;
    printf("%lld\n", ans);
    return 0;
}

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


int left_black[4001][2001] = {}, left_white[4001][2001] = {};
long long dp[2001][2001] = {};
int bl_pos[2001], wh_pos[2001];

int main(){
    int N;

    cin >> N;
    // left_black[k][i] := [0, k)にある数がi以下の黒いボールの個数
    for(int i = 0; i < 2*N; i++){
        char c;
        int a;
        cin >> c >> a;
        if(c == 'B'){
            bl_pos[a] = i;
            for(int j = a; j <= N; j++){
                left_black[i+1][j]++;
            }
        }else{
            wh_pos[a] = i;
            for(int j = a; j <= N; j++){
                left_white[i+1][j]++;
            }
        }
    }
    for(int j = 0; j <= N; j++){
        for(int i = 0; i < 2*N; i++){
            left_black[i+1][j] += left_black[i][j];
            left_white[i+1][j] += left_white[i][j];
        }
    }
    /*
    for(int i = 0; i <= 2*N; i++){
        for(int j = 0; j <= N; j++){
            cout << left_black[i][j] << " ";
        }
        cout << endl;
    }
    */

    dp[0][0] = 0;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(i == 0 && j == 0)continue;
            long long tmp1 = 10000000000, tmp2 = 10000000000;
            if(i > 0){
                tmp1 = dp[i-1][j]
                    + (i-1) - left_black[bl_pos[i]][i] + (left_black[bl_pos[i]][N] - left_black[bl_pos[i]][i])
                    + j - left_white[bl_pos[i]][j] + (left_white[bl_pos[i]][N] - left_white[bl_pos[i]][j]);
            }
            if(j > 0){
                tmp2 = dp[i][j-1]
                    + i - left_black[wh_pos[j]][i] + (left_black[wh_pos[j]][N] - left_black[wh_pos[j]][i])
                    + (j-1) - left_white[wh_pos[j]][j] + (left_white[wh_pos[j]][N] - left_white[wh_pos[j]][j]);
            }
            dp[i][j] = min(tmp1, tmp2);
        }
    }
    cout << dp[N][N]/2 << endl;
    /*
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            cout << dp[i][j] << "\t";
        }
        cout << endl;
    }
    */
}


Measured memory_bytes: 94080
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int a = num.nextInt();
        int b = num.nextInt();
        int c = num.nextInt();
        int x[] = {a,b,c};
 
        Arrays.sort(x);
        System.out.println(x[0]+" "+x[1]+" "+x[2]);
}
}

Measured memory_bytes: 26364
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    sort(a,a+n);
    int ans=0;
    multiset<int>s;
    s.insert(a[n-1]);
    for(int i=n-2;i>=0;i--){
    	auto it=s.end();
    	it--;
    	ans+=*it;
    	s.erase(it);
    	s.insert(a[i]);
    	s.insert(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}
    
    
    
    

Measured memory_bytes: 14592