akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
const int maxn = 100005;
int t[maxn];
int v[maxn];
int f[maxn];
//int sign[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> t[i];
        t[i] *= 2;
        t[i] += t[i-1];
    }
//    t[0] = INF;
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i];
        v[i] *= 2;
    }
    v[n+1] = INF;
    int now = 0;
    int ji = 1;
    for(int i = 0; i <= t[n]; i++)
    {
        now = min(now, v[ji]);
        if(i == t[ji])ji++;
        f[i] = now;
        now++;
    }
    now = 0;
    ji = n+1;
    for(int i = t[n]; i >= 0; i--)
    {
        now = min(now, v[ji]);
        if(i == t[ji-1])ji--;
//        cout << ji << endl;
        f[i] = min(now, f[i]);
        now++;
    }
    double len = 0;
    double ans = 0;
    int last = 0;
    int sta;
    if(f[0] == f[1])sta == 2;
    if(f[0] < f[1])sta == 1;
    for(int i = 0; i <= t[n]; i++)
    {
//        cout << f[i] << endl;
        if(f[i] < f[i+1]){
            if(sta == 1)len++;
            else {
                if(sta == 3){
                    ans += len*len/2;
                    ans += (last-len)*len;
                    last = last-len;
                }
                if(sta == 2){
                    ans += len*last;
                }
                sta = 1;
                len = 1;
            }
        }
        else if(f[i] == f[i+1]){
            if(sta == 2)len++;
            else {
                if(sta == 1){
                    ans += len*len/2;
                    ans += last*len;
                    last += len;
                }
                if(sta == 3){
                    ans += len*len/2;
                    ans += (last-len)*len;
                    last -= len;
                }
                sta = 2;
                len = 1;
            }
        }
        else if(f[i] > f[i+1]-1){
            if(sta == 3)len++;
            else {
                if(sta == 1){
                    ans += len*len/2;
                    ans += last*len;
                    last += len;
                }
                if(sta == 2){
                    ans += last*len;
                }
                sta = 3;
                len = 1;
            }
        }
//        cout << ans << endl;
    }
    printf("%.3f\n", ans/4.0);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

bool isOdd(int val) {
        if (val < 10) {
                return true;
        }

        if (10 <= val && val <= 99) {
                return false;
        }

        if (100 <= val && val <= 999) {
                return true;
        }

        if (1000 <= val && val <= 9999) {
                return false;
        }

        if (10000 <= val && val <= 99999) {
                return true;
        }

        if (100000 <= val && val <= 999999) {
                return false;
        }
}

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

        int count = 0;

        for (int i = 1 ; i <= a ; i++) {
                if (isOdd(i)) {
                        count++;
                }
        }

        printf("%d", count);

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int coordinates[n];
  int sum = 0;
  for (int i=0; i<n; i++){
    int num;
    cin >> num;
    if (num-0 > k-num){
      sum += (k-num)*2;
    }else{
      sum += num*2;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		sc.close();
		for(int i=0;i<10;i++) {
			x = r * x - d;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 26952
MOD = 10 ** 9 + 7


def solve(N, K):
    ans = 0
    numExact = [0] * (K + 1)
    for g in reversed(range(1, K + 1)):
        # Count number of sequences where every element is a multiple of g
        # The gcd of such sequence is at least g
        numGreaterEq = pow(K // g, N, MOD)
        # But we want exact, so subtract the sequences where the gcd is a multiple of g
        numGreater = 0
        for multipleG in range(2 * g, K + 1, g):
            numGreater += numExact[multipleG]
        numExact[g] = numGreaterEq - numGreater
        ans += g * numExact[g]
        ans %= MOD

    return ans


if False:
    import random
    from itertools import product
    from math import gcd

    random.seed(0)
    for _ in range(10000):
        N = random.randint(1, 1)
        K = random.randint(1, 10)

        brute = 0
        for arr in product(range(1, K + 1), repeat=N):
            g = 0
            for x in arr:
                g = gcd(g, x)
            brute += g
        brute = brute % MOD

        ans = solve(N, K)
        # print(N, K, ans, brute)
        assert ans == brute


N, K = [int(x) for x in input().split()]

print(solve(N, K))


Measured memory_bytes: 74520
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

vector<int> edge[200000];

int d1[200000];
int d2[200000];
void dfs1(int k){
  REP(i,edge[k].size()){
    int nn = edge[k][i];
    if(d1[nn] > d1[k]+1){
      d1[nn] = d1[k]+1;
      dfs1(nn);
    }
  }
}

void dfs2(int k){
  REP(i,edge[k].size()){
    int nn = edge[k][i];
    if(d2[nn] > d2[k]+1){
      d2[nn] = d2[k]+1;
      dfs2(nn);
    }
  }
}



signed main(){
  int n;
  cin >> n;
  REP(i,n-1) {
    int k1,k2;
    cin >> k1 >> k2;
    edge[k1].pb(k2);
    edge[k2].pb(k1);
  }
  REP(i,n+1) d1[i] = INF;
  REP(i,n+1) d2[i] = INF;
  d1[1] = 0;
  d2[n] = 0;
  dfs1(1);
  dfs2(n);
  int ans = 0;
  FOR(i,n){
    if(d1[i] > d2[i])
    ans ++;
  }
  if(n-ans>ans) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 15104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    int i;
    int n;
    int a[20] = {0};
    int cnt = 0;

    scanf("%d\n", &n);
    for(i = 0; i < n; i++){
        scanf("%d ", &a[i]);
    }

    for(i = 1; i < n - 1; i++){
        if(a[i-1] - a[i] > 0 && a[i] - a[i+1] > 0) cnt++;
        if(a[i-1] - a[i] < 0 && a[i] - a[i+1] < 0) cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 128
function main(arg) {
  const _a: string[] = arg.split("\n")
  const _n: number = _a[0].split(" ")[0]
  const _m: number = _a[0].split(" ")[1]
  let list: number[] = []

  for (let i = 1; i <= _n; i++) {
    let a = _a[i].split(" ")
    let k: number = a[0]

    if(i==1){
      for (let j=1; j < a.length; j++) {
        list.push(a[j])
      }
    } else {
      let new_list = []
      for (let j = 1; j <= k; j++) {
        let idx = list.indexOf(a[j])
        if (idx >= 0) {
          new_list.push(list[idx])
        }
      }
      list = new_list
    }
  }
  console.log(list.length)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<string.h>
using namespace std;

vector<int>d;
vector<int>e;
int sum;
int ans;
int a;
void saiki(int o, int b) {
	if (o == e.size()) {
		if (((sum + b) % 10) == 0) {
			ans++;
		}
		return;
	}
	if (e[o]) {//??????
		for (int i = 0; i < d.size(); i++) {
			int K = d[i];
			K *= 2;
			if (K >= 10)K = K % 10 + 1;
			saiki(o + 1, b + K);
		}
	}
	else{
		for (int i = 0; i < d.size(); i++) {
			saiki(o + 1, b + d[i]);
		}
	}
}
signed main() {
	scanf("%d", &a);
	string b; cin >> b;
	int c; scanf("%d", &c);
	for (int e = 0; e < c; e++) {
		int f;scanf("%d", &f);
		d.push_back(f);
	}
	reverse(b.begin(), b.end());
	for (int i = 0; i < b.length(); i++) {
		if (b[i] == '*')e.push_back(i & 1);
		else {
			if (i & 1) {
				int f = b[i] - '0';
				f *= 2;
				if (f >= 10)f = f % 10 + 1;
				sum += f;
			}
			else {
				sum += b[i] - '0';
			}
		}
	}
	saiki(0, 0);
	printf("%d\n", ans);
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b, k;
	cin >> a >> b >> k;

	int cnt = 0;
	vi modTbl;
	for(int i = 1; i < 10000; i++)
	{
		if(a % i == 0 && b % i == 0)
		{
			cnt++;
			modTbl.push_back(i);
		}
	}
	reverse(all(modTbl));
	cout << modTbl[k-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }







void solve() {
    ll n;
    ll a[200010],b[200010];
    cin>>n;
    ll cnt_a[200010]={},cnt_b[200010]={};
    rep(i,n){
        cin>>a[i];
        cnt_a[a[i]]++;
    }
    rep(i,n){
        cin>>b[i];
        cnt_b[b[i]]++;
    }
    rep2(i,1,n+1){
        if(cnt_a[i]+cnt_b[i] > n){
            cout<<"No"<<endl;
            return;
        }
    }
    rep2(i,1,n+1){
        cnt_a[i]+=cnt_a[i-1];
        cnt_b[i]+=cnt_b[i-1];
    }
    ll x = 0;
    rep2(i,1,n+1) chmax(x, cnt_a[i]-cnt_b[i-1]);
    cout<<"Yes"<<endl;
    rep(i,n){
        cout<<b[(i+n-x)%n];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;





    


}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


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

using namespace std;
using i64 = int64_t;

int main()
{
    i64 n, m;
    cin >> n >> m;
    vector<i64> a(n), b(n);
    vector<vector<i64>> v(m + 1);
    for(i64 i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        if(m - a[i] >= 0)
            v[m - a[i]].emplace_back(b[i]);
    }
    priority_queue<i64> que;
    i64 s = 0;
    for(i64 i = m - 1; i >= 0; --i){
        for(auto& x : v[i])
            que.emplace(x);
        if(que.size()){
            s += que.top();
            que.pop();
        }
    }
    cout << s << endl;
    return 0;
}




Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 10000000000

int gcd(int a,int b){
  while(a%b!=0){
    int tmp=a%b;
    a=b;
    b=tmp;
  }
  return b;
}

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

  vector<int> count(1000005,0);
  for(int i=0;i<N;i++){
    int a=A[i];
    for(int j=2;j*j<=a;j++){
      if(a%j==0){
        count[j]++;
        while(a%j==0){
          a/=j;
        }
      }
    }
    if(a>1){
      count[a]++;
    }
  }

  bool flag=true;
  for(int i=0;i<=1000000;i++){
    if(count[i]>1){
      flag=false;
    }
  }

  if(flag){
    cout<<"pairwise coprime"<<endl;
  }else{
    int a=A[0];
    for(int i=1;i<N;i++){
      a=gcd(a,A[i]);
    }

    if(a==1){
      cout<<"setwise coprime"<<endl;
    }else{
      cout<<"not coprime"<<endl;
    }
  }


}


Measured memory_bytes: 11176
#include<bits/stdc++.h>
using namespace std;
int n;
const long long INF=int(1e13);
vector<int> a;
vector< vector <long long > > dp;

long long solve(int i,int j,int player){
	if(i==j) return a[i];
	else if(dp[i][j]!=INF) return dp[i][j];
	else{
		dp[i][j]=max(a[i]-solve(i+1,j,-player),a[j]-solve(i,j-1,-player));
	}
	//cout<<i<<" " <<j<<" "<<dp[i][j]<<"\n";
	return dp[i][j];
	
}
int main(){
	cin>>n;
	a.assign(n,0);
	for(int i=0;i<n;i++) cin>>a[i];
	dp.assign(n,vector<long long> (n,INF));

	cout<<solve(0,n-1,1);
	return 0;

}




	









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

int main()
{ int n,m,a,b,c,t;
  while(~scanf("%d %d",&n,&m))
  {  a=n+m;
     b=n-m;
     c=n*m;
     if(a<b)
        t=a,a=b,b=t;
     if(a<c)
         t=a,a=c,c=t;
    printf("%d\n",a);

  }
    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int n; cin >> n;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		String S = sc.next(),T=sc.next();
		String ans="No";
		for(int i=0;i<S.length();i++) {
			if(S.equals(T)) {
				ans="Yes";
			}else {
				S=S.substring(S.length()-1,S.length())+S.substring(0,S.length()-1);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ld;
int main()
{
    int n,i,j;
    cin>>n;
    ld dp[n][3],a[n][3],k,res;
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    k=max(dp[n-1][0],dp[n-1][1]);
    res=max(k,dp[n-1][2]);
    cout<<res;
    return 0;
}

Measured memory_bytes: 4992
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_a"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n int, heights []int) int {
	t := make([]int, n+1, n+1)
	for i := range t {
		t[i] = math.MaxInt64
	}

	t[0] = 0
	for i := 1; i < n; i++ {
		if v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {
			t[i] = v
		}
		if 1 < i {
			if v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {
				t[i] = v
			}
		}
	}

	return t[n-1]
}

func main() {
	sc := newScanner(os.Stdin)
	n := sc.Int()
	heights := sc.IntSlice(n)
	ans := solve(n, heights)
	fmt.Println(ans)
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,n,d;
  int mxx,mxy,mnx,mny;
  int dx[4]={-1,0,1,0};
  int dy[4]={0,-1,0,1};
  while(1){
    cin>>N;
    if(N==0) break;
    mxx=mxy=mnx=mny=0;
     vector<int> x(N),y(N);
     for(int i=1;i<N;i++){
       cin>>n>>d;
       x[i]=x[n]+dx[d];
       y[i]=y[n]+dy[d];
       mxx=max(mxx,x[i]);
       mnx=min(mnx,x[i]);
       mxy=max(mxy,y[i]);
       mny=min(mny,y[i]);
     }
     cout<<mxx-mnx+1<<" "<<mxy-mny+1<<endl;
  }
  return 0;
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

string str;

int parse(int lft, int rgt) {
	int k = 0, nxl = -1, num = 0;
	priority_queue< int, vector< int >, greater< int > > que;
	
	for_(i,lft,rgt) {
		if (str[i] == '[') {
			if (k == 0) nxl = i+1;
			++k;
		}
		
		if (k > 0 && str[i] == ']') {
			--k;
			if (k == 0) que.push(parse(nxl, i));
		}
		
		if (k == 0 && isdigit(str[i])) {
			num = 10 * num + (str[i] - '0');
		}
	}
	
	if (num != 0) return num / 2 + 1;
	
	int qsize = (int)que.size();	
	int res = 0;
	
	for_(i,0,qsize/2 + 1) {
		res += que.top();
		que.pop();
	}
	
	return res;
}

int main() {
	int T;
	cin >> T;
	
	for_(i,0,T) {
		cin >> str;
		cout << parse(0, (int)str.size()) << endl;		
	}
}

Measured memory_bytes: 1276
package main

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

func solve() {
	n, k := getInt(), getInt()
	es := make([]float64, n)
	for i := range es {
		p := getFloat() + 1.0
		es[i] = p / 2
	}

	ans := 0.0
	r := 0
	now := 0.0
	for l := 0; l < n; l++ {
		r = max(r, l)
		for r < n {
			if r-l >= k {
				break
			}
			now += es[r]
			r++
		}
		ans = maxFloat(ans, now)

		now -= es[l]
	}

	fmt.Fprintln(wr, ans)
}

func maxFloat(a, b float64) float64 {
	if a > b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}

func getFloat() float64 {
	f, err := strconv.ParseFloat(getString(), 64)
	if err != nil {
		panic(err)
	}
	return f
}


Measured memory_bytes: 3072
def gcd(a,b) :
	if a % b == 0 :
		return b
	return gcd(b,a%b)

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

N = int(input())
res = 1
for i in range(N) :
	res = lcm(res, int(input()))
print(res)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc129/tasks/abc129_c

int main() {
  int N, M; cin >> N >> M;
  int a[N+1]; REP(i, N+1) a[i] = 0;
  REP(i, M) {
    int b; cin >> b;
    a[b] = 1;
  }
  ll dp[N+5]; REP(i, N+5) dp[i] = 0;
  dp[0] = 1;
  dp[1] = 1;

  REP(i, N+1) {
    if (i==0||i==1) continue;
    dp[i] += (a[i-2]?0:dp[i-2]);
    dp[i] %= MOD;
    dp[i] += (a[i-1]?0:dp[i-1]);
    dp[i] %= MOD;
  }
  cout << dp[N] << "\n";
  
  return 0;
}


Measured memory_bytes: 1408
using System;

namespace Rectangle
{
    class Rectangle
    {
        static void Main()
        {
            string input = Console.ReadLine();
            string[] hw = input.Split(' ');
            int[] answer=new int[2];
            answer[0] = int.Parse(hw[0]) * int.Parse(hw[1]);
            answer[1] = int.Parse(hw[0]) * 2 + int.Parse(hw[1]) * 2;
            Console.WriteLine(answer[0] + " " + answer[1]);
            //Console.ReadKey();
        }
    }
}



Measured memory_bytes: 15924
#coding:utf-8
import Queue

X,Y,Z,K=map(int, raw_input().split())
A=map(int, raw_input().split())
B=map(int, raw_input().split())
C=map(int, raw_input().split())

pq=Queue.PriorityQueue()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
S=[]
vis=set()
pq.put((-(A[0]+B[0]+C[0]),0,0,0))
vis.add((0,0,0))
while len(S)!=K:
    cost,ap,bp,cp=pq.get()
    S.append(-cost)
    for i in range(1<<3):
        da=i&0b001
        db=(i&0b010) >> 1
        dc=(i&0b100) >> 2
        nap=ap+da;nbp=bp+db;ncp=cp+dc
        if nap>=len(A) or nbp>=len(B) or ncp>=len(C):continue
        if (nap,nbp,ncp) not in vis:
            vis.add((nap,nbp,ncp))
            newcost=A[nap] + B[nbp] + C[ncp]
            pq.put((-newcost, nap,nbp,ncp))

for s in S:
    print(s)

            

        





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

using namespace std;
#define int long long
const int N = 3e4 + 10;
int dp[N][4], last[N];

int32_t main()
{
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 1; i <= n; i++) {
        dp[i][1] = 1;
        for (int k = 2; k <= 3; k++) for (int j = 0; j < 10; j++) dp[i][k] += dp[last[j]][k - 1];
        last[s[i - 1] - '0'] = i;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++) ans += dp[last[i]][3];
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n,t;
  cin>>n>>t;
  ll tot = 0;
  vector<ll>time(n);
  for(int i=0;i<n;i++){
  	cin>>time[i];
  }
  for(int i=1;i<n;i++){
  	tot+=min(time[i]-time[i-1],t);
  }
  cout<<tot+t<<endl;
}  







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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  rep(i, 0, N) cin >> V[i];
  int ans = 0;
  rep(i, 0, min(N, K) + 1) rep(j, 0, min(N, K) + 1) {
    if(i + j > min(N, K)) continue;
    priority_queue<int,vector<int>,greater<int>> Q;
    rep(n, 0, i) Q.push(V[n]);
    rep(n, 0, j) Q.push(V[N-1-n]);
    int n = K - i - j;
    while(n-- && !Q.empty() && Q.top() < 0) Q.pop();
    int tmp = 0;
    while(!Q.empty()) {
      tmp += Q.top();
      Q.pop();
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1000000009;

int main()
{
  string s;
  cin>>s;
  reverse(s.begin(),s.end());

  //maerd,remaerd,esare,resareに分解
  string word[4]={"maerd","remaerd","esare","resare"};

  int cnt=0;
  bool flag=true;
  while(cnt<s.size())
  {
    flag=false;
    rep(i,4)
    {
      if(s.substr(cnt,word[i].size())==word[i])
      {
        cnt+=word[i].size();
        flag=true;
        break;
      }
    }
    if(!flag) break;
  }

  if(flag) cout<<"YES";
  else cout<<"NO";

  cout<<endl;

}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll N;
  cin >> N;
  ll a[N+1], b[N];
  for (int i = 0; i < N + 1; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  // 前から貪欲法
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] <= b[i]) {
      ans += a[i];
      b[i] -= a[i];
    } else {
      ans += b[i];
      b[i] = 0;
    }

    if (a[i+1] >= b[i]) {
      ans += b[i];
      a[i+1] -= b[i];
    } else {
      ans += a[i+1];
      a[i+1] = 0;
    }
  }

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


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 998244353;


const int MAX = 510000;
const ll MOD = 998244353;


long long 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;
    }
}

// 二項係数計算
//注意！nはllかもしれない？<-大丈夫そう
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMinit();
    int n, m, k;
    cin >> n >> m >> k;

    vector<ll> cnt(n);
    rep(i, n) {
        if (i == 0) cnt[i] = (ll)m;
        else cnt[i] = cnt[i - 1] * (ll)(m - 1) % INF;
    }
    ll ans = (ll)0;
    for (int i = n-k; i <= n; i++) {
        ans += cnt[i - 1] * COM(n - 1, i-1);
        ans %= INF;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16720
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-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; }



int main(){
  ll A,B,M; cin>>A>>B>>M;
  vector<ll> a(A),b(B);
  ll mina=INF,minb=INF;
  rep(i,A) {cin>>a.at(i); chmin(mina,a.at(i));}
  rep(i,B) {cin>>b.at(i); chmin(minb,b.at(i));}
  
  ll ans=mina+minb;
  rep(i,M){
    ll x,y,c; cin>>x>>y>>c; x--; y--;
    ll sum=a.at(x)+b.at(y)-c;
    chmin(ans,sum);
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4836
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;
        int sub = 0;
        for(int x = 0; x <= k; x++){
            for(int y = 0; y <= k; y++){
                sub = s - (x+y);
                if(0 <= sub && sub <= k){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = numeric_limits<ll>::max();
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

const int MX=3;
ll L,A,B,M;

struct Matrix{
	ll A[MX][MX];
	Matrix(){
		memset(A,0,sizeof A);
	}
};

Matrix matmul(Matrix X,Matrix Y){
	Matrix res;
	REP(i,MX)
		REP(k,MX)
			REP(j,MX)
				(res.A[i][j]+=X.A[i][k]%M*Y.A[k][j]%M)%=M;	
	return res;
}

Matrix matpow(Matrix X,ll p){
	Matrix res;
	REP(i,MX) res.A[i][i]=1;
	while(p){
		if(p&1LL) res=matmul(res,X);
		X=matmul(X,X);
		p>>=1LL;
	}	
	return res;
}

ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%M;a=a*a%M;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>L>>A>>B>>M;
	vector<ll> ub;
	ub.pb(9);
	REP(i,17) ub.pb(ub.back()*10LL+9LL);
	ub.pb(IINF);
	ll k=0,xA=A;
	array<ll,3> base={0,0,1};
	REP(i,sz(ub)){
		if(A>=ub[i]) continue;
		ll cnt=min(L,(ub[i]-A)/B+1);
		Matrix T;
		T.A[0][0]=fpow(10,i+1)%M;
		T.A[0][1]=B%M;
		T.A[0][2]=xA%M;
		T.A[1][0]=0;
		T.A[1][1]=1;
		T.A[1][2]=1;
		T.A[2][0]=0;
		T.A[2][1]=0;
		T.A[2][2]=1;
		T=matpow(T,cnt);
		array<ll,3> tmp;
		tmp[0]=base[0]*T.A[0][0]%M+base[1]*T.A[0][1]%M+base[2]*T.A[0][2]%M;
		tmp[1]=base[1]*T.A[1][1]%M+base[2]*T.A[1][2]%M;
		tmp[2]=base[2]*T.A[2][2]%M;
		tmp[0]%=M;
		tmp[1]%=M;
		tmp[2]%=M;
		base=tmp;
		L-=cnt;
		A+=B*cnt;
		if(!L) break;
	}
	cout<<base[0]<<'\n';
}
// i didn't read the last sentence in constraints, which caused me a lot of time 
// calculate number of terms whose number of digits is D
// for each group of D-digits, we can do matrix multiplication to compute the answer


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> a(n);
    for (int i = 0; i < n - 1; i++) {
        a[i + 1] = a[i] + (s[i] == 'A' && s[i + 1] == 'C');
    }

    for (int h = 0; h < q; h++) {
        int l, r;
        cin >> l >> r;
        l--;

        cout << a[r - 1] - a[l] << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 1488
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;if(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


int b[40],sz,a[N],c[N];
int dp[1<<18],f[1<<18],l[N][20],r[N][20];
int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    //cerr<<setprecision(9)<<fixed;
    int T,i,j,k,ca=0,m,K,n;
    scanf("%d%d",&n,&m);
    K=m;sz=0;
    while(K)b[sz++]=K,K>>=1;
    DBG(sz)
    b[sz++]=0;
    swap(b[0],b[sz-1]);
    rep(i,0,n)scanf("%d",&a[i]);
    rep(k,0,sz){
        K=b[k];
        //cerr<<k<<" "<<K<<"\n";
        l[0][k]=0;
        rep(i,1,n){
            if(K>=a[i]-a[i-1])l[i][k]=l[i-1][k];
            else l[i][k]=i;
        }
        r[n-1][k]=n-1;
        per(i,0,n-1){
            if(K>=a[i+1]-a[i])r[i][k]=r[i+1][k];
            else r[i][k]=i;
        }
    }
    sz--;
    memset(dp,-1,sizeof(dp));
    rep(i,0,(1<<sz)){
        int x=dp[i];
        rep(j,0,sz)if((i>>j&1)==0){
            Max(dp[i|1<<j],x);
            if(x+1<n)Max(dp[i|1<<j],r[x+1][j]);
        }
    }
    per(i,0,(1<<sz))f[i]=n;
    rep(i,0,(1<<sz)){
        int x=f[i];
        rep(j,0,sz)if((i>>j&1)==0){
            Min(f[i|1<<j],x);
            if(x)Min(f[i|1<<j],l[x-1][j]);
        }
    }
    int mask=(1<<sz)-1,flag=0;
    rep(i,0,(1<<sz)){
        int x=dp[i],y=f[mask^i];
        if(y<=x+1){
            flag=1;break;
        }
        k=r[x+1][sz];
        j=l[y-1][sz];
        if(j<=x+1&&k>=y-1)c[j]++,c[k+1]--;
    }
    
    if(flag){
        rep(i,0,n)puts("Possible");
    }
    else
    {
        rep(i,1,n)c[i]+=c[i-1];
        rep(i,0,n){
            if(c[i])puts("Possible");
            else puts("Impossible");
        }
    }//*/
    /*
    rep(i,0,n){
        int x=l[i][sz],y=r[i][sz],ok=0;
        //cerr<<i<<" "<<x<<" "<<y<<"\n";
        rep(j,0,(1<<sz)){
            k=mask^j;
            //cerr<<j<<" "<<dp[j]<<","<<k<<" "<<f[k]<<"\n";
            if(dp[j]>=x-1&&f[k]<=y+1){ok=1;break;}
        }
        puts(ok?"Possible":"Impossible");
    }//*/
    //cerr<<clock()*1./CLOCKS_PER_SEC<<"ms\n";
    return 0;
}

Measured memory_bytes: 37248
#include<iostream>
#include<cstdio>
using namespace std;
long long N,C,a[405],b[405],c[405][405],f[405][405],tmp;
inline long long add(long long x,long long y){
	return ((x+y)<1000000007)?(x+y):(x+y-1000000007);
}
inline long long mul(long long x,long long y){
	return x*y%1000000007;
}
int main(){
	scanf("%lld%lld",&N,&C);
	for(int i=1;i<=N;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=N;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=N;i++)
		for(int j=a[i];j<=b[i];j++){
			tmp=1;
			for(int k=0;k<=C;k++){
				c[i][k]=add(c[i][k],tmp);
				tmp=mul(tmp,j);
			}
		}
	f[0][0]=1;
	for(int i=1;i<=N;i++)
		for(int j=0;j<=C;j++)
			for(int k=0;k<=C-j;k++)
				f[i][j+k]=add(f[i][j+k],mul(f[i-1][k],c[i][j]));
	printf("%lld\n",f[N][C]);		
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<string>
using namespace std;
int n,ans=-1;
string s;
int main(void){
  cin>>n>>s;
  for(int i=0;i<n;i++){
    int x[26]={0},y[26]={0},k=0;
    for(int j=0;j<i;j++)x[s[j]-'a']++;
    for(int j=i;j<n;j++)y[s[j]-'a']++;
    for(int j=0;j<26;j++)k+=(min(x[j],y[j])==0?0:1);
    ans=max(ans,k);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 384
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-09-19 20:24:04
 * @LastEditTime: 2020-09-19 20:27:14
 * @FilePath: \VSC\C++\Practice\AC abc179 C.cpp
 */
#include <bits/stdc++.h>
using namespace std;

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

    int ans = 0;
    for (i = 1; i < n; ++i) {
        if (n % i == 0)
            ans += n / i - 1;
        else
            ans += floor(n / i);
    }

    printf("%d\n", ans);
    return 0;
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
string S;

int main()
{
	cin >> S;
	N = S.size();

	int cnt = 0,l,r;
	if(N % 2){
		l = N / 2 - 1;
		r = N / 2 + 1;
		cnt++;
	}
	else{
		l = N / 2 - 1;
		r = N / 2;
	}
	while(l >= 0){
		if(S [l] == S [N / 2] && S [r] == S [N / 2]){
			cnt += 2;
			l--;
			r++;
		}
		else{
			break;
		}
	}

	cout << cnt + (N - cnt) / 2 << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 1000000;

long long 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 COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
    int N; cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> v(N);
    int aaa=0;
    for(int i=0;i<N;i++){cin >> P[i];}
    for(int i=0;i<N;i++){cin >> Q[i]; v[i] = i+1;}
    int a=-1,b=-1;
    int cnt=0;
    do{
        bool aa=true,bb=true;
        for(int i=0;i<N;i++){
            if(P[i]!=v[i]){
                aa=false;
            }
            if(Q[i]!=v[i]){
                bb=false;
            }
        }
        if(aa) a = cnt;
        if(bb) b = cnt;
        cnt++;
        if(a>=0 && b>=0) break;
    }while(next_permutation(v.begin(),v.end()));
    cout << abs(b-a) << endl;
    return 0;
}


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

int main() {
  int N, l, r;
  cin >> N;
  int total = 0;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    total = total + r + 1 -l;
  }
  cout << total << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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 INF = 1LL << 60;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll h,w,cx,cy,dx,dy;
    cin >> h >> w >> cx >> cy >> dx >> dy;
    cx--;
    cy--;
    dx--;
    dy--;
    string s[h];
    for (ll i=0;i<h;i++)cin >> s[i];
    deque<P> que;

    que.push_back(P(cx,cy));
    bool visited[h][w];
    ll d[h][w];
    for (ll i=0;i<h;i++){
        fill(visited[i],visited[i]+w,false);
        fill(d[i],d[i]+w,INF);
    }
    d[cx][cy]=0;
    visited[cx][cy]=true;

    while(!que.empty()){
        P p=que.front();
        ll X=p.first,Y=p.second;
        if (X==dx and Y==dy){
            cout << d[X][Y] << endl;
            return 0;
        }
        visited[X][Y]=true;
        que.pop_front();
        for (ll i=-2;i<3;i++){
            for (ll j=-2;j<3;j++){
                ll x=X+i,y=Y+j;
                if (x<h and x>=0 and y<w and y>=0 and s[x][y]=='.'){
                    if (visited[x][y])continue;
                    if (abs(i)+abs(j)<2){
                        que.push_front(P(x,y));
                        d[x][y]=d[X][Y];
                        visited[i][j]=true;
                    }else{
                        if (d[X][Y]+1<d[x][y]){
                            d[x][y]=d[X][Y]+1;
                            que.push_back(P(x,y));
                        }
                    }
                }
            }
        }

    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 14464
//oof array too small lol

#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
using namespace std;

int x,y,z,dp[100005][5],ar[100005][5];

int main(){
	cin >> x;
	for (int a = 1; a <= x; a++) {
		for (int b = 1; b <= 3; b++) {
			cin >> ar[a][b];
		}
	}
	for (int a = 1; a <= x; a++) {
		dp[a][1] = max(dp[a-1][2],dp[a-1][3]) + ar[a][1];
		dp[a][2] = max(dp[a-1][1],dp[a-1][3]) + ar[a][2];
		dp[a][3] = max(dp[a-1][1],dp[a-1][2]) + ar[a][3];
	}
	cout << max(dp[x][1],max(dp[x][2],dp[x][3])) << "\n";
    return 0;
}

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

int main(){
	cin>>a;
	int x,y;
	x=a.find('C');
	y=a.find('F',x);
	if(x!=-1&&y!=-1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
a = []
if r - l > 2019:
  for i in range(l, l + 2019):
    for j in range(i + 1, min(r + 1, l + 2020)):
      a.append((i * j) % 2019)
else:
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      a.append((i * j) % 2019)
ans = min(a)
print(ans)

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

const double PI=acos(-1.0);

int main() {
    string n;
    cin >> n;
    int x[4];
    rep(i, 4) x[i] = n[i] - '0';

    
    char op[3];
    int sum = 0;
    rep(i, 2) {
        rep(j, 2) {
            rep(k, 2) {
                int sum = 0;

                if(i == 0) sum = x[0] + x[1];
                else sum = x[0] - x[1];
                if(j == 0) sum += x[2];
                else sum -= x[2];
                if(k == 0) sum += x[3];
                else sum -= x[3];

                if(sum == 7) {
                    op[0] = (i == 0 ? '+' : '-');
                    op[1] = (j == 0 ? '+' : '-');
                    op[2] = (k == 0 ? '+' : '-');
                }
            }
        }
    }

    rep(i, 3) {
        cout << x[i] << op[i];
    }
    cout << x[3] << "=7" << endl;

    return 0;
}

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

using namespace std;

typedef vector<char> vc;
typedef vector<vc> vvc;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<char, pii> mcpii;
typedef pair<pair<string, string>, int> ppssi;
typedef vector<ppssi> vppssi;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second
#define read freopen("..\\in.txt", "r", stdin)
#define write freopen("..\\out.txt", "w", stdout)

const int dir_x[]{0, 0, -1, 1}, dir_y[]{-1, 1, 0, 0};

const int INF = 1e9 + 5;

int main() {
//    read;
    int T = 1;
//    cin >> T;
    for (int tc = 1; tc <= T; ++tc) {
        int n, k = 0, m;
        cin >> n >> m;
        int sum = 0;
        vector<int> a(n);
        for (int &x : a) cin >> x, sum += x;
        for (int i = 0; i < n; ++i) {
            int p = 4 * m;
            if ((a[i] * p) >= sum) {
                k++;
            }
        }
        if (k >= m) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   long long int n;
   while(cin>>n)
   {
     long long int kk=n;
     int result=0;
     while(kk)
     {
       result=result+kk%10;
       kk/=10;         
     }
     if(n%result==0) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
   }
   return 0;
 }
 


Measured memory_bytes: 256
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int n;cin>>n;
	if(n&1)
	{
		printf("%.9lf\n",(double)(n+1.0)/2.0/(double)n);
	}
	else
		printf("0.5000000\n");
	return 0;
}



Measured memory_bytes: 384
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }

    let n = if n <= 1 { 0 } else { n - 1 };
    let m = if m <= 1 { 0 } else { m - 1 };
    let ans = (n * (n+1) / 2) + (m * (m+1) / 2);

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


Measured memory_bytes: 2180
import sys

class Dise():
    def __init__(self, aLabelList):
        self.LabelList = aLabelList
        self.NEWS = {"N": [0,4,5,1],
                     "E": [0,2,5,3],
                     "W": [0,3,5,2],
                     "S": [0,1,5,4],
                     "R": [1,2,4,3]}
       
    def move(self,aNEWS):
        idx = self.NEWS[aNEWS]
        tmp = self.LabelList[idx[0]]
        self.LabelList[idx[0]] = self.LabelList[idx[3]]
        self.LabelList[idx[3]] = self.LabelList[idx[2]]
        self.LabelList[idx[2]] = self.LabelList[idx[1]]
        self.LabelList[idx[1]] = tmp

def step1():
    for i in range(4):
        if Dise1.LabelList[0] == Dise2.LabelList[0] and \
           Dise1.LabelList[5] == Dise2.LabelList[5]:
            step2()
        else:
            Dise2.move("E")
    
    Dise2.move("N")
    if Dise1.LabelList[0] == Dise2.LabelList[0] and \
       Dise1.LabelList[5] == Dise2.LabelList[5]:
        step2()
    
    Dise2.move("S")
    Dise2.move("S")
    if Dise1.LabelList[0] == Dise2.LabelList[0] and \
       Dise1.LabelList[5] == Dise2.LabelList[5]:
        step2()
    
def step2():
    for i in range(4):
        if Dise1.LabelList[1] == Dise2.LabelList[1] and \
           Dise1.LabelList[2] == Dise2.LabelList[2] and \
           Dise1.LabelList[3] == Dise2.LabelList[3] and \
           Dise1.LabelList[4] == Dise2.LabelList[4]:
            print("No")
            sys.exit()
        else:
            Dise2.move("R")

n = int(input())
DiseList = [Dise(input().split()) for i in range(n)]
for x in range(n-1):
    for y in range(x+1,n):
        Dise1 = DiseList[x]
        Dise2 = DiseList[y]
        step1()

print("Yes")




Measured memory_bytes: 5620