akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll n,cnt=0;
ll a[N],f[N];
bool prime[N];
string s1,s2;
int main() {
 //   freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    ll t, i, j = 0;
    ll m, x, y,k;
    memset(prime,true,sizeof(prime));
    for(i=2;i<=N;i++){
        if(prime[i]){
            for(j=i*2;j<=N;j+=i) prime[j]=false;
        }
    }
    cin>>n;
    for(i=0;i<n;i++) {
        cin>>x;
        if(prime[x]) f[x]++;
        else{
            for(j=2;j<=sqrt(x);j++){
                if(x%j==0) f[j]++;
                while(x%j==0) x/=j;
            }
            f[x]++;
        }
    }
    bool f1=true,f2=true;
    for(i=2;i<=N;i++){
        if(f[i]>1) f1=false;
        if(f[i]>=n) f2=false;
    }
    if(f1) cout<<"pairwise coprime";
    else if(f2) cout<<"setwise coprime";
    else cout<<"not coprime";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 12404
n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
ans = 0

def dfs(n, point):
    for m in L[n]:
        if point[m] == 1:
            continue
        else:
            point[m] = 1
            dfs(m, point)

for i in range(m):
    L = [[] for _ in range(n + 1)]
    point = [0]*(n+1)

    for j in range(len(list_AB)):
        a = list_AB[j][0]
        b = list_AB[j][1]
        if i != j:
            L[a].append(b)
            L[b].append(a)
    point[1] = 1
    dfs(1, point)

    if sum(point) != n:
        ans += 1

print(ans)

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

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

  int n, high=0;
  cin >> n;
  vi h(n);
  rep(i, n)cin >> h[i];

  int ans=0;
  rep(i, n){
    int cnt=0;
    rep(j, i)if(h[i]>=h[j])cnt++;
    if(cnt==i)ans++;
  }

  cout << ans << endl;

  return 0;
}

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

namespace Contest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var p = new ProbremA();
            p.Run();
        }
    }

    internal class ConsoleOutput
    {
        public void Print<T>(T target)
        {
            Console.WriteLine(target.ToString());
        }

        public void PrintList<T>(IEnumerable<T> targets)
        {
            var results = targets.Select(obj => obj.ToString());
            Console.WriteLine(string.Join(" ", results));
        }
    }

    internal class ConsoleInput
    {
        private bool testMode = false;

        private List<string> testInput = new List<string>{
            "cupofcoffee",
            "cupofhottea",
        };

        #region Impl

        public int GetInt()
        {
            return int.Parse(Get());
        }

        public List<int> GetIntList()
        {
            return Get().Split(' ').Select(obj => int.Parse(obj)).ToList();
        }

        public string GetString()
        {
            return Get();
        }

        private string Get()
        {
            if (testMode)
            {
                var result = testInput[0];
                testInput.RemoveAt(0);
                return result;
            }

            return Console.ReadLine();
        }

        #endregion Impl
    }

    internal class ProbremA
    {
        private ConsoleInput input = new ConsoleInput();
        private ConsoleOutput output = new ConsoleOutput();

        public void Run()
        {
            var s = input.GetString();
            var t = input.GetString();
            int diffCount = 0;

            for (int i = 0; i < s.Length; ++i)
            {
                if (s[i] != t[i])
                {
                    ++diffCount;
                }
            }

            output.Print($"{diffCount}");
        }
    }

}

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

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

  int64_t a, b;
  for (int i = sqrt(n); i > 0; i--) {
    if (n % i == 0) {
      a = n / i;
      b = n / a;
      break;
    }
  }

  cout << a + b - 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;


int main() {

int N;

cin >>N;

int a;

int ans=0;

for(int i=0; i<N; i++){
cin >>a;
ans=ans+a-1;
}

cout <<ans;


}



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

vector<string> v(3);
bool okmr[3][3][7000]={};

void fill(string x, string y, bool f[]){
	for(int i=0; i<x.size(); ++i){
		f[i]=1;
		for(int j=0; j<y.size() && i+j<x.size(); ++j){
			f[i]=f[i]&&(x[i+j]==y[j] || x[i+j]=='?' || y[j]=='?');
		}
	}
}

int solve(int x, int y, int z){
	int res=7000;
	for(int i=0; i<=v[x].size(); ++i){
		if(i==v[x].size() || okmr[x][y][i]){
			for(int j=0; j<=v[y].size() || i+j<=v[x].size(); ++j){
				if(j>=v[y].size() || okmr[y][z][j]){
					if(i+j>=v[x].size() || okmr[x][z][i+j]){
						res=min(res, int(max({v[x].size(), i+v[y].size(), i+j+v[z].size()})));
						break;
					}
				}
			}
		}
	}
	return res;
}

int main() {
	for(int i=0; i<3; ++i) cin >> v[i];
	for(int i=0; i<3; ++i){
		for(int j=0; j<3; ++j){
			if(i!=j){
				fill(v[i], v[j], okmr[i][j]);
			}
		}
	}
	int ans=7000;
	for(int i=0; i<3; ++i){
		for(int j=0; j<3; ++j){
			if(i!=j){
				ans=min(ans, solve(i, j, 3-i-j));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
  int n,a,i,j,k,ans=0;

  scanf("%d",&n);

  char s[n];
    scanf("%s",s);

  int f1,f2,f3;

  for(a=0; a<1000; a++){

    f1 = a / 100;
    f2 = (a - f1*100) /10;
    f3 = a % 10;

    int fla = 0;

    for(i=0; i<n-2; i++)
    {
      if(s[i] - '0' == f1)
      {
      fla++;
      break;
      }
    }

    if(fla == 0)
      continue;

    for(j=i+1; j<n-1; j++)
    {
      if(s[j] - '0' == f2)
      {
      fla++;
      break;
      }
    }

    if(fla == 1)
      continue;

    for(k=j+1; k<n; k++)
    {
      if(s[k] - '0' == f3)
      {
      ans++;
      break;
      }
    }

  }

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


Measured memory_bytes: 1756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int a, b;
char c;

int main(){
	cin >> a >> c >> b;
	if (c == '+')cout << a + b << endl;
	else cout << a - b << endl;
}

Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
ab=[]
for _ in [0]*n:
    ai,bi=[int(x) for x in input().split()]
    ab.append((ai,bi))
ans=0
ab=sorted(ab,key=lambda x :x[0])
for a,b in ab:
    if b>=m:
        ans+=m*a
        break
    else:
        ans+=a*b
        m-=b
print(ans)

Measured memory_bytes: 18724
PROGRAM-ID.                      ABC_050_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(23).
    01 A       PIC 9(10).
    01 op      PIC X(1).
    01 B       PIC S9(10).
    01 ans     PIC X(10).

    01 ZS      PIC -(10)9.
    01 DUMMY   PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A op B.

    IF op = '+' THEN
        ADD A TO B
    ELSE
        SUBTRACT B FROM A GIVING B
    END-IF.

    MOVE B TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


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

using namespace std;

int main()
{
    
    int n,k;
    cin>>n>>k;
    int j=0;
     int c=0,sum=0;
        int arr[n],b[100000];
    while(k--)
    {
        int d;
        cin>>d;
       
        for(int i=0;i<d;i++)
        {
            cin>>arr[i];
            b[j]=arr[i];
            j++;
        }
    
     }   sort(b,b+j);
        for(int i=0;i<j;i++)
        {
         //   cout<<b[i]<<" ";
        }
       
        for(int s=1;s<=n;s++)
        {
        for(int i=0;i<j;i++)
          {
            if(s!=b[i])
            {
                c++;
                 if(c==j)
                {
                    sum++;
                }
                
            }
            
          }
         
               c=0;
        }
    
     cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3652
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

vector<vector<ll>> connect;
vector<vector<ll>> dp;

void update(ll v, ll d, ll i) {
    if (dp[v][d] != -1) {
        return;
    }

    dp[v][d] = i;

    if (d == 0) {
        return;
    }

    update(v, d - 1, i);
    for (auto next : connect[v]) {
        update(next, d - 1, i);
    }
}

int main() {
    ll N, M;
    cin >> N >> M;

    connect.resize(N);

    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }

    ll Q;
    cin >> Q;

    vector<ll> v(Q), d(Q), c(Q);
    for (ll i = 0; i < Q; i++) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    dp.assign(N, vector<ll>(11, -1));

    for (ll i = Q - 1; i >= 0; i--) {
        update(v[i], d[i], i);
    }

    for (ll i = 0; i < N; i++) {
        assert(dp[i][0] == -1 || (0 <= dp[i][0] && dp[i][0] < Q));
        cout << (dp[i][0] == -1 ? 0 : c[dp[i][0]]) << endl;
    }
}

Measured memory_bytes: 20980
#include<iostream>
using namespace std;
int main(){
  
  int a,b,s=0;
 cin>>a>>b;
 for (int i=0;i<2;i++){
  if(a>=b){
    s+=a;
    a--;
  }else{
    s+=b;
    b--;
 }
  
 }   
  cout<<s<<endl;
  
  
     
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<stack> 
#include<bitset>
#include<iterator>
using namespace std;


int n,m;
bitset<10000> maps[11];
int ans;


void dfs(int line){
    if(line == n){
        int tmp = 0;
        for(int i = 0 ; i < m ; i ++){
            int rownum = 0;
            for(int j = 0 ; j < n ; j ++){
                if(maps[j][i]) rownum++;
            }
            rownum = max(rownum,n-rownum);
            tmp += rownum;
        }
        ans = max(ans,tmp);
        return ;
    }
    maps[line].flip();
    dfs(line+1);
    maps[line].flip();
    dfs(line+1);

}

int main(){    
    
    while(scanf("%d%d",&n,&m) != EOF && n+m){
        ans = -1;
        for(int i = 0 ; i < n ; i ++){
            for(int j = 0 ; j < m ; j ++){
                int x;
                scanf("%d",&x);
                maps[i][j] = x;
            }
        }    
        dfs(0);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1200
N = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(N-2):
        l = [p[i],p[i+1],p[i+2]]
        if max(l) != p[i+1] and min(l) != p[i+1]:
                cnt += 1
print(cnt)

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];

    vector<int> backet(110, 0);
    for(int i = 0; i < n; i++) backet[d[i]]++;
    int ans = 0;
    for(int i = 0; i <= 100; i++){
        if(backet[i] > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;
use std::io::Read;

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<i32> = Vec::with_capacity(n);

    for _ in 0..n {
        let a_i: i32 = iter.next().unwrap().parse().unwrap();
        a.push(a_i);
    }

    a.sort();

    let mut sum: i64 = 0;
    for i in a.iter() {
        sum += *i as i64;
    }

    println!("{} {} {}", a[0], a[n - 1], sum);
}


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

public class Main {

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

    static class Coffee {
        public void solve(Scanner sc) {
            String str = sc.next();
            if (str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5)) System.out.println("Yes");
            else System.out.println("No");
        }
    }
}


Measured memory_bytes: 20820
from sys import stdin

S = stdin.readline().rstrip()
T = stdin.readline().rstrip()

flag = True
for i in range(len(S)):
    S1 = S

    if S[i] != T[i]:
        S = S.translate(str.maketrans({S[i]: T[i], T[i]: S[i]}))
    else:
        continue

    if i == 0:
        continue
    elif i > 0 and S[:i] == S1[:i]:
        pass
    else:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4400
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		boolean exist = false;
		for(int i = 0; i < a * b; i += a) {
			if(i % b == c) {
				exist = true;
				break;
			}
		}
		if(exist) System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0;
    ll cnt = 0;
    rep(i, n) {
        if (i % 2 == 0 && a[i] + sum <= 0) {
            cnt += abs(1 - sum - a[i]);
            sum = 1;
        }
        else if (i % 2 == 1 && a[i] + sum >= 0) {
            cnt += abs(-1 - sum - a[i]);
            sum = -1;
        }
        else {
            sum += a[i];
        }
    }

    ll ans = cnt;
    cnt = 0;
    sum = 0;
    rep(i, n) {
        if (i % 2 == 1 && a[i] + sum <= 0) {
            cnt += abs(1 - sum - a[i]);
            sum = 1;
        }
        else if (i % 2 == 0 && a[i] + sum >= 0) {
            cnt += abs(-1 - sum - a[i]);
            sum = -1;
        }
        else {
            sum += a[i];
        }
    }

    cout << min(ans, cnt) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1),v(n+1),vmax(n+1);
    v[0]=1; vmax[0]=1;
    rep(i,n+1){
        cin >> a[i];
        if(i!=n){
            vmax[i+1]= min( (vmax[i]-a[i])*2, (ll)1e18 );
            if(vmax[i+1]<0){
                cout << -1 << endl;
                return 0;
            } 
        }
    }

    v[n]=a[n];
    if(v[n] > vmax[n]){
        cout << -1 << endl;
        return 0;
    }

    for(int i=n-1; i>=0; --i){
        if(v[i+1]<=(vmax[i]-a[i]) ) v[i]=v[i+1]+a[i];
        else if(v[i+1]<=(vmax[i]-a[i])*2) v[i]=vmax[i];
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    ll sum=0;
    rep(i,n+1){
        sum+=v[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n;
    while(cin >> n && n){
        int x[256] = {};
        bool fin = false;
        rep(i, n){
            char c;
            cin >> c;
            if(fin) continue;
            ++x[c];
            vector<char> v(27);
            iota(all(v), 'A');
            sort(all(v), [&](char a, char b){ return x[a] > x[b]; });
            if(x[v[0]] > x[v[1]] + n-i-1){
                cout << v[0] << ' ' << i+1  << '\n';
                fin = true;
            }
        }
        if(!fin) puts("TIE");
    }
}

Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define lINF 9223372036854775807
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;

ll n,h[111111],m[111111];

ll dp(int i){
	if(m[i]!=-1)return m[i];
	if(i==n-1)return 0;
	ll x,y,sum=0,sum2=0;
	x=abs(h[i]-h[i+1]);
	if(i+2>n-1)y=lINF;
	else y=abs(h[i]-h[i+2]);
	
	sum+=dp(i+1)+x;
	sum2+=dp(i+2)+y;
	
	return m[i]=min(sum,sum2);
}

int main(){
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
		m[i]=-1;
	}
	cout<<dp(0)<<endl;
	return 0;

}

Measured memory_bytes: 6528
using System;
using static System.Console;

class Program
{
    static void Main()
    {
        var input = ReadLine().Split();
        var x1 = int.Parse(input[0]);
        var y1 = int.Parse(input[1]);
        var x2 = int.Parse(input[2]);
        var y2 = int.Parse(input[3]);

        var x_distance = x2 - x1;
        var y_distance = y2 - y1;

        var x3 = x2 - y_distance;
        var y3 = y2 + x_distance;
        var x4 = x1 - y_distance;
        var y4 = y1 + x_distance;
        
        WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
    }
}


Measured memory_bytes: 11092
import numpy as np

i = [int(each) for each in input().split()]

n = i[0]
m = i[1]

l2 = np.zeros(m)

for i in range(n):
    for j, each in enumerate([int(each) - 1 for each in input().split()]):
        if j != 0:
            l2[each] += 1
    # print(l)

count = 0
for each in l2:
    if each == n:
        count += 1
print(count)


Measured memory_bytes: 12520
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 3;
    if (a == b)ans--;
    if (a == c)ans--;
    if (b == c)ans--;
    if (ans == 0)ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

const int INF = 1000000007;

int main()
{
    // long long int a[65][3];
    array< array<long long int, 3>, 65 > a;

    // int p[64]
    array<int, 64> p;

    long long int N;

    scanf("%lld", &N);

    for (int i = 0; i < 64; i++)
    {
        p[63 - i] = N % 2;
        N = N / 2;
    }

    a[0][0] = 1;
    a[0][1] = 0;
    a[0][2] = 0;

    for (int i = 1; i < 65; i++)
    {
        if (p[i - 1] == 0)
        {
            a[i][2] = (3 * a[i - 1][2] + a[i - 1][1]) % INF;
            a[i][1] = a[i - 1][1];
            a[i][0] = (a[i - 1][0] + a[i - 1][1]) % INF;
        }
        else
        {
            a[i][2] = (3 * a[i - 1][2] + 2 * a[i - 1][1]) % INF;
            a[i][1] = (a[i - 1][0] + a[i - 1][1]) % INF;
            a[i][0] = a[i - 1][0];
        }
    }

    printf("%lld\n", (a[64][0] + a[64][1] + a[64][2]) % INF);
    return 0;
}


Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>int LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>int UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);
	//O(6^(n/2))
	int i,j,n,K,bi,ans;cin>>n>>K;
	ans=n;
	if(K>3e6*n){cout<<0<<endl;return 0;}
	int na=n/2,nb=n-na;
	int A[20];
	for(i=0;i<n;i++){cin>>A[i];}
	vector<vector<int>>adp(1<<na);
	for(bi=0;bi<(1<<na);bi++){
		vector<int>dp(1);
		for(i=0;i<na;i++){
			if(bi&(1<<i)){
				int siz=dp.size();
				for(j=0;j<siz;j++){dp.pub(dp[j]+A[i]);}
			}
		}
		
		SO(dp);
		dp.erase(unique(dp.begin(),dp.end()),dp.end());
		adp[bi]=dp;
	}
	vector<vector<int>>bdp(1<<nb);
	for(bi=0;bi<(1<<nb);bi++){
		vector<int>dp(1);
		for(i=0;i<nb;i++){
			if(bi&(1<<i)){
				int siz=dp.size();
				for(j=0;j<siz;j++){dp.pub(dp[j]+A[i+na]);}
			}
		}
		SO(dp);
		dp.erase(unique(dp.begin(),dp.end()),dp.end());
		REV(dp);
		bdp[bi]=dp;
	}
	for(bi=0;bi<(1<<n);bi++){
		int ku=0;
		for(i=0;i<n;i++){if(bi&(1<<i)){ku++;}}
		ku=n-ku;
		if(ku>=ans){continue;}
		int ax=bi&((1<<na)-1);
		int bx=bi>>na;
		bool can=true;
		int az=0,bz=0;
		while(az<adp[ax].size()&&bz<bdp[bx].size()){
			if(adp[ax][az]+bdp[bx][bz]==K){can=false;break;}
			if(adp[ax][az]+bdp[bx][bz]<K){az++;}
			else{bz++;}
		}
		if(can){mineq(ans,ku);}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    ll ans = 0;
    vector<ll> d(N+1, 2);
    d.at(1)--;
    
    for(int i = 2; i <= N/2; i++){
        ll n = i;
        ll k = 2;
        while(n*k<=N){
            d.at(n*k)++;
            k++;
        }
    }

    rep(i, N){
        ans += (i+1)*d.at(i+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 81332
def main():
    N = [0] + [int(i) for i in input()]
    r = 0
    c = 0
    f = 0
    for i in reversed(N):
        if f:
            if i + c >= 5:
                c += 1
                r += 5
            else:
                r += 5
            f = 0
        i += c
        c = 0
        if i < 5:
            r += i
        elif i == 5:
            f += 1
        else:
            c += 1
            r += 10 - i
    print(r)



main()


Measured memory_bytes: 116260
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(data) {
    var result = [];
    var apartment = buildArray();
    data.map(function(v){
      var info = v.split(' ');
      apartment[info[0] - 1][info[1] - 1][info[2] - 1] += parseInt(info[3]);
    });

    apartment.forEach(function(apart){
      apart.forEach(function(room){
        result.push(' ' + room.join(' '))
      });
      result.push('####################');
    });
    result.pop();
    return result.join('\n');

    function buildArray() {
      var all = [];
      for (var i = 0; i < 4; i++) {
        var apart = [];
        for (var j = 0; j < 3; j++){
          var room = [];
          for (var k = 0; k < 10; k++)
            room.push(0);
          apart.push(room)
        }
        all.push(apart);
      }
      return all;
    }

  }(lines.slice(0,lines.shift())
    ));

  if(result.length !== 0) console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 8644
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//ソートすればいいんですか？
//???

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


	int N, T;
	scanf("%d", &N);
	scanf("%d", &T);
	int AB[3000];
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		AB[i] = (a << 12) + b;
	}
	sort(AB, AB + N);

	vector<int> dp(T);
	int saidai = 0;
	rep(i, N) {
		int a = AB[i] >> 12;
		auto dp2 = dp.begin() + a;
		int b = AB[i] & ((1 << 12) - 1);
		chmax(saidai, dp[0] + b);
		rep(j, T - a) {
			chmax(dp[j], dp2[j] + b);
		}
	}
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
static const int inf = 10000;
static const int emp = -1;
static const int black = 1;
static const int white = 0;
 
int   graph[124][124] = {{}};;
int d[124] = {};
int color[124] = {};
int p[124] = {};
int n;
 
int  prim(){
 
  for(int i = 0;i < n;i++){
    d[i] = inf;
    color[i] = white;
    p[i] = -1;
  }
 
  d[0] = 0;
  int u ,v;
  
 
  while(1){
 
    v = inf;
    u = -1;
 
    for(int i = 0;i < n;i++){
      if(d[i] < v && color[i] != black){
    v= d[i];
    u = i;
      }
    }
    //    cout << "u = " << u << endl; 
 
    if(u == -1) break;
    color[u] = black;
 
    // cout << 'a' << endl;
    for(int i = 0;i < n;i++){
      if(graph[u][i] != -1 && color[i] != black){
    if(graph[u][i] < d[i]){
      d[i] = graph[u][i];
      p[i]= u;
      //  cout << "d = " << d[i] <<endl;
      // cout << "i = " << i << endl;
    }
      }
    }
  }
 
  int sum = 0;
  for(int i = 0;i < n;i++){
    if(p[i] != -1) sum += graph[i][p[i]];
  }
  return sum;
}
 
 
 
int main(){
 
  cin >> n;
 
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cin >> graph[i][j];
    }
  }
 
 
 
  cout <<  prim() << endl;
 
  return 0;
}

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

int main(){
    int a,b,k,cnt;
    cin>>a>>b>>k;
    cnt=0;
    for (int i=min(a,b);i>=1;--i){
        if (a %i==0 && b%i==0){
            cnt++;
            if (cnt==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
return 0;

}

Measured memory_bytes: 3064
/*
      author : nishi5451
      created: 11.08.2020 22:41:50
*/

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


int main(){
    string s,t;
    int a,b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if(s==u) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int ans = 1e9;
int main()
{
    cin >> n;
    cin >> s;
    vector<int> w(n + 1, 0);
    vector<int> b(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        b[i + 1] = b[i];
        w[i + 1] = w[i];
        if (s[i] == '#')
        {
            b[i + 1]++;
        }
        else
        {
            w[i + 1]++;
        }
    }
    for (int i = 0; i <= n; i++)
    {
        /* code */
        int t = b[i] + w[n] - w[i];
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

struct L {
  long long k, b;
  double at(double x) const { return k * x + b; }
  long long at(int x) const { return k * x + b; }
};

double intersect(const L& a, const L& b) {
  return (double) (b.b - a.b) / (a.k - b.k);
}

bool in(const L& a, const L& b, const L& c) {
  auto x = intersect(a, c);
  return a.at(x) <= b.at(x);
}

bool ni(int x, const L& a, const L& b) {
  return a.at(x) >= b.at(x);
}

int main() {
  int N;
  long long C;
  scanf("%d%lld", &N, &C);
  static L Q[200000];
  auto qb = 0, qe = 1;
  long long f;
  int h;
  scanf("%d", &h);
  L li{-h * 2, (long long) h * h};
  Q[0] = li;
  for (auto i = 1; i < N; ++i) {
    scanf("%d", &h);
    while (qe - qb > 1 && ni(h, Q[qb], Q[qb + 1]))
      ++qb;
    f = Q[qb].at(h) + C + (long long) h * h;
    L li{-h * 2, (long long) h * h + f};
    while (qe - qb > 1 && in(Q[qe - 2], Q[qe - 1], li))
      --qe;
    Q[qe++] = li;
  }
  printf("%lld\n", f);
  return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int ans = 1;
		for(int i = 0;i < N;i++){
			P[i] = sc.nextInt();
		}
		for(int i = 1;i < N;i++){
			if(P[i - 1] >= P[i]){
				ans++;
			}else{
				P[i] = P[i - 1];
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int main(void){
    int n;
    string command, str;
    cin >> n;
    set<string> dic;
    for(int i = 0; i < n; i++){
        cin >> command >> str;
        if(command == "insert"){
            dic.insert(str);
        }else{
            if(dic.find(str) != dic.end())cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 32580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int taro = 0, hanako = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string t, h;
        cin >> t >> h;
        if (t > h) {
            taro += 3;
        } else if (t < h) {
            hanako += 3;
        } else {
            taro++;
            hanako++;
        }
    }
    cout << taro << " " << hanako << endl;
    return 0;
}


Measured memory_bytes: 3248
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
#import numpy
#from collections import deque
sys.setrecursionlimit(10**5)

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())

childsof = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w = list(map(int, input().split()))
    childsof[u].append((v,w))
    childsof[v].append((u,w))

distances = [-1]*(N+1)
distances[1] = 0

def dfs(i):
    childs = childsof[i]

    for c in childs:
        j = c[0]
        if distances[j] == -1:
            distances[j] = distances[i] + c[1]
            dfs(j)

dfs(1)

for d in distances[1:]:
    if d % 2 == 0: #even
        print(0)
    else:
        print(1)


Measured memory_bytes: 146976
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

o = ns()
e = ns()
if len(o) - len(e) == 0:
        for oi, ei in zip(o, e):
                print(oi + ei, end='')
else:
        for oi, ei in zip(o[:-1], e):
                print(oi + ei, end='')
        print(o[-1], end='')

Measured memory_bytes: 5072
package main

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

func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

func SplitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := StrStdin()

	// 空白で分割
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplited := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

func main() {
	var n int
	fmt.Scanf("%d", &n)


	fmt.Printf("%d", n*n*n)
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = 1 << n;
		long[] a = new long[m];
		for (int i=0;i<m;i++) {
			a[i]=sc.nextInt();
		}
		long[][] max = new long[m][2];
		for (int i=0;i<m;i++) {
			TreeSet<Long> set = new TreeSet<Long>();
			max[i][0]=a[i]*m+i;
			for (int j=0;j<n;j++) {
				if ((i>>j)%2!=0) {
					merge(max,i,i-(1<<j));
				}
			}
		}

		long ans = 0;
		for (int i=1;i<m;i++) {
			ans = Math.max(ans, max[i][0]/m+max[i][1]/m);
			System.out.println(ans);
		}
	}

	static void merge(long[][] max, int a, int b) {
		if (max[b][1] > max[a][0]) {
			max[a][0]=max[b][0];
			max[a][1]=max[b][1];
		} else if (max[b][0] > max[a][0]) {
			max[a][1]=max[a][0];
			max[a][0]=max[b][0];
		} else if (max[b][0] > max[a][1] && max[b][0] < max[a][0]) {
			max[a][1]=max[b][0];
		}
	}

}


Measured memory_bytes: 109592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> ans(n+1, 0);
    for(int j = 1; j <= 100; j++){
        for(int k = 1; k <= 100; k++){
            for(int l = 1; l <= 100; l++){
                int cnt = j*j+k*k+l*l+j*k+k*l+l*j;
                if(cnt <= n){
                    ans[cnt]++;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a) 
typedef long long ll;
using namespace std;
int main(){
	 double l;
	 while(cin>>l){
	 	printf("%.10lf\n",pow(l/3.0,3));
	 }
	 return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    char b;
    cin>>b;
    if(b=='A')cout<<'T'<<endl;
    if(b=='C')cout<<'G'<<endl;
    if(b=='G')cout<<'C'<<endl;
    if(b=='T')cout<<'A'<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[7] = {1 , 3 , 5 , 7 , 8 , 10 , 12} , b[4] = {4 , 6 , 9 , 11} , c , d , m = 0;
    cin >> c >> d;
    for ( int i = 0 ; i < 7 ; i++ ) {
        if ( c == a[i] || d == a[i] ) m++;
        if ( m == 2 ) {
            cout << "Yes";
            return 0;
        }
    }
    m = 0;
    for ( int i = 0 ; i < 4 ; i++ ) {
        if ( c == b[i] || d == b[i] ) m++;
        if ( m == 2 ) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
import java.util.*;

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

    long pre_total = 0;
    long total = 0;
    int mojisuu = 0;

    long n = sc.nextLong();
    StringBuilder val = new StringBuilder();


    while(n>0){
      val.append(alpha((int)((n-1)%26)));
      n = (n-1) /26;
    }




      //0x61 = ９７ = a

      System.out.println(val.reverse());
    }








  static char alpha(int n){
      return (char)(n+97);
  }
}

Measured memory_bytes: 35392
#include <cstdio>
#include <algorithm>
using namespace std;

int N, W;
int w[105], v[105];
long long dp[105][100005];

void solve() {
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j-w[i] >= 0) {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  printf("%lld\n", dp[N][W]);
}

int main() {
  scanf("%d%d", &N, &W);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", w+i, v+i);
  }
  solve();
}


Measured memory_bytes: 79820
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
  ll n, k;
  cin >> n >> k;
  ll tmp = n / k + 1;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << min(k * tmp - n, n) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            int[] abcxy = ReadAndParseIntArr();
            int a = abcxy[0];
            int b = abcxy[1];
            int c = abcxy[2];
            int x = abcxy[3];
            int y = abcxy[4];

            // 場合分けして一番小さい金額
            List<int> priceList = new List<int>();
            // ab only
            priceList.Add( a * x + b * y);
            // c only
            priceList.Add(2 * c * Math.Max(x, y) );
            
            if( x >= y)
            {
                priceList.Add(a * (x - y) + 2 * c * y);
            }
            else
            {
                priceList.Add(b * (y - x) + 2 * c * x);
            }
            int ans = priceList.Min();
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=100001;

int main(){
  int N,M;
  cin >> N >> M ;
  int freq[N];
  fill(freq,freq+N,0);
  rep(i,M){
    int a,b;
    cin >> a >> b ;
    a--; b--;
    freq[a]++; freq[b]++;
  }
  bool ans=true;
  rep(i,N){
    if(freq[i]%2){
      ans=false;
      break;
    }
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    for(int i = 0; i <= n; i++) {
      int d = n - (4 * i);
      if((d >= 0) && ((d % 7) == 0)) ans = "Yes";
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <cstdio>

int gcd(int a, int b)
{
    return b ? gcd(b, a%b): a;
}

int m[50];

int main()
{
    int n;
    scanf("%d",&n);
    int mui = 1;
    for(int i = 1; i <= n; i ++) scanf("%d",&m[i]);
    int g = gcd(m[1], m[2]);
    int ans = m[1]/g*m[2];
    for(int i = 3; i <= n; i ++) ans = ans/gcd(ans, m[i])*m[i];
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2760
N, M = (int(x) for x in input().split())
answer_cand = []

for i in range(N):
    new_answer_cand = []
    food_list = []
    food_list.extend(list(map(int, input().split())))

    if i == 0:
        answer_cand.extend(food_list)
        answer_cand = answer_cand[1:]
    else:
        for j in range(0, len(answer_cand)):
            for k in range(1, len(food_list)):
                if answer_cand[j] == food_list[k]:
                    new_answer_cand.append(answer_cand[j])
        answer_cand = new_answer_cand

print(len(answer_cand))

Measured memory_bytes: 3064
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N>>M) {
		ll ans = -1;
		if(N%M==0) ans=-1;
		else ans = N;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
n = int(input())
ki = [[]for _ in range(n)]
dist1 = [0]*n
distN = [0]*n
def dfs1(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dist1[next] = dist1[now]+1
        dfs1(next,now)
def dfsN(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        distN[next] = distN[now]+1
        dfsN(next,now)
        
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
fs = 0
dfs1(0)
dfsN(n-1)
for i in range(n):
    if dist1[i] <= distN[i]:fs+=1
ss = n-fs
if fs > ss:print('Fennec')
else:print('Snuke')

Measured memory_bytes: 136112
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

s = []
N = int(input())
A=[]
Rules=[]

def check():
    for i in range(len(Rules)):
        if s[i] != True:
            continue
        r = Rules[i]
        for rr in r:
            (x,y) = rr
            if y == 1:
                if s[x -1 ] == False:
                    return False
            else:
                if s[x-1] == True:
                    return False
            # print(rr)
    return True

for _ in range(N):
    a = ni()
    A.append(a)
    r = []
    for _ in range(a):
        rr = nl()
        r.append(rr)
    Rules.append(r)

# print(A,Rules)

l = 2 **N 
maxgood = 0
for i in range(1,l ):
    s=[]
    ix = i 
    good = 0
    for _ in range(N):
        if ix %2 != 0:
            good += 1
        s.append(ix%2 !=0 )
        ix = ix //2
    # print(good,s)
    if good > maxgood:
        if check():
            maxgood = good
print(maxgood)


Measured memory_bytes: 3064