akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

template<uint32_t N>
struct Sieve_of_Eratosthenes{
  using u32 = uint32_t;
  std::array<u32,N+1> factor;
  Sieve_of_Eratosthenes(){
    factor.fill(0);
    for(u32 p=2;p<=N;++p){
      if(factor[p])continue;
      factor[p] = p;
      for(u32 x=p+p;x<=N;x+=p){
        if(factor[x])continue;
        factor[x] = p;
      }
    }
  }
  std::vector<u32> prime_factor(u32 x){
    std::vector<u32> pf;
    while(factor[x]){
      pf.push_back(factor[x]);
      x /= factor[x];
      while(factor[x]==pf.back())x/=factor[x];
    }
    return pf;
  }
};

signed main(){
  using namespace std;
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  constexpr int a_max = 1e6;
  Sieve_of_Eratosthenes<a_max> ushi;

  map<int,int> mp;
  bool pairwise_coprime = true;
  for(auto const& ai:a){
    for(auto const& p:ushi.prime_factor(ai)){
      if(mp.count(p)){
        pairwise_coprime = false;
        break;
      }
      mp[p]++;
    }
  }
  
  if(pairwise_coprime){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }

  bool setwise_coprime = accumulate(begin(a),end(a),0,[](auto a,auto b){return gcd(a,b);}) == 1;
  if(setwise_coprime){
    cout<<"setwise coprime"<<endl;
    return 0;
  }

  cout<<"not coprime"<<endl;


}

Measured memory_bytes: 14576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,z,w,a[2222],i;
	cin >> n >> z >> w;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	cout << ((n==1)?(abs(a[0]-w)):(max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])))) << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

H, W, K = map(int, input().split())
A = [[int(x) for x in input()] for _ in range(H)]

def solve(blocks):
    n_block = len(blocks)
    n_cut = n_block - 1
    sums = [0 for _ in range(n_block)]

    for c in range(W):
        adds = [block[c] for block in blocks]
        if any(a > K for a in adds):
            return H * W
        
        sums = [s + a for s, a in zip(sums, adds)]
        if any(s > K for s in sums):
            n_cut += 1
            sums = adds
    
    return n_cut

ans = H * W
for mask in itertools.product([0, 1], repeat=H - 1):
    mask = [1] + list(mask) + [1]
    pivots = [r for r in range(H + 1) if mask[r]]
    blocks = [A[p1:p2] for p1, p2 in zip(pivots[:-1], pivots[1:])]
    blocks = [[sum(row[c] for row in block) for c in range(W)] for block in blocks]
    ans = min(ans, solve(blocks))
print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<char> c(n);
    bool need = false;
    int r_num = 0;
    rep(i,n) {
        cin >> c[i];
        if(i >= 1){
            if(c[i-1] == 'W' && c[i] == 'R'){
                need = true;
            }
        }
        if(c[i] == 'R') r_num++;
    }

    int count = 0;

    if(need){
        for(int i = r_num; i < n; i++){
            if(c[i] == 'R') count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d", &a,&b,&c);
  
  int s = a-b;
  if(s > c){
    printf("0\n");
  } else{
    printf("%d\n",c-s);
  }
  return 0;
}

Measured memory_bytes: 128
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    N2 = math.floor(math.sqrt(N))
    print(N2**2)
    
if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

map <string,int> ans;
string str[4] = {"AC","WA","TLE","RE"};
int N;
int main(){
	fast;
	cin>>N;
	
	FOR(i,1,N){
		string S;
		cin>>S;
		ans[S]++;
	}
	
	FOR(i,0,3){
		cout<<str[i]<<" x "<<ans[str[i]]<<'\n';
	}
}


Measured memory_bytes: 3664
#include <iostream>
typedef long long int ll;
using namespace std;

int arrays[100001];

int main(){
	int sum = 0,n;
	ll a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		if(n >= a)
			++arrays[a];
		else
			++sum;
	}
	for(int i=0;i <= n;i++){
		if(arrays[i]){
			if(i > arrays[i])
				sum += arrays[i];
			else if(i < arrays[i])
				sum += arrays[i] - i;
		}
	}
	cout << sum << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a_i(N+1);
  
  int count=1, i=1;
  
  for (int j=1;j<=N;j++)
    cin >> a_i.at(j);
  
  while (count<N){
    if (a_i.at(i)==2){
      cout << count << endl;
      break;
    }
    i = a_i.at(i);
    count++;
  }
  if (a_i.at(i)!=2)
    cout << -1 << endl;
}

Measured memory_bytes: 3776
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/arc069/editorial.pdf
"""

N = int(input())
s = list(input())

def verify(t):
    # 2か所決まれば芋づる式に全て定まる
    for i in range(1, N-1):
        # 羊がoと言ってるor狼がxと言ってる
        if t[i] == 'S' and s[i] == 'o' or t[i] == 'W' and s[i] == 'x':
            # 両隣は同じ
            if t[i-1] == 'S':
                t[i+1] = 'S'
            else:
                t[i+1] = 'W'
        # 逆
        else:
            # 両隣は違う
            if t[i-1] == 'S':
                t[i+1] = 'W'
            else:
                t[i+1] = 'S'
    # 終点手前 - 終点 - 始点、の辻褄が合ってるか検証する
    if t[-1] == 'S' and s[-1] == 'o' or t[-1] == 'W' and s[-1] == 'x':
        if not (t[-2] == 'S' and t[0] == 'S' or t[-2] == 'W' and t[0] == 'W'):
            return False
    else:
        if not (t[-2] == 'S' and t[0] == 'W' or t[-2] == 'W' and t[0] == 'S'):
            return False
    # 終点 - 始点 - 始点の次、の辻褄が合ってるか検証する
    if t[0] == 'S' and s[0] == 'o' or t[0] == 'W' and s[0] == 'x':
        if not (t[-1] == 'S' and t[1] == 'S' or t[-1] == 'W' and t[1] == 'W'):
            return False
    else:
        if not (t[-1] == 'S' and t[1] == 'W' or t[-1] == 'W' and t[1] == 'S'):
            return False
    return True

# 2か所決める方法4通り
for a, b in [('S', 'S'), ('W', 'W'), ('S', 'W'), ('W', 'S')]:
    t = [''] * N
    t[0] = a
    t[1] = b
    if verify(t): 
        print(''.join(t))
        exit()
print(-1)


Measured memory_bytes: 5544
# -*- coding: utf-8 -*-
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    c=Counter(input())
    for x in c.values():
        if x%2:
            print('No')
            break
    else:
        print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    map<ll,ll> m;
    rep(i,3){
        ll a;
        cin >> a;
        m[a]++;
    }
    for(auto x:m){
        if(x.se==1){
            cout << x.fi << endl;
        }
    }
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000];

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

  long long ans = a[0] - 1, mini = 2;
  for (int i = 1; i < n; i++) {
    if (a[i] == mini) { mini++; continue; }

    ans += (a[i]-1) / mini;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 768
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$N = $sc->nextInt();
$ans = 1000000;
for ($A = 1; $A < $N; $A++) {
  $B = $N - $A;
  $a = array_sum(str_split($A));
  $b = array_sum(str_split($B));
    if ($a + $b < $ans) {
        $ans = $a + $b;
    }
}

echo $ans;

Measured memory_bytes: 4728
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>



using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a)

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef  long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-7;
const int MAX = 20 * 1000 + 47;
const int MAS = 1e5 * 6; 
const int MOD = 1000 * 1000 * 1000 + 7;


int main()
{
    int n,k;
    cin >> n >> k ; 
    VI a(n); 
    rep(i, n)
    {
        cin >> a[i]; 
    }
    VI dp(n,INF);
    dp[0] = 0;
    rep(i, n)
    {
       
        FOR(j, i + 1, i + k + 1) 
        {
          if(j < n)
          {
              dp[j ] = min(dp[j], dp[i] + abs(a[j] - a[i]));
          }
        }
    }
    cout << dp[n - 1]; 

    

}










Measured memory_bytes: 1024
package main
import (
    "bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main(){
    sum := 0
    maxLen := nextInt()
    for k := 0; k < maxLen; k++ {
        i := nextInt()
        
        if i > 2 && i % 2 == 0 {
            continue
        }
        
        isPrime := true
		sqrtNum := math.Sqrt(float64(i))
		max := int(math.Floor(sqrtNum))
        for j := 3; j <= max; j+=2 {
    		mod := i % j
    		if mod == 0 {
    		    isPrime = false
    		    break
    	    }
    	}
    	if isPrime {
    	   sum++;
    	}
    }
	
	fmt.Println(sum)
}


Measured memory_bytes: 1172
class Union:
  def __init__(s, num):
    s.T = [-1 for i in range(num)]
 
  def root(s, x):
    if s.T[x] < 0: return x, -s.T[x]
    t, k = s.root(s.T[x])
    s.T[x] = t
    return t, k
 
  def merge(s, x, y):
    an, am = s.root(x)
    bn, bm = s.root(y)
    if an == bn: return False
    if am < bm: an, bn  = bn, an
    s.T[an] += s.T[bn]
    s.T[bn] = an
    return True
 
  def size(s, x):
    return s.root(x)[1]

  def same(s, x, y):
    return s.root(x)[0] == s.root(y)[0]

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

uni = Union(N)

for a, b in AB:
  a -= 1
  b -= 1
  uni.merge(a, b)

ans = 0
for i in range(1, N):
  if not uni.same(0, i):
    ans += 1
    uni.merge(0, i)

print(ans)


Measured memory_bytes: 91268
#include <stdio.h>

int main(void) {
  int a, b, c, d;

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

  if(a + b > c + d) {
    printf("Left");
  }
  else if(a + b == c + d) {
    printf("Balanced");
  }
  else {
    printf("Right");
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const long long Mod=1000000007;
int n,k;
long long fac[4000010],inv[4000010],f[2010][2010],s[2010];
long long pw(long long x,long long y)
{
	long long res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		} 
		y>>=1;
		x=x*x%Mod;
	}
	return res;
}
long long c(int n,int m)
{
	if (n<m)
	{
		return 0;
	}
	return fac[n]*inv[n-m]%Mod*inv[m]%Mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	if (k==1)
	{
		puts("1");
		return 0;
	}
	fac[0]=1;
	for (int i=1;i<=n*k;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[n*k]=pw(fac[n*k],Mod-2);
	for (int i=n*k-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%Mod;
	}
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		s[n+1]=0;
		for (int j=n;j>=0;j--)
		{
			s[j]=(s[j+1]+f[i-1][j])%Mod;
		}
		for (int j=1;j<=i;j++)
		{
			f[i][j]=s[j-1]*c(i*k-j-1,k-2)%Mod;
		}
	}
	long long ans=0;
	for (int i=1;i<=n;i++)
	{
		ans=(ans+f[n][i])%Mod;
	}
	ans=ans*fac[n]%Mod;
	printf("%lld\n",ans);
    return 0;
}
//花开堪折直须折，莫待无花空折枝。
//——《金缕衣》

Measured memory_bytes: 92928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

//1-indexedなので注意！！！！
//＄１には頂点数＋３くらいをいれるといい
vector<vector<ll>> graph(100003, vector<ll>(0));  // DAG
vector<ll> order(0);  // トポロジカルソートされた頂点を格納
vector<bool> used(100003,0);  // 訪問済みフラグ

// 辿れるところまで辿る深さ優先探索
void dfs(ll u){
    if(used[u]) return;
    used[u] = true;
    for(ll v : graph[u]) dfs(v);
    order.emplace_back(u);     // 帰りがけ順で頂点を入れていく
}

// トポロジカルソート
//Nは頂点数
void tsort(ll N){
    for(ll v = 1; v <= N; v++) dfs(v);
    //reverse(order.begin(), order.end());
}
//1-indexedなので注意！！！！
//1-indexedなので注意！！！！
//1-indexedなので注意！！！！
//1-indexedなので注意！！！！

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> x(N-1,0);
    vector<ll> y(N-1,0);
    for(ll i=0;i<N-1;++i){
        cin>>x[i]>>y[i];
        graph[x[i]].emplace_back(y[i]);
        graph[y[i]].emplace_back(x[i]);
    }
    tsort(N);
    vector<bool> check(N+1,0);
    vector<ll> dpb(N+1,0);
    vector<ll> dpw(N+1,0);
    for(auto p: order){
        check[p]=1;
        ll retw=1;
        ll retb=1;
        for(auto q: graph[p]){
            if(!check[q])continue;
            retw*=dpw[q]+dpb[q];
            retb*=dpw[q];
            retw%=MOD;
            retb%=MOD;
        }
        dpw[p]=retw;
        dpb[p]=retb;
    }
    prt((dpw[order[N-1]]+dpb[order[N-1]])%MOD)


    return 0;
}


Measured memory_bytes: 13940
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char   s8;
typedef unsigned char   u8;
typedef          short s16;
typedef unsigned short u16;
typedef          int   s32;
typedef unsigned int   u32;
typedef float          f32;
typedef double         f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int X;
	cin >> X;
	/////////////////////
	
	int sum = 0;
	int out = 0;
	for( int i = 0; ; ++i ) {
		sum += X;
		if( sum % 360 == 0 ) {
			out = i+1;
			break;
		}
	}
	
	//////// 出力 ////////
	cout << out;
	/////////////////////
	
	return 0;
}

#if 0


#endif


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    int r;
    cin >> r;
    printf("%.2lf", 2 * PI * r);
}


Measured memory_bytes: 3804
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 9;

int x[N];
int y[N];
int p[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    p[i] = i;
  }
  double ans = 0;
  do {
    for (int i = 0; i < n - 1; ++i) {
      ans += sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
    }
  } while (next_permutation(p, p + n));
  for (int i = 2; i <= n; ++i) {
    ans /= i;
  }
  printf("%.15f\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  int p[100]={};
  cin >> n;
  for(int i=0; i<n; i++) cin >> p[i];
  for(int j=1; j<=100; j++){
    int count=0;
    for(int i=0; i<n; i++){
      if(p[i] >= j){
        count++;
        if(count >= j) ans = j;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3076
=begin
  －－－－－－－－－－－－－－
  n = ループ回数
  A = 数列
  ans = 分割回数(答)
  pre = 前回の数値(A[i-1])
  vec = 前回の不等号 (< == 1 , > == -1)
  －－－－－－－－－－－－－－
  1: 一つ前の数値と比べる
  2: A[i-1] 小なり A[i] の場合 
    2.1: vec が 1 ならそのまま
    2.2: vec が -1 なら ans += 1 vec = 0
  3: A[i-1] 大なり A[i] の場合
    3.1: vec が -1 ならそのまま
    3.2: vec が 1　なら ans += 1 vec = 0
  4: A[i] イコール A[i+1]　なら 何もしない
  5: pre = A[i]
=end

n = gets.to_i
A = gets.split.map(&:to_i)

pre = A.first
vec = 0
ans = 0

A[1..-1].each{|v|
  if pre < v
    if vec == -1
      ans += 1
      vec = 0
    else
      vec = 1
    end
  elsif pre > v
    if vec == 1
      ans += 1
      vec = 0
    else
      vec = -1
    end
  end
  pre = v
}

puts ans + 1

Measured memory_bytes: 8452
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
  N = int(input())
  XY = [tuple(map(int,input().split())) for _ in range(N-1)]
  MOD =10**9+7
  
  E = [[] for _ in range(N)]
  for x,y in XY:
    x -= 1
    y -= 1
    E[x].append(y)
    E[y].append(x)
  
  def dfs(v,s):
    b = 1
    w = 1
    for u in E[v]:
      if u != s:
        b0,w0 = dfs(u,v)
        b *= w0
        w *= (b0+w0)
    #b %= MOD
    #w %= MOD
    return b,w

  b,w = dfs(0,-1)
  print((b+w) % MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 136324
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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


const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,h,w;
	cin>>h>>w>>n;
	vector<P> p(n),q(n);
	for(int i = 0; i < n; i++){
		cin>>p[i].first>>p[i].second;
	}
	map<P,ll> mp;
	for(int i = 0; i < n; i++){
		ll above = max(1,p[i].first-2),below=p[i].first;
		if(p[i].first==h)below = p[i].first-2;
		else if(p[i].first+1==h) below = p[i].first-1;
		ll left = max(1,p[i].second-2),right = p[i].second;
		if(p[i].second==w) right= p[i].second-2;
		else if(p[i].second+1==w) right = p[i].second-1;
		for(ll k = above; k <=below; k++){
			for(ll j = left; j <= right; j++){
				mp[P(k,j)]++;
			}
		}
	}
	vector<ll> cnt(10);
	for(auto itr = mp.begin(); itr != mp.end(); ++itr){
		cnt[itr->second]++;
		// cout << itr->first.first << " " << itr->first.second << " " << itr->second << endl;
	}
	ll sum = 0;
	for(int i = 1; i < 10; i++){
		sum += cnt[i];
	}
	cnt[0] = (h-2)*(w-2) - sum;
	for(int i = 0; i < 10; i++){
		cout << cnt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 58112
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var T_X = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();

        Console.WriteLine(T_X[0] / (double)T_X[1]);

        Console.ReadLine();
    }
}


Measured memory_bytes: 13268
// B - Reverse and Compare

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1000000007;
// using mint = modint1000000007;
// const ll MOD = 998244353;
// using mint = modint998244353;

int main() {
	string A;
	cin >> A;

	unordered_map<char, int> cnt;

	for (char c : A) {
		cnt[c]++;
	}

	ll N = A.size();
	ll ans = N * (N-1) / 2 + 1;

	for (auto itr : cnt) {
		ll n = itr.second;
		ans -= n * (n-1) / 2;
	}

	cout << ans << endl;

	return 0;
}

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

#define ll long long int
#define vi vector<int>

int main() {

    int N;
    cin >> N;

    int a;
    bool approve = true;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a%2 == 0) {
            if (a%3 != 0 && a%5 != 0) {
                approve = false;
            }
        }
    }

    if (approve) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i =0; i<N;i++){
    cin >> H[i];
  }
  
  int count = 0;
  if(*max_element(H.begin(),H.end()) == 0){
    cout << 0 << endl;
    return 0;
  };
  while(true){
    int max = *max_element(H.begin(),H.end());
    int max_index = distance(H.begin(),max_element(H.begin(),H.end()));
    H[max_index]--;
    //cout << max_index  << " ";
    //それより後を検索
    int index = max_index + 1;
    while(index < H.size()){
      if(H[index] > 0){
        H[index]--;
        index++;
      }else{
        break;
      }
    }
    
    index = max_index - 1;
    while(index >= 0){
      if(H[index] > 0){
        H[index]--;
        index--;
      }else{
        break;
      }
    }
    
    count++;
    if(max = *max_element(H.begin(),H.end()) == 0)break;
  }
  
  cout << count << endl;
}

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

int main(){
     int n, k; cin >> n >> k;
     int item[n];
    for (int i=0; i<n; i++){
        cin >> item[i];
    }
    sort(item, item + (sizeof(item)/sizeof(item[0])));
    int sum=0;
    for (int i=0; i<k; i++){
        sum+=item[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

int32_t main()
{
    IOS
    
    
    int n;
    cin>>n;
    double a[n];
    double sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        
    }
    sort(a,a+n);
    double ans=(a[0]+a[1])/2;
    for(int i=2;i<n;++i)
    {
        ans=(ans+a[i])/2;
    }
    printf("%0.10lf",ans);


}



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

int main(int argc, char const *argv[])
{
	int N;
	int i,j;
	int ans = -1;
	cin>>N;
	ll H[N+1];
	for(i=0; i<N; i++) cin>>H[i];
	H[N]=LLONG_MAX;
	i=0;
	while(i < N){
		j = i+1;
		while(H[j] <= H[j-1]){
			j++;
		}
		ans = std::max(ans, j-i-1);
		i = j;
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<int> his;
    while (n)
    {
        n--;
        int a = n % 26;
        his.push_back(a);
        n /= 26;
    }
    reverse(his.begin(), his.end());
    for (auto i : his)
    {
        cout << (char)('a' + i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
from operator import mul
from functools import reduce

def cmb(n, r):
	if n < r:
		return 0
	r = min(n-r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n-r, -1))
	denom = reduce(mul, range(1, r+1))
	return numer // denom % mod

N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K+1):
	print(cmb(K-1, i-1) * cmb(N-K+1, i) % mod)

Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    set<int> st;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') continue;
        st.insert(i);
        v.eb(i);
    }
    vector<int> dp(n), d(n), co(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'x') continue;
        auto it = st.lower_bound(i + c + 1);
        if (it == st.end()) {
            dp[i] = 1;
        } else {
            dp[i] = dp[(*it)] + 1;
        }
    }
    st.insert(-INF);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') continue;
        auto it = st.upper_bound(i - c - 1);
        --it;
        if (it == st.begin()) {
            d[i] = 0;
        } else {
            d[i] = d[(*it)] + 1;
        }
        if (d[i] + dp[i] == k) {
            co[dp[i]]++;
        } else if (d[i] + dp[i] > k) {
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') continue;
        if (d[i] + dp[i] == k && co[dp[i]] == 1) {
            cout << i + 1 << '\n';
        }
    }
}

Measured memory_bytes: 14220
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N, M, a, b;
    long long ans=0;
    cin >> N >> M;
    vector<pair<long long, int>> data(N);

    for(int i=0; i<N; i++){
        cin >> a >> b;
        data[i] = make_pair(a, b);
    }

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

    for(int i=0;i<N;i++){
        if(data[i].second < M){
            ans += data[i].first * data[i].second;
            M -= data[i].second;
        }else{
            ans += data[i].first * M;
            break;
        }
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
    
using namespace std;
ll bin(ll a[],ll s,ll e,ll x){
    ll m=(s+e)/2;
if(s==e){if(a[s]<=x) return s;else return s-1;}
else if(m==s){
    if(a[s]<=x&&a[e]<=x) return s+1;
    else if(a[s]<=x&&a[e]>x) return s;
    else return s-1;
}
else if(a[m]<=x) return bin(a,m+1,e,x);
else return bin(a,s,m-1,x);
}  

int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll a,b;
  cin>>a>>b;
  cout<<a*b;
 
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
 
    return 0;
}   

Measured memory_bytes: 3652
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll r;
    cin >> r;
    cout << setprecision(12) << 2 * 3.141592653589793238 * r;
}

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

A = [[] for i in range(N)]

for i in range(M) :
    l,r,d = map(int,input().split())
    
    l -= 1
    r -= 1
    
    A[l].append([r,d])
    A[r].append([l,-d])
    
ans = "Yes"

distance = ["#" for i in range(N)]

flg = 0

for i in range(N) :
    if flg :
        break
    
    if distance[i] != "#" :
        continue
    
    distance[i] = 0
    stack = [i]
    
    while stack :
        now = stack.pop()
        
        for to,d in A[now] :
            if distance[to] == "#" :
                distance[to] = distance[now] + d
                stack.append(to)
            
            elif distance[to] != distance[now] + d :
                ans = "No"
                stack = []
                flg = 1
                break
            
print(ans)


Measured memory_bytes: 76944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N - 1) {
        if(A[i] + A[i + 1] >= L) {
            cout << "Possible" << endl;
            rep(j, 0, i) cout << j + 1 << '\n';
            for(int j = N - 2; j >= i; --j) cout << j + 1 << '\n';
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}


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

int a,b,c;

int solve(){
  int maximum = 0;
  for(int i = 1;i < c;++i){
    for(int j = 1;j < c;++j){
      int pre = i * (100 + a) / 100 + j * (100 + a) / 100;
      if(pre == c){
	maximum = max(maximum, i * (100 + b) / 100 + j * (100 + b) / 100);
      }
    }
  }
  return maximum;
}

int main() {
  while(cin >> a >> b >> c && a > 0){
    cout << solve() << endl;
  }
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string S;
  cin >> S;

  S[3] = '8';

  cout << S << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int x;
    int y;
	while(1){
		scanf ("%d %d", &x, &y);
		if ( x == 0  && y == 0)break;
				
		if( x < y ){
			printf("%d %d\n", x, y);
		} else{
			printf("%d %d\n", y, x);

		}
	}
	return 0;

}

Measured memory_bytes: 600
a=list(map(int,input().split()))
a.sort()
ans=0
ans+=(a[2]-a[0])//2+(a[2]-a[1])//2
if (a[2]-a[0])%2==(a[2]-a[1])%2==1:
    print(ans+1)
elif (a[2]-a[0])%2==(a[2]-a[1])%2==0:
    print(ans)
else:
    print(ans + 2)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long N, long long M)
{
    cout << (N * (N - 1)) / 2 + (M * (M - 1)) / 2 << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int n;
cin>>n;
VI num(n,0);
for (int i = 0; i < n-1; i++)
{ int a;
    cin>>a;
    num.at(a-1)+=1;
}
for (int i = 0; i < n; i++)
{
    cout<<num.at(i)<<endl;
}

    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	int pasta[3];
	int juice[2];
	for (int a = 0; a < 3; a++){
		scanf("%d", &pasta[a]);
	}
	scanf("%d%d", &juice[0], &juice[1]);
	sort(pasta, pasta + 3);
	printf("%d\n", pasta[0] + min(juice[0], juice[1]) - 50);
	return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;
  int ans = 0;
  for (; 1 < str.size(); ) {
    str = str.substr(0, str.size() - 1);
    if (str.size() % 2 == 0) {
      string s1 = str.substr(0, str.size() / 2);
      string s2 = str.substr(str.size() / 2, str.size() / 2);
      if (s1 == s2) {
        ans = str.size();
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, sum = 0;
  cin >> n;
  vl a(n), b(n, 0);
  rep(i, n) {
    cin >> a[i];
    b[0] += a[i];
    if(i % 2) b[0] -= 2 * a[i];
  }
  rep(i, n - 1) b[i + 1] = 2 * a[i] - b[i];
  rep(i, n) cout << b[i] << '\n';
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
int a[110];


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	double av = accumulate(RNG(a, 0, N), 0)/(double)N;

	double err = INF;
	int ans = 0;

	rep(i, 0, N)
		if(abs(a[i]-av) < err) ans = i, err = abs(a[i]-av);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    LL n,mini,maxi;
    vector<LL> a;
    Problem(LL n):n(n),a(n){};

    void solve(){
        for(int i=0; i<n; ++i){
             cin >> a[n-1-i];
        }
        mini=maxi=2;
        for(int i=0; i<n; ++i){
            mini = (mini+a[i]-1)/a[i]*a[i];
            maxi = (maxi/a[i]+1)*a[i]-1;
            if(mini>maxi)no();
        }
        cout << mini <<' '<<maxi <<"\n";
    }
    void no (){cout <<-1 <<"\n"; exit(0);}
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Solver::Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll h,w,n;
  cin >> h >> w >> n;
  set<P>org,around;
  rep(i,n){
    int y,x;
    cin >> y >> x;
    y--;
    x--;
    org.insert({y,x});
    rep(j,3)rep(k,3)around.insert({y-j,x-k});
  }
  vector<ll>ans(10);
  ans[0]=(h-2)*(w-2);

  for(auto s:around){
    int y=s.first;
    int x=s.second;
    if(y<0 || h<=y+2 || x<0 || w<=x+2)continue;
    int res = 0;
    rep(j,3)rep(k,3) res += org.count({y+j,x+k});
    
    ans[res]++;
    ans[0]--;
  }
  rep(i,10) cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 62720
/*
 * ITP1_11_C: Rolling the dice III (compare two dices)
 */

#include <stdio.h>

// rolling relations by index (N, S, E, W, clockwise, anti-clockwise)
int T[6][1 + 6] = {{0, 2, 6, 3, 4, 1, 5},
                   {0, 5, 1, 3, 4, 6, 2},
                   {0, 4, 2, 1, 6, 5, 3},
                   {0, 3, 2, 6, 1, 5, 4},
                   {0, 1, 3, 5, 2, 4, 6},
                   {0, 1, 4, 2, 5, 3, 6}};
int move['Z'];

void rotate(int direction, int p[])
{
    int q[1 + 6];
    int i;

    for (i = 1; i <= 6; i++)
        q[i] = p[T[move[direction]][i]];

    for (i = 1; i <= 6; i++)
        p[i] = q[i];

    return;
}

int main(void)
{
    int dice[1 + 6]; // one-based indexing
    int dice2[1 + 6]; // one-based indexing
    int top, front;
    int i;

    move['N'] = 0;
    move['S'] = 1;
    move['E'] = 2;
    move['W'] = 3;
    move['C'] = 4; // Clockwise
    move['A'] = 5; // Anti-clockwise

    for (i = 1; i <= 6; i++)
        scanf("%d", &dice[i]);
    for (i = 1; i <= 6; i++)
        scanf("%d", &dice2[i]);

        top = dice2[1];
        front = dice2[2];

        // align the top face.
        if      (top == dice[2])
                rotate('N', dice);
        else if (top == dice[3])
                rotate('W', dice);
        else if (top == dice[4])
                rotate('E', dice);
        else if (top == dice[5])
                rotate('S', dice);
        else if (top == dice[6]) {
                rotate('N', dice);
                rotate('N', dice);
        }

        // align the front face.
        int count = 0;
        while (dice[2] != front && count <= 3) {
            count++;
            rotate('C', dice);
        }
        // cannot adjust the front face even by one rotation.
        if (count == 4) {
            printf("No\n");
            return 0;
        }

        // compare the right faces.
        if (dice[3] == dice2[3] && dice[4] == dice2[4] &&
            dice[5] == dice2[5] && dice[6] == dice2[6])
            printf("Yes\n");
        else
            printf("No\n");

    return 0;
}



Measured memory_bytes: 2108
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%1d%1d%1d%1d", &a, &b, &c, &d)

	switch {
	case a+b+c+d == 7:
		fmt.Printf("%d+%d+%d+%d=7", a, b, c, d)
	case a+b+c-d == 7:
		fmt.Printf("%d+%d+%d-%d=7", a, b, c, d)
	case a+b-c+d == 7:
		fmt.Printf("%d+%d-%d+%d=7", a, b, c, d)
	case a+b-c-d == 7:
		fmt.Printf("%d+%d-%d-%d=7", a, b, c, d)
	case a-b+c+d == 7:
		fmt.Printf("%d-%d+%d+%d=7", a, b, c, d)
	case a-b+c-d == 7:
		fmt.Printf("%d-%d+%d-%d=7", a, b, c, d)
	case a-b-c+d == 7:
		fmt.Printf("%d-%d-%d+%d=7", a, b, c, d)
	case a-b-c-d == 7:
		fmt.Printf("%d-%d-%d-%d=7", a, b, c, d)
	}
	fmt.Println("")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   ll n,k,s=0ll,e=0ll,ans=0ll;
   cin>>n>>k;
   for(int i=0;i<k;i++){
      s+=i;
      e+=(n-i);
   }
   for(int j=k;j<=n+1;j++){
      ans=(ans+e-s+1ll)%mod;
      while(ans<0ll)
         ans+=mod;
      e+=(n-j);
      s+=j;
   }
   cout<<ans<<'\n';
   return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		rep(i, h) {
			rep(j, w)cout << '#';
			cout << endl;
		}
		cout << endl;
	}
	ggr
}



Measured memory_bytes: 3076
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define N (1000000000 + 7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll, ll> P;

int dp[2][505][512] = {};

int main(void) {
  int n, x;
  cin >> n >> x;
  for(int i = 0; i <= n; i++) dp[0][i][0] = 1;
  for(int i = 1; i <= x; i++) {
    for(int j = 0; j <= n; j++) {
      for(int k = 0; k < 512; k++) {
        dp[i % 2][j][k] = dp[(i + 1) % 2][j][k];
        if(j != 0)
          dp[i % 2][j][k] =
              (dp[i % 2][j][k] +
               dp[(i + 1) % 2][j - 1][k ^ i]) %
              M;
      }
    }
    for(int j = 2; j <= n; j++) {
      for(int k = 0; k < 512; k++) {
        dp[i % 2][j][k] =
            (dp[i % 2][j][k] + dp[i % 2][j - 2][k]) % M;
      }
    }
  }
  cout << dp[x % 2][n][x] % M << endl;
  return 0;
}



Measured memory_bytes: 5096