akhauriyash/Code-Regression huggingface dataset:
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func test(flags uint64, i uint64) bool {
	return (flags & (1 << i)) != 0
}
func set(flags uint64, m uint64) uint64 {
	// fmt.Fprintf(wtr, "set(%08b,%08b) en:\n", flags, m)
	return flags | m
}
func clear(flags uint64, m uint64) uint64 {
	// fmt.Fprintf(wtr, "clear(%08b,%08b) en:\n", flags, m)
	return flags & ^m
}
func flip(flags uint64, m uint64) uint64 {
	// fmt.Fprintf(wtr, "flip(%08b,%08b) ex: %08b\n", flags, m, flags^m)
	return flags ^ m
}
func all(flags uint64, m uint64) bool {
	//fmt.Fprintf(wtr, "all(%08b, %08b) en:\n", flags, m)
	return (flags & m) == m
}
func any(flags uint64, m uint64) bool {
	//fmt.Fprintf(wtr, "any(%08b, %08b) en:\n", flags, m)
	return (flags & m) != 0
}
func none(flags uint64, m uint64) bool {
	//fmt.Fprintf(wtr, "none(%08b, %08b) en:\n", flags, m)
	return (flags & m) == 0
}
func count(flags uint64, m uint64) uint64 {
	//fmt.Fprintf(wtr, "count(%08b, %08b) en:\n", flags, m)
	cnt := uint64(0)
	flags &= m
	for i := 0; i < 64; i++ {
		if (flags & (1 << uint64(i))) != 0 {
			cnt++
		}
	}
	return cnt
}

var wtr = bufio.NewWriter(os.Stdout)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	masks := make([]uint64, n)
	for i := 0; i < n; i++ {
		k := nextInt(sc)
		for j := 0; j < k; j++ {
			b := nextInt(sc)
			masks[i] |= (1 << uint64(b))
		}
		// fmt.Fprintf(wtr, "masks[%d] -> %08b\n", i, masks[i])
	}
	var flags uint64
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		op := nextInt(sc)
		x := uint64(nextInt(sc))
		if op == 0 || op == 1 || op == 2 || op == 3 {
			if op == 0 {
				if test(flags, x) {
					fmt.Fprintln(wtr, 1)
				} else {
					fmt.Fprintln(wtr, 0)
				}
			} else if op == 1 {
				flags = set(flags, masks[x])
			} else if op == 2 {
				flags = clear(flags, masks[x])
			} else {
				//flags = flip(flags, masks[x])
				flags ^= masks[x]
			}
		} else if op == 4 {
			if all(flags, masks[x]) {
				// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "all", op, 1)
				fmt.Fprintln(wtr, 1)
			} else {
				// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "all", op, 0)
				fmt.Fprintln(wtr, 0)
			}
		} else if op == 5 {
			if any(flags, masks[x]) {
				//fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "any", op, 1)
				fmt.Fprintln(wtr, 1)
			} else {
				// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "any", op, 0)
				fmt.Fprintln(wtr, 0)
			}
		} else if op == 6 {
			if none(flags, masks[x]) {
				// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "none", op, 1)
				fmt.Fprintln(wtr, 1)
			} else {
				// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "none", op, 0)
				fmt.Fprintln(wtr, 0)
			}
		} else if op == 7 {
			// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "count", op, count(flags, masks[x]))
			fmt.Fprintln(wtr, count(flags, masks[x]))
		} else {
			// fmt.Fprintf(wtr, "q[%d] op %q(%d) ans %d\n", i, "val", op, flags&masks[x])
			fmt.Fprintln(wtr, flags&masks[x])
		}
	}
	wtr.Flush()
}



Measured memory_bytes: 4016
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final long MOD = (long) (Math.pow(10, 9) + 7);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);
        long ans = 1;
        if (n % 2 == 0) {
            long even = -1;
            for (int i = 0; i < n; i += 2) {
                even += 2;
                int temp1 = ary[i];
                int temp2 = ary[i + 1];
                if (temp1 != even || temp2 != even) {
                    System.out.println(0);
                    return;
                }
            }
        } else {
            if (ary[0] != 0) {
                System.out.println(0);
                return;
            }
            long odd = 0;
            for (int i = 1; i < n; i += 2) {
                odd += 2;
                int temp1 = ary[i];
                int temp2 = ary[i + 1];
                if (temp1 != odd || temp2 != odd) {
                    System.out.println(0);
                    return;
                }
            }
        }
        for (int i = 0; i < (n / 2); i++) {
            ans = (2 * ans) % MOD;
        }
        System.out.println(ans);
    }
}

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

int main(){

    while(1){
        int x, y, s; cin >> x >> y >> s;
        if(x == 0) break;
        int ans = 0;
        for(int i = 1; i < 1010; i++){
            for(int j = 1; i + j < 1010; j++){
                if(i*(100 + x) / 100 + j * (100 + x) / 100 == s){
                    ans = max(ans, i*(100 + y) / 100 + j * (100 + y) / 100);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let r = read!(i64);
    println!("{}", r * r)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    set<int> arr[n];
    int t,j;
    for(int x=0;x<n;x++)
    {  cin>>t;
        for(int y=0;y<t;y++)
        {   cin>>j;
            arr[x].insert(j);
        }
    }
    int ans=0;
    for(int x=1;x<=m;x++)
    {  bool k=true;
        for(int y=0;y<n;y++)
        {
            if(arr[y].find(x)==arr[y].end())
                k=false;
        }
        if(k)
          ++ans;
    }
    cout<<ans;
}


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

int s[400], l[400], p[400];
int dp[400][400];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d%d", &s[i], &l[i], &p[i]);
	rep(i, n)rep(j, 400) {
		if (j && !dp[i][j] && !dp[i + 1][j])continue;
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		for (int k = s[i]; k <= l[i] && j + k < 400; k++)
			dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i + 1][j] + p[i]);
	}
	int m; scanf("%d", &m);
	vector<int>v;
	rep(i, m) {
		int w; scanf("%d", &w);
		if (dp[n][w] == 0) { puts("-1"); return 0; }
		v.push_back(dp[n][w]);
	}
	for (int i : v)printf("%d\n", i);
}

Measured memory_bytes: 3832
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
import numpy as np
import bisect

N , Z ,W = input().split()
N = int(N)
Z = int(Z)
W = int(W)
a = input().split()
a = [int(i) for i in reversed(a)]

if N == 1 : 
    print(np.abs(W - a[0]))
else : 
    rst = [ np.abs(W - a[0]) , np.abs(a[1] - a[0]) ]
    print(np.max(rst))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll dp[104][100005];

int main() {
  ll n, ans = 0, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j - w[i] >= 0)
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      else
        dp[i + 1][j] = dp[i][j];
    }
  }

  cout << dp[n][W] << endl;
  return 0;
}


Measured memory_bytes: 79360
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);

  int n;
  cin >> n;

  vector<int> as(3 * n);
  for (auto &a : as)
    cin >> a;

  sort(as.rbegin(), as.rend());

  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    ans += as[i * 2 + 1];
  }

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


Measured memory_bytes: 1408
n=int(input())
c1=c2=c3=c4=0
for i in range(n):
 x=input()
 if x=="AC":
  c1+=1
 elif x=="WA":
  c2+=1
 elif x=="TLE":
  c3+=1
 elif x=="RE":
  c4+=1
print("AC x "+str(c1))
print("WA x "+str(c2))
print("TLE x "+str(c3))
print("RE x "+str(c4))

Measured memory_bytes: 8940
import java.util.Scanner;

public class Main {

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

		int Arrays[][] = new int[r + 1][c + 1];

		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				Arrays[i][j] = scan.nextInt();
			}
		}

		for (int i = 0; i < c; i++) {
			for (int j = 0; j < r; j++) {
				Arrays[j][c] += Arrays[j][i];

			}
		}

		for (int i = 0; i < r; i++) {
			for (int j = 0; j <= c; j++) {
				Arrays[r][j] += Arrays[i][j];
			}
		}



		for (int i = 0; i <= r; i++) {
			for (int j = 0; j <= c; j++) {
				System.out.print(Arrays[i][j]);
				if(j != c) {
					System.out.print(" ");
				}else {

				}
			}
			System.out.println();
		}

		scan.close();
	}

}



Measured memory_bytes: 42712
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll 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() {
  IOS;
  ll a,b,ans=0;
  cin>>a>>b;
  while(a<=b){
    ans++;
    a*=2;
  }
  cout<<ans<<endl;
}

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


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


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
int n, A[100];
cin >> n;
for(int i=1;i<=n;i++){cin >> A[i];
}
for(int i=n; i>=1;i--){cout << A[i];
if(i==1)break;
cout << " ";}
cout << endl;
return 0;
}


Measured memory_bytes: 3100
s=[0 for i in range(60)]
def totwo(x):
  return [int(x&(2**i)>0) for i in range(60)]

n=int(input())
a=list(map(lambda x:totwo(int(x)),input().split()))

d=[a[0][i] for i in range(60)]
for i in range(1,n):
  for j in range(60):
    if a[i][j]:
      s[j]+=i-d[j]
    else:
      s[j]+=d[j]
    d[j]+=a[i][j]

ss=0
r=1
mod=10**9+7
for i in range(60):
  ss=(ss+r*s[i])%mod
  r=(r*2)%mod
print(ss)



Measured memory_bytes: 256752
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> sum(n+1);
    sum[0] = 0;
    map<ll, ll> mp;
    mp[0] = 1;
    rep(i, n) {
        sum[i+1] = (sum[i]+a[i]) % m;
        ++mp[sum[i+1]];
    }
    ll ans = 0;
    for ( auto p : mp ) {
        ans += p.second * (p.second - 1 ) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

ll dp[3010][3010];
ll a[3010];

int N;

ll rec(int i, int j){

  if(dp[i][j] != INF ) return dp[i][j];

  if((N - (j - i)) % 2 == 0){

    if(i >= j) return -INF;
    if(i < 0) return -INF;
    if(j > N) return -INF;

    ll res = max(rec(i, j-1) + a[j-1], rec(i+1, j) + a[i]);
    return dp[i][j] = res;

  }else{

    if(i >= j) return INF;
    if(i < 0) return INF;
    if(j > N) return INF;
    ll res = min(rec(i, j-1) - a[j-1], rec(i+1, j) - a[i]);
    return dp[i][j] = res;

  }

}


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

  cin >> N;

  rep(i, N){
    cin >> a[i];
  }

  rep(i, N+1){
    rep(j, N+1){
      dp[i][j] = INF;
    }
  }

  rep(i, N){
    if(N % 2 == 0){
      dp[i][i+1] = -a[i];
    }else{
      dp[i][i+1] = a[i];
    }
  }

  cout << rec(0, N) << endl;


  return 0;
}


Measured memory_bytes: 71040
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 30;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

struct Edge{
    int to, cost;
};
int N, K, C[10000], R[10000];
std::vector<Edge> G[10000], G_[10000];
int d[10000], used[10000];

void dijkstra(int s){
    std::fill(used, used+10000, 0);
    std::fill(d, d+10000, INF);

    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push(mp(0, s));
    d[s] = 0;

    while(!q.empty()){
        P p = q.top(); q.pop();
        int cost = p.first, u = p.second;
            
        if(d[u] < cost){continue;}

        used[u] = 1;

        REP(j, G[u].size()){
            Edge e = G[u][j];
            int v = e.to;

            if(!used[v] && cost + e.cost <= R[s] && d[v] > cost + e.cost){
                q.push({cost+e.cost, v});
                d[v] = cost + e.cost;
                    
                G_[s].push_back({v, C[s]});
            }
        }
    }
}

int dijkstra2(int s, int g){
    std::fill(used, used+10000, 0);
    std::fill(d, d+10000, INF);
    
    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push(mp(0, s));
    d[s] = 0;

    while(!q.empty()){
        P p = q.top(); q.pop();
        int cost = p.first, u = p.second;
            
        if(d[u] < cost){continue;}

        used[u] = 1;

        REP(j, G_[u].size()){
            Edge e = G_[u][j];
            int v = e.to;

            if(!used[v] && d[v] > cost + e.cost){
                q.push({cost+e.cost, v});
                d[v] = cost + e.cost;
            }
        }
    }

    return d[g];
}

int main(){
    std::cin >> N >> K;
    
    REP(i, N){
        std::cin >> C[i] >> R[i];
    }
    
    REP(i, K){
        int from, to;
        std::cin >> from >> to;
        from--; to--;

        G[from].push_back({to, 1});
        G[to].push_back({from, 1});
    }

    REP(i, N){
        dijkstra(i);
    } 

    std::cout << dijkstra2(0, N-1) << std::endl;
}

Measured memory_bytes: 126612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

const int maxn=10000;
const int inf=(1<<20);

int n;
vector<pair<int,int> > adj[maxn];

void Dijkstra(){
    priority_queue<pair<int,int> > PQ;
 //   int color[maxn];
    bool vis[maxn];
    int d[maxn];
    for(int i=0;i<n;i++){
        d[i]=inf;
     //   color[i]=white;
        vis[i]=false;
    }

    d[0]=0;
    PQ.push(make_pair(0,0));
 //   color[0]=gray;
  //  vis[0]=1;

    while(!PQ.empty()){
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;

      //  color[u]=black;
        vis[u]=true;

        if(d[u]<f.first*(-1))   continue;

        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(vis[v]==true) continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
    // priority_queue priority_queue 默认优先较大值， 因此要乘以-1。
                PQ.push(make_pair(d[v]*(-1),v));
              //  vis[v]=true;这句不能加
              //  color[v]=gray;
            }
        }
    }

    for(int i=0;i<n;i++){
        printf("%d %d\n",i,(d[i]==inf?-1:d[i]));
    }
}

int main(){
    int k,u,v,c;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(int j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            adj[u].push_back(make_pair(v,c));
        }
    }

    Dijkstra();

    return 0;
}



Measured memory_bytes: 3464
import java.util.*;
 
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    //カーテンの長さを求める
    int BB = B*2;
    
    if(A <= BB){
      //カーテンの方が長い場合は全て隠れるので0
      System.out.println(0);
    }else{
      //カーテンの方が短い場合は隠れていない長さを求める
       System.out.println(A-BB);
    }
  }
      
 }

Measured memory_bytes: 23124
#include <iostream>
#include <queue>
#include <map>
#include <cstring>
using namespace std;

typedef pair<string, int> P;

int bfs(string worm){
  queue<P> que;
  que.push(P(worm, 0));

  map<string, int>  d;

  while(!que.empty()){
    P p = que.front();
    que.pop();

    if(d[p.first])  continue;

    string str = p.first;

    bool flag = true;
    for(int i = 0; i < str.size()-1; i++){
      if(str[i] != str[i+1]){
        flag = false;
        break;
      }
    }

    if(flag) return p.second;

    d[p.first] = p.second;

    for(int i = 0; i < str.size()-1; i++){
      if(str[i] != str[i+1]){
        string next;
        char tmp;
        if(str[i] != 'b' && str[i+1] != 'b'){
          tmp = 'b';
        }else if(str[i] != 'g' && str[i+1] != 'g'){
          tmp = 'g';
        }else{
          tmp = 'r';
        }

        next = str;
        next[i] = next[i+1] = tmp;
        que.push(P(next, p.second+1));
      }
    }
  }
  return -1;
}

int main(){
  string worm;
  while(cin >> worm && worm != "0"){
    int ans = bfs(worm);
    if(ans >= 0)  cout << ans << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int n, k;
vector<int> x, y;
vector<char> c;
/**********************************************/

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

    cin >> n >> k;
    x.resize(n);
    y.resize(n);
    c.resize(n);
    REP(i, n) cin >> x[i] >> y[i] >> c[i];
    REP(i, n) if(c[i] == 'W') x[i] += k;
    REP(i, n) {
        x[i] %= 2*k;
        y[i] %= 2*k;
    }

    vector<vector<int>> imos(2*k + 5, vector<int>(2*k + 5, 0));
    REP(i, n){
        imos[x[i]+1][y[i]+1]++;
    }

    FOR(i, 1, 2*k+1) FOR(j, 1, 2*k+1) imos[i][j] += imos[i-1][j];
    FOR(i, 1, 2*k+1) FOR(j, 1, 2*k+1) imos[i][j] += imos[i][j-1];
    
    int ans = -INF;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int a = imos[i][j];
            int b = imos[i+k][j+k] - imos[i][j+k] - imos[i+k][j] + imos[i][j];
            int c = imos[2*k][j] - imos[i+k][j];
            int d = imos[i][2*k] - imos[i][j+k];
            int e = imos[2*k][2*k] - imos[2*k][j+k] - imos[i+k][2*k] + imos[i+k][j+k];
            ans = max(ans, max(a+b+c+d+e, n-(a+b+c+d+e)));
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 16896
s=input()
t=input()
n=len(t)
m=len(s)
dp=[[0]*(n+1) for i in range(m+1)]
for i in range(m):
  for j in range(n):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1

    else:
      dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

        
kotae = []
 
while(i >= 0 and j >= 0):
    if(dp[i+1][j+1] == dp[i][j+1]):
        i -= 1
    elif(dp[i+1][j+1] == dp[i+1][j]):
        j -= 1
    else:
        i -= 1
        j -= 1
        kotae.append(s[i+1])


kotae.reverse()
kotae = "".join(kotae)
print(kotae)
    

Measured memory_bytes: 112348
#include <iostream>

using namespace std;

const int maxn = 1e5+10;

int a[maxn][3];
int dp[maxn][3];
int n , ans , maxx;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 0)
                dp[i][j] = a[i][j] + max(dp[i-1][1] , dp[i-1][2]);
            if (j == 1)
                dp[i][j] = a[i][j] + max(dp[i-1][0] , dp[i-1][2]);
            if (j == 2)
                dp[i][j] = a[i][j] + max(dp[i-1][0] , dp[i-1][1]);
        }
    }
    cout << max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2])) << endl;
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s;

	if(s[0]=='9' || s[1]=='9'){
        cout<<"Yes"<<endl;
	}
	else {
        cout<<"No"<<endl;
	}



}


Measured memory_bytes: 256
ac = 0
wa = 0
tle = 0
re = 0

num = int(input())

while(num>0):

	tipo = input().upper()
	
	if(tipo == "AC"): ac+=1
	elif(tipo == "WA"): wa+=1
	elif(tipo == "TLE"): tle+=1
	elif(tipo == "RE"): re+=1
	
	num-=1

print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(ac,wa,tle,re))

Measured memory_bytes: 9044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>


using namespace std;

const double PI = 3.14159265358979;

int G[101][101];
int visited[101];
int n;

int d[101];
int p[101];

void dijkstra(int startpoint) {

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

	d[startpoint] = 0;

	while (true) {

		int minx = INT_MAX;
		int u = -1;
		for (int i = 0; i < n; i++)	{
			if (!visited[i] && minx > d[i]) {
				minx = d[i];
				u = i;
			}
		}
		if (u == -1) break;

		visited[u] = 1;
		
		for (int i = 0; i < n; i++)	{
			if (!visited[i] && G[u][i] < INT_MAX) {
				if (d[u] + G[u][i] < d[i]) {
					d[i] = d[u] + G[u][i];
					p[i] = u;
				}
			}
		}
	}
}

int main() {
	
	
	cin >> n;
	for (int i = 0; i < n; i++)	{
		for (int j = 0; j < n; j++) {
			G[i][j] = INT_MAX;
		}
	}

	for (int i = 0; i < n; i++)	{
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++)	{
			int v, w; cin >> v >> w;
			G[u][v] = w;
		}
	}

	dijkstra(0);

	for (int i = 0; i < n; i++)	{
		cout << i << " " << d[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, ans = 0, min = 200000;
    cin >> N;
    vector<int> p(N);
    for (int i = 0, L; i < N; i++) {
        cin >> L;
        if (L <= min) {
            ans++;
            min = L;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]




n, w = li()
l = []
for i in range(n):l.append(li())

l.sort()

knapsack = [0] * (w + 1)
for i in l:
    for j in range(w - i[0], -1, -1):
        if not j or knapsack[j]:
            knapsack[j + i[0]] = max(knapsack[j + i[0]], knapsack[j] + i[1])

print(max(knapsack))


Measured memory_bytes: 69264
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M,*f = map(int, open(0).read().split())
AB = [f[i*2:i*2+2] for i in range(M)]
uf = UnionFind(N)
for A,B in AB:
    uf.union(A-1,B-1)
print(min(uf.parents)*(-1))

Measured memory_bytes: 57144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  int h,m,se;
  scanf("%d",&s);
  h=s/3600;
  m=s%3600/60;
  se=s%3600%60;
  printf("%d:%d:%d\n",h,m,se);
  return 0;
}

Measured memory_bytes: 3208
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private void solve() throws IOException {

        int N = nextInt();

        long MOD = 1_000_000_007;
        long[] cnt = new long[1001];
        long p = 1L;
        for(int i = 2; i <= N; ++i) {
            int z = i;
            for(int q = 2; q * q <= z; ++q) {
                if(z % q == 0) {
                    int c = 0;
                    while(z % q == 0) {
                        z /= q;
                        ++c;
                    }
                    cnt[q] += c;
                }
            }
            if(z > 1) {
                cnt[z]++;

            }
        }
        for(int j = 1; j <= 1000; ++j) {
            if(cnt[j] > 0) {
                p *= (cnt[j] + 1);
                p %= MOD;
            }
        }
        writer.println(p);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    //    BufferedReader reader2;
    StringTokenizer tokenizer;
    PrintWriter writer;
    //    BufferedWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
//            reader = new BufferedReader(new FileReader("highcard.in"));
            //            reader2 = new BufferedReader(new FileReader("1.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
//            writer = new     PrintWriter("highcard.out");
//                                                    writer = new BufferedWriter(System.out);
            //                        writer = new BufferedWriter(new OutputStreamWriter(System.out));
            solve();
            reader.close();
            //            reader2.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    short nextShort() throws IOException {
        return Short.parseShort(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }

        return tokenizer.nextToken();
    }

}

Measured memory_bytes: 8020
#include <cstdio>

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    char s[n+1];
    scanf("%s", s);
    s[k-1] = s[k-1] - ('A' - 'a');
    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll X; cin >> X;
  
  ll ans = 0;
  for (ll i = 0; i < 1e5; i++) {
    if (i*(i+1) >= 2*X) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> a >> b; 
    cout << a+b/2 <<endl;
    return 0;
} 

Measured memory_bytes: 256
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int main()
{
    //std::ios::sync_with_stdio(false);
    int A,B;
    scanf("%d%d", &A, &B);
    printf("%d\n",(A+B)%24);
    //system("pause");
}


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

int main() {
  bool flag=true;
  int n,m;
  cin >> n >> m;
  int a[3]={-1,-1,-1};
  r(i,m){
    int s,c;
    cin >> s >> c;
    if(a[s-1]!=-1&&a[s-1]!=c)flag=false;
      a[s-1]=c;
  }
  if(!flag)cout<<-1<<endl;
  else {
    if(n==1){
      if(a[0]==-1)cout<<0<<endl;
      else cout<<a[0]<<endl;
    }
    else if(n==2){
      if(a[0]==0)cout<<-1<<endl;
      else {
        if(a[0]==-1)cout<<1;
        else cout<<a[0];
        if(a[1]==-1)cout<<0<<endl;
        else cout<<a[1]<<endl;
      }
    }
    else{
      if(a[0]==0)cout<<-1<<endl;
      else {
        if(a[0]==-1)cout<<1;
        else cout<<a[0];
        if(a[1]==-1)cout<<0;
        else cout<<a[1];
        if(a[2]==-1)cout<<0<<endl;
        else cout<<a[2]<<endl;
      }
    }
  }
}

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

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < 20; ++i)
  {
    for (int j = 0; j < 30; ++j)
    {
      if (7 * i + 4 * j == n)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>
#include <unordered_map>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

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(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N);
  unordered_map<ll,int>gcd;
  REP(i,N)cin>>A[i];
  REP(i,N){
    unordered_map<ll,int> mp=prime_factor(A[i]);
    for(auto e:mp){
      gcd[e.first]=max(gcd[e.first], e.second);
    }
  }
  ll ans=0ll, l=1ll;
  for(auto e:gcd){
    ll f=e.first;
    ll s=e.second;
    l*=RepeatSquaring(f, s, MOD);
    l%=MOD;
  }
  REP(i,N){
    ans+=l*modinv(A[i],MOD)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

int main(){
  string s;
  int num=1;
  cin >> s;
  rep(i,s.size()){
    if(s.at(i)!=s.at(s.size()-1-i)){
      cout << "No";
      return 0;
    }
  }
  
  rep(j,(s.size()-1)/2){
    if(s.at(j)!=s.at((s.size()-1)/2-1-j)){
      cout << "No";
      return 0;
    }
  }
  
  for(int k = (s.size()+3)/2-1; k < s.size(); k++){
    if(s.at(k)!=s.at(s.size()-num)){
      cout << "No";
      return 0;
    }
    num++;
  }
  
  cout << "Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
 
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;
 

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    
    SORT(a);
    SORT(b);
    
    if (n%2 == 1){
        cout << b[n/2] - a[n/2] + 1;
        return;
    }
    
    ll smallx2  = a[n/2] + a[n/2-1];
    ll bigx2  = b[n/2] + b[n/2-1];
    
    cout << (bigx2 - smallx2 + 1);
    
    
}


 
int main(){
    int T;
    T = 1;
    while(T--){
        solve(); 
    }
}
 


Measured memory_bytes: 6428
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

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

var bigint = new(big.Int)
var zero = big.NewInt(0)

func gcd(a, b *big.Int) *big.Int {
	for b.Cmp(zero) != 0 {
		t := b
		b = a.Mod(a, b)
		a = t
	}
	return a
}

func lcm(arr ...big.Int) *big.Int {
	if len(arr) < 2 {
		panic("error")
	}
	mul := big.NewInt(0)
	result := big.NewInt(0)
	mul.Mul(&arr[0], &arr[1])
	result.Div(mul, gcd(&arr[0], &arr[1]))

	for i := 2; i < len(arr); i++ {
		result = lcm(*result, arr[i])
	}

	return result
}

func main() {
	N := nextInt()
	if N == 1 {
		num, _ := bigint.SetString(nextLine(), 10)
		fmt.Println(num)
	} else {
		arr := make([]big.Int, N)
		i := 0
		for i < N {
			arr[i].SetString(nextLine(), 10)
			i++
		}
		fmt.Println(lcm(arr...))
	}
}


Measured memory_bytes: 640
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n";
using namespace std;
//-------------------------------------------

int main(void){
  ll A,B,C;cin>>A>>B>>C;
  ifYN( (A==B&&A!=C)||
      (A!=B&&B==C)||
     (A==C&&C!=B));
  return 0;
}


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

int w,h;
int sx,sy,gx,gy;
int n,c,d,x,y;
int g[200][200];
bool use[200][200];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

void rec(int Y,int X, char c){
  if(use[Y][X])return;
  use[Y][X] = true;

  for(int i=0;i<4;i++){
    int ny = Y+dy[i], nx = X+dx[i];
    if(ny<1 || nx<1 || ny>h || nx>w)continue;
    if(g[ny][nx] == c)rec(ny,nx,c);
  }
}

int main(){
  while(cin >> w >> h,w||h){
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	g[i][j] = 0;
	use[i][j] = false;
      }
    }

    cin >> sx >> sy >> gx >> gy >> n;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
      if(d==0){
	for(int j=0;j<2;j++){
	  for(int k=0;k<4;k++){
	    g[y+j][x+k] = c;
	  }
	}
      }else{
	for(int j=0;j<4;j++){
	  for(int k=0;k<2;k++){
	    g[y+j][x+k] = c;
	  }
	}
      }
    }

    if(!g[sy][sx] || !g[gy][gx] || g[sy][sx] != g[gy][gx]){
      cout << "NG\n";
    }else{
      rec(sy,sx,g[sy][sx]);
      cout << (use[gy][gx]?"OK":"NG") << endl;
    }
  }
}

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

int main() {
  int r,g,b;
  cin >>r >>g >>b;
  if((100*r+10*g+b)%4==0){
    cout <<"YES" <<endl;
  }
  else{
    cout <<"NO" <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

max = 0
sum = 0
1.upto(n-1) do |i|
  aa = a[i] - a[i-1]
  sum += aa
  max = aa if aa > max
end
aa = a[0] + k - a[-1]
max = aa if aa > max


puts k - max

Measured memory_bytes: 15876
using static System.Console;

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var n = int.Parse(ReadLine());
			char x;
			if(n < 1000)
			{
				x = 'C';
			}
			else
			{
				x = 'D';
			}
			WriteLine("AB"+x);
		}
	}
}


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

int main(){
    int a,b;
    while (true){
        cin>>a>>b;
        for(int t=0;t<a;t++){
            for(int h=0;h<b;h++){
                if(t%2==0){
                    if(h%2==0){
                        cout<<"#";
                         
                        
                    }else{
                        cout<<".";
                    
                        
                  
                    }
                        
                    }else{
                     if(h%2==0){
                        cout<<".";
                         
                        
                        }else{
                        cout<<"#";
                        }
                        
                    }
                
             if(h==b-1){
                 cout<<endl;
                        }
            }
            
             
                 
                        
        }
    if(a==0&&b==0){
        break;
    }    
               
 
                 cout<<endl;
                           
    
        
    }
}


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

int main() {
	int n,accnt=0,wacnt=0,tlecnt=0,recnt=0;
	cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	for(int i=0;i<n;i++){
		if(s[i]=="AC"){
			accnt++;
		}else if(s[i]=="WA"){
			wacnt++;
		}else if(s[i]=="TLE"){
			tlecnt++;
		}else{
			recnt++;
		}
	}
	cout << "AC x " << accnt << endl;
	cout << "WA x " << wacnt << endl;
	cout << "TLE x " << tlecnt << endl;
	cout << "RE x " << recnt << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<pair<ll, ll> > ch(m);
  int b, c;
  for (int i = 0; i < m; i++) {
    cin >> b >> c;
    ch[i].first = c;
    ch[i].second = b;
  }

  sort(v.begin(), v.end());
  sort(ch.rbegin(), ch.rend());

  int count = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < ch[i].second; j++) {
      if (count >= v.size()) break;
      if (ch[i].first > v[count]) {
        v[count] = ch[i].first;
      }
      count++;
    }
  }

  cout << accumulate(v.begin(), v.end(), 0ll) << endl;
}


Measured memory_bytes: 2560