akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define erep(i,n) for(int i=1; i<=(n); i++)
using namespace std;

vector<int> x(10), y(10);

double distance(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

int main() {
  int N;
  cin >> N;
  erep(i,N) {
    cin >> x[i] >> y[i];
  }

  vector<int> v(N);
  rep(i,N) {
    v[i] = i + 1;
  }

  int cnt = 1;
  erep(i,N) {
    cnt *= i;
  }

  double dis_sum = 0.0;
  do {
    for (int i = 0; i < N - 1; ++i) {
      dis_sum += distance(v[i], v[i + 1]);
    }
  } while (next_permutation(v.begin(), v.end()));

  cout << setprecision(10) << dis_sum / cnt << endl;
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    vector<ll> ans;
    ans.push_back(a); ans.push_back(b); ans.push_back(c); 
    sort(ans.begin(), ans.end());
    if(ans[0]+ans[1] == ans[2]) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    string weather[] = {"Sunny", "Cloudy", "Rainy"};

    for(int i = 0; i < sizeof(weather) / sizeof(*weather); i++) {
        if(weather[i] == s) {
            int idx = (i + 1) % 3;
            cout << weather[idx] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N,K=map(int, input().split())
P = list(map(int, input().split()))

P.sort()
ans = 0

for i in range(K):
    ans += P[i]
print(ans)


Measured memory_bytes: 72736
#include <stdio.h>

int main()
{
    int n,k,s;
    scanf("%d %d %d",&n,&k,&s);

    int i;
    for (i = 0; i < k; i++)
    {
        printf("%d ",s);
    }
    for (; i < n; i++)
    {
        printf("%d ",s != 1 ? s - 1 : 2);
    }
    
    
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
switch(n){
case 1: printf("1"); break;
case 2: printf("3"); break;
case 3: printf("4"); break;
case 4: printf("7"); break;
case 5: printf("11"); break;
case 6: printf("18"); break;
case 7: printf("29"); break;
case 8: printf("47"); break;
case 9: printf("76"); break;
case 10: printf("123"); break;
case 11: printf("199"); break;
case 12: printf("322"); break;
case 13: printf("521"); break;
case 14: printf("843"); break;
case 15: printf("1364");  break;
case 16: printf("2207"); break;
case 17: printf("3571"); break;
case 18: printf("5778"); break;
case 19: printf("9349"); break;
case 20: printf("15127"); break;
case 21: printf("24476"); break;
case 22: printf("39603"); break;
case 23: printf("64079"); break;
case 24: printf("103682"); break;
case 25: printf("167761"); break;
case 26: printf("271443"); break;
case 27: printf("439204"); break;
case 28: printf("710647"); break;
case 29: printf("1149851"); break;
case 30: printf("1860498"); break;
case 31: printf("3010349"); break;
case 32: printf("4870847"); break;
case 33: printf("7881196"); break;
case 34: printf("12752043"); break;
case 35: printf("20633239"); break;
case 36: printf("33385282"); break;
case 37: printf("54018521"); break;
case 38: printf("87403803"); break;
case 39: printf("141422324"); break;
case 40: printf("228826127"); break;
case 41: printf("370248451"); break;
case 42: printf("599074578"); break;
case 43: printf("969323029"); break;
case 44: printf("1568397607"); break;
case 45: printf("2537720636"); break;
case 46: printf("4106118243"); break;
case 47: printf("6643838879"); break;
case 48: printf("10749957122"); break;
case 49: printf("17393796001"); break;
case 50: printf("28143753123"); break;
case 51: printf("45537549124"); break;
case 52: printf("73681302247"); break;
case 53: printf("119218851371"); break;
case 54: printf("192900153618"); break;
case 55: printf("312119004989"); break;
case 56: printf("505019158607"); break;
case 57: printf("817138163596"); break;
case 58: printf("1322157322203"); break;
case 59: printf("2139295485799"); break;
case 60: printf("3461452808002"); break;
case 61: printf("5600748293801"); break;
case 62: printf("9062201101803"); break;
case 63: printf("14662949395604"); break;
case 64: printf("23725150497407"); break;
    
case 79: printf("32361122672259149"); break;
    
case 85: printf("580696784543856761"); break;
case 86: printf("939587134549734843"); break;
default: break;
}
return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <functional>

const  long long int INF = 1LL << 60;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<long long int,int> P;

struct edge{
  int to;
  long long int cost;
};

int N;
vector<edge> G[100001];
long long int d[100001];


int main(){

  cin >> N;
  for( int i = 0; i < N-1; ++i){
    int a,b;
    long long int c;
    cin >> a >> b >> c;
    G[a].push_back(edge{b,c});
    G[b].push_back(edge{a,c});
  }
  fill( d, d+N+1, INF);
  int Q,r;

  cin >> Q >> r;

  d[r] = 0;
  priority_queue< P, vector<P>, greater<P> > q;
  q.push( P(d[r],r));
  while(!q.empty()){
    P p = q.top();q.pop();
    int from = p.second;
    long long int cost = p.first;
    for( int i = 0; i < G[from].size(); ++i){
      edge e = G[from][i];
      int next = e.to;
      long long int newCost = e.cost + cost;
      if( d[next] > newCost){
        d[next] = newCost;
        q.push( P(newCost, next));
      }
    }
  }




  for( int i = 0; i < Q; ++i){
    int x,y;
    cin >> x >> y;
    cout << d[x]+d[y] << endl;
  }
}


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

int main()
{
    string s;
    cin >> s;
    cout << s[0] << (int) s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

tmp = []
counter = 0
for i in range(N):
    new_str = ''.join(sorted(str(input())))
    
    #if i != 0:
    #    counter += tmp.count(new_str)
    tmp.append(new_str)

import collections
c = collections.Counter(tmp)

#new_str_list = [i for i in new_str = ''.join(list(sorted(str(input()))))]
#print(new_str_list)

    #for j in range(i):
    #    if str(new_str) == str(tmp[j]):
    #        counter += 1
value = list(c.values())
#print(value)

for j in value:
    for k in range(j):
        counter += k

print(counter)


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

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

  //カードの最大値の計算
  int xa = min(a,k); //どちらか小さい方を選択した数とする
  k -= xa;

  int xb = min(b,k); //どちらか小さい方を選択した数とする
  k -= xb;

  int xc = k;
  //最終的な総和を求める
  int ans = xa - xc;

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int b = k+1; b <= n; b++){
        int q = n / b;
        int r = n % b;
        ans += q * (b-k);
        ans += max(r-k+1, 0);
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
    return 0;
}

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

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

    string Answer [1000];

    for (int x = 0; x <  TestCase ; x++)
        {
            int a;
            int b;
            int c;
            int o;
            int p;

            cin >> a >> b >> c;

            /* a < b < c */
            if (a < b)
            {
                o = b;
                b = a;
                a = o;
            }
            if (a < c)
            {
                p = c;
                c = a;
                a = p;
            }
            if (c*c + b*b == a*a)
            {
                Answer [x] = "YES";
            }
            else
            {
                Answer [x] = "NO";
            }

        }
    for (int y = 0; y < TestCase; y++)
    {
        cout << Answer [y] << endl;
    }


    return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
#include<string.h>
int main()
{
    char s[1003];
    scanf("%s", s);
    int i;
    int N, W, S, E;
    N = W = S = E = 0;
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] == 'N')N++;
        else if (s[i] == 'W')W++;
        else if (s[i] == 'S')S++;
        else E++;
    }
    if ((N > 0 && S == 0) || (N == 0 && S > 0))
        printf("No\n");
    else if ((W > 0 && E == 0) || (W == 0 && E > 0))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;
ll dp[N];

int main(){
	cin >> n;
	dp[3] = 1;
	dp[4] = 1;
	dp[5] = 1;
	dp[6] = 2;
	for(int i = 7; i <= n; i ++ ){
		dp[i] = 1;
		for(int j = 3; i - j >= 3; j ++ ){
			dp[i] = (dp[i] + dp[i - j]) % mod; 
		}
	}
	cout << dp[n] << endl;



	return 0;
}



Measured memory_bytes: 3656
import math
def digits(n):
  return int(math.log10(n))+1
  
def main():
  n = int(input())
  n_digit = digits(n)
  ans = 0
  
  if n_digit%2==0:
    for i in range(n_digit-1,0,-2):
      ans = ans + (pow(10,i)-pow(10,i-1))  
  else:
    ans = n - pow(10,n_digit-1) + 1
    for i in range(n_digit-2,0,-2):
      ans = ans + (pow(10,i)-pow(10,i-1)) 
  print(ans)
    
  
if __name__ == "__main__":
  main()



Measured memory_bytes: 3064
def solve(ip):
    g, y, m, d = ip.split()
    y, m, d = map(int, [y, m, d])
    if (y == 31 and m >= 5) or (y >= 32):
        g = "?"
        y -= 30

    return [g, y, m, d]


def main():
    ans = []
    while True:
        ip = input()
        if (ip[0] == "#"):
            break
        ans.append(solve(ip))
    for i in ans:
        print(*i)


main()



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

using namespace std;

int main()
{
    int x[5] ;
    for(int i = 0 ; i < 5 ; i++)
    {
      cin >> x[i] ;
    }
    int ans ;
    for(int i = 0 ; i < 5 ; i++)
    {
      if(x[i] == 0)
      {
        cout << i+1 << endl ;
      }
    }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define sz 300005

int num[sz], visi[sz];

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

    int i,j,k,n,r,d;
    cin>>n>>k;

    if(k==1 || k ==2*n-1) cout<<"No\n";
    else if(n==2) cout<<"Yes"<<endl<<"1"<<endl<<"2"<<endl<<"3"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        if(k!=2)
        {
            num[n] =k;
            num[n+1] = k-1;
            num[n-1] = k+1;
            num[n-2] = k-2;

            visi[k]=1, visi[k-1]=1, visi[k+1]=1, visi[k-2]=1;
        }
        else
        {
            num[n] =k;
            num[n+1] = k+1;
            num[n-1] = k-1;
            num[n-2] = k+2;

            visi[k]=1, visi[k+1]=1, visi[k-1]=1, visi[k+2]=1;
        }
        j=1;
        for(i=1; i<2*n; i++)
        {
            while(visi[j]) j++;
            if(!num[i]) num[i] =j ++;
        }

        for(i=1; i<2*n; i++) cout<<num[i]<<endl;
    }
    return 0;
}





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

struct UnionFind {
    // メンバ変数
    vector<int> par;    // 親の番号
    // 要素数n, 全ての要素の値-1で初期化
    UnionFind(int n) : par(n, -1) { }
    // n要素で初期化
    void init(int n) { par.assign(n, -1); } // コンテナの再代入
    // 木の根を求める
    int root(int x) {
        if (par[x] < 0) return x;   // 要素-1は親
        else return par[x] = root(par[x]);  // 経路圧縮
    }
    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    // xとyの属する集合を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    UnionFind uf(N);
    ll count = N*(N-1)/2;
    vector<ll> ans;
    for(int i=M-1;i>=0;i--){
        ans.push_back(count);
        if(uf.same(A[i], B[i]))   // AとBが同一グループなら
            continue;               // 以下の処理は行わない
        count -= uf.size(A[i])*uf.size(B[i]);
        uf.unite(A[i], B[i]);
    }

    reverse(ans.begin(), ans.end());
    for(int i=0;i<M;i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3444
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N, A, B, C = map(int, input().split())
    T = [A, B, C]
    L = [int(input()) for i in range(N)]

    ans = 10 ** 9
    for i in range(4**N):
        l = [0, 0, 0]
        cur = 0
        for j in range(N):
            idx = i // (4**j) % 4 - 1
            if idx >= 0:
                if l[idx]:
                    cur += 10
                l[idx] += L[j]

        for j in range(3):
            if l[j] == 0:
                cur += 10 ** 9
            cur += abs(T[j]-l[j])

        ans = min(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43372
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,M,Q;
    cin >> N >> M >> Q;
    int P[501][501];
    int X[501][501];

    for ( int i = 0; i < 501; i++ ) {
    for ( int j = 0; j < 501; j++ ) {
        P[i][j] = 0;
        X[i][j] = 0;
    }
    }

    for ( int i = 0; i < M; i++ ) {
        int l,r;
        cin >> l >> r;
        P[l][r]++;
    }

    for ( int i = 1; i <= N; i++ ) {
    for ( int j = i; j <= N; j++ ) {

        for ( int k = i; k <= j; k++ ) {
        for ( int l = k; l <= j; l++ ) {
            X[i][j] += P[k][l];
        }
        }

    }
    }

    vector<int> ans;
    for ( int i = 0; i < Q; i++ ) {
        int p,q;
        cin >> p >> q;
        ans.push_back(X[p][q]);
    }
    for ( int i = 0; i < Q; i++ ) {
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 3448
import math
a,b=map(int,input().split())
a_min=math.ceil(a*12.5)
a_max=math.ceil((a+1)*12.5)-1
b_min=math.ceil(b*10)
b_max=math.ceil((b+1)*10)-1
if a_min<=b_min:
    if a_max<b_min:
        print(-1)
    else:
        print(b_min)
else:
    if b_max<a_min:
        print(-1)
    else:
        print(a_min)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[] ss){
        int h,w,i,j;
        Scanner s = new Scanner(System.in);
        while(true){
        h = s.nextInt();
        w = s.nextInt();
        if(h*w==0)break;
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if((i+j)%2==0)System.out.print("#");
                else System.out.print(".");
            }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "\t\t" << #y << ": " << y << endl;
#define debugv(v, n) cerr << #v << " : " << " "; for(int i = 0; i < n; i++) cerr << "\t" << #v << "[" <<  i <<  "]" <<  " : " << v[i] << "\n"; cerr << endl;
#define sep() cerr << "--------------------" << endl;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int N = 1e5 + 5;

vector <int> vv[123];

int done[123];
char a[N];
int n, k, R, S, P;

ll ans = 0;
void playR() {
	// s, play r
	for(int i = 0; i < sz(vv['s' - 'a']); i++) {
		int idx = vv['s' - 'a'][i];
		if(idx - k >= 0) {
			if(a[idx - k] == 'r') continue;
			else a[idx] = 'r', ans += R;
		}
		else a[idx] = 'r', ans += R;
	}
}
void playS() {
	// p, play s
	for(int i = 0; i < sz(vv['p' - 'a']); i++) {
		int idx = vv['p' - 'a'][i];
		if(idx - k >= 0) {
			if(a[idx - k] == 's') continue;
			else a[idx] = 's', ans += S;
		}
		else a[idx] = 's', ans += S;
	}
}
void playP() {
	// r, play p
	for(int i = 0; i < sz(vv['r' - 'a']); i++) {
		int idx = vv['r' - 'a'][i];
		if(idx - k >= 0) {
			if(a[idx - k] == 'p') continue;
			else a[idx] = 'p', ans += P;
		}
		else a[idx] = 'p', ans += P;
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	cin >> R >> S >> P;
	string ss;
	cin >> ss;

	for(int i = 0; i < n; i++) 
		vv[ss[i] - 'a'].pb(i);
	vector <int> b;
	b.pb(R);
	b.pb(S);
	b.pb(P);
	sort(all(b));
	reverse(all(b));	
	if(R == b[0]) {
		if(S == b[1]) {
			playR(); playS(); playP();
		}
		else {
			assert(P == b[1]);
			playR(); playS(); playP();
		}
	}
	else if(S == b[0]) {
		if(R == b[1]) {
			playS(); playR(); playP();
		}
		else {
			assert(P == b[1]);
			playS(); playP(); playR();
		}
	}
	else {
		assert(P == b[0]);
		if(S == b[1]) {
			playP(); playS(); playR();
		}
		else {
			playP(); playR(); playS();
		}
	}

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

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    for(int i = 0;i < n - 1;i++){
        if(s[i] != s[i + 1])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int L;
    int R;
    int d;
    int answer;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        L = sc.nextInt();
        R = sc.nextInt();
        d = sc.nextInt();
    }
    
    //解答処理
    int solve() {
        for (int i=L; i<R+1; ++i){
            if (i % d == 0){
                ++answer;
            }
        }
        
        return answer;
    }
    
    //出力
    void show(int answer) {
        System.out.print(answer);
    }
}

Measured memory_bytes: 35676
#include<cstdio>
#define maxn 2005
#define min(a,b) ((a)<(b)?(a):(b))
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
int n,k,dist[maxn],deg[maxn],d1,d2,ans;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u,int fa,int d)
{
	dist[u]=d;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs(v,u,d+1);
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d%d",&n,&k);
	ans=n;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
		deg[u]++,deg[v]++;
	}
	if(k%2)
		for(int i=1;i<=n;i++)
			for(node *p=head[i];p;p=p->nxt)
			{
				if(p->v<i) continue;
				dfs(i,p->v,0); dfs(p->v,i,0);
				int cnt=0,tmp=k/2;
				for(int j=1;j<=n;j++)
					if(dist[j]>tmp) cnt++;
				ans=min(ans,cnt);
			}
	else
		for(int i=1;i<=n;i++)
		{
			dfs(i,0,0);
			int cnt=0,tmp=k/2;
			for(int j=1;j<=n;j++)
				if(dist[j]>tmp) cnt++;
			ans=min(ans,cnt);
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

const int MAX = 510000;
vector<ll> fac(MAX),finv(MAX),inv(MAX);
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    rep2(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B,C,D; cin >> N >> A >> B >> C >> D;
    COMinit();
    vector<vector<ll>> powfinv(N+1,vector<ll>(N+1,1));
    rep2(i,A,B+1){
        rep2(j,1,N+1){
            powfinv[i][j]=powfinv[i][j-1]*finv[i]%MOD;
        }
    }
    vector<vector<ll>> dp(B+2,vector<ll>(N+1,0));
    dp[A][N]=1;
    rep2(i,A,B+1){
        rep(j,N+1){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            for (int k=C;j-i*k>=0&&k<=D;++k){
                dp[i+1][j-i*k]=(dp[i+1][j-i*k]+dp[i][j]*fac[j]%MOD*finv[j-i*k]%MOD*powfinv[i][k]%MOD*finv[k]%MOD)%MOD;
            }
        }
    }
    cout << dp[B+1][0] << endl;
}

Measured memory_bytes: 27904
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , m ;
    cin >> n >> m ;
    ll tot = n * m  ;
    if(n == 1) {
        if(m == 1){
            cout << 1 << el ;
            ro  ;
        }
        else if(m == 2){
            cout << 0 << el ;
             ro ;
        }
        else {
            cout << m-2 << el ;
            ro ;
        }
    }
    if(m == 1){
        if(n == 1){
            cout << 1 << el ;
            ro ;
        }
        else if(n == 2){
            cout << 0 << el ;
            ro;
        }
        else {
            cout << n-2 << el ;
            ro ;
        }
    }
    if(n == 2){
        if(m == 1){
            cout << 0 << el ;
            ro ;
        }
        else if(m == 2){
            cout << 0 << el ;
            ro ;
        }
        else {
            cout << 0 << el ;
            ro  ;
        }
    }
    if(m == 2){
        cout << 0 << el ;
        ro;
    }
    ll rr = n - 2 ;
    ll rc = m- 2 ;
    ll foo = rr * rc ;
    cout << foo << el ;
    ro ;
}































Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a=n%10;
    int b=n/100;
    if(a==b)
        printf("Yes\n");
    else
        printf("No\n");
}


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

using namespace std;

struct Edge {
  int t,f,next;
  Edge() {}
  Edge(int a,int b,int c):t(a),f(b),next(c) {}
};

Edge e[2000000];
int head[200005],vs,vt,tot=-1;

inline void addEdge(int x,int y,int z) {
  e[++tot]=Edge(y,z,head[x]);
  head[x]=tot;
  e[++tot]=Edge(x,0,head[y]);
  head[y]=tot;
}

namespace Flow {

int d[200005],cur[200005];
queue <int> q;

bool bfs() {
  while (!q.empty()) q.pop();
  memset(d,255,sizeof(d));
  d[vs]=0;cur[vs]=head[vs];
  q.push(vs);
  while (!q.empty()) {
  	int x=q.front();q.pop();
  	for(int i=head[x];i!=-1;i=e[i].next)
  	  if (e[i].f&&d[e[i].t]==-1) {
  	  	  int u=e[i].t;
  	  	  d[u]=d[x]+1;
  	  	  cur[u]=head[u];
  	  	  if (u==vt) return 1;
  	  	  q.push(u);
		}
  }
  return 0;
}

int dfs(int x,int a) {
  if (x==vt||!a) return a;
  int ans=0;
  for(int &i=cur[x];i!=-1;i=e[i].next)
    if (e[i].f&&d[e[i].t]==d[x]+1) {
    	int u=e[i].t;
    	int f=dfs(u,min(a,e[i].f));
    	if (f) {
    		e[i].f-=f;
    		e[i^1].f+=f;
    		ans+=f;
    		a-=f;
    		if (!a) break;
		}
	}
  return ans;
}

int maxflow() {
  int ans=0;
  while (bfs())
    ans+=dfs(vs,1e9);
  return ans;
}

}

int a[100005],b[100005];
int id1[100005],id2[100005];

int main() {
  memset(head,255,sizeof(head));
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]++;
  for(int i=1;i<=n;i++) scanf("%d",&b[i]),b[i]++;
  int cnt1=0,cnt2=0;
  for(int i=1;i<=n;i++)
    if (!id1[i]) {
    	int x=i;
    	cnt1++;
    	do {
    		id1[x]=cnt1;
    		x=a[x];
		} while (x!=i);
	}
  for(int i=1;i<=n;i++)
    if (!id2[i]) {
    	int x=i;
    	cnt2++;
    	do {
    		id2[x]=cnt2;
    		x=b[x];
		} while (x!=i);
	}
  vs=0;vt=cnt1+cnt2+1;
  int s=0;
  for(int i=1;i<=n;i++) {
  	int u=id1[i],v=id2[i];
    if (a[i]!=i&&b[i]!=i) {
    	addEdge(u,cnt1+v,1);
    	if (a[i]==b[i]) addEdge(cnt1+v,u,1);
	}
	else if (a[i]!=i) addEdge(u,vt,1);
	else if (b[i]!=i) addEdge(vs,cnt1+v,1);
	else s++;
  }
  printf("%d\n",n-s-Flow::maxflow());
  return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
using namespace std;
 
int main()
{  
    int n,k;
    string s;
  cin >>n >> k;
  cin>> s;
  if (s[k-1]=='A'){
  	s[k-1]='a';
  }else if (s[k-1]=='B'){
  	s[k-1]='b';
  }else if (s[k-1]=='C'){
  	s[k-1]='c';
  }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int INF = 1e8;
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = INF;
    for(int n = -100; n <= 100; n++) {
        int tmp = 0;
        for(int i = 0; i < N; i++) {
            tmp += pow(n - a[i], 2);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

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

#define task "C" //ABC132
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
int n,a[100005];
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i,1,n) cin >> a[i];
	sort(a+1,a+1+n);
	cout << a[n/2+1]-a[n/2];
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[10010];
int main() {
	int k, t;
	cin >> k >> t;
	int ans = 0;
	for (int i = 0; i < t; i++) {
		cin >> a[i];
		ans += max(0, a[i] - k + a[i] - 1);
	}
	cout << ans << endl;

}

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

void dfs(int c, vector<int> v, vector<vector<int>> &vv)
{
    v.push_back(c);
    if (v.size() == 6)
    {
        vv.push_back(v);
        return;
    }
    for (int i = 1; i <= 6; i++)
    {
        auto x = v;
        if (i == c)
            continue;
        dfs(i, x, vv);
    }
}

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

int main()
{
    int H, W, C;
    while (cin >> H >> W >> C, H | W | C)
    {
        vector<vector<int>> P(H, vector<int>(W));
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                cin >> P[i][j];
        int sclr = P[0][0];
        vector<vector<int>> orders;
        dfs(sclr, vector<int>(), orders);
        int res = 0;
        for (auto v : orders)
        {
            if(v.back()!=C)
                continue;
            auto CP = P;
            int sz = 0;
            for (int k = 1; k < v.size(); k++)
            {
                int c = v[k];
                queue<pair<int, int>> que;
                que.push(make_pair(0, 0));
                int sc = CP[0][0];
                int tmp = 0;
                while (!que.empty())
                {
                    auto p = que.front();
                    que.pop();
                    int x = p.first, y = p.second;
                    CP[y][x] = c;
                    for (int i = 0; i < 4; i++)
                    {
                        int nx = x + dx[i], ny = y + dy[i];
                        if (nx >= 0 && nx < W && ny >= 0 && ny < H)
                        {
                            if (CP[ny][nx] == sc)
                            {
                                CP[ny][nx] = c;
                                que.push(make_pair(nx, ny));
                            }
                        }
                    }
                }
            }
            queue<pair<int, int>> que;
            que.push(make_pair(0, 0));
            int sc = CP[0][0];
            while (!que.empty())
            {
                auto p = que.front();
                que.pop();
                int x = p.first, y = p.second;
                CP[y][x] = 0;
                sz++;
                for (int i = 0; i < 4; i++)
                {
                    int nx = x + dx[i], ny = y + dy[i];
                    if (nx >= 0 && nx < W && ny >= 0 && ny < H)
                    {
                        if (CP[ny][nx] == sc)
                        {
                            CP[ny][nx] = 0;
                            que.push(make_pair(nx, ny));
                        }
                    }
                }
            }
            res = max(res, sz);
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3268
n, m = gets.split.map(&:to_i)
py = Array.new(m){gets.split.map(&:to_i)}
sorted = py.sort
ps = Array.new(n){[]}
hash = Hash.new{|h,k| h[k]={}}

sorted.each do |ary|
  ps[ary[0]-1] << ary[1]
end

ps.each_with_index do |ary, i|
  ary.each_with_index do |year, j|
    hash[i+1][year] = (i+1).to_s.rjust(6,"0") + (j+1).to_s.rjust(6,"0")
  end
end

py.each do |ary|
  puts hash[ary[0]][ary[1]]
end

Measured memory_bytes: 59244
import sys
from operator import itemgetter
input = sys.stdin.readline

_s = input()


def chker(s):
    l, r, minisum = 0, 0, 0
    if s[0] == '<':
        l += 1
    elif s[0] == '>':
        r += 1
    for i in range(1, len(s)):
        if s[i - 1] == '>' and s[i] == '<':
            l, r = (l, r) if l > r else (r, l)
            minisum += l * (l + 1) / 2 + r * (r - 1) / 2
            l, r = 1, 0
        else:
            if s[i] == '<':
                l += 1
            elif s[i] == '>':
                r += 1

    l, r = (l, r) if l > r else (r, l)
    minisum += l * (l + 1) / 2 + r * (r - 1) / 2

    print(int(minisum))


chker(_s)


Measured memory_bytes: 4084
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
int main() {
	int X;
	cin >> X;
	if (X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3600
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u64 = read();
    let a: u64 = read();
    let b: u64 = read();

    let ans = if n % (a + b) <= a {
        (n / (a + b)) * a + (n % (a + b))
    } else {
        (n / (a + b)) * a + a 
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
def run():
  D, N = map(int, input().split())
  d_li = [int(input()) for d in range(D)]
  clothe_li = [list(map(int, input().split())) for n in range(N)]
  dp = [[0]*N for d in range(D)]
  #init
  d = d_li[0]
  for n, (a, b, c) in enumerate(clothe_li):
    if (a <= d) and (d <= b):
      dp[0][n] = 1
  #loop
  for i in range(1, D):
    d = d_li[i]
    #print(dp)
    for pre_n in range(N):
      if dp[i-1][pre_n] == 0: continue
      for n, (a, b, c) in enumerate(clothe_li):
        if (a <= d) and (d <= b):
          #print(c)
          dp[i][n] = max(dp[i][n], 
                         dp[i-1][pre_n] + abs(clothe_li[pre_n][2] - c))
  print(max(dp[-1])-1) 
    
if __name__ == '__main__':
  run()


Measured memory_bytes: 6300
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    rep(i,0,n){
        set<string> st;
        string s;
        cin>>s;
        string ls,rs;
        rep(i,0,s.length()){
            ls=s.substr(0,i);
            rs=s.substr(i,s.length()-i);
            rep(j,0,2){
                rep(k,0,2){
                    st.insert(ls+rs);
                    st.insert(rs+ls);
                    reverse(all(ls));
                    
                }
                reverse(all(rs));
            }
        }
        
        cout<<st.size()<<endl;
    }
    
    return 0;
}



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

int main(){
    int n,a;
    cin>>n>>a;
    vector<queue<int> > q(n);
    while(a--){
        int y;
        cin>>y;
        if(y==0){
            int t,x;
            cin>>t>>x;
            q[t].push(x);
        }
        else if(y==1){
            int t;
            cin>>t;
            if(!q[t].empty()){
                cout<<q[t].front()<<endl;
            }
        }
        else{
            int t;
            cin>>t;
            if(!q[t].empty()){
                q[t].pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4248
//#include<bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <utility>
#include <cstring>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2));
    sq=(sq*sq);
    if(k%2==1)
        sq=(sq*n);
    return sq;
}
ll nCr(ll n, ll r) {
    if(r > n - r) r = n - r;
    ll ans = 1;
    for(int i = 1; i <= r; i++)
        ans *= (n - r + i)/i;
    return ans;
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
// int dx[]={1,-1,0,0,1,-1,1,-1};
// int dy[]={0,0,1,-1,1,1,-1,-1};
// freopen("input.txt" ,"r",stdin );
// freopen("output.txt","w",stdout);

ll dp[150+5][100000+50];
int n,W;
ll w[150],v[150];
ll maxSum(ll i,ll curw){
    if(dp[i][curw]!=-1) return dp[i][curw];
    if(i==n) return 0;
    if(curw+w[i]<=W)
        return dp[i][curw]=max(maxSum(i+1,curw+w[i])+v[i],maxSum(i+1,curw));
    else
        return dp[i][curw]=maxSum(i+1,curw);
}
int main(){
    fast();
    cin>>n>>W;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<maxSum(0,0);
    return 0;
}


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

int main()
{
  int h;
  cin >> h;
  int w;
  cin >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++)
  {
    cin >> a[i];
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (a[i][j] == '#')
      {
        row[i] = true;
        col[j] = true;
      }
    }
  }
  for (int i = 0; i < h; i++)
  {
    if (row[i])
    {
      for (int j = 0; j < w; j++)
      {
        if (col[j])
        {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

cat = {}
for c in a:
  if c in cat:
    cat[c] += 1
  else:
    cat[c] = 1

min_cat = N
min_cat_cnt = 0
max_cat = 0
max_cat_cnt = 0
for c in cat:
  if c < min_cat:
    min_cat = c
    min_cat_cnt = cat[c]
  if c > max_cat:
    max_cat = c
    max_cat_cnt = cat[c]
    
if max_cat - min_cat == 1 and min_cat_cnt <= min_cat and 2 * min_cat - min_cat_cnt + 2 <= N:
  print("Yes")
elif max_cat == min_cat and 2 * (max_cat) <= N:
  print("Yes")
elif max_cat == min_cat and min_cat_cnt - 1 == min_cat:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 17400
#include <iostream>
using namespace std;
using ll = long long;
template<typename T>T gcd(T a, T b){return b?gcd(b,a%b):a;}

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

  ll lcm = 1;
  for(int i = 0; i < N; ++i) {
    ll t; scanf("%lld", &t);
    lcm = t / gcd(t, lcm) * lcm;
  }
  printf("%lld\n", lcm);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define sz(x) (int)x.size()
#define el '\n'
#define M 10e9 + 7 
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,k;
  cin>>n>>k;
  double ans=0.0,tmp;
  for(int i=1;i<=n;i++){
      int cnt=0;
      for(int j=i;;j=j*2){
          if(j<k)
          cnt++;
          else
          break;
      }
     // cout<<cnt<<el;
      tmp =(ld) pow(0.5,cnt);
      tmp=(ld)tmp/n;
      ans+= tmp;
     
  }
  cout<<setprecision(14)<<ans<<el;
  return 0;
}


Measured memory_bytes: 256
import math
n,m = map(int,input().split())
if m >= 2 and n >= 2:
    s = math.factorial(n)/(math.factorial(2)*math.factorial(n-2)) + math.factorial(m)/(math.factorial(2)*math.factorial(m-2))
elif m >= 2 and n < 2:
    s = math.factorial(m)/(math.factorial(2)*math.factorial(m-2))
elif m < 2 and n >= 2:
    s = math.factorial(n)/(math.factorial(2)*math.factorial(n-2))
else:
    s = 0
print(round(s))

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int W =sc.nextInt(),a = sc.nextInt(),b = sc.nextInt(),result=0;
		if(a<b) {
			result = b-(a+W);
		}
		else if(b<a) {
			result= a-(b+W);
		}
		if(result <=0) result=0;
		System.out.print(result);
	}
 
}

Measured memory_bytes: 21844
N,Y=gets.split.map &:to_i
n=N+1
f=false
n.times do |x|
  n.times do |y|
    break if x+y>N
    z=(Y-10000*x-5000*y)/1000
    if x+y+z===N && z>=0
      puts "#{x} #{y} #{z}"
      f=true
      break
    end
  end
  break if f
end
puts "-1 -1 -1" unless f

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main()
{
	int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    vector<long long> asum(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        asum[i + 1] = asum[i] + a[i];
    }
    
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += ((a[i - 1] % MOD) * ((asum[n] - asum[i]) % MOD)) % MOD;
        ans %= MOD;
    }
    
    cout << ans << endl;
}

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

 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++){
    cin >> a.at(i) >> b.at(i);
  }
  vector<int> c(N);
  for(int i =0; i < M; i++){
    c.at(a.at(i)-1)++;
    c.at(b.at(i)-1)++;
  }
  for (int i=0; i< N; i++){
    cout << c.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 5300000
int main(){
  int t,i,n,p[500],m[500][500],minm=INF,l=0,j=0,k=0,q=0;
  scanf("%d",&n);/*n??????????????°*/
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
     
  }
  for(l=2;l<n+1;l++){
 
    for(i=1;i<n-l+2;i++){
      j=i+l-1;
      m[i][j]=INF;
 
     for(k=i;k<j;k++){
    q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      
    if(q<=m[i][j]){
      m[i][j]=q;
 
    }
      }
    }}
  printf("%d\n",m[1][n]);
  return 0;
}

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

int main(){
  int n,smin;
  while(true){
    smin= 10000000;
    cin >> n;
    if(n == 0) break;
    int s[n];
    for(int i = 0 ; i < n ; i++) scanf("%d",&s[i]);
    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j<n; j++){
        smin = min( (abs(s[i]-s[j])) ,smin);
      }
    }
    cout << smin << endl;
  }
  return 0;
}



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

int main(){
  string s,c="CODEFESTIVAL2016";
  cin >> s;
  int cnt=0;
  for(int i=0;i<16;++i){
    if(s[i]!=c[i])++cnt;
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
	// your code goes here
	const long double pi = acos(-1);
//	double a = tan(pi/2);
//	cout << pi << endl;
//	cout << a << endl;

	long double a, b, x;
	cin >> a >> b >> x;
	long double hori = atan(b/a);
	long double ang1 = 0.0, ang2 = pi / 2.0;
	long double ans = 0.0;
//	while(true){
	for(int i=0; i<100000; i++){
		long double ang = (ang1 + ang2) / 2.0;
		long double full = 0.0;
		if(ang <= hori){
			full = a * a * (b * 2.0 - (a * tan(ang))) / 2.0;
		}
		else{
			full = a * b * (b / tan(ang)) / 2.0;
		}
		
//		if(full >= x - 0.000000001 && full <= x + 0.000000001){
//			ans = ang * 180.0 / pi;
//			break;
//		}
//		else
		if(full - x > 0){ang1 = ang;}
		else{ang2 = ang;}
	}
	cout << setprecision(10) << ang2 * 180.0 / pi << endl;
	return 0;
}

Measured memory_bytes: 512