akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int L[10];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;

	int sum = 0;
	for(int i = 0; i < N; i++){
		cin >> L[i];
		sum += L[i];
	}
	sort(L, L + N);
	sum -= L[N - 1];

	if(L[N - 1] < sum){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
int MOD = 1000000007;
signed main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ok = 1000000001;
	int ng = 0;
	int m;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int sum;
	while (ok > ng + 1) {
		m = (ok + ng) / 2;
		sum = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] - B*m>0) {
				sum += ((h[i] - B*m - 1) / (A - B)) + 1;
			}
		}
		if (sum > m) {
			ng = m;
		}
		else {
			ok = m;
		}


	}

	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 1024
from scipy.special import comb

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

'''
n += 1
an = comb(n, k, exact=True)
ans = an
for i in range(k,n):
    an=an*(n-i)//(i+1)
    ans += an
    ans %= (10**9+7)

print(ans)
'''
ans = 0
for i in range(k,n+2):
    ans += (n*i+i-i**2+1)

print(ans%(10**9+7))


Measured memory_bytes: 42364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll answer=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                answer+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const long long mod2=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n;
int A[N],B[N];
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n+1;i++)cin>>A[i];
	for(int i=1;i<=n;i++)cin>>B[i];
	for(int i=1;i<=n;i++){
		if(A[i]>=B[i])ans+=B[i];
		else{
			ans+=A[i]; 
			B[i]-=A[i];
			if(A[i+1]>=B[i]){
				ans+=B[i];A[i+1]-=B[i];
			}else{
				ans+=A[i+1];A[i+1]=0;
			}
		}
	}
	o(ans);
}


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

ll i,j,k,l;

ll mypow(ll a,ll b){
    ll num=1;
    while(b!=0){
        num*=a;
        num%=mod;
        b--;
    }
    return num;
}

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

    ll ans=0;
    sort(a.begin(),a.end());
    if(n%2==1){
        if(a[0]!=0){cout<<0<<endl;return 0;}
        for(i=1;i<n-1;i+=2){
            if(a[i+1]!=a[i]){cout<<0<<endl;return 0;}
        }
        for(i=1;i<n-2;i+=2){
            if(a[i+2]!=a[i]+2){cout<<0<<endl;return 0;}
        }

        ans=(a[n-1])/2;
    }else{
        for(i=0;i<n-1;i+=2){
            if(a[i+1]!=a[i]){cout<<0<<endl;return 0;}
        }
        for(i=0;i<n-2;i+=2){
            if(a[i+2]!=a[i]+2){cout<<0<<endl;return 0;}
        }

        ans=(a[n-1]+1)/2;
    }

    cout<<mypow(2,ans)<<endl;
    return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	a, b, c := sc.nextInt(), sc.nextInt(), sc.nextInt()
	// if math.Sqrt(a)+math.Sqrt(b) < math.Sqrt(c) {
	left := 4 * a * b
	right := (c - a - b) * (c - a - b)
	if (c - a - b) < 0 {
		no()
		return
	}
	if left < right {
		yes()
	} else {
		no()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


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

static const int MAX = 100;
static const int INF = 1<<21;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i = 0; i < n; i++){
        d[i] = INF;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){
        minv = INF;
        u = -1;

        for(int i = 0; i < n; i++){
            if(color[i] != BLACK && minv > d[i]){
                u = i;
                minv = d[i];
            }
        }

        if(u == -1) break;

        color[u] = BLACK;
        for(int v = 0; v < n; v++){
            if(M[u][v] != INF && color[v] != BLACK && d[v] > M[u][v]){
                d[v] = M[u][v];
                p[v] = u;
                color[v] = GRAY;
            }
        }
    }

    int sum = 0;

    for(int v = 0; v < n; v++){
        if(p[v] != -1)  sum += M[p[v]][v];
    }

    return sum;
}

int main(){
    cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int x;
            cin >> x;
            if(x == -1) M[i][j] = INF;
            else        M[i][j] = x;
        }
    }

    cout << prim() << endl;
    
    return 0;
}


Measured memory_bytes: 3096
N, M = map(int,input().split())
a = []
ans = range(1,M + 1)
ans = list(ans)
for i in range(N):
    A = list(map(int,input().split()))
    K = A[0]
    A.remove(A[0])
    for j in range(1,M + 1):
        if j not in A:
            a.append(j)
for i in a:
    if i in ans:
        ans.remove(i)
print(len(ans))

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

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

    int n;
    cin >> n;
    vector<double> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    double ans = (A[0] + A[1]) / 2;
    for(int i = 2; i < n; i++){
        ans = (ans + A[i]) / 2;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   if(a>b){
      cout << "safe\n";
   }else{
      cout << "unsafe\n";
   }
   return 0;
} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

void fill(char* s, int n, int idx) {
  if (idx == n) {
    printf("%s\n", s);
    return;
  } else {
    int max = 'a' - 1;
    for (int i = 0; i < idx; ++i) {
      if (s[i] > max) {
        max = s[i];
      }
    }
    for (char c = 'a'; c <= max + 1; ++c) {
      s[idx] = c;
      fill(s, n, idx + 1);
    }
  }
  return;
}


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

  char* s = new char[n + 1];
  s[0] = 'a';
  s[n] = 0;

  fill(s, n, 1);

  return 0;
}


Measured memory_bytes: 1536
def judge(S,T):
    d={}
    length=len(S)
    for i in range(length):
        if S[i] not in d:
            d[S[i]]=T[i]
        else:
            if d[S[i]]!=T[i]:
                return "No"
    d={}          
    for i in range(length):
        if T[i] not in d:
            d[T[i]]=S[i]
        else:
            if d[T[i]]!=S[i]:
                return "No"
    return "Yes"
  
print(judge(input(),input()))

Measured memory_bytes: 3632
n,a,b = map(int, input().split())
x = []
for i in range(1, n+1):
    y = 0
    y += i//10000
    y += (i%10000)//1000
    y += (i%1000)//100
    y += (i%100)//10
    y += i%10
    if(a <= y <= b):
        x.append(i)

print(sum(x))


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;


int main() {
    using vp=vector<pii>;
    int N;
    constexpr ll MOD = 1000000007;

    cin >> N;
    vi c(N + 1);
    c[0] = 3;
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        ans *= c[a];
        ans %= MOD;
        if (ans == 0) {
            ans = MOD;
        }

        c[a]--;
        c[a + 1]++;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    for(int i=0;i<s.size();i+=2) {
        cout << s[i];
    }
}


Measured memory_bytes: 512
n = int(input())
xs = [int(i) for i in input().split()]
dict = {}
for i in range(n):
    if xs[i] in dict:
        dict[xs[i]] += 1
    else:
        dict[xs[i]] = 1
edges = []
for k in dict.keys():
    while dict[k] >= 2:
        edges.append(k)
        dict[k] /= 2
edges.sort()
edges.reverse()
if len(edges) >= 2:
    print(edges[0] * edges[1])
else:
    print(0)

Measured memory_bytes: 18060
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(0,n,2):
    if a[i]%2==1:
        ans+=1
print(ans)

Measured memory_bytes: 65260
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
	return 0;
}


Measured memory_bytes: 256
main = do
    [r, g, b, n] <- map read . words <$> getLine
    print $ length [() |
        i <- [0..(div n r)],
        j <- [0..(div n g)],
        n >= i*r + j*g,
        (n - i*r - j*g) `mod` b == 0]

Measured memory_bytes: 1276
N = int(input())
MAX = 0
cnt = 0
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        cnt += 1
        MAX = max(MAX, cnt)
    else:
        cnt = 0
if MAX >= 3:
    print('Yes')
else:
    print('No')

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

int n, m, k;
map< int, int > cnt;

void rec(int i, int sum) {
	if (i == n) { cnt[max(1, sum - k)]++; }
	else { for (int x=1; x<=m; ++x) rec(i+1, sum + x); }
}

int main() {
	while (cin >> n >> m >> k, n>0) {
		cnt = map< int, int >();
		rec(0, 0);
		
		int T = 1;
		for (int i=0; i<n; ++i) T *= m;
		
		double ans = 0;
		for (auto it : cnt) {
			int a = it.first, b = it.second;
			ans += a * (double)b / T;
		}
		printf("%.9lf\n", ans);
	}
}


Measured memory_bytes: 3588
N,M  = [int(zz) for zz in input().split()]
student = [[int(zz) for zz in input().split()] for _ in range(N)]
checkpoint = [[int(zz) for zz in input().split()] for _ in range(M)]

ans = []
for i in range(N):
    tmp = [0]*M
    for j in range(M):
        tmp[j] = abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])
    ans.append(tmp.index(min(tmp)))

[print(i+1) for i in ans]


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


def read():
    N = int(input().strip())
    return N,


def solve(N):
    AB = []
    for a in range(1, N+1):
        if a * a > N:
            break
        if N % a == 0:
            b = N // a
            AB.append((a, b))
    minl = 100000000
    for a, b in AB:
        minl = min(minl, max(len(str(a)), len(str(b))))
    return minl


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/

int a[125];

int main() {

  DRI(n);

  REP(i,n) RI( a[i] );
  sort(a,a+n, greater<int>() );

  int b = a[0];
  int ch = b+1;

  int s = ch /2;
  int ns = (ch%2)? 1 : 2;



  map<int,int> mp;
  REP(i,n) mp[ a[i] ]++;

  FORD(i,b,s+1){
    if(mp[i] < 2) {cout << "Impossible" << endl; return 0;}
  }
  if( mp[s] != ns){cout << "Impossible" << endl; return 0;}

  cout << "Possible" << endl;





  return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ.ITP
{
    public class StructuredProgramming
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            string output = "";
            string tmp;
            // 3の倍数または"3"が含まれる数字を出力
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 == 0) { output += " " + i; }
                else
                {
                    tmp = i.ToString();
                    if (tmp.IndexOf("3") >= 0) { output += " " + i; }
                }
            }

            Console.WriteLine(output);
        }
    }
}

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

int32_t main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int res=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			for(int k=0;k<10;k++){
			   int cur=0;
			   for(int id=0;id<n;id++){
				   if(cur==0){
					   if(s[id]-'0'==i)cur++;
				   }else if(cur==1){
					   if(s[id]-'0'==j)cur++;
				   }else if(cur==2){
					   if(s[id]-'0'==k){
						   cur++;
						   res++;
					   }
				   }
			   }	
			}
		}
	}
	cout<<res<<endl;
}

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

int main() {
    
	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > stu, chk;
    for (int i=0; i<n; i++) {
		int a, b;
		cin >> a >> b;
		stu.push_back(make_pair(a, b));
	}
	for (int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		chk.push_back(make_pair(a, b));
	}
	
	for (int i=0; i<n; i++) {
		int mnd = INT_MAX;
		int ind = 0;
		for (int j=0; j<m; j++) {
			int di = abs(stu[i].first - chk[j].first) + abs(stu[i].second - chk[j].second);
			if (di < mnd) {
				ind = j+1;
				mnd = di;
			}
		}
		cout << ind << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
using P = pair<int,int>;
signed main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N+1);
    vector<int> dist(N+1,-1);

    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    } 

    int fennec = N-1;
    int snuke = 1;
    queue<int> Q;
    Q.push(1);
    dist[1] = 0; 
    while(!Q.empty()){
        int now = Q.front(); Q.pop();
        for(auto v : G[now]){
            if(dist[v] != -1) continue;
            dist[v] = dist[now] + 1;
            Q.push(v);
        }
    }

    Q.push(N);
    dist[N] = 0;
    while(!Q.empty()){
        int now = Q.front(); Q.pop();
        for(auto v : G[now]){
            if(dist[v] <= dist[now] + 1) continue;
            --fennec;
            ++snuke;
            dist[v] = dist[now] + 1;
            Q.push(v);
        }
    }

    if(fennec > snuke) cout << "Fennec\n";
    else cout << "Snuke\n";
}

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

int const N = 100000;
int x[N << 1], tp[N];
pair<int, int> y[N << 1];
bool bad[N << 1];

void upmn(ll v, ll &mn1, ll &mn2, int i, int &x){
	if (v < mn1)mn2 = mn1, mn1 = v, x = i;
	else if (v < mn2)mn2 = v;
}

void upmx(ll v, ll &mx1, ll &mx2, int i, int &x){
	if (v > mx1)mx2 = mx1, mx1 = v, x = i;
	else if (v > mx2)mx2 = v;
}

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d%d", x + (i << 1), x + (i << 1 | 1));
	f(i, 0, n << 1)y[i] = make_pair(x[i], i);
	sort(y, y + (n << 1));
	f(i, n, n << 1)bad[y[i].second] = true;
	bool easy = false;
	f(i, 0, n){
		int a = i << 1, b = i << 1 | 1;
		if (!bad[a] && !bad[b] || bad[a] && bad[b]) { easy = true; break; }
		if (bad[a] && !bad[b])tp[i] = 1;
	}
	int z = 0;
	f(i, 0, n)if (tp[i])++z;
	if (z == 0 || z == n)easy = true;
	ll an = 0;
	f(i, 0, n)an += y[i].first;
	if (!easy){
		ll mn = 1e18, mn1 = 1e18, mx = -1e18, mx1 = -1e18;
		int a = 0, b = 0;
		f(i, 0, n)if (tp[i]){
			upmn(x[i << 1], mn, mn1, i, a);
			upmx(x[i << 1 | 1], mx, mx1, i, b);
		}else {
			upmn(x[i << 1 | 1], mn, mn1, i, a);
			upmx(x[i << 1], mx, mx1, i, b);
		}
		
		if (a != b)an += mn - mx;
		else an += min(mn1 - mx, mn - mx1);
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;


string s;
int a[26] = {0};

int main(){
    cin >> s;

    for(int i=0; i<s.length(); i++){
        a[s[i]-'A'] ++;
    }

    int cnt = 0;
    for(int i=0; i<26; i++){
        if(a[i] == 2){
            cnt ++;
        }
    }

    if(cnt == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

ll N, A;

void mult (ll &r, ll v) {
        v = min(v, N/r + 1);
        r *= v;
}

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

        ll ans = N;
        fo(a, 1, 61) { //SDFLKJSDLKFJSDLKFJSDFFUCKFUCKFUCK
                ll lo = a, hi = ((ll) 1e12) + 1ll, mid;
                while (lo <= hi) {
                        mid = (lo + hi) / 2;
                        ll r = 1, inc = mid/a;
                        fo(i, 0, a) {
                                if (i < mid-inc*a) mult(r, inc+1);
                                else mult(r, inc);
                                if (r >= N) break;
                        }
                        if (r >= N) hi = mid-1, ans = min(ans, mid + A*(a-1));
                        else lo = mid+1;
                }
        }

        printf("%lld\n", ans);

        return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

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

    println!("{}", std::cmp::min(n * a, b));
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, K;
vector<int> h;
int dp[100001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  h.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  fill(dp, dp + 100001, INF);

  dp[0] = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = 1; j <= K; j++) {
      if (i + j < N) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
  }

  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<pair<ll,ll>> A;
  REP(i,N){
    ll tmp;
    cin >> tmp;
    A.push_back(make_pair(tmp,i));
  }
  sort(ALL(A));
  REP(i,N) cout << A[i].second + 1 << " ";
  return 0;
}

Measured memory_bytes: 2544
#include<stdio.h>
int main()
{
    int n,a,b,x;
    input:
    scanf("%d%d%d",&n,&a,&b);
    if(n>=1&&n<=20&&a>=1&&a<=50&&b>=1&&b<=50)
    {
    x=n*a;
    if(x<b)
        printf("%d\n",x);
    else
        printf("%d\n",b);
    }
    else
        goto input;

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      String sTaro;
      String sHanako;
      int iTaro = 0;
      int iHanako = 0;
      
      for(int i = 0; i < n; i++){
         sTaro = sc.next();
         sHanako = sc.next();
         
         if(sTaro.compareTo(sHanako) < 0){
            iHanako += 3;
         }else if(sTaro.compareTo(sHanako) > 0){
            iTaro += 3;
         }else{
            iTaro ++;
            iHanako ++;
         }
      }  
      
      System.out.println(iTaro + " " + iHanako);    
         
   }//main
      
}//class


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

int main() {
	int sum, i;
	string n;
	while (true) {
		cin >> n;
		if (n == "0")
			break;
		else {
			for (i = 0, sum = 0; i < n.length(); i++) 
				sum +=  n[i] - 48;
			cout << sum << endl;
		}
	}
	return 0;
}


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

using namespace std;
long tam,n,a[100001],s,t;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    t=1;
    while(true){
        s++;
        t=a[t];
        if(t==2)break;
        if(s==100000001)return cout<<-1,0;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string S;
    vector<string> W = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    cin >> S;

    REP(i, 7){
        if(W[i] == S){
            cout << 7 - i << endl;
        }
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std ;
using ll = long long ;
ll mod = 1e+9+7 ;

int main(){
	ll n ; cin >> n ;
	string u,d ;
	cin >> u >> d ;
	ll ans = 1 ;
	ll pre = 0 ;
	for(int i=0;i<n;i++){
		if(i==0){
			if(u.at(0)==d.at(0)){
				ans *= 3 ;
			}else{
				ans *= 6 ;
				pre = 1 ;
				i++ ;
			}
		}else{
			if(u.at(i)==d.at(i)){
				if(pre==0) ans = ans*2%mod ;
				pre = 0 ;
			}else{
				if(pre==0) ans = ans*2%mod ;
				else ans = ans*3%mod ;
				pre = 1 ;
				i++ ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 1<<30

int count;

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    
    for (int i=0; i<n1; i++) L[i] = A[left + i];
    for (int i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;
    
    int i=0, j=0;
    for (int k=left; k<right; k++) {
        count++;
        if (L[i] < R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int *A, int left, int right) {
    if(left+1 < right) {
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i=0; i<n; i++) scanf("%d", &A[i]);
    
    count = 0;
    mergeSort(A, 0, n);
    
    for (int i=0; i<n; i++) {
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    
    printf("%d\n", count);
    
    return 0;
}




Measured memory_bytes: 6484
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define foreach(i, c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define isa(c) ('a'<=c && c<='z')
#define isA(c) ('A'<=c && c<='Z')
#define isn(c) ('0'<=c && c<='9')
//#define DEBUG
using namespace std;

bool err;
map<string, int> aw;

int molw(string mf){
	//ÅÌÌöðÔµ½¢
	int n = 0, p = 0;
	rep(i, mf.length()){
		if(mf[i]=='(' || mf[i]==')'){
			n += (mf[i]=='('?1:-1);
		}
		if(n == 0){
			p = i+1;
			break;
		}
	}
	while(p != mf.length() && (isn(mf[p]) || isa(mf[p])) )p++;
	//p = mf.length();
	if(p == mf.length()){//mf:P
		if(!isn(mf[mf.length()-1])){//mf:öÉÈµ
			if(mf[0] != '('){//mf:¼[ªÊÅÈµ
				if(aw[mf])return aw[mf];
				err = 1; return 0;
			}
			return molw(mf.substr(1, mf.length()-2));
		}
		int n = 0;
		if( mf.length()>2 && isn(mf[mf.length()-2]) )n = mf[mf.length()-2]-'0';
		if(isn(mf[mf.length()-1]))n = n*10 + mf[mf.length()-1]-'0';
		return n*molw(mf.substr(0, mf.length()-1-(n>9)));
	}
	return molw(mf.substr(0, p)) + molw(mf.substr(p));
}
int main(){
	string s; int i;
	while(cin>>s, s != "END_OF_FIRST_PART"){
		cin>>i;
		aw.insert(make_pair(s, i));
	}
	#ifdef DEBUG
	cout<<"input debug."<<endl;
	foreach(j, aw)cout<<j->first<<" "<<j->second<<endl;
	#endif
	while(cin>>s, s != "0"){
		err = false;
		i = molw(s);
		if(!err)cout<<i<<endl;
		else cout<<"UNKNOWN"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}

  
  

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
  #endif*/

  ll n;

  vec<vec<ll>>dp(402,vec<ll>(402,inf));

  cin>>n;

  ll a[n+1];
  vec<ll>pre(n+1);

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

    pre[i]=pre[i-1]+a[i];
    dp[i][i]=0;
  }

  for(int l=2;l<=n;l++){

    for(int i=1;i+l-1<=n;i++){

      int j=i+l-1;

      for(int k=i;k<j;k++){

        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1]);
      }

    }
  }

  cout<<dp[1][n];

   



  auto end = chrono::high_resolution_clock::now();

  /*#ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

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

int main() {
	ios_base::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<bool> dp(K + 1, false);
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j < N; j++) {
			if (dp[i]) {
				continue;
			}
			if (i < a[j]) {
				continue;
			}
			if (!dp[i - a[j]]) {
				dp[i] = true;
			}
		}
	}
	if (dp[K])
		cout << "First";
	else
		cout << "Second";

	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int L = s.size();
  int cnt = 0;
  
  for(int i = 0; i < L; i += 2) {
    if(s[i] == '0') cnt++;
  }
  for(int i = 1; i < L; i += 2) {
    if(s[i] == '1') cnt++;
  }
  
  int ans = cnt;
  cnt = 0;
  
  for(int i = 0; i < L; i += 2) {
    if(s[i] == '1') cnt++;
  }
  for(int i = 1; i < L; i += 2) {
    if(s[i] == '0') cnt++;
  }
  ans = min(ans, cnt);    
  
  cout << ans << "\n";

}

Measured memory_bytes: 512
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] += 1
        else:
            L[i][j] += L[i][j-1] + 1
for i in range(H):
    for j in range(-1,-W-1,-1):
        if S[i][j] == '#':
            continue
        elif j == -1:
            R[i][j] += 1
        else:
            R[i][j] += R[i][j+1] + 1
for i in range(W):
    for j in range(H):
        if S[j][i] == '#':
            continue
        elif j == 0:
            U[j][i] += 1
        else:
            U[j][i] += U[j-1][i] + 1
for i in range(W):
    for j in range(-1,-H-1,-1):
        if S[j][i] == '#':
            continue
        elif j == -1:
            D[j][i] += 1
        else:
            D[j][i] += D[j+1][i] + 1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,U[i][j]+D[i][j]+L[i][j]+R[i][j]-3)
print(ans)

Measured memory_bytes: 364344
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll x;
    cin >> x;
    int ans=0;
    int X = x;
    int i;

    for(i=1;i<=x;i++){
        X=i;
        if(i*(i+1)/2>=x)break;
    }
    cout << X << endl;
    return 0;
}

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

char a[2010][2010];

int main(){
    
    int n,m,ans;
    char b;
    
    cin >> n >> m;
    for(int i=0;i<n;i++) cin >> a[i];
    ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> b;
            ans += b!=a[i][j];
        }
    }
    cout << ans << endl;
    
    return(0);
}


Measured memory_bytes: 6940
t = []
while 1:
    n,a = map(int, raw_input().split(','))
    if n==a==0: break
    t.append([a,n])
t.sort(reverse = True)
o = [0]*(len(t)+1); c = 1;
o[t[0][1]] = 1;
for i in xrange(1,len(t)):
    if t[i-1][0]!=t[i][0]:
        c += 1
    o[t[i][1]] = c
while 1:
    try:
        n = input()
        print o[n]
    except EOFError:
        break

Measured memory_bytes: 4236
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N, M;
    cin >> N >> M;

    vector<bool> B(N + 2, false);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        for (int i = a; i < b; i++) B[i] = true;
    }

    int ans = N + 1;
    for (int i = 0; i < B.size(); i++) if (B[i]) ans += 2;

    cout << ans << endl;

    return 0;
}






























































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

using namespace std;

int main()
{
    string n;
    int flg = 0;
    cin >> n ;
    if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
//spread.cpp
#include<iostream>
using namespace std;

int main()
{
    int r,c,i,j;
    cin>>r>>c;
    int table[r+1][c+1];
    for ( i = 0; i < r; i++)
    {
        for ( j = 0; j < c; j++) cin>>table[i][j];
        table[i][c]=0;
    }
    for ( i = 0; i < c+1; i++) table[r][i]=0;
    for ( i = 0; i < r; i++)
    {
        for ( j = 0; j < c; j++)
        {
            cout<<table[i][j]<<" ";
            table[r][j]+=table[i][j];
            table[i][c]+=table[i][j];
        }
        cout<<table[i][c]<<endl;
        table[r][c]+=table[i][c];
    }
    for ( i = 0; i < c; i++) cout<<table[r][i]<<" ";
    cout<<table[r][c]<<endl;
}


Measured memory_bytes: 3136
#include <iostream>

using namespace std;
int N;
long long int T[105];

long long int gcd(long long int a, long long int b) {
	if (a < b) { return gcd(b, a); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
long long int lcm(long long int a, long long int b) {

	long long int ret = a / gcd(a, b);
	return ret*b;
}

int main(void) {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> T[i];
	}

	long long int ans = 1;
	for (int i = 1; i <= N; i++) {
		ans = lcm(ans, T[i]);
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 800010
#define inf 2000000000
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,q,tot,cnt;
ll ans;
int fa[maxn],t[maxn];
struct edge
{
    int x,y;
    ll v;
}e[maxn];
bool cmp(const edge &a,const edge &b)
{
    return a.v<b.v;
}
int find(int x)
{
    return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main()
{
    read(n),read(q),cnt=n-1;
    for(int i=0;i<n;++i) fa[i]=i,t[i]=inf;
    for(int i=1;i<=q;++i)
    {
        int x,y,v;
        read(x),read(y),read(v);
        e[++tot]={x,y,v},t[x]=min(t[x],v+1),t[y]=min(t[y],v+2);
    }
    for(int i=0;i<=2*n;++i) t[i%n]=min(t[i%n],t[(i-1+n)%n]+2);
    for(int i=0;i<n;++i) e[++tot]={i,(i+1)%n,t[i]};
    sort(e+1,e+tot+1,cmp);
    for(int i=1;i<=tot;++i)
    {
        int x=find(e[i].x),y=find(e[i].y);
        if(x==y) continue;
        fa[x]=y,ans+=e[i].v;
        if(++cnt==n-1) break;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 17692
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")



#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const int D = 310;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[MX][D];
deque<ll> mx[D];


ll get(int i) {
    if (mx[i].empty())
        return 0;
    return mx[i].front();
}

void add(int i, ll x) {
    while (mx[i].size() && mx[i].back() < x)
        mx[i].ppb;
    mx[i].pb(x);
}

void del(int i, ll x) {
    if (mx[i].size() && mx[i].front() == x)
        mx[i].pop_front();
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
       
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    fi(0, n) {
        ll a;
        cin >> a;
        fj1(min(i + 1, k) + 1, 1) {
            if (i >= m)
                del(j, dp[i - m][j]);
            dp[i][j] = a * j + get(j - 1);
            add(j, dp[i][j]);
        }
        maxe(ans, dp[i][k]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 246072
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}

int main(){
ll N;
cin>>N;
string S[N];
ll m=0; ll a=0; ll r=0; ll c=0; ll h=0;
for(int i=0; i<N; ++i){
cin>>S[i];
if (S[i].at(0) == 'M') {m++;}
else if (S[i].at(0) == 'A') {a++;}
else if (S[i].at(0) == 'R') {r++;}
else if (S[i].at(0) == 'C') {c++;}
else if (S[i].at(0) == 'H') {h++;}
}
cout<<m*a*r+m*a*h+m*a*c+m*c*r+m*h*r+m*h*c+c*a*r+h*a*r+h*c*r+h*a*c<<endl;
}












Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    vector<int> A = vector<int>(b, a);
    vector<int> B = vector<int>(a, b);

    
    if(B>A){
        for (int i = 0; i < b; i++) {
        cout << A.at(i) ;
        }
        cout << endl;
    }else{
        for (int i = 0; i < a; i++) {
        cout << B.at(i) ;
        }
        cout << endl;
    }
    
}

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

int main(){
    int n;
    cin >> n;
    bool ok=true;
    long long time=0;
    vector<vector<int>> a(n,vector<int>(2));
    for(int i=0;i<n;i++){
        cin >> a.at(i).at(1) >> a.at(i).at(0);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        time+=a.at(i).at(1);
        if(time>a.at(i).at(0))ok=false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 14328
n = int(input())
d = []
judge = 'No'

for i in range(n):
  d.append(list(int(x) for x in input().split()))
  if i >= 2:
    if d[i-2][0] == d[i-2][1] and d[i-1][0] == d[i-1][1] and d[i][0] == d[i][1]:
      judge = 'Yes'

print(judge)


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#define showvv(v)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n,m; cin >> n >> m;
  vector<ll> d(n,1ll<<59); d[0] = 0;
  vector<pair<pair<ll,ll>,ll>> edge;
  ll a,b,c;
  rep(i,m){
    cin >> a >> b >> c; a--; b--; c *= -1;
    edge.pb(make_pair(pii(a,b),c));
    if(a == 0) d[b] = c;
  }

  // ベルマンフォード
  rep(i,n-1) rep(j,m){
    ll u = edge[j].fst.fst, v = edge[j].fst.snd, c = edge[j].snd;
    if(d[v] > d[u] + c)
      d[v] = d[u] + c;
  }
  dump(d);
  ll ans = d[n-1];

  // 負経路検出
  vi negative(n);
  rep(i,n) rep(j,m){
    ll u = edge[j].fst.fst, v = edge[j].fst.snd, c = edge[j].snd;
    if(d[v] > d[u] + c){
      d[v] = d[u] + c;
      negative[v] = 1;
    }
    if(negative[u]) negative[v] = 1;
  }

  dump(d,negative);
  if(negative[n-1]) cout << "inf\n";
  else cout << -ans << endl;  
}

Measured memory_bytes: 384