akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

    long ans=0;
    for(int i=1;i<N;i++){
        ans+=i;
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
def main():
    a,b,c = map(int,input().split())

    lst = []
    # aから
    lst.append(abs(b-a) + abs(c-b))
    lst.append(abs(c-a) + abs(b-c))

    # bから
    lst.append(abs(a-b) + abs(c-a))
    lst.append(abs(c-b) + abs(a-c))

    # cから
    lst.append(abs(c-b) + abs(a-c))
    lst.append(abs(a-c) + abs(b-a))

    print(min(lst))

if __name__ == "__main__":
        main()


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, k;
    cin >> n >> k;
    vector<llong> A(n), Cum(n + 1);
    Cum[0] = 0;
    rep(i, n) {
        cin >> A[i];
        Cum[i + 1] = Cum[i] + A[i];
    }

    vector<llong> P;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n + 1; ++j) {
            P.push_back(Cum[j] - Cum[i]);
        }
    }
    sort(allr(P));

    vector<llong> cur = P;
    for (llong bit = 62; bit >= 0; --bit) {
        vector<llong> tmp;
        for (int e = 0; e < cur.size(); ++e) {
            if (cur[e] & (1LL << bit)) tmp.push_back(cur[e]);
        }
        if (tmp.size() >= k) cur = tmp;
    }

    llong res = -1;
    
    rep(i, k) {
        res &= cur[i];
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 9964
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
int main(){
    FAST_IO ;
    bigint N , K ; cin >> N >> K ;
    bigint max_sum = (N * ( N + 1 )) / 2 ;
    bigint min_sum[N+3] ;
    memset(min_sum, 0, sizeof(min_sum)) ;
    min_sum[1] = 0 ;
    for( int i = 2 ; i <= N + 1 ; i++ ){
        min_sum[i] = min_sum[i-1] + i - 1 ;
    }
    bigint ans = 0 ;
    for( bigint i = K ; i <= N + 1; i++ ){
        bigint a = ((max_sum - min_sum[N-i+1] - min_sum[i] + 1) % mod + mod ) % mod ;
        ans = ( ans + a ) % mod ;
    }
    cout << ans << endl ;
    
    return 0 ;
}
 
 

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
vector<int> g[N];
 
int dfs(int v)
{
	vector<int> vv;
	for(int i=0;i<g[v].size();i++)
	{
		int x=g[v][i];
		vv.push_back(dfs(x));
	}
	int z=0;
	sort(vv.begin(),vv.end());
	rep(i,0,vv.size())
	z=max(z,vv[i])+1;
	return z;
}
int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
int n;
cin>>n;
rep(i,1,n)
{
	int x;
	cin>>x;
	x--;
	g[x].push_back(i);
}
cout<<dfs(0);


}





Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll time=(A-1)/D+1;
  if(B*time>=C)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
confo = [A[N-1]]
for i in range(N-1):
	ans += confo[i]
	confo.append(A[N-i-2])
	confo.append(A[N-i-2])
print(ans)

Measured memory_bytes: 31568
#!/usr/bin/env python3
import sys
INF = float("inf")


def argmax(a):
    m, n = -(1 << 31), -1
    for i, v in enumerate(a):
        if m < v:
            m, n = v, i
    return m, n


def solve(N: int, A: "List[int]"):
    m, mi = argmax(A)
    m2, mi2 = argmax(A[:mi]+A[mi+1:])
    for i in range(N):
        if i == mi:
            print(m2)
        else:
            print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14112
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
ll n,a,b,ans,ch[100];
vector<P>r,br;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        r.push_back({b,a});
    }
    for(int i=0;i<n;i++){
        cin>>a>>b;
        br.push_back({a,b});
    }
    sort(r.begin(),r.end());
    sort(br.begin(),br.end());
    reverse(r.begin(),r.end());
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(br[i].second>r[j].first&&br[i].first>r[j].second&&ch[j]==0){
                ch[j]=1;
                break;
            }
        }
    }
    for(int i=0;i<100;i++){
        ans+=ch[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int main()
{
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<char> t(Q);
    vector<char> d(Q);
    REP(i, Q) cin >> t[i] >> d[i];

    int L = -1, R = N;
    IREP(i, Q)
    {
        if (d[i] == 'L')
        {
            L += (L + 1 < N and s[L + 1] == t[i]);
            R += (R < N and s[R] == t[i]);
        }
        else
        {
            L -= (L >= 0 and s[L] == t[i]);
            R -= (R > 0 and s[R - 1] == t[i]);
        }
        if (L + 1 >= R) break;
    }
    cout << max(R - L - 1, 0) << endl;
}


Measured memory_bytes: 976
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] menu = new int[5];
		int max=0;
		int mvalue=0;
		for(int i=0;i<5;i++) {
			menu[i]=sc.nextInt();
          int temp=10-menu[i]%10;
          
			if(temp>mvalue && temp!=10) {
				max=i;
				mvalue=temp;
			}
		}
		int count=0;
		for(int i=0;i<5;i++) {
			if(i==max) continue;
			int temp = 10-menu[i]%10;
			if(temp!=10) {
			count+=menu[i]+10-menu[i]%10;
			}else {
				count+=menu[i];
			}
		}
		count+=menu[max];
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import collections
n = int(input())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
branch = b[1]
ct = 1
for i in range(max(a)+1):
    if i == 0:
        continue
    else:
        ct *= b[i-1]**b[i]
if b[0] != 1 or a[0] != 0:
    print(0)
else:
    print(ct%998244353)

Measured memory_bytes: 62004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int ans = 0;

		for (int i = 1; i < n+1;i++) {
			if (String.valueOf(i).length() % 2 == 1) {
				ans += 1;
			}
		}

		System.out.println(ans);

}}

Measured memory_bytes: 27348
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n,i;
    cin >>n;
    int l,r,ans=0;
    for(i=0;i<n;i++){
      cin >> l >> r;
      ans+=r-l+1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
def even_cnt(x): #(a,b,c)a,b,c<=xであってa+b,b+a,c+aのいずれも偶数となる組の数
    if x%2==0:
        s,t=x//2,x//2
    else:
        s,t=x//2,x//2+1
    return s**3+t**3

if k%2!=0:
    print((n//k)**3)
else:
    k//=2
    print(even_cnt(n//k))

Measured memory_bytes: 3060
#include <stdio.h>

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

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

#define forw(m,i,n) for(i=m; i<n; i++)
#define done return 0
#define in(x) cin >> x
#define out(x) cout << x << endl
#define pb(x) push_back(x)
#define w(x) while(x--)
#define maxx 1000000000

using namespace std;

typedef long long ll;

 map<int,int>dig;

int main() {
    //freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    int a,b,i;
    in(a),in(b);
    if(a>b) {
        for(i=0; i<a; i++) {
            cout << b;
        }
    }
    else {
        for(i=0; i<b; i++) {
            cout << a;
        }
    }
    cout << endl;
    done;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
	int n, ans = 1;
	cin >> n;
	int h[21];
	int dp[21];

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

	dp[0] = h[0];

	for (int i = 1; i < n; ++i)
	{
		if (dp[i - 1] <= h[i])
			++ans;
		dp[i] = max(dp[i - 1], h[i]);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cinm(int, n, a);
    ll ans = 0;
    for(auto [x, y] : a){
        ans += (ll)x*y;
    }
    
    Cin(int, q);
    Rep(q){
        Cin(int, b, c);
        a[c] += a[b];
        ans += (ll)a[b]*(c-b);
        a[b] = 0;
        Cout(ans);
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll H,W;
    cin>>H>>W;
    if(H==1||W==1)cout<<1<<endl;
    else if(H%2==1&&W%2==1)cout<<H*W/2+1<<endl;
    else cout<<H*W/2<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
 
class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String s;
        while((s=reader.readLine()) !=null){
            String[] t=s.split(" ");
            int c =Integer.parseInt(t[0])+Integer.parseInt(t[1]);;
            System.out.println(c);
        }   

    }
}

Measured memory_bytes: 24392
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int ans[1000000];
int cnt[505];
int mm[1000005];

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
	if(fopen("INPUT.txt","r"))
	{
	freopen ("INPUT.txt" , "r" , stdin);
	freopen ("OUTPUT.txt" , "w" , stdout);
	}
#endif  

	int a[7];
	for(int i=0;i<7;i++)
		cin>>a[i];
	int ans=0;
	ans+=a[1];
	if(a[0]==0||a[3]==0||a[4]==0)
	{
		int z=(a[0]/2+a[3]/2+a[4]/2)*2;
		ans+=z;
	}
	else
	{
		int x=a[0]%2;
		int y=a[3]%2;
		int z=a[4]%2;
		if(x==y&&x==z)
		{
			ans+=(a[0]+a[3]+a[4]);
		}
		else 
		{
			ans+=(a[0]+a[3]+a[4])-1;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  double a;
  while (cin >> a) {
    if (a <= 48.0) cout << "light fly";
    else if (a <= 51.0) cout << "fly";
    else if (a <= 54.0) cout << "bantam";
    else if (a <= 57.0) cout << "feather";
    else if (a <= 60.0) cout << "light";
    else if (a <= 64.0) cout << "light welter";
    else if (a <= 69.0) cout << "welter";
    else if (a <= 75.0) cout << "light middle";
    else if (a <= 81.0) cout << "middle";
    else if (a <= 91.0) cout << "light heavy";
    else cout << "heavy";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
main :: IO ()
main = do
    line <- getLine
    let
        [a, op, b] = words line
    case op of
      "+" -> print $ ((read a :: Int) + (read b :: Int))
      "-" -> print $ ((read a :: Int) - (read b :: Int))
      "*" -> print $ ((read a :: Int) * (read b :: Int))
      "/" -> print $ ((read a :: Int) `div` (read b :: Int))
      "?" -> return ()
    if "?" == op then return () else main

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
int main(){
  int a,b;
  cin>>a>>b;
  if((a-b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
	cout<<"IMPOSSIBLE"<<endl;
  }

}
         


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, ab, x, y;
    cin >> a >> b >> ab >> x >> y;
    int ans = min({a*x + b*y, 2*ab*x + b*max(0, y-x), ab*2*y + a*max(0, x-y)});
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	puta(180*(n-2));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    ll sum=0;
    ll maxx=0;
    while (n--){
        ll u;
        cin >> u;
        if (maxx==0) maxx=u; else{
            if (u>=maxx) maxx=u;
            else {
                sum += maxx-u;
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3576
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ab = []

for i in range(N):
    a = inp()
    ab.append([a,1])

for i in range(N):
    b = inp()
    ab.append([b,-1])

ab.sort()
cnt = 0
ans = 1
for x,k in ab:
    cnt += k
    if (cnt > 0) and (k > 0):
        ans *= cnt
    elif (cnt < 0) and (k < 0):
        ans *= -cnt
    ans %= mod
    
print(ans%mod)


Measured memory_bytes: 32928
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<numeric>
using namespace std;
typedef long long int lli;
#define rep(i,n) for(lli i = 0;i<((lli)(n));i++)
#define reg(i,a,b) for(lli i = ((lli)(a));i<=((lli)(b));i++)
#define irep(i,n) for(lli i = ((lli)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(lli i = ((lli)(b));i>=((lli)(a));i--)
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprllif(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	for(int i = n-1 ; i >= 0 ; i -= 2) cout << a[i] << " ";
	for(int i = n%2 ; i <= n-2 ; i += 2) cout << a[i] << (i >= n-3 ? "" : " ");
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int h,w;
char s[105][105];
int dp[105][105];
int t[105][105];
 
int main() {

    cin >> h >> w;
    rep(i,h) {
        rep(j,w) {
            cin >> s[i][j];
            if(s[i][j]=='#')    t[i][j]=1;
        }
    }

    for(int i=-1;i<h;i++) {
        for(int j=-1;j<w;j++) {
            if(i+1==0&&j+1==0)  continue;
            if(i+1==0)  goto migi;
            if(j+1==0)  goto sita;
            if(dp[i+1][j]>dp[i][j+1]) {
                sita:
                dp[i+1][j+1]=dp[i][j+1];
                if(s[i+1][j+1]!='#') {
                    dp[i+1][j+1]+=t[i][j+1];
                }
            }
            else if(dp[i+1][j]==dp[i][j+1]) {
                if(dp[i+1][j]+t[i+1][j]>dp[i][j+1]+t[i][j+1]) {
                    dp[i+1][j+1]=dp[i][j+1];
                    if(s[i+1][j+1]!='#') {
                        dp[i+1][j+1]+=t[i][j+1];
                    }                    
                }
                else {
                    dp[i+1][j+1]=dp[i+1][j];
                    if(s[i+1][j+1]!='#') {
                        dp[i+1][j+1]+=t[i+1][j];
                    }                   
                }
            }
            else {
                migi:
                dp[i+1][j+1]=dp[i+1][j];
                if(s[i+1][j+1]!='#') {
                    dp[i+1][j+1]+=t[i+1][j];
                }
            }
        }
    }

    cout<<dp[h-1][w-1]+t[h-1][w-1]<<endl;

 return 0;
}

Measured memory_bytes: 384
const main = () => {
  const s = getParams();
  console.log(solve(s));
};

const getParams = () =>
  getStdin();

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = s =>
  s.split('').filter(c => c === '1').length;

main();


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  long long n,su=0,ans = 1e18;
  std::cin >> n;
  vi a(n);
  rep(i,n){
    std::cin >> a[i];
    su+=a[i];
  }
  long long tmp=su;
  rep(i,n-1){
    tmp-=a[i];
    if(ans>abs((su-tmp)-tmp)) ans=abs((su-tmp)-tmp);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
n,t = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[0 for i in range(t)] for j in range(n+1)]
ab.sort()

ans = 0

for i in range(n):
    for j in range(t):
        #for k in range(2):
        #dp[i+1][j] = max(dp[i][j],dp[i-1][j])
        dp[i+1][j] = dp[i][j]
        #print(j,ab[i][0])
        if j >= ab[i][0]:
        #if dp[i][j] < dp[i][j-ab[i][0]] + ab[i][1]:
        #    dp[i+1][j] = dp[i][j-ab[i][0]] + ab[i][1]
            dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i][0]] + ab[i][1])
        #print(dp)
    #print(h,dp)

#print(ab)
#print(dp)


max_num = [0]*n

for i in reversed(range(n)):
    #print(i)
    if i == 0:
        break
    if max_num[i] < ab[i][1]:
        max_num[i-1] = ab[i][1]
    else:
        max_num[i-1] = max_num[i]

#print(max_num)
#print(ab[2272:2336])
#exit()

ans = 0
for i in range(n-1):
    #print(i)
    if ans < dp[i+1][t-1]+max_num[i]:
        ans = dp[i+1][t-1]+max_num[i]
        #print(i,ans,max_num[i],max_num[i+1],max_num[i-1])
    #ans = max(ans,)
    #print(max(ab[i:][1]))
    #print()
        
print(ans)
#print())

Measured memory_bytes: 123864
#include<stdio.h>
int main(void)
{
    int i,j,data[4],temp;
	for(i=1;i<=3;i++){
	scanf("%d",&data[i]);
	}
	for(i=1;i<3;i++){
		for(j=i+1;j<=3;j++){
            if(data[i]>data[j]){
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}	
	}
	
	printf("%d %d %d\n",data[1],data[2],data[3]);
	return 0;
}	
	

Measured memory_bytes: 1028
n=int(input())
par=[-1]*n

# this par & rank are initialized lists
def find(x):
    global par
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
        
def unite(x,y):
    x,y=find(x),find(y)
    global par
    if x==y:return False
    else:
        if par[x]>par[y]:x,y=y,x
        par[x]+=par[y]
        par[y]=x
        return True

def size(x):
    return -par[find(x)]
def same(x,y):
    return find(x)==find(y)

p=[]
edge=[]
for i in range(n):
  x,y=map(int,input().split())
  p.append([x,y,i])
p.sort(key=lambda x:x[0])
for i in range(n-1):
  x0,_,j=p[i]
  x1,_,k=p[i+1]
  edge.append([x1-x0,j,k])

p.sort(key=lambda x:x[1])
for i in range(n-1):
  _,y0,j=p[i]
  _,y1,k=p[i+1]
  edge.append([y1-y0,j,k])

edge.sort()
ans=0
for i in range(len(edge)):
  cost,u,v=edge[i]
  if not same(u,v):
    unite(u,v)
    ans+=cost

print(ans)

Measured memory_bytes: 51400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();

		scan.close();
		int ans = 0;
	    while(true){
	      int n = (a * ans) - (ans - 1);
	      if(b <= n) break;
	      ans++;
	    }
	    System.out.println(ans);

	}
}

Measured memory_bytes: 23892
//18
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    while(n--){
      int m,e,j;
      cin>>m>>e>>j;
      if(m==100||e==100||j==100||m+e>=180||m+e+j>=240){
	cout<<'A'<<endl;
      }else if(m+e+j>=210||(m+e+j>=150&&(m>=80||e>=80))){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const ll INF = ll(1e14);
int par[100000]; //parent
int rnk[100000]; //depth

//init with n elements
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        rnk[i] = 0;
    }
}
//find a root of the tree
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

//merge the sets contains x,y
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (rnk[x] < rnk[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (rnk[x] == rnk[y])
            rnk[x]++;
    }
}

//the set contains x and y or not
bool same(int x, int y)
{
    return find(x) == find(y);
}

int main()
{
    int N, M;
    cin >> N >> M;
    init(N);
    rep(i, M)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        unite(x, y);
    }
    set<int> st;
    st.insert(find(0));
    int ans = 1;
    reps(i, 1, N)
    {
        if (st.count(find(i)) == 0)
        {
            ans++;
            st.insert(find(i));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
import java.util.Scanner;

    public class Main{
        public void solve(){
        Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int kekka = x*x*x;
		System.out.println(kekka);
        }
    public static void main(String[]args){
    Main obj = new Main();
    obj.solve();
    }
    }

Measured memory_bytes: 17156
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::cin >> N;

    for (int64_t i = 1; i <= 50000; ++i) {
        int64_t cost = i * 1.08;
        if (N == cost) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << ":(" << std::endl;

    return 0;
}

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

class lazy_segtree {
    private:
        int size;
        vector<long long> node,lazy;
    public:
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2*size, 0);
            lazy.resize(2*size, 0);
        }

        void setlazy(int k,long long v,int l, int r) {
            lazy[k] += v;
            node[k] += v*(r-l);
        }

        void push(int k,int l,int r) {
            if (lazy[k] == 0) return ;
            setlazy(k*2+1,lazy[k],l,(r+l)/2);
            setlazy(k*2+2,lazy[k],(r+l)/2,r);
            lazy[k] = 0;
        }

        void merge(int k){
            node[k]=node[k*2+1]+node[k*2+2];
        }

        void range_add(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val,nodeL,nodeR);
                return ;
            }
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                range_add(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_add(queryL,queryR,val,k*2+2,nodeM,nodeR);
                merge(k);
                return ;
            }
        }

        long long get_sum(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return 0;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                long long vl=get_sum(queryL,queryR,k*2+1,nodeL,nodeM);
                long long vr=get_sum(queryL,queryR,k*2+2,nodeM,nodeR);
                return vl+vr;
            }
        }
};

int n,q;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_add(s-1,t,x);
        }
        else {
            cin >> s >> t ;
            cout << ls.get_sum(s-1,t) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
struct UF {
  vector<int> pare, rank;
  UF(int n) : pare(n), rank(n){ for(int i=0; i<n; i++){ pare[i]=i; rank[i]=0; } }
  int root(int x){ return (pare[x]==x)?x:pare[x]=root(pare[x]); }
  bool same(int x, int y){ return root(x)==root(y); }
  void marg(int x, int y){
    x=root(x); y=root(y); if(x==y) return;
    if(rank[x]<rank[y]){ pare[x]=y; }
    else{ pare[y]=x; if(rank[x]==rank[y]){rank[x]++;} }
  }
};

int main(){
int N, M; cin >> N >> M; int X[M], Y[M], Z[M], ans=N; UF G(N);
for(int i=0; i<M; i++){ cin >> X[i] >> Y[i] >> Z[i]; X[i]--; Y[i]--; }
for(int i=0; i<M; i++){ if(!G.same(X[i], Y[i])){ ans--; } G.marg(X[i], Y[i]); }  
cout << ans << "\n";
}

Measured memory_bytes: 2176
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int main() 
{ 
	turbo();
	ll n ,mod=1e9+7,i,ans=1;
	cin>>n;
	for(i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<"\n";
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
  int N,M;
  cin >> N >> M;
  priority_queue<ll> que;
  for(int i=0;i<N;i++){
    ll a;
    cin >> a;
    que.push(a);
  }
  for(int j=0;j<M;j++){
    ll b = que.top()/2;
    que.pop();
    que.push(b);
  }
  ll sum=0;
  for(int i=0;i<N;i++){
    sum+=que.top();
    que.pop();
  }
  cout << sum << endl;
}


Measured memory_bytes: 3808
from types import GeneratorType
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
    return wrappedfunc
n, k = map(int, input().split())
lis = list(map(int, input().split()))
dp = {}
@bootstrap
def TD(idx):
    if idx==n-1:
        yield 0
    if idx in dp:
        yield dp[idx]
    mi = float('inf')
    for i in range(1, k + 1):
        if i+idx < n:
            tmpx = yield TD(idx+i)
            tmp = abs(lis[idx]-lis[i+idx])+tmpx
            mi = min(mi, tmp)
    dp[idx] = mi
    yield mi
print(TD(0))

Measured memory_bytes: 142176
#include <stdio.h>

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

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

    for (i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            j++;
        }
    }
    printf("%d\n", j);

    return 0;
}


Measured memory_bytes: 2716
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int64_t absi(int64_t a, int64_t b) {
    return a > b ? a - b : b - a;
}


int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    A.push_back(0); // 始点 A[0]
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }
    A.push_back(0); // 終点 A[N+1]

    int64_t sum = 0;
    for (size_t i = 1; i <= N+1; ++i) {
        sum += absi(A[i], A[i-1]);
    }

    for (size_t i = 1; i <= N; ++i) {
        // i番目抜いた時、減る・増える金額

        //通関点
        if ((A[i-1] < A[i] && A[i] < A[i+1]) ||
            (A[i-1] > A[i] && A[i] > A[i+1]))
        {
            std::cout << sum << std::endl;
        }
        else {
            std::cout << sum - 2 * std::min(absi(A[i-1], A[i]), absi(A[i+1], A[i])) << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2164
from collections import deque
k=int(input())
d = deque([1,2,3,4,5,6,7,8,9])
for i in range(k-1):
	x=d.popleft()
	mod=x%10
	if mod!=0:
		d.append(10*x+mod-1)
	d.append(10*x+mod)
	if mod!=9:
		d.append(10*x+mod+1)
print(d.popleft())

Measured memory_bytes: 11956
n=int(input())
s=input()
ans=0
for j in range(2):
    for k in range(2):
        ans1=""
        last=j+1 #狼1 羊2
        start=k+1
        a0=last
        a1=start
        for i in range(n):
            if a1==1:
                ans1+="W"
            else:
                ans1+="S"

            if [a0,a1]==[1,1] and s[i]=='o':
                a0=a1
                a1=2
            elif [a0,a1]==[1,1] and s[i]=='x':
                a0=a1
                a1=1
            elif [a0,a1]==[1,2] and s[i]=='o':
                a0=a1
                a1=1
            elif [a0,a1]==[1,2] and s[i]=='x':
                a0=a1
                a1=2
            elif [a0,a1]==[2,1] and s[i]=='o':
                a0=a1
                a1=1
            elif [a0,a1]==[2,1] and s[i]=='x':
                a0=a1
                a1=2
            elif [a0,a1]==[2,2] and s[i]=='o':
                a0=a1
                a1=2
            elif [a0,a1]==[2,2] and s[i]=='x':
                a0=a1
                a1=1

        if a0==last and a1==start:
            ans=1
            break
    if ans==1:
        break
if ans==1:
    print(ans1)

else:
    print(-1)

Measured memory_bytes: 3444
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

d = []
for key,value in Counter(A).items():
    if value >=4 :
        d.append(key)
        d.append(key)
    if value >= 2:
        d.append(key)

if len(d) < 2:
    print(0)
else:
    d = sorted(d,reverse=True)
    x = d[0]
    y = d[1]

    print(x*y)

Measured memory_bytes: 18600
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
  static void Main(string[] args) {
    int N = int.Parse(Console.ReadLine());
    var inputs = new string[N];
    var labels = new Dictionary<string, int>();
    var dist = new int[N + 1, N + 1];

    for(int i = 0; i < N + 1; i++) {
      for(int j = 0; j < N + 1; j++) {
        dist[i, j] = int.MaxValue / 4;
      }
    }

    for(int i = 0; i < N; i++) {
      string s;
      s = Console.ReadLine();
      s = s.Substring(0, s.Length - 1);
      inputs[i] = s;

      string label;

      // label
      if (TryParseGoto(s, out label) == false) {
        labels.Add(label, i);
        dist[i, i + 1] = 0;
      }
    }
    
    for(int i = 0; i < N; i++) {
      string s = inputs[i];
      string label;
      // goto
      if (TryParseGoto(s, out label) == true) {
        dist[i, i + 1] = 1;
        dist[i, labels[label]] = 0;
      }
    }

    /*
    for(int i = 0; i < N + 1; i++) dist[i, i] = 0;

    for(int i = 0; i < N + 1; i++)
      for(int j = 0; j < N + 1; j++)
        Console.WriteLine("dist[{0}, {1}] = {2}", i, j, dist[i, j]);
    */
    
    for(int k = 0; k < N + 1; k++) {
      for(int i = 0; i < N + 1; i++) {
        for(int j = 0; j < N + 1; j++) {
          dist[i, j] = Math.Min(dist[i, j], dist[i, k] + dist[k, j]);
        }
      }
    }

    Console.WriteLine(dist[0, N]);
  }

  static bool TryParseGoto(string s, out string label) {
    string[] a = s.Split(' ');

    if (a[0] == "goto") {
      label = a[1];
      return true;
    }
    else {
      label = a[0];
      return false;
    }
  }
}

Measured memory_bytes: 20144
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

map<ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


map<ll, int > v;
int main() {
  int n;
  cin >> n;
  vi a(n);
  int f = true;
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    auto res = prime_factor(a[i]);
    for(auto it:res){
      v[it.fi]++;
      if(v[it.fi] >=2){
        f = false;
      }
    }
    if(!f)break;
  }

  if(f){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }
  ll x = a[0];
  srep(i,1,n){
    x = gcd(x,a[i]);
  }
  if(x == 1){
    cout<<"setwise coprime"<<endl;
    return 0;
  }
  cout<<"not coprime"<<endl;
  return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

int sm(ll n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int fact(ll n){
    if(n==1)
        return 1;
    else
        return n*fact(n-1);
}

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        string s;
        cin>>s;
        n=s.length();
        vector<int> a(3);
        for(int i=0;i<n;i++){
            a[s[i]-'a']++;
        }
        sort(a.begin(),a.end());
        if(a[2]-a[0]>1)
            cout<<"NO";
        else
            cout<<"YES";
    }   
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll a;
    string b;cin >> a >> b;
    b.erase(1,1);
    ll t=stoll(b);
    cout << a*t/100 <<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

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

int ma[1 << 20];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<int> cop = a;
	rep(i, n) {
		Rep1(j,2, 1000) {
			int cnt = 0;
			while (a[i] % j == 0) {
				cnt++; a[i] /= j;
			}
			if (cnt > 0)ma[j] = max(ma[j], cnt);
		}
		if (a[i] > 1)ma[a[i]] = 1;
	}
	ll pro = 1;
	rep(i, (1 << 20)) {
		if (!ma[i])continue;
		rep(j, ma[i])pro = pro * i%mod;
	}

	//cout << pro << endl;
	ll ans = 0;
	rep(i, n) {
		(ans += pro * mod_pow(cop[i], mod - 2)) %= mod;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 4096