akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
#define MAX 2505LL
using ll = long long;
typedef pair<ll,ll>P;
typedef pair<P,P>Q;
vector<Q>node[59];
ll min_cost[59][2509];

int main(){
  ll n,m,s;
  cin>>n>>m>>s;
  for(int i=0;i<=n;i++){
    rep(j,MAX+1){
      min_cost[i][j]=LLINF;
    }
  }
  for(int i=0;i<m;i++){
    ll s,t,a,b;
    cin>>s>>t>>a>>b;
    s--;t--;
    node[s].push_back(Q(P(t,a),P(b,0)));
    node[t].push_back(Q(P(s,a),P(b,0)));
  }
  vector<ll>c(n),d(n);
  rep(i,n)cin>>c[i]>>d[i];

  priority_queue<Q,vector<Q>,greater<Q> >pq;
  pq.push(Q(P(0,0),P(min(s,MAX),0)));
  min_cost[0][min(s,MAX)]=0;

  while(!pq.empty()){
    Q now=pq.top();pq.pop();
    ll cost=now.fi.fi;
    int pos=now.fi.se;
    ll sil=now.se.fi;
    if(sil+c[pos]<=MAX&&cost+d[pos]<min_cost[pos][sil+c[pos]]){
      chmin(min_cost[pos][sil+c[pos]],cost+d[pos]);
      pq.push(Q(P(cost+d[pos],pos),P(sil+c[pos],0)));
    }
    for(int i=0;i<node[pos].size();i++){
      int next=node[pos][i].fi.fi;
      ll a=node[pos][i].fi.se;
      ll b=node[pos][i].se.fi;
      if(sil-a>=0 && cost+b<min_cost[next][sil-a]){
        chmin(min_cost[next][sil-a],cost+b);
        pq.push(Q(P(cost+b,next),P(sil-a,0)));
      }
    }
  }

  rep2(i,1,n){
    ll ans=LLINF;
    rep(j,MAX){
      chmin(ans,min_cost[i][j]);
    }
    cout<<ans<<endl;
  }
  return(0);
}


Measured memory_bytes: 8364
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std; 
typedef long long ll; 
char str[100005]; 
int arr[100005]; 
int main()
{
	// freopen("ARC088-D.in", "r", stdin); 
	scanf("%s", str); 
	int n = strlen(str); 
	for (int i = 0; i < n; i++)
		str[i] -= '0'; 
	for (int i = 0; i <= n; i++)
		arr[i] = str[i] ^ (i ? str[i - 1] : 0); 
	int l = 1, r = n, ans; 
	while (l <= r)
	{
		int m = l + r >> 1, x = 0, y = 0, z = 0; 
		for (int i = m; i <= n; i++)
			x ^= arr[i]; 
		for (int i = 0; i <= min(m - 1, n - m); i++)
			y ^= arr[i]; 
		for (int i = n - m + 1; i < m; i++)
			z += arr[i]; 
		if (x == y && !z)
		{
			ans = m; 
			l = m + 1;
		}
		else
			r = m - 1; 
	}
	printf("%d\n", ans);
	return 0; 
}


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

#define ll long long
#define ar array
 
using namespace std;

int main() {

    int a, b, r;
    
    cin >> a >> b;
    
    r = max(a, b);
    
    if(a == b){
    	cout << r+r << endl;
	}
	else{
		cout << r+r-1 << endl;
	}

    return 0;
}

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

int main(void){
 
    string s;
    cin >> s;
    
    if(s[0] == 'S'){
        cout << "Cloudy" <<endl;
    }
    else if(s[0] == 'C'){
        cout << "Rainy" <<endl;
    }
    else{
        cout << "Sunny" <<endl;
    }
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,i,flag;
    cin>>n;
    while(1){
        x=n;
        flag=0;
        for(i=2;i<=sqrt(x);i++){
            if(x%i==0){
                flag=1;
                break;
            }
        }
        if(flag==0){
            cout<<x;
            break;
        }
        n++;
    }
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    ll W, H; cin >> W >> H;
    ll X, Y; cin >> X >> Y;

    double ans = W * H / 2.0;

    cout << fixed << setprecision(6) << ans << " ";
    if (X * 2 == W && Y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n==1){
      System.out.println("Hello World");
      System.exit(0);
    }
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a+b);
  }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


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

    int gc;
    cin >> gc;
    int ma = gc;
    REP(i,N-1) {
        int a;
        cin >> a;
        gc = gcd(gc,a);
        chmax(ma,a);
    }

    //cout << ma << " " << gc << endl;

    if(K <= ma && K%gc == 0){
        pl("POSSIBLE")
    } else {
        pl("IMPOSSIBLE")
    }
    
    return 0;
}


Measured memory_bytes: 256
s = input()
st1=[]
st2=[]
st3=[]
n=len(s)
lv = 0
total=0
for i in range(n):
	c=s[i]
	if c=='\\':
		lv-=1
		st1.append(i)
	elif c=='/':
		lv+=1
		if len(st1) > 0:
			a = i - st1.pop()
			total+=a
			tmp=0	
			while len(st2)>0 and st2[-1]<lv:
				st2.pop()
				tmp+=st3.pop()
			st3.append(a+tmp)		
			st2.append(lv)
		elif len(st2) > 0:
			st2.pop()
			st2.append(lv)
		
print(total)
n = len(st3)
print(n,end='')
for i in range(n):
	print(' '+str(st3[i]),end='')
print()



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

using namespace std;

#define int long long

signed main()
{
    map<int, int> mp;
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        sum += mp[i - a[i]];
        mp[i + a[i]]++;
    }
    cout << sum;
}

Measured memory_bytes: 27944
a = int(input())
b = [int(input()) for _ in range(a)]
c = 1
d = 0
e = {}
while True:
    d += 1
    if b[c-1] == 2:
        print(d)
        exit()
    else:
        if (c-1) not in e:
            e.setdefault((c-1), "")
        else:
            print(-1)
            exit()
        c = b[c - 1]


Measured memory_bytes: 19064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	In := readLineInt()
	L, R := In[0], In[1]

	Result := int(^uint(0) >> 1)
	for i := L; i <= R; i++ {
		for j := i + 1; j <= R; j++ {
			Result = min(Result, (i*j)%2019)
			if Result == 0 {
				goto end
			}
		}
	}

end:
	fmt.Println(Result)
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func min(a ...int) int {
	result := int(^uint(0) >> 1)

	for _, i := range a {
		if result > i {
			result = i
		}
	}

	return result
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *treeMinimum(Node *x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node *find(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){
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->right;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL) y=z;
  else y = treeSuccessor(z);
  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y == y->parent->left){
      y->parent->left = x;
    }else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
}

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

  z = (Node *)malloc(sizeof(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 invorder(Node *u){
  if(u == NIL) return;
  invorder(u->left);
  printf(" %d",u->key);
  invorder(u->right);
}

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

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL){
	printf("yes\n");
      }
      else printf("no\n");
    }
    else if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      invorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com == "delete"){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }
  
  return 0;
}



Measured memory_bytes: 22036
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         ll a,b;
        cin>>a>>b;
        if(a==b) cout<<"Yes\n";
        else cout<<"No\n";
         
         

      }
      






}





Measured memory_bytes: 256
#include <iostream>

#include <iomanip>

using std::cin;
using std::cout;
using std::endl;

static double const PI = 3.14159265358979323846;

int
main()
{
  int R;
  cin >> R;
  cout << std::fixed << PI * (R * 2) << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

int a[100005];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == i+1)a[i] = 1;
		else a[i] = 0;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			if (a[i + 1] == 1) {
				a[i] = a[i + 1] = 0;
				ans++;
			}
			else {
				a[i] = 0;
				ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int count;
	while(1){
		scanf("%d",&count);
		if(count==0){
			break;
		}
		int counter=0;
		int min=1001,max=-1;
		int i;
		int sum=0;
		while(counter<count){
			scanf("%d",&i);
			if(min>i){
				min=i;
			}
			if(max<i){
				max=i;
			}
			sum+=i;
			counter++;
		}
		sum-=(min+max);
		printf("%d\n",sum/(count-2));
		
	}
	return 0;
}

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

int main(void)
{
    int n;
    scanf("%d", &n);
    int *A;
    A = malloc(sizeof(int) * n * 500000);
    int I[1000] = {0};

    int q;
    scanf("%d", &q);
    int op, t, x, i, j;

    while (q--) {
        scanf("%d", &op);
        scanf("%d", &t);
        if (op == 0) {
            scanf("%d", &x);
            A[500000 * t + I[t]] = x;
            I[t] += 1;
        }
        else if (op == 1) {
            if (I[t] == 0) printf("\n");
            else {
                j = 500000 * t;
                printf("%d", A[j]);
                for (i = 1; i < I[t]; i++) printf(" %d", A[j + i]);
                printf("\n");
            }
        }
        else I[t] = 0;
    }

    return 0;
}


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

int main(void){

  char tcard[100];
  char hcard[100];
  int i, ii, t;
  int taro = 0;
  int hana = 0;

  scanf("%d", &t);
  for(i = 0; i < t; i++){
    scanf("%s%s", tcard, hcard);
    for(ii = 0; ii < 100; ii++){
      if(tcard[ii] > hcard[ii]){
	taro += 3;
	break;
      }
      if(tcard[ii] < hcard[ii]){
	hana += 3;
	break;
      }
      if(!strcmp(tcard, hcard)){
	  taro++;
	  hana++;
	  break;
      }
    }
  }
  printf("%d %d\n", taro, hana);
  return 0;
}

Measured memory_bytes: 604
using System;

public class AtCoder
{
    public static void Main()
    {
        int n, k;
        string[] s;
        s = Console.ReadLine().Trim().Split(' ');
        n = int.Parse(s[0]);
        k = int.Parse(s[1]);
        int[] h = new int[n];
        for (int i = 0; i < n; i++)
        {
            h[i] = int.Parse(Console.ReadLine().Trim());
        }
        Array.Sort(h);
        int ans = 2000000000;
        int j = 0;
        int x = 0;
        for (int i = 0; i < n; i++)
        {
            j = i + k - 1;
            if (j < n)
            {
                x = h[i] - h[j];
                if (x < 0) x = -x;
                if (x < ans) ans = x;
            }
        }       
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 17344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N, H;
	cin >> N >> H;
	int saidai = 0;
	int b[100000];
	rep(i, N) {
		int a;
		cin >> a >> b[i];
		saidai = max(saidai, a);
	}

	sort(b, b + N);

	int kaisuu = 0;
	rep(i, N) {
		if (b[N - i - 1] > saidai) {
			kaisuu++;
			H -= b[N - i - 1];
			if (H <= 0) break;
		}
	}

	if (H > 0) {
		kaisuu += (H + saidai - 1) / saidai;
	}
	co(kaisuu);

	Would you please return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k=s.size();
	if(s[k-1]=='2'||s[k-1]=='4'||s[k-1]=='5'||s[k-1]=='7'||s[k-1]=='9')
	cout<<"hon";
	else if(s[k-1]=='3')
	cout<<"bon";
	else cout<<"pon";
	return 0;
}

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll x, n;
    cin >> x >> n;
    vector<ll> a(102);
    for(ll i = 0;i < n;i++){
        ll p;
        cin >> p;
        a[p]++;
    }
    
    ll m, ans;
    m = x;
    ans = 0;

    for(ll i = 0;i < 102;i++){
        if(a[i] == 0){
            if(abs(x - i) < m){
                m = abs(x - i);
                ans = i;
            }
        }
    }

    cout << ans;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(3);
  set<vector<int>> s;
  for (int i = 0; i < n; i++) {
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    s.insert(v);
  }
  cout << n - s.size() << "\n";
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define inf __INT_MAX__

int main() {
    int N, M, P;
    cin>>N>>M>>P;
    vector<vector<pair<int, int>>> V(N);
    vector<long> D(N, inf);
    vector<bool> update(N, false);
    REP(i, 0, M){
        int A, B, C;
        cin >> A >> B >> C;
        V[A-1].push_back({B-1, -(C-P)});
    }
    D[0] = 0;
    REP(i, 0, N){
        REP(j, 0, N){
            for(pair<int, int> k: V[j]){
                long newCoin = D[j] + k.second;

                if (D[j] != inf && newCoin < D[k.first]){
                    D[k.first] = newCoin;
                }
                if(update[j]) update[k.first] = true;
            }
        }
    }
    REP(i, 0, N){
        REP(j, 0, N){
            for(pair<int, int> k: V[j]){
                long newCoin = D[j] + k.second;

                if (D[k.first] != inf && newCoin < D[k.first]){
                    D[k.first] = newCoin;
                    update[k.first] = true; 
                }
                if(update[j]) update[k.first] = true;
            }
        }
    }
    long ans = (D[N-1] < 0 ? -D[N-1] :0 );
    cout << (update[N-1] ? -1 : ans) << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[50];

int cmp(int x, int y){
	return x > y;
}
int main()
{
	int n,k, sum = 0;
	scanf("%d%d",&n,&k);
	for(int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	sort(a + 1,a + n + 1, cmp);
	for(int i = 1; i <= k; i++)
		sum += a[i];
	printf("%d\n",sum);

	return 0;
}

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

bool done = false;

void calc(int sum, string Sl, string Sr){
  if (!done){
    if (Sr.size() == 1){
      if (sum + stoll(Sr) == 7){
        cout << Sl << "+" << Sr << "=7" << endl;
        done = true;
      } else if (sum - stoll(Sr) == 7){
        cout << Sl << "-" << Sr << "=7" << endl;
        done = true;
      }
    }else{
      if (Sl.size() == 0){
		calc(sum+stoll(Sr.substr(0,1))
             ,Sr.substr(0,1)
             ,Sr.substr(1));
      }else{
        calc(sum+stoll(Sr.substr(0,1))
             ,Sl + "+" + Sr.substr(0,1)
             ,Sr.substr(1));
        calc(sum-stoll(Sr.substr(0,1))
             ,Sl + "-" + Sr.substr(0,1)
             ,Sr.substr(1));
      }
    }
  }
}

int main(){
  string S;
  cin >> S;
//cout << S.size();
  calc(0,"",S);

}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  if(a>b){
    c=a;
    a=b;
    b=c;
  }
  
  if(a*2+2*(b-a)>16){
    cout << ":(" <<endl;
  }else{
	cout << "Yay!" <<endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int w = sc.nextInt();

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < S.length(); i += w) {
            sb.append(S.substring(i,i+ 1));
        }
        System.out.println(sb);

    }
}


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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var x = (inputLongArray[0] + inputLongArray[1] + 1) / 2;

            Console.WriteLine(x);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
};

int dfs(Tree &t, int u){
    int res = 0;
    for(int v : t.t[u]){
        res ^= dfs(t, v) + 1;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        g.add_edge(x, y);
        g.add_edge(y, x);
    }
    Tree t(g, 0);
    if(dfs(t, 0) != 0) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 16640
#include<stdio.h>

int main()
{
	int a, b, c, i=0;

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

	if (a + b + c == 17) {
		i++;
	}

	if (a == 5 || a == 7) {
		i++;
	}

	if (b == 5 || b == 7) {
		i++;
	}

	if (i == 3) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>



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


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

	int sum = 0;
	vector<int> diff;
	
	rep(i, n) {
		string s; cin >> s;
		int temp = 0;
		int cur = 0;
		rep(j, s.size()) {
			if (s[j] == '(') {
				cur--;
			}
			else {
				cur++;
			}
			temp = min(temp, cur);
		}
		diff.push_back(temp);
		sum += cur;
	}
	if (sum != 0) {
		cout << "No" << endl;
		return 0;
	}
	sort(diff.begin(), diff.end());

	int diffnow = 0;
	bool flag = true;
	rep(i, diff.size()) {
		diffnow += diff[diff.size() - i - 1];
		if (diffnow < 0)
			flag = false;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
*/


int main()
{
	long long int n, k;
	cin >> n >> k;
	vector<int> a;
	rep(i, n) {
		int temp; cin >> temp;
		a.push_back(temp);
	}

	vector<int> time(n, -1);

	int cur = 0;
	int count = 1;
	time[0] = 0;
	int first, last;
	rep(i, n+1) {
		int temp = cur;
		cur = a[cur] - 1;
		if (count == k) {
			cout << cur + 1 << endl;
			return 0;
		}
		if (time[cur] != -1) {
			first = cur;
			last = temp;
			break;
		}
		else {
			time[cur] = count;
			count++;
		}

	
	}

	long long int firsttime = time[first];
	int inter = count - time[first];
	
	int amari = (k - firsttime) % inter;
	cur = first;
	


	rep(i, amari) {
		cur = a[cur] - 1;
	}

	cout << cur + 1 << endl;
}



Measured memory_bytes: 4988
#include <stdio.h>

int Fibo(int);

int c[44];

int main () {
  int n = 0;

  scanf("%d",&n);

  printf("%d\n",Fibo(n));

  return 0;
}


int Fibo(int x) {
  if(x == 0 || x == 1) return c[x] = 1;

  if(c[x] != 0) return c[x];
  
  return c[x] = Fibo(x - 1) + Fibo(x - 2); 
}




Measured memory_bytes: 2104
H,W = map(int,input().split())
C = []
A = []
for i in range(10) :
    C.append(list(map(int,input().split())))
for i in range(H) :
    A.append(list(map(int,input().split())))
for i in range(10) :
    for j in range(10) :
        for k in range(10) :
            C[j][k] = min(C[j][k], C[j][i]+C[i][k])
ans = 0
for row in A :
    for a in row :
        if a == -1 or a == 1 :
            continue
        else :
            ans += C[a][1]
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

string f(ll n) {
    if (n==0) return "";
    n--;
    return f(n/26) + string(1,'a'+n%26);
}

int main() {
    ll N;
    cin >> N;
    cout << f(N) << endl;
}

Measured memory_bytes: 3128
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, m = MI()
    A = LI()

    s = sum(A)
    cnt = 0
    for a in A:
        if a * 4 * m >= s:
            cnt += 1
    print('Yes' if cnt >= m else 'No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
signed main(){
	ll cnta = 0, cntb = 0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '0')cnta++;
		else cntb++;
	}
	cout << min(cnta, cntb) * 2 << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 200009
int pre[N], arr[N];
inline int unionsearch(int rt) {
	
}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n;
	long long k;
	cin >> n >> k;
	for (int i = 1;i <= n;i++) {
		cin >> pre[i];
	}
	int i, count = 0, count1 = 0, cou2 = 0;
	arr[1] = 0;
	for (i = 1;count < k;i = pre[i]) {
		if (arr[i])
			break;
		count++;
		arr[i] = 1;
	}
	int begin = i;
	if (count < k) {
		cou2 = 0;
		for (;;i = pre[i]) {
			cou2++;
			if (pre[i] == begin)
				break;
		}
		for (i = begin;count1 < ((k - count) % cou2);i = pre[i]) {
			count1++;
		}
	}
	cout << i;
	return 0;
}

Measured memory_bytes: 4732
using System;

namespace ITP1_10_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] v1 = Console.ReadLine().Split(' ');
            string[] v2 = Console.ReadLine().Split(' ');
            double s1 = 0, s2 = 0, s3 = 0, s0 = 0;
            for (int i = 0; i < n; i++)
            {
                double delta = Math.Abs(double.Parse(v1[i]) - double.Parse(v2[i]));
                s1 += delta;
                s2 += delta * delta;
                s3 += delta * delta * delta;
                if (delta > s0) s0 = delta;
            }
            Console.WriteLine(s1);
            Console.WriteLine(Math.Sqrt(s2));
            Console.WriteLine(Math.Pow(s3, 1 / 3.0));
            Console.Write(s0);
        }
    }
}

Measured memory_bytes: 9368
#!/usr/bin/env python3
#!/usr/bin/env pypy3

from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)

    input = sys.stdin.readline

    #import numpy as np
    #import scipy as sp

    # Python 3 modules: https://docs.python.org/3/library/

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    # Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
    # Before Python 3.5.  Import from math after it.
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')

    def lcm(a, b):
        return a * b // gcd(a,b)

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    ############################################################################


    N, = list(map(int, input().split()))
    D = input_ints()

    D.sort()
    p1 = D[N // 2 - 1]
    p2 = D[N // 2]
    dprint(D, p1, p2)
    print(p2 - p1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16028
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
map<ll,ll> cnt;
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<ll> op{n};
	while (q--) {
		ll v;
		cin >> v;
		while (op.size() && op.back() >= v) op.pop_back();
		op.pb(v);
	}
	reverse(op.begin(), op.end());
	++cnt[ op[0] ];
	for (int i = 1;i < op.size();++i) {
		ll now = op[i];
		while (cnt.rbegin()->first > now) {
			auto [n, c] = *cnt.rbegin();
			cnt.erase(prev(cnt.end()));
			cnt[ now ] += n / now * c;
			cnt[ n % now ] += c;
		}
	}
	vector<ll> res(n+1);
	for (auto [f, s] : cnt) res[f] += s;
	for (int i = n-1;i >= 1;--i)
		res[i] += res[i+1];
	for (int i = 1;i <= n;++i)
		cout << res[i] << '\n';
}


Measured memory_bytes: 10808
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

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

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

    float a,b;
    float sum=0;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        sum=sum+(1/b);
        //cout<<sum<<endl;
    }
    cout<<1/sum*1.0<<endl;

}


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

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;

  std::vector<char> v;

  for (size_t i = 0; i < s.length(); i++) {
    v.push_back(s.at(i));
  }

  int count = 0;
  bool finished = false;
  
    
  for (size_t i = 0; i < v.size()-1; i++) {
    if (v.at(i) == v.at(i+1)) {
      if (v.at(i) == '0') {
        v.at(i+1) = '1';
      } else {
        v.at(i+1) = '0';
      }
      count++;
    }
  }
    

  std::cout << count << '\n';
  
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
  int i, j, n, k, l, m, o;
  while( 1 ) {
    scanf("%d%d", &n, &k);
    if(!n && !k) break;
    vector<string> v;
    string a[n], t;
    for(i = 0; i < n; ++i) cin >> a[i];
    for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) {
      if(i == j) continue;
      t = a[i] + a[j];
      if(k == 2) v.push_back(t);
      else {
        for(l = 0; l < n; ++l) {
          if(i == l || j == l) continue;
          t += a[l];
          if(k == 3) v.push_back(t);
          else {
            for(m = 0; m < n; ++m) {
              if(i == m || j == m || l == m) continue;
              t += a[m];
              v.push_back(t);
              for(o = 0; o < a[m].length(); ++o) t.pop_back();
            }
          }
        for(o = 0; o < a[l].length(); ++o) t.pop_back();
        }
      }
    }
   sort(v.begin(), v.end());
   printf("%d\n", (int)(unique(v.begin(), v.end()) - v.begin()));
   vector<string>::iterator it;
   //for(it = v.begin(); it != unique(v.begin(), v.end()); ++it) cout << (*it) << " ";
  }
  return 0;
}


Measured memory_bytes: 3308
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

#define y0 y0ChloeGraceMoretz
#define y1 y1ChloeGraceMoretz
#define ll long long
int nextInt() { int n; scanf("%d", &n); return n; }
ll nextLong() { ll n; scanf("%lld", &n); return n; }
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;

int x[59];
ll dp[59][2509];

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int n, a;
	scanf("%d %d", &n, &a);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &x[i]);
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int cnt = i; cnt >= 1; --cnt) {
			for (int sum = x[i]; sum <= 2500; ++sum) {
				dp[cnt][sum] += dp[cnt - 1][sum - x[i]];
			}
		}
	}
	ll res = 0;
	for (int cnt = 1; cnt <= n; ++cnt) {
		for (int sum = 1; sum <= 2500; ++sum) {
			if (sum % cnt == 0 && sum / cnt == a) {
				res += dp[cnt][sum];
			}
		}
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1280
// ---- My Template start------- //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0);
// ---- My Template end------- //
ll power(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res%p;
}

int main(){ 
	int n;
    cin>>n;
    char r='R';
    char w = 'W';
    string str; cin>>str;
    int cnt=0;
    for(int i=0;i<n;i++){ 
        if(str[i]==r) cnt++;}
    if(cnt==n or cnt==0) cout<<0;
    else{
        int start=0,end=n-1;
        cnt=0;
        for( ;start<end;start++){
            if(str[start]==w){
                //cout<<start<<endl;
                while(str[end]!=r and start<end) end--;
                if(str[end]==r){
                    //cout<<end<<endl;
                    char temp = str[start];
                    str[start]=str[end];
                    str[end]=str[temp];
                    cnt++; end--;
                }
            }
        }
        cout<<cnt;
    }
return 0; 
} 


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

int main()
{
	int n, ans=0; cin >> n;
	string s; cin >> s;
	for (int i=0; i<n-1; i++)
	{
		if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
			ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N,M;
    cin >> N >> M;
    const auto &res = enum_divisors(M);
    
    long long ans = 0;
    for (int i = 0; i < res.size(); ++i) {
        long long y;
        y = M / res[i];
        if ( y >= N ){
            ans = res[i];
        } else {
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
N, K = map(int, input().split())
A = list(map(int, input().split()))

buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1

kinds = sorted(buckets.values())
count = len(kinds)
if K < count:
    mini = 0
    for i in kinds:
        mini += i
        count -= 1
        if count <= K:
            break
    print(mini)
else:
    print(0)

Measured memory_bytes: 32184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    while(getline(cin,str)){
        stack<double> st;
        for(int i=0,point=0;;i++){
            if(str[i]==' '||str[i]=='\0'){
                if(i-point==1){
                    if(str[point]-'0'>9||str[point]-'0'<0){
                        double righ=st.top();
                        st.pop();
                        double lef=st.top();
                        st.pop();
                        if(str[point]=='+')st.push(lef+righ);
                        else if(str[point]=='-')st.push(lef-righ);
                        else if(str[point]=='*')st.push(lef*righ);
                        else st.push(lef/righ);
                        }
                    else st.push(str[point]-'0');
                }
                else{
                    double now=0;
                    bool kawa=0;
                    if(str[point]=='-'){
                        point++;
                        kawa=1;
                    }
                    for(int j=point;j<i;j++)now+=(str[j]-'0')*pow(10,i-j-1);
                    if(kawa)now*=-1;
                    st.push(now);
                }
                if(str[i]=='\0')break;
                point=i+1;
            }
        }
        printf("%lf\n",st.top());
    }
}

Measured memory_bytes: 1276
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    int lcm=1;
    while (n--){
    	int t; cin>>t;
    	lcm = lcm*(t/__gcd(lcm,t));
    }
    cout << lcm << endl;
}

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


Measured memory_bytes: 3544
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int a, b, m;
	cin >> a >> b >> m;

	vector<int> v1(a);
	vector<int> v2(b);

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

	for (int i = 0; i < b; ++i) {
		cin >> v2[i];
	}

	int ans = *min_element(v1.begin(), v1.end()) + *min_element(v2.begin(), v2.end());

	for (int i = 0; i < m; ++i) {
		int x, y, c;
		cin >> x >> y >> c;

		ans = min(ans, v1[x - 1] + v2[y - 1] - c);
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
static const int MOD = 1e9+7;
static const ll MAX = 1ll<<60;

int main(){
    ll x[2],y[2];
    for(int i=0; i<2; i++) cin>>x[i];
    for(int i=0; i<2; i++) cin>>y[i];

    ll ans = -MAX;

    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            ans = max(ans,x[i]*y[j]);
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#ifndef DEBUG
#pragma GCC optimize("O3,unroll-loops")
#pragma loop_opt(on)
#endif
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define All(v) v.begin(),v.end()
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MOD = 1e9+7;

signed main() {
    FAST;

    int n;
    string x;
    cin >> n >> x;
    reverse(All(x));
    vector<int> ans(n);
    int c = 0;
    Fr(j,0,n) c += x[j]=='1';
    auto f = [&](char t, int z) {
        const int mod = c+z;
        if (!mod) return;
        int k = 0, r = 1;
        Fr(i,0,n) {
            k = (k+r*(x[i]=='1'))%mod;
            r = r*2%mod;
        }
        r = (z+mod)%mod;
        Fr(i,0,n) {
            if (x[i] == t) {
                ans[i] = 1;
                int y = (k+r)%mod;
                while (y) {
                    ans[i]++;
                    y = y % __builtin_popcount(y);
                }
            }
            r = r*2%mod;
        }
    };
    f('1',-1);
    f('0',+1);
    reverse(All(ans));
    Fr(i,0,n) cout << ans[i] << endl;

}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define bit(idx) idx&(-idx)
#define bin(x, a) bitset<a>(x)
#define all(A) A.begin(), A.end()
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

const long double PI = 3.1415926535897932384626;

int main(){
	ios_base::sync_with_stdio(NULL); cin.tie(); cout.tie();
	long double r; cin >> r;
	cout << (long double) 2* r * PI << endl;
}
/**

*/

Measured memory_bytes: 3808
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split("");
        Map<String,Integer> map = new HashMap<>();

        int flag = 0;
        for(int i = 0;i<s.length;i++){
            if(map.get(s[i]) != null){
                flag++;
                System.out.println("no");
                break;
            }else{
                map.put(s[i],1);
            }
        }
        
        if(flag == 0){
            System.out.println("yes");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>
#include <set>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

int main() {
	Get(int, n, y);


	for (int a = 0; a <= n; a++) {
		for (int b = 0; b <= n - a; b++) {
			int c = n - a - b;
			int x = 10000 * a + 5000 * b + 1000 * c;

			if (x == y) {
				co << a << " " << b << " " << c << en;
				return 0;
			}
		}
	}
	co << "-1 -1 -1" << en;
}




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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    int sum = 0;
    sort(p.begin(), p.end());
    for(int i=0; i<k; i++){
        sum += p.at(i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624