akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(void) {

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    vector<pair<int, int>> s(n);
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        s[i] = make_pair(str[0] - 'A', str[1] - 'A');
    }

    vector<int> variable({ a,b,c });

    vector<char> output(n);
    for (int i = 0; i < n; i++) {
        int u = s[i].first;
        int v = s[i].second;
        if (variable[u] == variable[v]) {
            if (variable[u] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (i == n - 1) {
                output[i] = 'A' + u;
                variable[u]++;
                variable[v]--;
            }
            // u,vの得点が等しく、最終回でない場合は、次の回をみて、参加する方を+する。
            int nextU = s[i + 1].first;
            int nextV = s[i + 1].second;
            if (u == nextU || u == nextV) {
                output[i] = 'A' + u;
                variable[u]++;
                variable[v]--;
            }
            else {
                output[i] = 'A' + v;
                variable[u]--;
                variable[v]++;
            }
        }
        else if (variable[u] < variable[v]) {
            output[i] = 'A' + u;
            variable[u]++;
            variable[v]--;
        }
        else if (variable[u] > variable[v]) {
            output[i] = 'A' + v;
            variable[u]--;
            variable[v]++;
        }
    }

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

    return 0;

}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          for(int i=1;i<=a[1];i++){
            if(a[0]*i%a[1] == a[2]) { Out("YES"); return; }
          }
          
          
          Out("NO");
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#define out(a) printf("%d",a)
#define ll long long
using namespace std;
int n;
int a[1000];
int num,b; 
int read()
{
	int s=0,t=1; char ch;
	while (ch<'0'||ch>'9'){if (ch=='-') t=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){s=s*10+ch-'0'; ch=getchar();}
	return s*t;
}
int main()
{
	n=read();
	while (n>0){
		if (n%10==9) b=1;
		n=n/10;
		if (b==1) break;
	}
	if (b==1) puts("Yes");
	else puts("No");
}

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

/*
dp[i][j] = w ;  w is the min weight with which
		you can get total value j using the first
		i items...
*/
public class Main {

    private static int n;
    private static long c;
    private static long[] w, v;
    private static long[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        c = sc.nextLong();
        w = new long[n + 1];
        v = new long[n + 1];
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            w[i] = sc.nextLong();
            v[i] = sc.nextLong();
            sum += v[i];
        }
        dp = new long[n + 1][sum + 1];

        System.out.println(findknapsack(sum));

    }

    private static long findknapsack(int sum) {
        for (int i = 0; i <= sum; i++) {
            dp[0][i] = 1000 * 1000 * 1000;
        }

        for (int i = 0; i <= n; i++) {
            dp[i][0] = 0;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= sum; j++) {
                if (v[i] <= j) {
                    dp[i][j] = Math.min(w[i] + dp[i - 1][j - (int) v[i]], dp[i - 1][j]);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        long ans = 0;
        for (int i = 0; i <= sum; i++) {
            if (dp[n][i] <= c) {
                ans = Math.max(i, ans);
            }
        }
        return ans;
    }

}

Measured memory_bytes: 125652
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<b;i++)
#define per(i,a,b) for(register int i=b;i>=a;i--)
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long LL;
typedef pair<LL,LL> Pair;
typedef vector<LL> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INF=0x3f3f3f3f3f3f3f3f;
int main()
{
	char ch=getchar();
	(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') && cout<<"vowel"<<endl;
	!(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') && cout<<"consonant"<<endl;
	return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, l, fl;
string s, t, ss;
int main(){
	cin >> s >> t;
	for(int i=s.size()-1;i+2>t.size();i--){
		ss=s;
		fl=0;
		for(int j=0;j<t.size();j++){
			if(s[i-j]=='?'){
				ss[i-j]=t[t.size()-1-j];
				fl=1;
			}else if(s[i-j]==t[t.size()-1-j]){
				fl=1;
			}else{
				fl=0;
				break;
			}
		}
		if(fl==1){
			for(int i=0;i<s.size();i++){
				if(ss[i]=='?')ss[i]='a';
			}
			cout << ss << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	
	return 0;
}

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

int main() {
   int a, b;
   cin >> a >> b;

   cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll mod=1e9+7;
ll n,k,t,a[100000],b[100000],ans[100000],res;
vector<vector<int>> Tree;

void dfs(ll x,ll color,ll dep,ll p){
  ans[x]=color;
  ll t;
  if(dep==0) t=k-1;
  else t=k-2;
  for(auto i:Tree[x]){
    if(i==p) continue;
    dfs(i,t,dep+1,x);
    t--;
  }
}

int main(){
  cin >> n >> k;
  Tree.assign(n,vector<int>());
  for(ll i=0;i<n-1;i++){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    Tree[a[i]].push_back(b[i]);
    Tree[b[i]].push_back(a[i]);
  }
  dfs(0,k,0,-1);
  res=1;
  for(ll i=0;i<n;i++){
    res=res*ans[i]%mod;
    //cout << ans[i] << " ";
  }
  cout << res << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())

int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    int n,m;
    cin >>  n >> m; 
    vector<int> vec(n+1);
    vector<int> wa(n+1);

    REP(i,n+1){
        vec[i] = 0;
        wa[i] = 0;
    }
    int answa = 0;
    int x;
    string s;
    int ac = 0;
    REP(i,m){
        cin >> x >> s;
        if(s == "WA" && vec[x] == 0){
            wa[x] ++;
        }else if(s == "AC" && vec[x] == 0){
            ac ++;
            vec[x] = 1;
            answa += wa[x];
        }
    }

    cout << ac <<" "<< answa <<endl;
}





Measured memory_bytes: 1024
h, w = map(int, input().split())
g = []
for i in range(h):
    g.append(list(input()))

def check(i, j):
    if g[i][j] == '.':
        return True
    lis = [[-1, 0], [0, -1], [0, 1], [1, 0]]
    f = 0
    for k in lis:
        rh = i + k[0]
        rw = j + k[1]
        if 0 <= rh <= h - 1 and 0 <= rw <= w - 1:
            if g[rh][rw] == '#':
                return True
    if f == 0:
        return False

for i in range(h):
    for j in range(w):
        if not check(i, j):
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    cout.precision(10);
    cout << fixed;
    if (N%2 == 0) {
        cout << 0.5 << endl;
    } else {
        cout << double(N/2+1)/N << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int a;
    cin>>a;
    cout<<"ABC"<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int A, B;
    int answer;
    double smallA, smallB;
    double x, y;

    cin >> A >> B;

    answer = (100.0 / 8.0) * A;
    smallA = modf(answer * 0.08, &x);
    smallB = modf(answer * 0.1, &y);

while(true) {

    smallA = modf(answer * 0.08, &x);
    smallB = modf(answer * 0.1, &y);

    if (x == A && y == B) {
        cout << answer << endl;
        break;
    }

    if (y > B) {
        printf("-1\n");
        break;
    }

    answer++;
    //printf("x = %lf y = %lf\n", x, y);
}

    return 0;
}

Measured memory_bytes: 888
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 T = sc.nextInt();
      int sum = (T/A)*B;
      System.out.println(sum);
    }
}

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

public class Main{

    static Node root;
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int n=Integer.parseInt(br.readLine());

	for(int i=0;i<n;i++){
	    String str[]=br.readLine().split(" ");
	    
	    if(str[0].equals("insert")){
		int x=Integer.parseInt(str[1]);
		insert(x);
	    }else{
		inorder(root);
		System.out.println();
		preorder(root);
		System.out.println();
	    }
	}
    }
    
    static void insert(int key) {
	Node y = null;
	Node x = root;
	Node z = new Node(key);
	while (x != null) {
	    y = x;
	    if (z.key < y.key) {
		x = x.left;
	    } else {
		x = x.right;
	    }
	}
	if (y == null) {
	    root = z;
	} else if (z.key < y.key) {
	    y.left = z;
	} else {
	    y.right = z;
	}
    }
    
    static void inorder(Node u){
	if(u==null){
	    return;
	}
	inorder(u.left);
	System.out.print(" "+u.key);
	inorder(u.right);
    }

    
    static void preorder(Node u) {
	if (u == null)
	    return;
	System.out.print(" " + u.key);
	preorder(u.left);
	preorder(u.right);
    }
}

class Node{

    Node parent;
    Node left;
    Node right;

    int key;
    
    public Node(int key){
	this.key=key;
    }
    
}



Measured memory_bytes: 149492
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a = 1, b = 2, c = 3;

    if(x == 2) {
      x = a;
    } else if(x == 4 || x == 6 || x == 9 || x == 11) {
      x = b;
    } else {
      x = c;
    }
    if(y == 2) {
      y = a;
    } else if(y == 4 || y == 6 || y == 9 || y == 11) {
      y = b;
    } else {
      y = c;
    }

    if(x == y) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


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

using namespace std;
long long mx=-1e17;
vector<long long>v;
vector<vector<long long> >dp(2e5+5,vector<long long>(3,-1ll));
vector<vector<long long> >dpvs(2e5+5,vector<long long>(3,0));
int n;
int cnt=0;
long long slv(int idx,int rmm,long long ttl=0ll){
    cnt++;
    int mv=idx-(((n%2)?2:1)-rmm);
    mv/=2;
    mv++;
    ///cout <<idx<< ' '<< rmm<< ' '<< ttl << endl;
    if(dpvs[idx][rmm]!=0)
        return dp[idx][rmm];
    long long ret=-1e17;
    if(mv==n/2){
        ret=max(ret,v[idx]);
        if(rmm)
            ret=max(ret,slv(idx+1,rmm-1));
        return ret;
    }
    if(idx>=n){
        return (long long)-1e17;
    }
    ret=max(ret,slv(idx+2,rmm)+v[idx]);
    if(rmm)
        ret=max(ret,slv(idx+1,rmm-1));
    dpvs[idx][rmm]=1;
    return dp[idx][rmm]=ret;
}
int main()
{
    cin>>n;
    v=vector<long long>(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    cout << slv(0,(n%2)?2:1) << endl;
    ///cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 34384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b;
  cin >> a >> b;
  int x=b-a,sum=0;
  rep(i,x){
    sum+=i;
  }
  cout << sum-b << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc155/tasks/abc155_a

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    set<int> s;
    s.emplace(a);
    s.emplace(b);
    s.emplace(c);

    if(s.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

class Main{

    static int dp[][][] = new int[301][301][301];

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        int K = scan.nextInt();
        int N = S.length();

        //dp[i][j][x]:[i,j)でx以下使ったときの最大
        for(int i=0;i<N;++i)for(int k=0;k<=K;++k){
            dp[i][i+1][k]=1;
            dp[i][i][k]=0;
        }
        for(int k=0;k<=K;++k){
            for(int L=2;L<=N;++L){
                int i=0,j=L;
                while(j<=N){
                    if(k==0)dp[i][j][k]=Math.max(dp[i+1][j][k],
                                        Math.max(dp[i][j-1][k],
                                        ((S.charAt(i)==S.charAt(j-1) ? dp[i+1][j-1][k]+2 : dp[i+1][j-1][k]))));
                    else dp[i][j][k] = Math.max(dp[i+1][j][k],
                                       Math.max(dp[i][j-1][k],
                                       Math.max(dp[i][j][k-1],
                                       ((S.charAt(i)==S.charAt(j-1) ? dp[i+1][j-1][k]+2 : dp[i+1][j-1][k-1]+2)))));
                    ++i;++j;
                }
            }
        }
        System.out.println(dp[0][N][K]);
    }
}

Measured memory_bytes: 169228
#include <stdio.h>

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


Measured memory_bytes: 2132
#include <iostream>
using namespace std;
int main() {
  int a_hp, a_atk, b_hp, b_atk;
  cin >> a_hp >> a_atk >> b_hp >> b_atk;
  while (a_hp > 0 && b_hp > 0){
    b_hp -= a_atk;
    if (b_hp <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a_hp -= b_atk;
    if (a_hp <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>

using namespace std;

int prime[60000];

void makeprimechart(void);

int main(){

  makeprimechart();

  int n, max, min;

  while(cin >> n){

    for(int i = n+1; i < 60000; i++){
      if(prime[i] == 1){
	max = i;
	break;
      }
    }
    
    for(int i = n-1; i > 1; i--){
      if(prime[i] == 1){
	min = i;
	break;
      }
    }
    
    cout << min << " " << max << endl;
  } 
  return 0;
  
}


void makeprimechart(void){

  for(int i = 0; i < 60000; i++){
    prime[i] = 1;
  }

  prime[0] = 0;
  prime[1] = 0;


  for(int i = 2; i < sqrt(60000); i++){
    if(prime[i] == 1){
      for(int j = i * 2; j < 60000; j+=i){
	prime[j] = 0;
      }
    }
  }
}

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

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
const long long INF = 1e9;

int main()
{
  int n; cin >> n;
  vector<vector<int> > active(n, vector<int>(3));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){ //A:1, B:1, C:2
      cin >> active[i][j];
    }
  }

  //dp[n][0 or 1 or 2] 最終日に3つのうちどれかを選んだ際の最大値
  vector<vector<ll> > dp(n + 1, vector<ll>(3, 0));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if(j == k) continue;
        chmax(dp[i + 1][j], dp[i][k] + active[i][j]);
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++)
  {
    chmax(ans, dp[n][i]);
  }
  cout << ans << endl;   
}


Measured memory_bytes: 11136
using System;
namespace D
{
    class Dmondai
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            for(int i=0;i<n;i++){
                a[i] = int.Parse(Console.ReadLine());
            }
 
            int s = 0;
            for(int i=0;i<n;i++){
                s += a[i];
            }
 
            long[,] dp = new long[n+1,s+1];
            long[,] dp2 = new long[n+1,s+1];
            dp[0,0] = 1;
            dp2[0,0] = 1;
 
            for(int i=1;i<n+1;i++){
                for(int j=0;j<s+1;j++){
                    if (j+a[i-1] <= s){
                        dp[i,j+a[i-1]] += dp[i-1,j];
                        dp2[i,j+a[i-1]] += dp2[i-1,j];
                        dp[i,j+a[i-1]] %= 998244353;
                        dp2[i,j+a[i-1]] %= 998244353;
                    }
                    dp[i,j] += dp[i-1,j]*2;
                    dp2[i,j] += dp2[i-1,j];
                    dp[i,j] %= 998244353;
                    dp2[i,j] %= 998244353;
                }
            }
 
            long ans = 1;
            for(int i=0;i<n;i++){
                ans *= 3;
                ans %= 998244353;
            }
            for(int i=(s+1)/2;i<s+1;i++){
                ans -= dp[n,i]*3;
                ans %= 998244353;
                if(ans<0){
                    ans += 998244353;
                }
            }
            
 
            if(s%2==0){
                ans += dp2[n,s/2] * 3;
            }
 
            Console.WriteLine((ans%998244353).ToString());
        }
    }
}

Measured memory_bytes: 431320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w= scanner.nextInt();
        int[][] arr = new int[n+1][2];
        for(int i = 1 ;i<=n ;++i){
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
        }
        long[][] dp = new long[n+1][w+1];
        for(int i = 1 ; i<=n ; ++i){
            for(int j = 0 ; j<=w ; ++j){
                if(arr[i][0]<=j){
                    dp[i][j] = Math.max(dp[i-1][j],arr[i][1]+dp[i-1][j-arr[i][0]]);
                }else{
                    dp[i][j] =dp[i-1][j];
                }
            }
        }
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 140268
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
LL A[100000];
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	partial_sum(A, A + N, A);

	int i = N - 1;
	while (A[i] <= A[i - 1] * 3 && i > 0) {
		--i;
	}
	cout << N - i << endl;

	return 0;
}

Measured memory_bytes: 1024
import heapq

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = list(map(lambda x: int(x) * -1 , input().split(' ')))
    heapq.heapify(prices)
    for _ in range(num_coupon):
        max_price = heapq.heappop(prices) // (2*-1)
        heapq.heappush(prices, max_price*-1)

    print(sum(prices)*-1)

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)


Measured memory_bytes: 14180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
#include<utility>
#include<tuple>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define brep(i,n) for (int i=n-1;i>=0;i--)
#define LL long long int
 
 /* 
 greater<int>() 
 sortの第三因数に入れて降順 
sqrt(double) √を求める 
pair<int,int> x=make_pair(a,b)
x.first
tuple  get<番目>(変数名)

stack<int> s;//いきどまり
s.push(x) //先頭に入れる
s.pop() //先頭を消す
s.top() //先頭にアクセス
s.empty() //中身があれば0,空なら1
s.size() //中身の数

queue <int> q;//一方通行
q.push(x) //先頭に入れる
q.pop() //先頭を消す
q.front() //先頭にアクセス
q.empty() //中身があれば0,空なら1
q.size() //中身の数

 */
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}

int main(){
    int n;
    cin >>n;
    vector<double>v(n);
    rep(i,n){
        cin >>v[i];
    }
    sort(v.begin(),v.end());
    double ans =v[0];
    Rep(i,n-1){
        ans=(ans+v[i])/2;
      
    }
    cout <<ans<<endl;
    return 0;


}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int> a(5);
    rep(i,5){
        cin >> a[i];
    }
    int k;
    cin >> k;
    if(a[4]-a[0]<=k){
        cout << "Yay!";
    }
    else{
        cout << ":(";
    }

    

    return 0;
}

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

using namespace std;

int main(){
    double a, b, x, h, Ha, v, tg, rez, y;
    cin>>a>>b>>x;
    v=a*a*b;
    Ha=x/(a*a);
    h=b-Ha;
    if(v<=2.0*x) rez=90-atan2(a/2,h)*180/acos(-1);
    else{
        y=(2.0*x)/(b*a);
        rez=atan2(b,y)*180/acos(-1);
    }
    cout<<fixed<<setprecision(10)<<rez;
    return 0;
}

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

int main() { 
  vector<int> p(5);
  for(int i = 0; i < 5; i++) {
    cin >> p.at(i);
  }
  int k;
  cin >> k;
  
  bool flag = false;  
  for (int l = 0; l < 4; l++) {
    for (int r = l+1; r < 5; r++) {
      if (p.at(r)-p.at(l) > k) {
        cout << ":(" << endl;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  if (!flag)
    cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#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 = 1001001001;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if (c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> i_i;
int main(){
  int n,w,d;
  int b,c;
  cin >> n >> w >> d;
  while(n!=0||w!=0||d!=0){
    vector<i_i> v;
    i_i x;
    i_i a1,a2;
    x.first=w;x.second=d;
    v.push_back(x);
    for(int i=0;i<n;i++){
      cin >> b >> c;
      x=v[b-1];
      //cout << x.first <<":"<<x.second<<endl;
      v.erase(v.begin()+b-1);
      int k=c%(x.first+x.second);
      if(k<x.first){
	if(k<=x.first/2){
	  a1.first=k;a1.second=x.second;
	  a2.first=x.first-k;a2.second=x.second;
	}else{
	  a1.first=x.first-k;a1.second=x.second;
	  a2.first=k;a2.second=x.second;
	}
      }else{
	k-=x.first;
	if(k<=x.second/2){
	  a1.first=x.first;a1.second=k;
	  a2.first=x.first;a2.second=x.second-k;
	}else{
	  a1.first=x.first;a1.second=x.second-k;
	  a2.first=x.first;a2.second=k;
	}
      }
      //cout << a1.first <<":"<<a1.second<<endl;
      //cout << a2.first <<":"<<a2.second<<endl;
      v.push_back(a1);
      v.push_back(a2);
    }
    vector <int> s;
    for(int i=0;i<v.size();i++){
      //cout << v[i].first <<":"<<v[i].second<<endl;
      s.push_back(v[i].first*v[i].second);
    }
    sort(s.begin(),s.end());
    cout << s[0];
    for(int i=1;i<s.size();i++){
      cout << " " << s[i];
    }
    cout << endl;
    cin >> n >> w >> d;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;

/**************************************************************************/
/*vector < ll > graph[5001];
ll C[5001][5001],ans,child[5001],n;
const ll mod = 1e9+7,modi2=500000004;
void ncr()
{
	ll i,j;
	Fo(i,1,5001){C[i][0] = C[i][i] = 1;C[i][1] = i;}
	Fo(i,2,5001)
	{
		Fo(j,2,i)
		{
			C[i][j] = ((C[i-1][j] + C[i-1][j-1])%mod+mod)%mod;
		}
	}
}
void dfs(ll node, ll parent)
{
	child[node] = 1;
	for(ll x:graph[node])
	{
		if(x==parent)continue;
		dfs(x,node);
		child[node] += child[x];
	}
}
void dfs2(ll node, ll parent)
{
	for(ll x:graph[node])
	{
		if(x==parent)continue;
		dfs2(x,node);
		if(child[x]%2==0 and child[x]!=0)
		{
			ans = ((ans - C[child[x]][child[x]/2] * C[n-child[x]][(n-child[x])/2])
			       %mod+mod)%mod;
		}
	}
}
int main()
{
	fastIO;
	ncr();
	ll t,i,j,k;
	ans=0;
	cin>>n;
	ans = C[n][n/2];
	fo(i,n+1)child[i]=0;
	fo(i,n-1)
	{
		cin>>j>>k;
		graph[j].pb(k);
		graph[k].pb(j);
	}
	dfs(1,0);
	dfs2(1,0);
	cout<<ans;

}*/
/*************************************************************************/ 

int main()
{
	ll n,k,a[100001],i,j,ans=1e9+7;
	cin>>n>>k;
	fo(i,n)cin>>a[i];
	i=0;
	while(i+k<=n)
	{
		ll val = a[i+k-1]-a[i];
		if(a[i]<0 and a[i+k-1]<0)val=abs(a[i]);
		if(a[i]<0 and a[i+k-1]>0)val=min(abs(2*a[i])+a[i+k-1],abs(a[i])+2*a[i+k-1]);
		if(a[i]>0 and a[i+k-1]>0)val=abs(a[i+k-1]);
		ans = min(ans,val);
		i++;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
package main

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

var (
	N, K int
	ind  int
	ans  int
)

func main() {
	readVariables()
	left := ind
	right := N - ind - 1
	div := K - 1
	answer := (left + div - 1) / div
	if left%div != 0 {
		right = MaxInt(right-(div-left%div), 0)
	}
	answer += (right + div - 1) / div
	fmt.Println(answer)
}

func readVariables() {
	N, K = nextInt(), nextInt()
	for i := 0; i < N; i++ {
		if nextInt() == 1 {
			ind = i
		}
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 1792
import sys
mod = 1000000007
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def input(): return sys.stdin.readline()
def main():
    a = int(input())
    s = input()
    print(s if a >= 3200 else 'red')
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/*
 
 Author: @ygyash

*/

#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

ll minll(ll a, ll b)
{
    return a < b ? a : b;
}
ll maxll(ll a, ll b)
{
    return a > b ? a : b;
}


int main() {
   
    #ifndef ONLINE_JUDGE    
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif    

    string s;cin>>s;
    ll cnt = 0;
    ll ans = 0;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            cnt++;
        }
        else if(s[i]=='S'){
            ans = max(cnt,ans);
            cnt =0;
        }
    }
    ans= max(cnt,ans);

    cout<<ans<<endl;
}

Measured memory_bytes: 3620
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	_, s := getInt(), getString()
	out(strings.Count(s, "ABC"))
}


Measured memory_bytes: 1776
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
d = defaultdict(int)
for i in s:
    d[i] += 1

dsort = sorted(d.items(), key=lambda x : x[1], reverse=True)
ans = []
tmp = dsort[0][1]
for i, v in dsort:
    if tmp == v:
        ans.append(i)

ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 47664
def main():
    t = int(input())
    for _ in range(t):
        nn, aa, s, r, mm = int(input()), list(map(int, input().split())), input(), 0, []
        for ii in range(nn-1, -1, -1):
            ai = aa[ii]
            mm += [[(ai >> jj) & 1 for jj in range(64)]]
            n, i, j = r+1, 0, 0
            while i < n and j < 64:
                if mm[i][j] == 1 and mm[n-1][j] == 0:
                    i += 1
                    j += 1
                    continue
                if mm[i][j] == 0:
                    if mm[n-1][j] != 0:
                        for l in range(j, 64):
                            mm[i][l] ^= mm[n-1][l]
                    else:
                        j += 1
                        continue
                M2 = mm[i]
                for k in range(i+1, n):
                    M3 = mm[k][j]
                    mm[k][j] = 0
                    for l in range(j+1, 64):
                        mm[k][l] ^= M3*M2[l]
                i += 1
                j += 1
    
            if s[ii] == "0":
                if i > r:
                    r += 1
                else:
                    mm.pop()
            else:
                mm.pop()
                if i > r:
                    print(1)
                    break
        else:
            print(0)


main()


Measured memory_bytes: 72956
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = 1e16;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	ll l = 0, r = INT32_MAX;
	while (r - l - 1) {
		ll mid = (r + l) / 2;
		ll cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += (a[i] - 1) / mid;
		}
		if (cnt <= k) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	cout << r;
}

Measured memory_bytes: 4784
#include<iostream>
using namespace std;
long long gcd(long long a, long long b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int t;
    long long a,s=1;
    cin >> t;
    while(t--){
        cin>>a;
        s=s/gcd(s,a)*a;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,q;
    cin>>n>>q;
    int x,y,z;
    
    dsu uf(n);
    rep(i,q){
        cin>>x>>y>>z;
        if(x) cout<<uf.same(y,z)<<endl;
        else  uf.merge(y,z);
    }

}/*
./problem.exe
*/

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

int main() {
    string s; cin >> s;
    int Q; cin >> Q;
    bool rev = false;
    string top,bottom;
    rep(i,Q) {
        int q; cin >> q;
        if(q == 1) {
            rev = !rev;
        }else{ 
            int f; cin >> f;
            string c; cin >> c;
            if(f == 1){
                if(!rev){  
                    top = c + top;
                }else{
                    bottom += c;
                }
            }else{
                if(!rev){
                    bottom += c;
                }else{
                    top = c + top;
                }
            }
        }
    }
    string ans = top + s + bottom;
    if(rev) reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <queue>

using namespace std;
typedef long long ll;

queue<int> que;

void Search(int n, vector<list<int>> &e, vector<int> &ok, vector<ll> &ans) {
	ok[n] = false;
	for (auto itr = e[n].begin(); itr != e[n].end(); itr++) {
		if (ok[*itr]) {
			que.push(*itr);
			ans[*itr] += ans[n];
		}
	}
	if (que.empty())
		return;
	n = que.front();
	que.pop();
	Search(n, e, ok, ans);
	return;
}

int main(void) {
	int num, q, i, a, b;
	cin >> num >> q;
	vector<list<int>> e(num + 1);
	vector<int> ok(num + 1, true);
	vector<ll> ans(num + 1, 0);
	for (i = 0; i < num - 1; i++) {
		scanf("%d%d", &a, &b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for (i = 0; i < q; i++) {
		scanf("%d%d", &a, &b);
		ans[a] += b;
	}
	Search(1, e, ok, ans);
	for (i = 1; i <= num; i++)
		printf("%lld ", ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 20992
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
const int mod=1e9+7;
int h,w,a,b,ans=0LL;
int gt[300053],mgt[300053];
int binpow(int a,int n){
	if(n==0) return 1;
	if(n==1) return a;
	int m=binpow(a,n/2)%mod;
	if(n%2==0) return m*m%mod;
	else return (m*m)%mod*a%mod;
}
int c(int k,int n){
	return (gt[n]*mgt[k]%mod)*mgt[n-k]%mod;
}

signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	gt[0]=1;
	mgt[0]=1;
	for(int i=1;i<=300050;i++){
		gt[i]=gt[i-1]*i%mod;
		mgt[i]=binpow(gt[i],mod-2);
	}
	cin>>h>>w>>a>>b;
	for(int i=1;i<=h-a;i++){
	 	ans+=c(i-1,b-1+i-1)*c(h-i,h-i+w-b-1)%mod;
		ans%=mod;
	}
	cout<<ans;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    int N; cin>>N;
    vii A(N,vi(N,2));
    rep(i,0,N){
        int X; cin>>X;
        rep(j,0,X){
            int Y,Z; cin>>Y>>Z;
            A[i][Y-1]=Z;
        }
    }
    int ans=0;
    rep(i,0,(1ll<<N)){
        bitset<15> B(i);
        bool flag=1;
        rep(j,0,N){
            if(B.test(j)){
                rep(k,0,N){
                    if(A[j][k]==0){
                        if(B.test(k)) flag=0;
                    }
                    else if(A[j][k]==1){
                        if(!B.test(k)) flag=0;
                    }
                }
            }
        }
        int X=B.count();
        if(flag) ans=max(ans,X);
    }
    cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  bool f[100]={false};
  for(int i=1;;i++){
    int d=(a*i)%b;
    if(f[d]==true){
      cout<<"NO"<<endl;
      break;
    }
    if(d==c){
      cout<<"YES"<<endl;
      break;
    }
    f[d]=true;
  }
}

Measured memory_bytes: 256
main = do
  li <- getLine
  let n = read li
  let ans = compute n
  print ans

compute :: Int -> Int
compute n
 | n < 10 = n
 | n < 100 = 9
 | n < 1000 = 9 + n - 99
 | n < 10000 = 9 + 900
 | n < 100000 = 9 + 900 + n - 9999
 | otherwise = 9 + 900 + 90000


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 1e5 + 10;
pii a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (abs(i - a[i].S) & 1) {
            ans++;
        }
    }
    cout << ans / 2 << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4444