akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;

const int N = 1e5 + 20;
const int inf = 1e9;
int n;
char g[55][55];
int num[55][30];
char ans[550];
int main()
{
#ifndef ONLINE_JUDGE
    //IN;
#endif

    SC(n);
    FF(i, 1, n)
    {
        SS(g[i]+1);
        int len = strlen(g[i]+1);
        FF(j, 1, len)
        {
            int id = g[i][j] - 'a' + 1;
            ++num[i][id];
        }
    }
    int cnt = 0;
    FF(i, 1, 26)
    {
        int mx = 1e9;
        FF(j, 1, n)
            mx = min(mx, num[j][i]);
        FF(j, 1, mx)
        {
            ++cnt;
            ans[cnt] = i + 'a' - 1;
        }
    }
    FF(i, 1, cnt) putchar(ans[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int h, n;
    scanf("%d %d", &h, &n);
    int a, sum = 0;

    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        sum += a;
    }
    if (h <= sum) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(n,i) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    long long int n,a,b;
    cin>>n>>a>>b;
    long long int kei,kai,sa;
    kei=a+b;
    kai=n/kei;
    sa=n-(kei*kai);
    
    long long int ans;
    if(sa<a){
        ans=kai*a+sa;
    }
    else{
        ans=kai*a+a;
    }
    
    cout<<ans;
}


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

using namespace std;

int main()
{
	int a[12] = {0};
	char s[12];
	int x, y;
	cin >> x >> y;
	cin >> s;
	for (int i = 0; i < strlen(s); i++)
		if (s[i] == '-')
			a[i] = 0;
		else
			a[i] = 1;
	int ok = 0;
	for (int i = 0; i < strlen(s); i++) {
		if (i == x) {
			if (!a[i])
				ok = 1;
			else {
				ok = 0;
				break;
			}
		}
		else {
			if (!a[i]) {
				ok = 0;
				break;		
			}
			else
				ok = 1;
		}
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rall(x) x.rbegin(),x.rend()
#define int long long 
using namespace std;

int32_t main(){

    int n , k;  cin >> n >> k;
    unordered_map<int,int> f;

    for(int x=0;x<n;x++) {
        int t; cin >> t;
        f[t]++;
    }

    if(f.size() <= k) {
        cout << 0 << endl;
        exit(0);
    }
    
    auto itr = f.begin();
    vector<int> a;
    for( ; itr != f.end() ; itr++)
        a.push_back(itr->second);
    

    sort(rall(a));
    int ans = 0;

    while(a.size() != k){
        ans += (a[a.size() - 1]);
        a.pop_back();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	cin>>a>>b;
	int pos = 0;
	for(int i =0;i<a.size();i++)
	{
		if(a[i] == b[0])
		{
			pos = i;
			break;
		}
		else
			continue;
	}
	bool ok = true;
	for(int i = 0; i < b.size();i++)
	{
		int check = i + pos;
		if(check >= b.size())
			check-=b.size();
			
		//cout<<i<<" "<<check<<endl;
		if(b[i] == a[check])
			continue;
		else
		{
			ok = false;
			break;
		}
	}
	if(ok)
		puts("Yes");
	else
		puts("No");
		
	return 0;
}

Measured memory_bytes: 256
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)

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

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    rep(i, A)
    {
        cin >> a.at(i);
    }
    vector<int> b(B);
    rep(i, B)
    {
        cin >> b.at(i);
    }

    int a_min = a.at(0), b_min = b.at(0);
    rep(i, A)
    {
        a_min = min(a_min, a.at(i));
    }
    rep(i, B)
    {
        b_min = min(b.at(i), b_min);
    }
    int ans = a_min + b_min;
    int x, y, c, tmp = 0;
    rep(i, M)
    {
        cin >> x >> y >> c;
        // cout << x << y << c << endl;
        tmp = (a.at(x - 1) + b.at(y - 1)) - c;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
fn main() {                                                                                                                                                                                                                                      let scan = std::io::stdin();                                                                                                                                                                                                                                                                                                                                                                                                                                                              let mut line = String::new();                                                                                                                                                                                                                                                                                                                                                                                                                                                             let _ = scan.read_line(&mut line);                                                                                                                                                                                                           let vec: Vec<&str> = line.split_whitespace().collect();                                                                                                                                                                                                                                                                                                                                                                                                                                   let a: u32 = vec[0].parse().unwrap_or(0);                                                                                                                                                                                                    let b: u32 = vec[1].parse().unwrap_or(0);                                                                                                                                                                                                                                                                                                                                                                                                                                                 println!("{} {} {:.5}", &(&a / &b), &(&a % &b), &(a as f64 / b as f64));                                                                                                                                                                 }


Measured memory_bytes: 5036
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<int>qs[110000];
int d[110000];
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	ll now = 0;
	int cnt = 0;
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &d[i]);
		d[i]--;
		if (i != 0)
		{
			if (d[i - 1] < d[i])now += d[i] - d[i - 1];
			else
			{
				now += d[i] + 1;
				cnt++;
				qs[d[i]].push_back(i);
			}
		}
	}
	ll mini = now;
	for (int i = 0; i < gen; i++)
	{
		mini = min(mini, now);
		//printf("%d %lld %d\n", i, now, cnt);
		if (d[0] == i)cnt++, now++, qs[d[1]].push_back(1);
		for (int j = 0; j < qs[i].size(); j++)
		{
			if (qs[i][j] == num - 1)cnt--;
			else now++, qs[d[qs[i][j] + 1]].push_back(qs[i][j] + 1);
			now--;
			now += (d[qs[i][j]] + gen - d[qs[i][j] - 1]) % gen;
		}
		now -= cnt;
	}
	printf("%lld\n", mini);
}

Measured memory_bytes: 5504
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int num[3], mi = 2 << 24;
        rep(i,n){
            cin >> num[i];
            mi = min(mi, num[i]);
        }
        range(i,1,10000000 / 2){
            if(i > mi) break;
            bool c = true;
            rep(j,n){
                if(num[j] % i != 0){
                    c = false;
                    break;
                }
            }
            if(c)
                cout << i << endl;
        }
    }
}

Measured memory_bytes: 1160
from collections import deque
n = int(input())
ab = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

fnc = deque()
snk = deque()

fnc.appendleft(0)
snk.appendleft(n-1)

check = [0]*(n)

check[0] = 1
check[n-1] = 1

fnc_num = 0
snk_num = 0

while len(fnc) > 0 or len(snk) > 0:
    for i in range(len(fnc)):
        tmp = fnc.popleft()
        for j in range(len(ab[tmp])):
            if check[ab[tmp][j]] == 0:
                fnc_num += 1
                check[ab[tmp][j]] = 1
                fnc.append(ab[tmp][j])
                
    for i in range(len(snk)):
        tmp = snk.popleft()
        for j in range(len(ab[tmp])):
            if check[ab[tmp][j]] == 0:
                snk_num += 1
                check[ab[tmp][j]] = 1
                snk.append(ab[tmp][j])
                
    #fnc.popleft()
    #snk.popleft()
    
if fnc_num > snk_num:
    print('Fennec')
else:
    print('Snuke')

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

int main(){
  int n, k, r, s, p; string t;
  cin>>n>>k>>r>>s>>p>>t;

  long long sum=0LL;
  for(int i=0; i<n; ++i){
    if(t[i]=='r')sum+=p;
    if(t[i]=='s')sum+=r;
    if(t[i]=='p')sum+=s;
  }

  for(int i=k; i<n; ++i){
    if(t[i]==t[i-k]){
      if(t[i]=='r'){sum-=p; t[i]='a';}
      if(t[i]=='s'){sum-=r; t[i]='a';}
      if(t[i]=='p'){sum-=s; t[i]='a';}
    }
  }

  cout<<sum<<endl;
}

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

vector<int> dp = {0, 0, 0, 1, 1, 1};

const int mod = 1e9 + 7;

int main() {
    vector<int> sumdp(dp.size() + 1);
    for (int i = 0; i < (int)dp.size(); i++)
        sumdp[i + 1] = sumdp[i] + dp[i];
    int s;
    cin >> s;
    dp.resize(s + 1);
    sumdp.resize(s + 2);
    
    for (int i = 6; i <= s; i++) {
        dp[i] = (sumdp[i - 3 + 1] - sumdp[3] + 1 + mod) % mod;
        sumdp[i + 1] = (sumdp[i] + dp[i]) % mod;
    }

    cout << dp[s];
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n;
    string s;
    cin >> n >> s;

    int w = 0,b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '.') w++;
    }
    int ans = w;
    for(int i = 0; i < n; i++){
        if(s[i] == '#') b++;
        else w--;
        ans = min(ans,b+w);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void){
 string a = "CODEFESTIVAL2016";
 string s;
cin >> s;
int ans = 0;
for( int i = 0; i<16;++i){
 if(a[i] != s[i])ans++;
}
cout << ans<<endl;



}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
const int N=1e6+5,M=405;
typedef long long ll;
int a[N],b[N];
bool s[M][M];
bool vis[M];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&a[i],&b[i]);
    for(int i=1;i<=n;i++){
        s[i][i]=1;
        for(int j=m;j>=1;j--){
            bool x=s[i][a[j]],y=s[i][b[j]];
            if(x&&y)
                vis[i]=1;
            else if(x)
                s[i][b[j]]=1;
            else if(y)
                s[i][a[j]]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(vis[i])
            continue;
        for(int j=i+1;j<=n;j++){
            if(vis[j])
                continue;
            bool flag=true;
            for(int k=1;k<=n;k++)
                if(s[i][k]&&s[j][k]){
                    flag=false;
                    break;
                }
            ans+=flag;
        }
    }
    printf("%d\n",ans);
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;

const ll mod = 1000000007;
const double pi = 3.1415926535897932384626;

ll powmod(ll a, ll b) {ll res = 1; ll rem = a % mod; for (; b; b >>= 1) {if (b & 1) res = (res * rem) % mod; rem = (rem * rem) % mod;} return res;}

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    
    int a = 0;
    int b = 0;
    int c = 0;
    bool check = false;
    scanf("%d %d %d", &a, &b, &c);

    if (a == 5 && b == 5 && c == 7) check = true;
    else if (a == 5 && c == 5 && b == 7) check = true;
    else if (a == 7 && b == 5 && c == 5) check = true;

    if (check) puts("YES");
    else puts("NO");

    return 0;
}


Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

N = SORO_INT()
A = list(MULT_INT_MAP())
x = max(A) - min(A)
print(x)

Measured memory_bytes: 2940
/**
*    author:  yuya1234
*    created: 15.08.2020 21:00:39
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  string s;
  cin>>s;

  if(s=="RRR")cout<<3<<endl;
  else if(s=="SSS")cout<<0<<endl;
  else if(s=="RRS")cout<<2<<endl;
  else if(s=="SRR")cout<<2<<endl;
  else cout<<1<<endl;

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
using namespace std;
bool flg[10000001];

int main(){

	for(int i=0;i <= 1000000;i++){
		if(i<=1)flg[i]=false;
		else flg[i]=true;
	}
	for(int i=2;i <= 1001 ;i++){
		if(flg[i]==true){
			for(int j=i*2 ; j<=1000000 ; j=j+i){
				flg[j] = false;
			}
		}
	}
    while(1){
        int n=0,ans=0;
		cin>>n;
		if(!n)break;
		for(int i=2;i<=n;i++){
            if(flg[i]==true&&flg[n-i]==true&&i<=n-i)ans++;
		}
		cout<<ans<<endl;

	}
}

Measured memory_bytes: 2136
#include<iostream>

using namespace std;

int X, Y;

int main() {
	cin >> X >> Y;
	bool ans = false;
	for (int i = 0; i <= X; i++) {
		if (2 * i + 4 * (X - i) == Y) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
  int N; cin>>N;
  long long ans=0;
  int before, tmp, step;
  cin>>before;
  for (int i=1; i<N; i++) {
    cin>>tmp;
    if (before>tmp) {
      step = before - tmp;
      ans += step;
      before = tmp + step;
    } else {
      before = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();


        System.out.println(solve(S));
    }

    private static int solve(String S) {
        int count = 0;

        for (int i=0; i<S.length(); i++) {
            if (S.charAt(i) == 'A' || S.charAt(i) == 'T' || S.charAt(i) == 'C' || S.charAt(i) == 'G') {
                for (int j=i; j<S.length(); j++) {
                    if (S.charAt(j) == 'A' || S.charAt(j) == 'T' || S.charAt(j) == 'C' || S.charAt(j) == 'G') {
                        // System.err.println("i=" + i + ", j=" + j + ", val=" + (j-i+1));
                        count = Math.max(count, j-i+1);
                    } else {
                        break;
                    }
                }
            }
        }

        return count;
    }
}

Measured memory_bytes: 22612
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, ans;
	scanf("%d%d%d", &a, &b, &c);
	if(a*b >= c) ans = c;
	else ans = a*b;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    loop {
        let mut buf1 = String::new();
        io::stdin().read_line(&mut buf1).ok();
        let mut iter = buf1.split_whitespace().map(|n| usize::from_str(n).unwrap());
        let (m, nmin, nmax) = (iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap());

        if m == 0 && nmin == 0 && nmax == 0 {
            return;
        }

        let mut v: Vec<u16> = Vec::new();
        for _ in 0..m {
            let mut buf2 = String::new();
            io::stdin().read_line(&mut buf2).ok();
            let p: u16 = match buf2.trim().parse() {
                Ok(num) => num,
                Err(e) => { panic!("{}", e) },
            };
            v.push(p);
        }

        let mut ans_n: u16 = 0;
        let mut ans_gap: u16 = 0;
        for i in nmin..nmax+1 {
            let gap = v[i - 1] - v[i];
            if gap < ans_gap {
                continue;
            }

            ans_gap = gap;
            ans_n = i as u16;
        }
        println!("{}", ans_n);
    }
}



Measured memory_bytes: 5048
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int max = 0;
    int ans = 0;
    int cnt = 0;

    for(int i = 1; i <= n; i++){
      int j = i;
      while(j % 2 == 0){
        j /= 2;
        cnt++;
      }
      if(cnt >= max){
        max = cnt;
        ans = i;
      }
      cnt = 0;
    }
    System.out.println(ans);
  }
}


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

int main() {
    string N;
    cin >> N;
    char first = N[0];
    char second = N[1];
    char third = N[2];
    char fourth = N[3];
    
    if((first == second && second == third) || (second == third && third == fourth)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
signed main()
{
	int c, d;
	cin >> c >> d;
	if (c == 1 || d == 1)
	{
		cout << "1";
		return 0;
	}
	if (c * d % 2 != 0)
		cout << c * d / 2 + 1;
	else
		cout << c * d / 2;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



ll n;

ll res;

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ll tmp = n;
    ff(i,1,n){
        tmp = i;
        res += (tmp * (tmp + 1)) / 2;
    }
    ff(i,1,n - 1){
        ll a,b;
        cin >> a >> b;
        if(a > b)swap(a,b);
        ll kolko = a * (n - b + 1);
        res -= kolko;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include "string.h"
#define OPEN 0
#define N 100010
#define VISITED 1
#define UNVISITED 0
using namespace std;
vector<vector<pair<int,int>>> g(N);
int flag[N];
int color_map[N];
int dis[N];
void BFS(){
	int u =0;
	queue<int> q;
	q.push(u);
	flag[u] = VISITED;
	color_map[u] = 1;
	dis[u] = 0;
	while(!q.empty()){
		int u = q.front();q.pop();
		for(int i=0;i<(int)g[u].size();i++){
			int nx = g[u][i].first;
			int w = g[u][i].second;
			if(flag[nx] == UNVISITED){
				flag[nx] = VISITED;
				dis[nx] = dis[u] + w;
				if(dis[nx]%2 == 0)color_map[nx] = 1;
				else color_map[nx] =0;
				q.push(nx);
			}
		}
	}
}
int main(){
#if OPEN

	freopen("input.txt", "r", stdin);
#endif 
	int nv;
	cin>>nv;
	stringstream ss;
	string s;
	getline(cin, s);	//eat space

	while (getline(cin, s)) {
		ss << s;
		int u, v, w;
		//cin >> u >> v >> w;
		ss >> u;
		ss >> v;
		ss >> w;
		u = u - 1;
		v = v - 1;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
		ss.str("");
		ss.clear();
	}
	memset(flag,UNVISITED,sizeof(flag));
	BFS();
	for(int i=0;i<nv;i++)cout<<color_map[i]<<'\n';
	return 0;
}

Measured memory_bytes: 7552
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int main(){
    char ma[11][11];
    memset(ma,'0',sizeof(ma));
    for(int i=1;i<10;i++){
        if(i%2==1)
            for(int j=2;j<9;j+=2)
                cin>>ma[i][j];
        else
            for(int j=1;j<10;j+=2)
                cin>>ma[i][j];
    }
    int x=1,y=1,dir=0;
    int mv[4][2]={{2,0},{0,2},{-2,0},{0,-2}};
    int ts[4][8]={{1,-1,1,0,0,-1,0,1},{1,1,0,1,1,0,-1,0},{-1,1,-1,0,0,1,0,-1},{-1,-1,0,-1,-1,0,1,0}};
    string str[4]={"R","D","L","U"};
    string path="";
    int ch=0;
    for(int k=0;k<40;k++){
        int wen=1;
        while(ma[y+ts[dir][3]][x+ts[dir][2]]=='1'){
            y+=mv[dir][1];
            x+=mv[dir][0];
            wen=0;
            path+=str[dir];
            wen++;
           // cout<<x<<" "<<y<<"    "<<dir<<endl;
            if(ma[y+ts[dir][5]][x+ts[dir][4]]=='1'){
               // cout<<"dir: "<<dir<<"    "<<x<<" "<<y<<"   "<<x+ts[dir][4]<<"    "<<y+ts[dir][5]<<"     "<<ma[y+ts[dir][5]][x+ts[dir][4]]<<endl;
                break;
            }
        }
        if(x==1&&y==1)
            break;
       // cout<<x<<" "<<y<<"    "<<dir<<endl;
        if(ma[y+ts[dir][5]][x+ts[dir][4]]=='1')dir=(dir+3)%4;
        else do{
            dir=(dir+1)%4;
        }while((y+ts[dir][3]>10||y+ts[dir][3]<0||x+ts[dir][2]>10||x+ts[dir][2]<0)||ma[y+ts[dir][1]][x+ts[dir][0]]=='1');
        
    }
    cout<<path<<endl;
}
//RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
//RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
//RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL

Measured memory_bytes: 1192
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 110;
int cost[MAX_N][MAX_N], d[MAX_N];
bool used[MAX_N];
void dijkstra(int n)
{
    for(int i = 0; i <= n; i++) { d[i] = INF; used[i] = false; }
    d[0] = 0;
    while(true)
    {
        int v = -1;
        for(int u = 0; u < n; u++)
        {
            if(not used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if(v == -1) break;
        used[v] = true;
        for(int u = 0; u < n; u++) d[u] = min(d[u], d[v] + cost[v][u]);
    }
    for(int i = 0; i < n; i++) cout << i << " " << d[i] << endl;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++) cost[i][j] = INF;
    }
    for(int i = 0; i < n; i++)
    {
        int u, k; cin >> u >> k;
        for(int i = 0; i < k; i++)
        {
            int v, c; cin >> v >> c;
            cost[u][v] = c;
        }
    }
    dijkstra(n);
    return 0;
}



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

// void sort3(int *x,int *y, int *z){
//   int index;
//   if (*y > *z){
//     index = *y;
//     *y = *z;
//     *z = index;
//   }
//   if (*x > *y){
//     index = *x;
//     *x = *y;
//     *y = index;
//   }
//   if (*y > *z){
//     index = *y;
//     *y = *z;
//     *z = index;
//   }
// }
// 
// int main(){
//   int n;
//   string s;
//   cin >> n >> s;
//   //int ans = 0;
//   // REP(i,0,n-2)REP(j,i+1,n-1)REP(k,j+1,n){
//   //   if (s.at(i) != s.at(j) && s.at(i) != s.at(k)
//   //    && s.at(j) != s.at(k) && j-i != k-j){
//   //     ans++;
//   //   }
//   // }
//   vector<pair<char, int>> vec(n);
//   rep(i,(int)n){
//     vec.at(i).first = s.at(i);
//     vec.at(i).second = i;
//   }
//   sort(vec.begin(), vec.end());
//   int ei, sj, ej, sk;
//   rep(i,n-1){
//     //cout << vec.at(i).first << " " << vec.at(i).second << endl;
//     if (vec.at(i).first == 'B' && vec.at(i+1).first == 'G'){
//       ei = i;
//       sj = i + 1;
//     }
//     if (vec.at(i).first == 'G' && vec.at(i+1).first == 'R'){
//       ej = i;
//       sk = i + 1;
//     }
//   }
//   //printf("%d %d %d %d\n", ei, sj, ej, sk);
//   int ans = 0;
// 
//   for (int i=0; i<=ei; i++)for (int j=sj; j<=ej; j++)for (int k=sk; k<n; k++){
//     int x, y, z;
//     x = vec.at(i).second;
//     y = vec.at(j).second;
//     z = vec.at(k).second;
//     //printf("%d %d %d\n", x, y, z);
//     sort3(&x, &y, &z);
//     //printf("%d %d %d\n\n", x, y, z);
//     if (y - x != z - y){
//       ans++;
//     }
//   }
//   cout << ans << endl;
//   return 0;
// }

int main(){
  int n;
  string s;
  cin >> n >> s;
  vi vec(n);
  rep(i,n) vec.at(i) = (int)s.at(i) % 3;
  vi cnt(3);
  rep(i,n) cnt.at(vec.at(i))++;
  ll ans = 1;
  rep(i,3) ans *= cnt.at(i);
  rep(j,n)rep(i,j){
    int k = j + (j - i);
    if (k < n){
      if (s.at(i) == s.at(j)) continue;
      if (s.at(j) == s.at(k)) continue;
      if (s.at(i) == s.at(k)) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int MAX = 100000;
  vector<int> is_prime_list(MAX, 1);
  is_prime_list[0] = 0, is_prime_list[1] = 0;

  // エラトステネスのふるい
  for (int i = 2; i < MAX; i++) {
    if (!is_prime_list[i]) continue;
    for (int j = i * 2; j < MAX; j += i) is_prime_list[j] = 0;
  }

  // 2017に似た数のリストを作る
  vector<int> a(MAX, 0);
  for (int i = 0; i < MAX; i++) {
    if (i % 2 == 0) continue;
    if (is_prime_list[i] && is_prime_list[(i + 2) / 2]) a[i] = 1;
  }

  // 累積和
  vector<int> s(MAX + 1, 0);
  for (int i = 0; i < MAX; i++) s[i + 1] = s[i] + a[i];

  // 区間にある2017に似た数を出す
  int Q;
  cin >> Q;

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;

    // 終点(r)の値も含めるために + 1が必要
    int ans = s[r + 1] - s[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}
 
/* brownsands :Arpit */		

void solve()
{   int n,a,b,c;
    cin >> n;
    a=n/3;b=n/5;c=n/15;
    a=a*(a+1)*3;a=a/2;
    b=b*(b+1)*5;b=b/2;
    c=c*(c+1)*15;c=c/2;
    n=n*(n+1);n=n/2;
    n-=a+b;
    n+=c;
    cout << n;
}
signed main()
{ 
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int test=0,t;
  //  cin>>t;
    t=1;
   while(test++ <t){         
   	//cout<<"Case# "<<test<<": ";
        solve();}
  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  }


Measured memory_bytes: 3824
#include<iostream>


using namespace std;


int main() {


	int a, b;


	cin >> a >> b;

	if (a <= 5) {
		cout << 0 << endl;
		return 0;
	}
	else if (a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main()
{
    int a,b,h,m;
    long double rad1,rad2,rad,d;
    cin>>a>>b>>h>>m;
    rad2 = 2.0*PI*(long double)m * 6.0/360.0;
    rad1 = 2.0*PI*((long double)h * 30.0 + 0.5*(long double)m)/360.0;
    /*
    if(rad2>rad1)
    {
        if(rad2 - rad1 > PI)
        {
            rad = PI*2.0 - (rad2 - rad1);
        }else{
            rad = rad2 - rad1;
        }
    }else{
        if(rad1 - rad2 > PI)
        {
            rad = PI*2.0 - (rad1 - rad2);
        }else{
            rad = rad1 - rad2;
        }
    }
    if(rad == 0.0)
    {
        if(a>b)
        {
            d = (long double)(a-b);
        }else{
            d = (long double)(b-a);
        }
    }else if(rad == PI)
    {
        d = (long double)(a+b);
    }else{
        d = sqrt((long double)(a*a)+(long double)(b*b)-2.0*(long double)(a)*(long double)(b)*cosl(rad));
    }
    */
    rad = rad1 - rad2;
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

printf("%20.20Lf\n", sqrtl(rsq));
    // d = (long double)(a*a+b*b)-2.0*(long double)(2*a*b*cosl(rad));
    // cout<<sqrt(d)<<endl;
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  double a,b;
  cin >> a >> b;
  cout << ceil((a+b)/2.0) <<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s; cin >> s;
  int diff = 1000;
  for(int i=0; i<s.size()-2; i++) {
    int x;
  	x = (int)(s[i]-'0')*100+(int)(s[i+1]-'0')*10+(int)(s[i+2]-'0');
    diff = min(diff, abs(x-753));
  }
  cout << diff << endl;
  return 0;
}

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


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

    vector<int> ans(30, 0);
    for(int i = 0; i < n; i++)
    {
        vector<int> num(30, 0);
        string s;
        cin >> s;
        int len = s.size();
        for(int j = 0; j < len; j++)
        {
            int k = s[j] - 'a';
            num[k]++;
        }
        if(i == 0) ans = num;
        else
        {
            for(int k = 0; k < 26; k++)
            {
                ans[k] = min(ans[k], num[k]);
            }
        }
        
    }

    for(int i = 0; i < 26; i++)
    {
        int n = ans[i];
        for(int j = 0; j < n; j++)
        {
            cout << (char)(i+'a');
        }
        
    }
    
    cout << endl;
    
    
	return 0;
}

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

int main(){
  int A,B,X = 0;
  cin >> A >> B >> X;

  int C = 0;
  if(B*2<A){
    C = B*(X/500);
    if(X%500!=0)
      C += B;
  }else{
      C = A*(X/1000);
      if(X%1000!=0){
        if(X%1000>500 || B>A){
          C += A;
        }else{
          C += B;
        }
      }
  }

  cout << C << endl;
  return 0;
}



Measured memory_bytes: 3124
let solve n =
  let rec solve n max =
    if n = 0 then [[]]
    else
      let rec loop i acc =
        if i > (min n max) then acc
        else
          let cdrs = solve (n - i) i in
          let acc = List.rev_append
                      (List.rev_map (fun cdr -> i :: cdr) cdrs)
                      acc in
          loop (i + 1) acc in
      loop 1 [] in
  solve n n

let () =
  let rec loop () =
    let n = int_of_string @@ read_line () in
    if n = 0 then ()
    else
      let answers = solve n in
      List.iter
        (fun seq ->
         print_endline @@ String.concat " " @@ List.map string_of_int seq)
        answers;
      loop () in
  loop ()

Measured memory_bytes: 6064
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::VecDeque;
fn main() {
    input! {
    N:usize,
    M:usize,
    AB:[(Usize1,Usize1);M]
    }
    // 部屋iから繋がっている部屋のリスト
    let mut tonari: Vec<Vec<usize>> = vec![Vec::with_capacity(M); N];
    let mut ans: Vec<usize> = vec![N; N];
    for (a, b) in AB {
        tonari[a].push(b);
        tonari[b].push(a);
    }
    //    for i in 0..N {
    //        println!("{}={:?}", i, tonari[i]);
    //    }
    let mut nexts: VecDeque<usize> = VecDeque::new();
    nexts.push_back(0);
    while let Some(i) = nexts.pop_front() {
        //        println!("{}={:?}", i, tonari[i]);
        for &j in tonari[i].iter() {
            if ans[j] == N {
                ans[j] = i;
                nexts.push_back(j);
            }
        }
    }
    println!("Yes");
    for &j in ans.iter().skip(1) {
        println!("{}", j + 1);
    }
}


Measured memory_bytes: 16832
def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*q
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()

Measured memory_bytes: 90476
N, X, Y = map(int, input().split())

each_shortest_pathes = [0] * N
for i in range(1, N):
    for j in range(i + 1, N + 1):
        shortest_len = min(abs(j - i), abs(X - i) + 1 + abs(Y - j))
        each_shortest_pathes[shortest_len] += 1

for i in range(1, N):
    print(each_shortest_pathes[i])

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

int main()
{
    ll N, K; cin >> N >> K;
    vector<ll> A(N, 0);
    rep(i,N) {
        ll tmp; cin >> tmp;
        A[i] = tmp;
    }
#if 0
    vector<ll> T(K, 0);
    ll left = N - K - K + 1;
    left = 0;
    ll s = 1;
    rep(i,K) {
        s *= A[left+i];
    }
    vector<ll> R;
    R.push_back(s);
    for (int i=0; i < N-K; ++i) {
        s /= A[left+i];
        s *= A[left+i+K];
        R.push_back(s);
    }
#endif
    rep(i,N-K) {
        ll aa = A[i];
        ll bb = A[i+K];
//        cout << "aa = " << aa << ",bb = " << bb << endl;
        if (aa < bb) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }       
    }
    



}


Measured memory_bytes: 4832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

bool sqrt_check(long long n){
    if(n == int(pow(int(sqrt(n)), 2))) return true;
    else return false;
}

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<int> > X(N,vector<int>(D));
    rep(i,N){
        rep(j,D){
            cin >> X[i][j];
        }
    }
    int ans=0;
    rep(i,N-1){
        rng(j,i+1,N){
            int dist = 0;
            rep(k,D){
                dist += pow((X[i][k] - X[j][k]),2);
            }
            if(sqrt_check(dist)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

vector<l_l>fact(ll n){
    vector<l_l>v;
    for(ll i=2;i*i<=n;i++){
        ll c=0;
        if(n%i==0){
            while(n%i==0){
                n/=i;
                c++;
            }
            v.pb(l_l(i,c));
        }
    }
    if(n!=1)v.pb(l_l(n,1));
    return v;
}
ll len;
vector<l_l>v;
vector<ll>q;
void dfs(ll pos,ll val){
    if(pos==len){
        q.pb(val);return;
    }
    ll ne=val;
    rep(i,0,v[pos].second){
        dfs(pos+1,ne);
        ne*=v[pos].first;
    }
}

int main(){
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll sum=0;
    rep(i,0,n-1)sum+=a[i];
    v=fact(sum);
    len=v.size();
    dfs(0,1);
    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    //for(auto x:q)cout<<x<<" ";
    ll ans=1;
    for(auto x:q){
        vector<ll>mo;
        rep(i,0,n-1){
            if(a[i]%x==0)continue;
            mo.pb(a[i]%x);
        }
        sort(mo.begin(),mo.end());
        ll m=mo.size();
        if(m==0){
            Max(ans,x);continue;
        }
        ll b[m],c[m];
        b[0]=mo[0];
        rep(i,1,m-1)b[i]=b[i-1]+mo[i];
        rep(i,0,m-1)mo[i]=x-mo[i];
        c[m-1]=mo[m-1];
        for(ll i=m-2;i>=0;i--){
            c[i]=c[i+1]+mo[i];
        }
        
        rep(i,0,m-2){
            if(b[i]==c[i+1]){
                if(b[i]<=k){
                    Max(ans,x);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

















Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static long gozyohou(long a, long b) {
		if(b == 0) {
			return a;
		}else {
			return gozyohou(b, a%b);
		}
	}


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		//Tの最小公倍数を求めればいい

		long LeastCommonMultiple = sc.nextLong();

		for(int i = 1; i < N; i++) {
			long  k = sc.nextLong();
			LeastCommonMultiple = LeastCommonMultiple / gozyohou(LeastCommonMultiple,k) * k;
		}

		System.out.println((long) LeastCommonMultiple);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <queue>
#define INF 1e+18
#define int long long
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

signed main(){
	int n,m,k,s,p,q,a[200000],b[200000];
	int d[100000] = {};
	vector<int> vec[100000];
	vector<edge> G[100000];
	bool cant[100000] = {},danger[100000] = {};
	cin >> n >> m >> k >> s >> p >> q;
	queue<int> que;
	for(int i = 1;i < n;i++) d[i] = INF;
	for(int i = 0;i < k;i++){
		int c;
		cin >> c; c--;
		cant[c] = true;
		danger[c] = true;
		que.push(c);
	}
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
	}
	for(int i = 0;i < s;i++){
		int siz = que.size();
		for(int j = 0;j < siz;j++){
			int v = que.front();que.pop();
			for(int k = 0;k < vec[v].size();k++){
				if(!danger[vec[v][k]]){
					danger[vec[v][k]] = true;
					que.push(vec[v][k]);
				}
			}
		}
	}
	for(int i = 0;i < m;i++){
		if(a[i] > b[i]){
			int t = a[i];
			a[i] = b[i];
			b[i] = t;
		}
		if(!cant[b[i]]){
			if(b[i] == n - 1) G[a[i]].push_back({b[i],0});
			else if(danger[b[i]]) G[a[i]].push_back({b[i],q});
			else G[a[i]].push_back({b[i],p});
		}
		if(!cant[a[i]]){
			if(danger[a[i]]) G[b[i]].push_back({a[i],q});
			else G[b[i]].push_back({a[i],p});
		}
	}
	priority_queue<P,vector<P>,greater<P> > pque;
	pque.push(P(0,0));
	while(!pque.empty()){
		P pa = pque.top();pque.pop();
		int v = pa.second;
		if(d[v] < pa.first) continue;
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				pque.push(P(d[e.to],e.to));
			}
		}
	}
	cout << d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 28892
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int n, p;
int a[10005];
ll f[10005][2];
int main(){
	scanf("%d%d", &n, &p);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		a[i] &= 1;
	}
	f[0][0] = 1;
	for(int i = 1; i <= n; i ++){
		f[i][0] = f[i - 1][0];
		f[i][1] = f[i - 1][1];
		f[i][0] += f[i - 1][a[i] ^ 0];
		f[i][1] += f[i - 1][a[i] ^ 1];
	}
	printf("%lld\n", f[n][p]);
	return 0;
} 

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int w, h, a, b;

void main() {
    scan(h, w, a, b);

    auto c = ModCombo(w + h);

    long ans;

    foreach (i ; 0 .. h - a) {
        (ans += c.binom(b + i - 1, i) * c.binom(w + h - b - i - 2, h - i - 1) % c.mod) %= c.mod;
    }

    writeln(ans);
}


struct ModCombo {
    private {
        immutable long _mod;
        long[] _f;
        long[] _finv;

        long _powmod(long x, long y, long mod) {
            return y > 0 ? _powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
        }
    }

    @property {
        long mod() {return _mod;}
        long f(int n) {return _f[n];}
        long finv(int n) {return _finv[n];}
    }

    this (int N, long mod = 10^^9 + 7) {
        _mod = mod;
        _f = new long[](N + 1);
        _finv = new long[](N + 1);
        _f[0] = _finv[0] = 1L;

        foreach (i ; 1 .. N + 1) {
            _f[i] = i * _f[i - 1] % _mod;
        }

        _finv[N] = _powmod(_f[N], _mod - 2, _mod);

        foreach_reverse (i ; 1 .. N) {
            _finv[i] = (i + 1) * _finv[i + 1] % _mod;
        }
    }

    long perm(int n, int k) {
        return _f[n] * _finv[k] % _mod;
    }

    long binom(int n, int k) {
        return _f[n] * _finv[k] % _mod * _finv[n - k] % _mod;
    }

    long H(int n, int k) {
        if (n == 0 && k == 0) return 1L;
        return _f[n + k - 1] * _finv[k] % _mod * _finv[n - 1] % _mod;
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3964
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

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

  for (int i = 0; i < M; i++){
    cin >> A;
    N -= A;
    if(N < 0){
      cout << "-1" << endl;
      return 0;
    }
  }

  cout << N << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;
    cout << ((S == "ABC") ? "ARC" : "ABC");
    return 0;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    ll h, n;
    cin >> h >> n;
    ll a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];
    ll mn[100000] = {};
    fill(mn + 1, mn + 100000, 1e17);
    rep(i, n) rep(j, h + 1) if(mn[j] != 1e17) chmin(mn[j + a[i]], mn[j] + b[i]);
    for(int i = 100000 - 1; i; i--)
        chmin(mn[i - 1], mn[i]);
    cout << mn[h] << endl;
}

Measured memory_bytes: 1024