akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        ArrayList<Integer> list = new ArrayList<Integer>();
        int[] B = new int[N];
        for(int i=0; i<N-1; i++){
            B[i] = A[i + 1] - A[i];
            list.add(B[i]);
        }
        B[N - 1] = K - A[N - 1] + A[0];
        list.add(B[N - 1]);

        Collections.sort(list);

        int ans = 0;
        for(int i=0; i<N-1; i++){
            ans += list.get(i);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65264
#include <iostream>
#include <cmath>
#include <utility>
#include <vector>
 
using namespace std;
 
int GetSum(const vector<pair<int,int> >& data){
  int sum=0;
  for(auto priceandnum:data)
    sum+=priceandnum.first*priceandnum.second;
  return sum;
}
 
int GetAve(const vector<pair<int,int> >& data){
  double sum=0;
  for(auto priceandnum:data)
    sum+=priceandnum.second;
  sum/=data.size();
  return round(sum);
}
 
int main(){
  vector<pair<int,int> > data;
  int price,num;
  char c;
  while(cin>>price>>c>>num){
    data.push_back(pair<int,int>(price,num));
  }
  cout<<GetSum(data)<<endl;
  cout<<GetAve(data)<<endl;
}

Measured memory_bytes: 1200
s = input()
s_befo = s[0]
s_ans = []
tmp_num = 1
for i in s[1:]:
    if i == s_befo:
        tmp_num+=1
    else:
        s_ans.append(tmp_num)
        tmp_num=1
    s_befo = i
s_ans.append(tmp_num)

ans = []
kurikosi = 0
is_R = True
for j in s_ans:
    if is_R:
        for i in range(j-1):
            ans.append(0)
        ans.append(round(j/2+0.1))
        is_R = not is_R
        kurikosi = j//2
    else:
        ans.append(round(j/2+0.1)+kurikosi)
        ans[-2] += j//2
        is_R = not is_R
        for i in range(j-1):
            ans.append(0)
print(' '.join(map(str, ans)))

Measured memory_bytes: 11256
n=int(input())
A=[int(x) for x in input().split(' ')]
B=[int(x) for x in input().split(' ')]
ans=0
for i in range(n):
	if (A[i]>=B[i]):
		ans+=B[i]
	else:
		ans+=A[i]
		B[i]-=A[i]

		if (A[i+1]>=B[i]):
			ans+=B[i]
			A[i+1]-=B[i]
		else:
			ans+=A[i+1]
			A[i+1]=0
print(ans)

Measured memory_bytes: 18624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>


int main(void) {

	int max = 10;
	char c;
	char resultStr[10][201] = { 0 };

	
	int kurikaesi = 0;
	while (kurikaesi < max) {
		char str[201] = { 0 };

		int wn = 0; // n枚のカード

		scanf("%s%*[^\n]%*c", &str);
		wn = strlen(str);
		if (strcmp(str, "-") == 0) {
			break; 
		}
		int m = 0;
		scanf("%d%*[^\n]%*c", &m); // シャッフル回数

		int h = 0;
		int i_m = 0;
		for (; i_m < m; i_m++) {
			scanf("%d%*[^\n]%*c", &h);
			char rearStr[201] = { 0 };
			char frontStr[201] = { 0 };
			int j = 0;
			int i = 0;

			for (i = 0; i < h; i++) {
				frontStr[i] = str[i];
			}
			for (i = h; j < wn - h; i++, j++) {
				rearStr[j] = str[i];
			}
			strcat(rearStr, frontStr);

			for (i = 0; i < 200; i++) {
				str[i] = rearStr[i];
			}
		}
		strcat(resultStr[kurikaesi], str);
		kurikaesi++;
	}

	// resultを出力
	int i = 0;
	for (; i < kurikaesi; i++) {
		printf("%s\n", resultStr[i]);
	}


	return 0;
}


Measured memory_bytes: 2132
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  string s,t;

  cin>>s>>t;

  int ans=t.size();

  int ss=s.size();

  int tt=t.size();

  for(int i=0; i<=ss-tt; i++){

    int cnt=0,k=0;

    for(int j=0; j<tt; j++){

        if(s[i+j]!=t[j])

        cnt++;

    }

    ans=min(ans,cnt);

  }

  cout<<ans<<endl;

}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        for (int i = 0; i < s.length(); i += 2) {
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}

Measured memory_bytes: 29264
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double money = 0.;
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			if(sc.next().equals("JPY")) {
				money += Integer.parseInt(str);
			} else {
				money += Double.parseDouble(str) * 380000;
			}
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 23124
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    q, h, s, d = list(map(int, readline().split()))
    n = int(readline())
    h = min(h, q * 2)
    s = min(s, h * 2, q * 4)
    d = min(d, s * 2, h * 4, q * 8)
    cnt = 0
    cnt += n // 2 * d
    n -= n // 2 * 2
    cnt += n // 1 * s
    n -= n // 1
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){printf("Yes\n");}
    else{printf("No\n");}
    return 0;
    
}


Measured memory_bytes: 2700
#include<stdio.h>

int main(){
    int i, res=0;
    int  n,m;
    char s[99] = {};
    int flag = 1;

    // scanf("%d %d", &n, &m);
    scanf("%s", s);

    n = 0;
    while(s[n] != 0){
        n++;
    }
    m = n / 2;
    for(i =0;i<m;i++){
        if(s[i] != s[m+1+i]){
            printf("No");
            flag = 0;
            break;
        }
    }
    if(flag){
        printf("Yes");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(){
    long long A,B,gcd,x,rgcd;
    scanf("%lld%lld",&A,&B);
    while(A!=0&&B!=0){
      if(A>=B)
      A=A%B;
      else
      B=B%A;
    }
    gcd=A+B;
    rgcd=sqrt(gcd);
    if(gcd==1)
        printf("1\n");
    else{
        x=0;
        for(int i=2;i<=rgcd;i++){
            rgcd=sqrt(gcd);
            if(gcd%i==0)
            x++;
            while(gcd%i==0){
                gcd/=i;
            }
        }
        if(gcd==1)
            printf("%lld\n",x+1);
        else
            printf("%lld\n",x+2);
    }
    return 0;
}


Measured memory_bytes: 128
/*
Author : Vidish Joshi
*/

#include <bits/stdc++.h>
using namespace std;

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define re(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)
#define start1 ll t = 1; while(t--)
#define F first
#define S second
#define br "\n"

const ll MAX = 1e5 + 5;
ll a[MAX][3];
ll dp[MAX][3], vis[MAX][3];
ll n; 

ll foo(ll ind, ll last){
    if(ind==n) return 0;
    if(vis[ind][last]) return dp[ind][last];

    vis[ind][last] = 1;

    ll ans = 0;
    for(int i=0; i<3; i++){
        if(i!=last){
            ans = max(a[ind][i] + foo(ind + 1, i), ans);
        }
    }

    dp[ind][last] = ans;
    return ans;

}

void solve(){
    cin>>n;
    ll ans = 0;

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

    ans = max(foo(0, 0), max(foo(0, 1), foo(0, 2)));

    cout<<ans<<br;
}

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


/*
if(!x && !y && !z){
            if(a>=b && a>=c){
                x = 1;
                y = 0;
                z = 0;
                ans += a;
            }
            else if(b>=a && b>=c){
                x = 00;
                y = 1;
                z = 0;
                ans += b;
            }
            else{
                x = 0;
                y = 0;
                z = 1;
                ans += c;
            }
        }
        else if(x){
            if(b>=c){
                x = 0; y = 1; z = 0;
                ans += b;
            }
            else{
                x = 0; y = 0; z = 1;
                ans += c;
            }
        }
        else if(y){
            if(a>=c){
                x = 1; y = 0; z = 0;
                ans += a;
            }
            else{
                x = 0; y = 0; z = 1;
                ans += c;
            }
        }
        else if(z){
            if(a>=b){
                x = 1; y = 0; z = 0;
                ans += a;
            }
            else{
                x = 0; y = 1; z = 0;
                ans += b;
            }
        }
*/

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
ll arr[N];
ll n;

int main() {
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    ll ans = 0;
    ll right = 0;
    ll curr = 0;
    for(int left = 0; left < n; left ++) {
        while(right < n && (arr[right] & curr) == 0) {
            curr ^= arr[right];
            right ++;
        }
        ans += (right - left);
        curr ^= arr[left];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

const int SIZE = 100000;

int main(){
  int n, a[SIZE];

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }

  map<int, int> b, e;
  vector<int> ans;
  
  int counter = 1000000000;
  
  for(int i=0;i<n;i++){
    if(b[a[i]] == e[a[i]]){
      counter--;
    }

    if(b[a[n-i-1]] == e[a[n-i-1]]){
      counter--;
    }

    
    b[a[i]]++;
    e[a[n-i-1]]++;

    if(b[a[i]] == e[a[i]]){
      counter++;
    }

    if(b[a[n-i-1]] == e[a[n-i-1]]){
      counter++;
    }

    if(counter == 1000000000){
      ans.push_back(i+1);
    }
  }

  for(int i=0;i<ans.size();i++){
    printf("%d%c",ans[i], " \n"[i+1==ans.size()]);
  }

  return 0;
}
  




Measured memory_bytes: 7960
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,m;
int i;
int mati[100010];
long long int sum=0,temp;
int a;
int main(void){
	scanf("%d %d",&n,&m);
	mati[1]=0;
	for(i=1;i<n;i++){
		scanf("%d",&a);
		mati[i+1]=mati[i]+a;
	}
	int ba=1;
	for(i=0;i<m;i++){
		scanf("%d",&a);
		temp=mati[ba+a]-mati[ba];
		if(temp<0){
			temp=0-temp;
		}
		ba+=a;
		sum+=temp;
	}
	sum%=100000;
	printf("%lld\n",sum);
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

vector<int> childs[1005];
vector<string> msg(1005);

void dfs(int x, int d) {
    rep(i, 0, d) cout << '.';
    cout << msg[x] << endl;
    for (int h : childs[x]) dfs(h, d + 1);
}

int main() {
    
    
    int n; cin >> n;
    rep(i, 1, n + 1) {
        int p; cin >> p;
        childs[p].push_back(i);
        cin >> msg[i];
    }
    dfs(1, 0);

}


Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    string s[n];
    int ans=0;
    int cnta=0,cntb=0,cntab=0;
    rep(i,n){
        cin>>s[i];
        int nn=s[i].size();
        for(int j=0;j<nn-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
        }
        if(s[i][0]=='B'&&s[i].back()=='A') cntab++;
        else if(s[i][0]=='B') cntb++;
        else if(s[i].back()=='A') cnta++;
    }
    ans += max(cntab-1,0);
    if(cntab>0){
        if(cnta>0) ans+=1,cnta--;
        if(cntb>0) ans+=1,cntb--;
    }
    cout<<ans+min(cnta,cntb)<<endl;

    return 0;
}


Measured memory_bytes: 768
li = list(input())

for i in range(len(li)): li[i] = int(li[i])
p = ('-','+')
tail = '=7'

if li[0] + li[1] + li[2] + li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '+' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] + li[1] - li[2] + li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '-' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] + li[1] - li[2] - li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '-' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] + li[1] + li[2] - li[3] == 7:
    print(str(li[0]) + '+' + str(li[1]) + '+' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] - li[1] + li[2] + li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '+' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] - li[1] - li[2] + li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '-' + str(li[2]) + '+' + str(li[3]) + tail)

elif li[0] - li[1] - li[2] - li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '-' + str(li[2]) + '-' + str(li[3]) + tail)

elif li[0] - li[1] + li[2] - li[3] == 7:
    print(str(li[0]) + '-' + str(li[1]) + '+' + str(li[2]) + '-' + str(li[3]) + tail)


Measured memory_bytes: 3316
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
 
int main(){
  int N, L;
  scanf("%d %d", &N, &L);
  
  string str[100];
  
  for(int i=0; i<N; i++){
    char tmp[L];
    scanf("%s", tmp);
    str[i] = tmp;
  }
  sort(str, str+N);
  
  string s;
  for(int i = 0; i < N; i++){
    s += str[i];
  }
  printf("%s", s.c_str());
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0; i<s.size(); i++){
        if(n == 0) break;
        if (s.at(i) >= 90-n+1) s.at(i) -= 26;
        s.at(i) += n;
        
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
class DICE{
	public:
	int top,s1,s2,s3,s4,bottom;
	void turnE();
	void turnN();
	void turnS();
	void turnW();
} ;

void DICE::turnE(){
	int tmp=top;
	top=s3;
	s3=bottom;
	bottom=s2;
	s2=tmp;
}

void DICE::turnN(){
	int tmp=top;
	top=s1;
	s1=bottom;
	bottom=s4;
	s4=tmp;
}

void DICE::turnS(){
	int tmp=top;
	top=s4;
	s4=bottom;
	bottom=s1;
	s1=tmp;
}

void DICE::turnW(){
	int tmp=top;
	top=s2;
	s2=bottom;
	bottom=s3;
	s3=tmp;
}

int main(){
	DICE d;
	cin>>d.top>>d.s1>>d.s2>>d.s3>>d.s4>>d.bottom;
	string s;
	cin >> s;
	for(int i=0 ; i<s.length();i++){
		switch(*(s.begin()+i)){
			case 'N':
				d.turnN();
				break;
			case 'E':
				d.turnE();
				break;
			case 'S':
				d.turnS();
				break;
			case 'W':
				d.turnW();
		}
	}
	cout << d.top << endl;
	return 0;
}

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

int main() {
    int x[] = {0, 1, 2, 3, 4, 5};
    for (int i = 1; i <= 5; i++) scanf("%d", &x[i]);
    for (int i = 1; i <= 5; i++) {
        if (x[i] == 0) {
            printf("%d\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 3744
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;
typedef long long ll;

int main(){
	ll N;
	cin>>N;
	vector<ll> L(N);
	for(int i=0; i<N; i++) cin>>L[i];
	sort(L.begin(), L.end(), greater<ll>());
	ll ans=0;
	for(int i=0; i<L.size()-2; i++){
		for(int j=i+1; j<L.size()-1; j++){
			for(int k=j+1; k<L.size(); k++){
				if(abs(L[i] - L[j])< L[k] && L[k] <L[i] + L[j]){
					ans++;
				}else{
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
N = int(input())
a = [int(x) for x in input().split()]

count = 0

for i in range(N):
    if (i+1)%2 == 1 and a[i]%2 == 1:
        count += 1
print(count)


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

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        int c = 1000 - n;
        int sum = 0;
        sum = c / 500 + c % 500 / 100 + c % 500 % 100 / 50 + c % 500 % 100 % 50 / 10 + c % 500 % 100 % 50 % 10 / 5 + c % 500 % 100 % 50 % 10 % 5;
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3012
#include <iostream>

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

using namespace std;

struct Node {
  int p, l, r;
};

Node t[25];

void preorder(int i) {
  std::cout << ' ' << i;
  if (t[i].l != -1) preorder(t[i].l);
  if (t[i].r != -1) preorder(t[i].r);
}

void inorder(int i) {
  if (t[i].l != -1) inorder(t[i].l);
  std::cout << ' ' << i;
  if (t[i].r != -1) inorder(t[i].r);
}

void postorder(int i) {
  if (t[i].l != -1) postorder(t[i].l);
  if (t[i].r != -1) postorder(t[i].r);
  std::cout << ' ' << i;
}

int main() {
  int n;
  std::cin >> n;
  int id, left, right;

  rep(i, n) t[i] = Node{-1, -1, -1};

  rep(i, n) {
    std::cin >> id >> left >> right;
    t[id].l = left;
    t[id].r = right;
    if (left != -1) t[left].p = id;
    if (right != -1) t[right].p = id;
  }

  int root = 0;
  rep(i, n) {
    if (t[i].p == -1) root = i;
  }

  cout << "Preorder" << '\n';
  preorder(root);
  cout << endl;

  cout << "Inorder" << '\n';
  inorder(root);
  cout << endl;

  cout << "Postorder" << '\n';
  postorder(root);
  cout << endl;

  return 0;
}


Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    vector<int> a(3);
    cin >> a[0]>> a[1]>> a[2];
    sort(a.begin(),a.end(),greater<int>());
    int ans=0;
    int l=(a[0]-a[2])/2;
    a[2]+=2*l;
    int r=(a[0]-a[1])/2;
    a[1]+=2*r;
    ans+=l+r;
    if(a[0]==a[1]&&a[0]==a[2]){
        cout<<ans<<endl;
    }else if(a[0]==a[1]&&a[0]!=a[2]){
        cout<<ans+2<<endl;
    }else if(a[0]!=a[1]&&a[1]==a[2]){
        cout<<ans+1<<endl;
    }else if(a[0]!=a[1]&&a[0]==a[2]){
        cout<<ans+2<<endl;
    }else{
        cerr<<'?'<<endl;
    }
    return 0;
}

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

import sys
input=sys.stdin.readline

n=int(input())
arr=list(map(int,input().split()))
kane=1000
kabu=0
for i in range(n-1):
    if arr[i]>=arr[i+1]:
        continue
    else:
        kane=kane%arr[i]+(kane//arr[i])*arr[i+1]
print(kane)

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

int main()
{
    int n; 
    cin>>n; 
    int count =0 ; 
    
    for(int i=1 ;i<n; i++)
    {

        for(int j = 1; j<n;j++)
        {
            long long x = n - i*j; 
            if(x>0 && x<=n)
            {
                count++;
            }
            else if( x < 0)
            {
                break; 
            }

        }

    }

    cout<<count; 


}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;

// aoj GRL_1_C FloydWarshall O(V^3)
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int v = sc.nextInt();
		int e = sc.nextInt();

		FloydWarshall fw = new FloydWarshall(v);
		for (int i = 0; i < e; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();
			fw.addEdge(s, t, d);
		}

		out:
		for (int i = 0; i < v; i++) {
			for (int j = 0; j < v; j++) {
				long tmp = fw.getShortestPath(i, j);
				if (tmp == -fw.INF) {
					pr.println("NEGATIVE CYCLE");
					break out;
				} else if (tmp == fw.INF) {
					pr.print("INF");
				} else {
					pr.print(tmp);
				}
				
				if (j < v - 1) {
					pr.print(" ");
				} else {
					pr.println();
				}
			}
		}

		pr.close();
		sc.close();
	}
	
	private static class FloydWarshall {
		long[][] d;
		int n;
		long[][] result;
		boolean nf; // NEGATIVE CYCLE flag

		final long INF = Long.MAX_VALUE;

		FloydWarshall(int n) {
			this.n = n;
			d = new long[n][n];
			for (int i = 0; i < n; i++) {
				Arrays.fill(d[i], INF);
				d[i][i] = 0;
			}
			nf = false;
		}

		// i, j:0-indexed
		public void addEdge(int i, int j, int c) {
			d[i][j] = c;
		}

		public long getShortestPath(int i, int j) {
			if (nf) {
				return -INF;
			}

			if (result == null) {
				for (int kk = 0; kk < n; kk++) {
					for (int ii = 0; ii < n; ii++) {
						for (int jj = 0; jj < n; jj++) {
//							d[ii][jj] = Math.min(d[ii][jj], d[ii][kk] + d[kk][jj]);
							if (d[ii][kk] != INF && d[kk][jj] != INF && d[ii][jj] > d[ii][kk] + d[kk][jj]) {
								d[ii][jj] = d[ii][kk] + d[kk][jj];
							}
						}
					}
				}
				
				for (int k = 0; k < n; k++) {
					if (d[k][k] < 0) {
						nf = true;
						return -INF;
					}
				}
				
				result = d;
			}
			
			return result[i][j];
		}
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;
		
		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		
		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}
		
		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

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

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

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

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}

Measured memory_bytes: 36644
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)

int main() {
	int N;
	while(cin>>N && N>0){
		int A[N];
		rep(i,N) cin >> A[i];
		int M = 0;
		rep(i,N){
			if (M<A[i]){
				M=A[i];
			}			
		}
		int m = 10000000;
		rep(i,N){
			if(m>A[i]){
				m=A[i];
			}
		}
		int sum =0;
		rep(i,N){
			sum += A[i];
		}
		
		sum = sum - M - m;
		int ave = sum/( N - 2);
		cout << ave<<endl;
	}
	return 0;
}



Measured memory_bytes: 3084
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 20:58:38 2019

@author: USER
"""

N, M = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(M)]

min_p = 1
max_p = N
for lr in LR:
    min_p = max(min_p, lr[0])
    max_p = min(max_p, lr[1])
    
print(max(0, max_p-min_p+1))

Measured memory_bytes: 27332
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  auto totalMin = (h2 - h1) * 60 + (m2 - m1);
  
  cout << totalMin - k << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a[200],mi,ma;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	mi=ma=a[1];
	fo(i,2,n){
		if (a[i]<mi) mi=a[i];
		if (a[i]>ma) ma=a[i];
	}
	printf("%d\n",ma-mi);
	return 0;
} 

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

#define int long long int

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif
//!

int32_t main()
{
	GO
	//fioe();
	int n;
	cin>>n;
	int arr[n+2];
	map<int,int> m;
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
		m[arr[i]]++;
	}	
	int ans[n+3];
	memset(ans,0,sizeof(ans));
	for(auto x:m){
		ans[x.first] = x.second;
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N,X;
  cin >> N >> X;
  ll cnt = 0;
  ll cur = 0;
  rep(i, N){
    ll l;
    if(cur<=X)cnt++;
    cin >> l;
    cur+=l;
  }
  if(cur<=X)cnt++;
  cout << cnt;
  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double A = sc.nextInt();
        double B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();
        double ans;
        
        double sho = (H * 60 + M) * 360 / ( 12 * 60 );
        double lon = M * 360 / 60;
        double ang;
        
        ang = Math.abs(sho - lon);
        
        ans = Math.sqrt(A * A + B * B 
                - 2.0 * A * B * Math.cos(Math.toRadians(ang)));
        
        System.out.print(ans);
    }
}

Measured memory_bytes: 27140
import math


def main(n):
    # keta = int(math.log10(n)) + 1
    count = 0
    for i in range(1, n + 1):
        keta = int(math.log10(i) + 1)
        if (keta % 2) == 1:
            count += 1
    return count


if __name__ == '__main__':
    n = int(input())
    print(main(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

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

    if(n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(){

    int n, p;
    cin >> n >> p;

    int odd = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a%2) ++odd;
    }

    if(odd) cout << (1LL<<(n-1)) << endl;
    else {
        if(p) cout << 0 << endl;
        else cout << (1LL<<n) << endl;
    }

    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


  }*/

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    } else {
      u = u->right;
    }
  }
  return u;
}

/*Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y==NIL){
    root = z;
  } else if(z->key < y->key){
    y->left = z;
  } else{
    y->right = z;
  }
  
}

void inorder(Node u){
  if(u->left!=NIL){
    inorder(u->left);
  } 
  printf(" %d",u->key);
  if(u->right!=NIL){
    inorder(u->right);
  } 
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL){
    preorder(u->left);
  } 
  if(u->right!=NIL){
    preorder(u->right);
  } 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      } else 
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

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

















































































































































































































































































































































































































































































































































































































































int main()
{
	for(;;){
		int a;
		int b;
		int c;
		int d;
		int e;
		cin >> a;
		if(a==0)break;
		cin >> b >> c >> d >> e;
		int x1=0;
		int x2=0;
		int x3=0;
		if(a==1)x1++;
		if(a==2)x2++;
        if(a==3)x3++;
		if(b==1)x1++;
		if(b==2)x2++;
        if(b==3)x3++;
		if(c==1)x1++;
		if(c==2)x2++;
        if(c==3)x3++;
		if(d==1)x1++;
		if(d==2)x2++;
        if(d==3)x3++;
		if(e==1)x1++;
		if(e==2)x2++;
        if(e==3)x3++;
		if(x1>=1&&x2>=1&&x3>=1){
			printf("3\n3\n3\n3\n3\n");
		}
		else if(x1==5){
			printf("3\n3\n3\n3\n3\n");
		}
		else if(x2==5){
			printf("3\n3\n3\n3\n3\n");
		}
		else if(x3==5){
			printf("3\n3\n3\n3\n3\n");
		}
		else if(x3==0){
			if(a==1)printf("1\n");
			if(a==2)printf("2\n");
			if(b==1)printf("1\n");
			if(b==2)printf("2\n");
			if(c==1)printf("1\n");
			if(c==2)printf("2\n");
			if(d==1)printf("1\n");
			if(d==2)printf("2\n");
			if(e==1)printf("1\n");
			if(e==2)printf("2\n");
		}
		else if(x2==0){
			if(a==3)printf("1\n");
			if(a==1)printf("2\n");
			if(b==3)printf("1\n");
			if(b==1)printf("2\n");
			if(c==3)printf("1\n");
			if(c==1)printf("2\n");
			if(d==3)printf("1\n");
			if(d==1)printf("2\n");
			if(e==3)printf("1\n");
			if(e==1)printf("2\n");
		}
		else if(x1==0){
			if(a==2)printf("1\n");
			if(a==3)printf("2\n");
			if(b==2)printf("1\n");
			if(b==3)printf("2\n");
			if(c==2)printf("1\n");
			if(c==3)printf("2\n");
			if(d==2)printf("1\n");
			if(d==3)printf("2\n");
			if(e==2)printf("1\n");
			if(e==3)printf("2\n");
		}
	}
	return 0;
}

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

int main() {
    string S,T;
    cin >> S >> T;
    int count = 0;
    for (int i=0; i<S.size(); i++) {
        if (S.at(i) != T.at(i)) {
            count++;
        }
    }
    cout << count <<endl;
}

Measured memory_bytes: 3916
#!/bin/env python
  

if __name__=='__main__':
  val_n = input()
  list_v = list(map(int,input().split()))
  list_c = list(map(int,input().split()))

  answer = 0
  for i in range(len(list_v)):
    if(list_v[i] - list_c[i] > 0):
      answer += list_v[i] - list_c[i]
  print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;



int main(){
    int n;
    cin >> n;
    VEC(int, a, n);

    queue<int>que;
    que.push(0);
    que.push(0);
    que.push(0);
    ll res = 1;

    rep(i, n){
        int cnt = 0;
        bool f = true;
        rep(j, 3){
            int now = que.front();
            que.pop();
            if(now == a[i]){
                if(f){
                    f = false;
                    now++;
                }
                cnt++;
            }
            que.push(now);
        }
        res *= cnt;
        res %= MOD;
    }
    cout << res << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b) {
  // Eucledean algorithm
  while (a) {
    if (a < b) {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  ll ans = 1;
  rep(i, n) {
    ll v;
    cin >> v;
    ans = lcm(ans, v);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
#define MOD 1000000007
#define INF 1e18
#include <ctime>
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rev(i, n, x) for (ll i = n; i > x; i--)
#define endl "\n"
#define all(c) (c).begin(), (c).end()
#define int long long int
#ifdef mishra
#define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl;
#define print_time() cout << setprecision(6) << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n';
#else
#define debug(x) ;
#define print_time() ;
#endif

clock_t start;
void FAST(ll argc)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    start = clock();
    if (argc == 2)
        freopen("std.in", "r", stdin);
}

/*vector<ll> v;
void seive()
{
    v.pb(2);
    for (int i = 3; i < 100000; i += 2)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i % v[j] == 0)
                break;
            if (v[j] * v[j] > i)
            {
                v.pb(i);
                break;
            }
        }
    }
}
/*
void prime_factor(ll x, vector<ll> &r)
{
    ll sqrt_x = sqrt(x);

    for (ll i : v)
    {
        if (i > sqrt_x)
            break;

        if (x % i == 0)
            r.pb(i);

        while (x % i == 0)
        {
            x /= i;
        }
    }

    if (x >= 2)
        r.pb(x);
}
*/
/*
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
*/
/*
inline void dfs(ll curr, ll prev)
{

    for (ll i : a[curr])
        if (i != prev)
            dfs(i, curr);
}
*/
/*
ll multi(ll a, ll b)
{
    return ((a * b) % MOD);
}
*/
//---------------------CODE STARTS HERE---------------------

signed main(char argc, char *argv[])
{
    FAST(argc);

    ll testcase = 1;
    //cin >> testcase;

    while (testcase--)
    {
        int n, w;
        cin >> n >> w;
        pair<int, int> a[n];
        rep(i, 0, n)
                cin >>
            a[i].first >> a[i].second;

        // sort(a, a + n);
        // int z[w + 5] = {0};
        map<int, int> m;
        m[0] = 0;
        bool ck = 0;
        int ans = 0;
        rep(i, 0, n)
        {
            int x = a[i].first;
            int y = a[i].second;
            // z[x] = max(z[x], y);
            vector<pair<int, int> > st;
            for (auto it : m)
            {
                if (it.first + x > w)
                    continue;
                st.pb(make_pair(it.first + x, max(it.second + y, m[it.first + x])));
            }
            for (auto z : st)
            {
                m[z.first] = z.second;
                ans = max(ans, z.second);
            }
        }
        // for(auto it:m)
        // {
        //     cout << " ";
        //     debug(it.first);
        // debug(it.second);
        // }
        cout << ans << endl;
        //--------??--------CLEAR VECTORS--------??--------
        m.clear();
    }

    //v.clear();
    print_time();
    return 0;
}

Measured memory_bytes: 11636
from itertools import groupby
s = input()
k = int(input())
if len(set(s)) == 1:
    print(len(s)*k//2)
    exit()
g = [len(list(v)) for _, v in groupby(s)]
ans = sum(i//2 for i in g)*k
if s[0] != s[-1]:
    print(ans)
    exit()
a, *_, b = g
ans -= (a//2 + b//2 - (a+b)//2)*(k-1)
print(ans)


Measured memory_bytes: 9196
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
m = B[A[n-1]-1]
for i in range(n-1):
  if A[i] == A[i+1] - 1:
    m += B[A[i]-1] + C[A[i]-1]
  else:
    m += B[A[i]-1]
print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){

    int m, k; cin >> m >> k;
    
    if(m == 1 && k == 1){

        cout << -1 << endl;
        return 0;
    }

    int val = 1;
    for(int i = 0; i < m; i++) val *= 2;

    if(val <= k) cout << -1 << endl;
    else{
        
        if(k == 0){
            for(int i = 0; i < val; i++) cout << i << " " << i << " ";
            cout << endl;
            return 0;
        }else{
            cout << 0 << " " << k << " " << 0 << " ";
            vector<int> ans;
            for(int i = 1; i < val; i++){
                if(i != k) ans.push_back(i);
            }
            ans.push_back(k);
            for(int i = val - 1; i >= 1; i--){
                if(i != k) ans.push_back(i);
            }

            for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " ";
            cout << endl;
            
            
        }
    }
    return 0;
}



Measured memory_bytes: 3952
#include<stdio.h>
#include <string.h>
int main(void){
	int num,i,count,sum;
	char number[1001];
	char* str;
	while(1){
		scanf("%s",number);
		i = 0;
		sum = 0;
		str = &number;
		count = (int)strlen(str);
		if( number[0] == '0' ){
			if(count == 1){
				break;
			}
		}
		while(i < count){
			num = number[i] - '0';
			sum = sum + num;
			i++;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
class UnionFind {
public:
    
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ
 
    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }
 
    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }
 
    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }
 
    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
 
    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};
 
int main() {
    ll n, m;
    cin >> n >> m;
 
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
 
    UnionFind Uni(n);
    Uni.init(n);
 
    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        Uni.unite(x, y);
    }
 
    vvl G(n);
    ll renketuseibun = 0;  // 森の連結成分の個数
    rep(v, n) {
        if(Uni.root(v) == v) {
            renketuseibun++;
        }
        ll p = Uni.root(v);
        G[p].pb(a[v]);
    }
 
    if(renketuseibun == 1) {
        out(0);
        re0;
    }
 
    if(2*(renketuseibun-1) > n) {
        out("Impossible");
        re0;
    }
 
    vl vec;
    ll ans = 0;
    rep(v, n) {
        if(Uni.root(v) == v) {
            sort(all(G[v]));
            ans += G[v][0];
            rep(j, G[v].size()) {
                if(j == 0) {
                    continue;
                }
                vec.pb(G[v][j]);
            }
        }
    }
 
    sort(all(vec));
    rep(i, renketuseibun-2) {
        ans += vec[i];
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 8064