akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s;
	int k;
	cin >> k >> s;
	if ((int)s.size() > k) {
		cout << s.substr(0, k) << "...\n";
	} else {
		cout << s << endl;
	}
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;

bool secinc(const pair<ll, ll> a, const pair<ll, ll> b) {
  return a.second < b.second;
}

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

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

  vector<vector<int>> x(n+1, vector<int>(n+1, 0));

  rep(i, m) {
    int l, r;
    cin >> l >> r;
    x[l][r]++;
  }

  vector<vector<int>> c(n+1, vector<int>(n+1, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      c[i][j] = c[i][j-1] + x[i][j];
    }
  }

  rep(i, q)   {
    int p, q;
    cin >> p >> q;
    int sum = 0;
    for (int j = p; j <= q; j++) {
      sum += c[j][q] - c[j][p-1];
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
int N,M,i,j,f;
char P[300][11],T[11];

int s(char *S)
{
	int i;
	for(i=0;i<N;i++)
		if(strcmp(P[i],S)==0)
			return 1;
	return 0;
}

int main()
{
	for(scanf("%d\n",&N),i=0;i<N;i++)
		gets(P[i]);
	for(scanf("%d\n",&M),i=f=0;i<M;i++)
	{
		gets(T);
		if(s(T))
		{
			printf("%s by %s\n",f?"Closed":"Opened",T);
			f=!f;
		}
		else
			printf("Unknown %s\n",T);
	}
	return 0;
}

Measured memory_bytes: 608
import sys
readline = sys.stdin.readline

H,W = map(int,readline().split())
G = [None] * (H + 1)
G[0] = "." * (W + 1)
for i in range(H):
  G[i + 1] = "." + readline().rstrip()

dp = [[0] * (W + 1) for i in range(H + 1)]
dp[1][0] = 1 # 便宜上、枠外に1を入れておくことで、dp[1][1]が1になる
DIV = 10 ** 9 + 7

for i in range(1, H + 1):
  for j in range(1, W + 1):
    if G[i][j] == "#":
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
      dp[i][j] %= DIV
      
print(dp[H][W])

Measured memory_bytes: 49348
x,n,d=map(int, input().split())
x=abs(x)
opt=x//d
if (n-opt)%2==0 and opt<n:
  print(x-(d*opt))
elif opt>=n:
  print(x-(d*n))
else:
  a=x-(d*opt)
  a=d-a
  print(a)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    string a,b,c;
    cin>>a>>b>>c;
    cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
#AGC7 B

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
p = LI()
a = [i*n for i in range(1,n+1)]
b = a[::-1]
for i in range(n):
    a[p[i]-1] += i
print(*a)
print(*b)


Measured memory_bytes: 45484
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int n;
    cin >> n;

    if(n < 1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin>> r;
    cout << 3 * r * r;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,A;
	cin >> N >> K >> A;
	Combination cb(10);
	ll sum[200010] = {};
	ll val[200010] = {};
	ll inv = cb.power(N, MOD-2);
	val[1] = inv;
	sum[1] = val[1];
	rep(i,2,N+K){
		ll tt = (sum[min(K-1, i-1)] - sum[max(0LL, i-N-1)] + MOD) % MOD;
		tt *= A * cb.power(100LL, MOD-2) % MOD * inv % MOD;
		tt %= MOD;
		if(i <= N){
			(tt += inv) %= MOD;
		}
		val[i] = tt;
		sum[i] = (sum[i-1] + val[i]) % MOD;
		sum[i] %= MOD;
	}
	ll ans = 0;
	rep(i,K,N+K){
		(ans += val[i]) %= MOD;
	}
	print(ans);
}


Measured memory_bytes: 6340
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int n,k,m;
        cin >> n >> k >> m;
        if(n==0) break;

        vector<int> nums;
        for(int i=1;i<=n;i++){
            nums.push_back(i);
        }

        int pos = m-1;
        while(nums.size() > 1){
            nums.erase(nums.begin()+pos);
            pos--;
            pos = (pos+k) % nums.size();
        }
        cout << nums.front() << endl;
    }
    return 0;
}

Measured memory_bytes: 1324
while True:
    a, b, c = map(str,input().split())
    if b == "?":
        break
    if b == "+":
        print(int(a)+int(c))
    if b == "-":
        print(int(a)-int(c))
    if b == "*":
        print(int(a)*int(c))
    if b == "/":
        print(int(a)//int(c))



Measured memory_bytes: 5596
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min(abs(h[i - 2] - h[i]) + dp[i - 2], abs(h[i - 1] - h[i]) + dp[i - 1])

print(dp[-1])


Measured memory_bytes: 84896
/**
 *      ABC 53 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-07 21:40:12
**/

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

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

    long long answer = 0;
    
    answer += 2 * (x / 11);
    x %= 11;
    
    if (x <= 6 && x > 0){
        answer += 1;
    }
    else if (x == 0){
        answer += 0;
    }
    else {
        answer += 2;
    }
    
    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n, a[2][100];

	cin >> n;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	int ans = 0;
	int max = 0;
	int k = 0;
	for (int i = 0; i < n; i++) { //どの段階で下に移動するか
		ans = 0;
		k = 0;
		for (int j = 0; j < n; j++) { //各段階で下に降りる場合と最大値の比較
			if (j == i) {
				k = 1;
				ans += a[0][j];
			}
			ans += a[k][j];
		}
		if (max < ans) {
			max = ans;
		}
	}

	cout << max << endl;

	return 0;
}

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

int main(){
  long long X;
  cin >> X;

  int year=0;
  long long A=100;
  bool flag = true;

  while(flag){
    if(A>=X){
      flag =false;
    }
    A *=1.01;
    year++;
  }
  cout << year-1 << endl;
}


Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	k := nextInt()
	l := make([]int, 100+1)
	cnt := 0

	for i := 1; i <= 100; i++ {
		if a%i == 0 && b%i == 0 {
			l[cnt] = i
			cnt++
		}
	}
	sort.Ints(l)

	fmt.Println(l[101-k])

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int top, s[2000];

void push(int x){
    s[++top] = x;
}

int pop(){
    top--;
    return s[top+1];
}

int main(){
    int a, b;
    top = 0;
    char ss[100];

    while( scanf("%s", &ss) != EOF){
        //printf("%s ", ss);
        if( ss[0] == '+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if( ss[0] == '-'){
            b=pop();
            a=pop();
            push(a-b);
        }else if( ss[0] == '*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(ss));
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2128
#include <stdio.h>
#include <math.h>

int
main(void)
{
	int n;
	int s[1000];
	double sum, ave, sg2;

	for (;;) {
		scanf("%d", &n);
		if (n == 0)
			break;

		sum = 0; sg2 = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			sum += s[i];
		}
		ave = sum / n;
		for (int i = 0; i < n; i++)
			sg2 += pow(s[i] - ave, 2);
		sg2 /= n;
		printf("%f\n", sqrt(sg2));
	}

	return 0;
}



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

int main() {

  int long X,i=0,j=0,a;
  int long ans;
  
  cin >> X;

  ans=X;
  a=sqrt(X);

  while (j<a)
  {
    ans=X+i;
    for (j = 2; j<a; j++)
    {
      if (ans%j==0)
      {
        break;
      }
    }
    i++;
  }
  printf("%lld\n",ans);
  return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static int N = 0;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var capacity = new long[5];
            for (int i = 0; i < 5; i++)
            {
                capacity[i] = long.Parse(Console.ReadLine());
            }

            var time = 5L;
            time += (long)Math.Ceiling((double)N / capacity.Min()) - 1;

            Console.WriteLine(time);
        }
    }
}


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

int main(){

  int n,q,i,j,count=0;
  int *S,*T;

  scanf("%d",&n);
  S = malloc(sizeof(int)*n);

  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);
  T = malloc(sizeof(int)*q);

  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++)
      if(S[j]==T[i]){
	count++;
	break;
      }}

  printf("%d\n",count);

  free(S);
  free(T);
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
int main(){
    int n,i,a,b;
    cin>>n;
    int p[n];
    for(i=0;i<n;i++)
        cin>>p[i];
    a=0;
    for(i=1;i<n-1;i++){
        if(p[i]>p[i-1]&&p[i]<p[i+1]||p[i]<p[i-1]&&p[i]>p[i+1])
            a=a+1;
    }
    cout<<a;
    return 0;
}

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

int main(){
  char b;
  cin >> b;
  
  char ans;
  if(b=='A')ans='T';
  if(b=='T')ans='A';
  if(b=='G')ans='C';
  if(b=='C')ans='G';
  
  cout << ans << endl;
}

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

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

int main(){
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    bool yoko_flg[n] = {false};
    int idx = 0;
    while(1) {
        if ( idx >= n ) break;
        if ( idx + 1 < n && s1[idx] == s1[idx+1] ) {
            yoko_flg[idx] = true;
            yoko_flg[idx+1] = true;
            idx += 2;
            continue;
        }
        ++idx;
    }
//    rep(i, n) {
//        cout << yoko_flg[i] <<" " ;
//    }
//    cout << endl;
    ll ans = 3;
    idx = 0;
    while(1) {
        if ( idx >= n ) break;
        if ( yoko_flg[idx] ) {
            if ( idx == 0 ) {
                ans = ans * 2 % mod;
            }
            else if ( yoko_flg[idx-1] ) {
                ans = ans * 3 % mod;
            }
            else {
                ans = ans * 2 % mod;
            }
            idx += 2;
        }
        else if ( idx >= 1 && !yoko_flg[idx-1] ) {
            ans = ans * 2 % mod;
            ++idx;
        }
        else {
            ++idx;
        }
//        cout << idx << " " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//400
fun b017(args: Array<String>) {
    val (N, A, B, C, D) = args[0].split(" ").map { it.toLong() }
    val diff = Math.abs(A - B)
    if ((0 until N).any { C * (N - 1 - it) - D * it <= diff && diff <= -C * it + D * (N - 1 - it) }) {
        println("YES")
    } else {
        println("NO")
    }
}

fun main(args: Array<String>) {
    b017(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 40756
#include <iostream>
using namespace std;
int main(void)
{ 
    int x,y,z;
   cin >> x >> y >> z;
   int ans = 0;
   for(size_t i = 0 ;  ; i++)
   {
      int l =(i * y) + ((i+1) * z);
      if(l <= x)
        ans = i;
     else
       break;
   }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a[i];
    }else{
      B+=a[i];
    }
  }
  int ans;
  ans = A-B;
  cout << ans << endl;
}

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

namespace ConsoleApplication2
{
    //insertFirstを高速にし、Addを超低速にした逆順List
    public class RevList<T>
    {
        private List<T> arr;
        public RevList()
        {
            arr = new List<T>();
        }
        public void InsertFirst(T val)
        {
            arr.Add(val);
        }
        public void Add(T val)
        {
            arr.Insert(0, val);
        }
        public int Count
        {
            get
            {
                return arr.Count();
            }
        }
        public T this[int index]
        {
            set
            {
                arr[Count - index - 1] = value;
            }
            get
            {
                return this.arr[Count - index - 1];
            }
        }
    }
    class Program
    {

        static void Main(string[] args)
        {

            long n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            RevList<long> color = new RevList<long>();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            color.Add(a[0]);

            for (int i = 1; i < n; i++)
            {
                int cnt = color.Count;
                if (a[i] <= color[0])
                {
                    color.InsertFirst(a[i]);
                }
                else if (a[i] > color[cnt - 1])
                {
                    color[cnt - 1] = a[i];
                }
                else
                {
                    //2分探査
                    int iS, iM, iL;
                    iS = 0;
                    iL = cnt - 1;


                    for (int j = 0; j < cnt; j++)
                    {
                        iM = (iS + iL) / 2;

                        if (iS == iM)
                        {
                            color[iS] = a[i];
                            break;
                        }
                        if (color[iM] >= a[i])
                        {
                            iL = iM;
                        }
                        else
                        {
                            iS = iM;
                        }
                    }
                }
            }
            Console.WriteLine(color.Count);
        }
    }
}

Measured memory_bytes: 17756
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
Arr.forEach(function(v,i){
var arr=Arr[i].split(" ").map(Number);
var a=arr[0]%arr[1];
if(a==0)a=arr[1];
console.log(a);
});

Measured memory_bytes: 8768
#include"bits/stdc++.h"

using namespace std;

int main() {
	int X;
	cin >> X;
	int ans = 1;

	for (int i = 2; i < 40; i++) {
		int num = i*i;
		while (num <= X) {
			ans = max(ans, num);
			num *= i;
		}
	}

	cout << ans << endl;

	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int r = in.nextInt();
        int g = in.nextInt();
        System.out.println(g * 2 - r);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

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

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

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


Measured memory_bytes: 22484
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005;
int n,a,b,c,d,lst; char s[N]; bool flag;
int main()
{
	RI i; scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	for (i=a;i<c;++i) if (s[i]=='#'&&s[i+1]=='#') return puts("No"),0;
	for (i=b;i<d;++i) if (s[i]=='#'&&s[i+1]=='#') return puts("No"),0;
	if (c<d) return puts("Yes"),0; for (flag=0,i=b;i<=d&&!flag;++i)
	if (s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') flag=1;
	return puts(flag?"Yes":"No"),0;
}

Measured memory_bytes: 1856
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, c, k, i;
	int t[100000];
	scanf("%d%d%d", &n, &c, &k);
	for(i=0; i<n; i++){
		scanf("%d", t+i);
	}
	qsort(t, n, sizeof(int), comp);
	long ans=0;
	int j=0, T=0;
	for(i=0; i<n; i++){
		if(j>0 && T+k>=t[i]){
			j--;
		}else{
			j=c-1;
			T=t[i];
			ans++;
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M, 0);
    for (int i=0; i<M; i++) {
        cin >> B[i];
    }
    vector<vector<int>> vec(N, vector<int>(M, 0));
    for (int i=0; i<N; i++) {
        for (int j=0; j<M; j++) {
            cin >> vec[i][j];
        }
    }

    int result = 0;
    for (int i=0; i<N; i++) {
        int count = 0;
        for (int j=0; j<M; j++) {
            count += vec[i][j]*B[j];
            //cout << "vec[i][j]:" << vec[i][j] << " B[i]:" << B[i] << " " << count << "\n";
        }
        count += C;
        //cout << "C:" << count << "\n";
        if (0 < count) {
            result += 1;
        }
    }
    cout << result;

    return 0;
}   


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

int main() {
    double a, b;
    while (cin >> a >> b) {
        string s;
        if (a < 35.5 && b < 60 + 11) {
            s = "AAA";
        } else if (a < 37.5 && b < 60 + 17) {
            s = "AA";
        } else if (a < 40 && b < 60 + 23) {
            s = "A";
        } else if (a < 43 && b < 60 + 29) {
            s = "B";
        } else if (a < 50 && b < 60 + 45) {
            s = "C";
        } else if (a < 55 && b < 60 + 56) {
            s = "D";
        } else if (a < 60 + 10 && b < 60 * 2 + 28) {
            s = "E";
        } else {
            s = "NA";
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 3072
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int K, X;
	cin >> K >> X;
	if (500 * K >= X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
vector<int>v[100005];


int dfs(int n,int s){
    if (v[s].size()==0) {
        dp[s]=0;
        return 0;
    }
    if (dp[s]!=-1) {
        return dp[s];
    }
    for (int i = 0; i <v[s].size(); ++i) {
        int temp=dfs(n,v[s][i])+1;
        dp[s]=max(dp[s],temp);
    }
    return dp[s];

}

int main(){
    int n,m;
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    for (int i = 0; i <m ; ++i) {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
    }
    for (int j = 1; j <=n ; ++j) {
        dfs(n,j);
    }
    cout<<*max_element(dp+1,dp+n+1);


    return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static boolean[][] map;
	static boolean[][] check;
	static int island ;
	public static void main(String[] args) {
		while(scan.hasNext()) {
			map = new boolean[12][12];
			check = new boolean[12][12];
			island = 0;
			for(int i = 0; i < 12; i++) {
				int count = 0;
				for( String s : scan.next().split("",0)) {
					if(s.equals("1")) {
						map[i][count] = true;
					}
					else {
						map[i][count] = false;
					}
					count++;
				}
			}
			for(int i = 0; i < 12 ; i++) {
				for(int u = 0; u < 12; u++) {
					if(map[i][u] && !check[i][u]) {
						fun(i,u);
					}
				}
			}
			System.out.println(island);
		}
	}

	static void fun(int x, int y) {
		flag(x,y);
		island++;
	}

	static void flag(int x, int y) {
		check[x][y] = true;
	
		if(y + 1 < 12 && map[x][y+1] && !check[x][y+1]) {
			flag(x,y+1);
		}
		if(x + 1 < 12 && map[x+1][y] && !check[x+1][y]) {
			flag(x+1,y);
		}
		if(y - 1 > -1 && map[x][y-1] && !check[x][y-1]) {
			flag(x,y-1);
		}
		if(x - 1 > -1 && map[x-1][y] && !check[x-1][y]) {
			flag(x-1,y);
		} 			
	}
}

Measured memory_bytes: 26664
#include<queue>
#include<cstdio>
#include<vector>
#include<algorithm>
 
#define mp  make_pair
#define pb  push_back
 
using namespace std;
 
typedef pair<int,int> pii;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
 
int main(){
    for(int r;scanf("%d",&r),r;){
        int w[2],h[2],x[2],y[2];
        static int room[2][500][500];
        static int roomcnt[2][100001];
        for(int k=0;k<2;k++){
            scanf("%d%d%d%d",&w[k],&h[k],&x[k],&y[k]);
            x[k]--,y[k]--;
            for(int i=0;i<h[k];i++)for(int j=0;j<w[k];j++)    scanf("%d",&room[k][i][j]);
 
            for(int i=0;i<=r;i++)    roomcnt[k][i]=1<<30;
            roomcnt[k][0]=0;
 
            static bool visited[500][500];
            for(int i=0;i<h[k];i++)for(int j=0;j<w[k];j++)    visited[i][j]=false;
            visited[y[k]][x[k]]=true;
            int cnt=0,lev=0;
            priority_queue< pair<int,pii> > pq;
            pq.push(mp(-room[k][y[k]][x[k]],mp(y[k],x[k])));
            while(!pq.empty()){
                pair<int,pii> a=pq.top(); pq.pop();
                int nowlev=-a.first,x=a.second.second,y=a.second.first;
                cnt++;
                if(lev<nowlev)   lev=nowlev;
                roomcnt[k][cnt]=lev;
                if(cnt==r)  break;
 
                for(int i=0;i<4;i++){
                    int xx=x+dx[i],yy=y+dy[i];
                    if(0<=xx && xx<w[k] && 0<=yy && yy<h[k] && !visited[yy][xx]){
                        pq.push(mp(-room[k][yy][xx],mp(yy,xx)));
                        visited[yy][xx]=true;
                    }
                }
            }
        }
 
        int ans=1<<30;
        for(int i=0;i<=r;i++)    ans=min(ans,roomcnt[0][i]+roomcnt[1][r-i]);
        printf("%d\n",ans);
    }
 
    return 0;
}

Measured memory_bytes: 4140
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) cout << b + c << endl;
	else cout << a + 2 * b + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main() {
  // FILE;
  SPEED;
  int m,d;
  cin>>m>>d;
  int cc=0;
  for(int i=1;i<=m;i++) {
   for(int j=1;j<=d;j++){

      int d1;
      int d10;

      d1 = j%10;
      d10 = j/10;

      if(d1>=2&&d10>=2){
         if(d1*d10==i)cc++;
      }
   }
  }

  cout<<cc;

}

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

using namespace std;

inline int length(int num) {
	return num >= 0 ? num : -num;
}

int main()
{
	/*
		まず全入力を取得。その際最大値と最小値のうち絶対値が大きい方を保持。
		それが最大値ならindex=0から並べていく。逆ならindex = n-1から。
		二回足したら最大値をそちらにシフト。
	
	*/
	int n;
	cin >> n;
	int longest = 0;
	int maxIndex = 1;
	int num;
	for (int i = 1; i <= n; i++) {
		cin >> num;
		if (length(longest) < length(num)) {
			longest = num;
			maxIndex = i;
		}
	}

	int start;
	int end;
	int dir;

	if (longest > 0) {
		start = 2;
		end = n;
		dir = 1;
	}
	else {
		start = n-1;
		end = 1;
		dir = -1;
	}
	string ans = to_string(2 * (n - 1)).append("\n");
	string str = to_string(maxIndex).append(" ").append(to_string(start)).append("\n");
	ans.append(str).append(str);

	for (int i = start + dir; i != end + dir; i += dir) {
		str = to_string(i - dir).append(" ").append(to_string(i)).append("\n");
		ans.append(str).append(str);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string n;
	cin>>n;
	int s=0;
	rep(i,n.size())s+=(int)(n[i]-'0');
	int num=0;
	int tmp=1;
	for(int i=n.size()-1;i>=0;i--){
		num+=(int)(n[i]-'0')*tmp;
		tmp*=10;
	}
	cout<<((num%s)?"No":"Yes")<<endl;
	return 0;
}

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

typedef long long ll;

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string S;
    int K;
    cin >> S;
    cin >> K;
    
    ll N = S.size();
    vector<string> T;
    for ( int k = 1; k <= K; ++k){
        for ( int i = 0; i < N-k+1; ++i){
            T.push_back(S.substr(i,k));
        }
    }
    sort(T.begin(),T.end());
    
    /*for ( auto t: T){
        cout << t << endl;
    }*/
    
    int count = 0;
    string B = " ";
    string ans;
    bool flg = true;
    for ( int i = 0; i < T.size(); ++i){
        if ( B != T[i] and flg ) {
            //cout << "i " << i << " count " << count << " B " << B << " T " << T[i] << endl;
            B = T[i];
            ++count;
            if ( count == K ) {
                //cout << "B " << B << endl;
                ans = B;
                flg = false;
            }
        }
    }
    
    cout << B << endl;
    
    return 0;
}


Measured memory_bytes: 4268
import java.util.Scanner;

public class Main {

	public static final long MOD = 1_000_000_007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		long count1 = 0;
		long count2 = 0;
		for(int i=0;i<n;i++) {
			for (int j=0;j<n;j++) {
				if (a[i]>a[j]) {
					count1++;
					if (i<j) {
						count2++;
					}
				}
			}
		}
		
		System.out.println(((k*(k-1)/2)%MOD*count1%MOD+count2*k)%MOD);
		
		
		
		
	}



}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    map<char,ll> mp;
    rep(i,N) {
        string s;
        cin >> s;
        ++mp[s[0]];
    }
    ll ans = 0;
    ans += mp['M']*mp['A']*mp['R'];
    ans += mp['M']*mp['A']*mp['C'];
    ans += mp['M']*mp['A']*mp['H'];

    ans += mp['M']*mp['R']*mp['C'];
    ans += mp['M']*mp['R']*mp['H'];
    
    ans += mp['M']*mp['C']*mp['H'];

    ans += mp['A']*mp['R']*mp['C'];
    ans += mp['A']*mp['R']*mp['H'];
    ans += mp['A']*mp['C']*mp['H'];

    ans += mp['R']*mp['C']*mp['H'];
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  char b;
  cin >> b;
  cout << (b == 'A' ? 'T' : b == 'T' ? 'A' : b == 'C' ? 'G' : 'C');
}
#endif


Measured memory_bytes: 3584
while(True):
    L = int(input())
    if not L:
        break
    a = 0
    b = 0
    c = 0
    for _ in range(12):
        a += 1
        M,N = map(int, input().split())
        b += M-N
        if not c and b >= L:
            c = a
    print(c if c else "NA")



Measured memory_bytes: 5608
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 200;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int n, k;
int h[maxn], dp[maxn];

int main()
{
	n = read(), k = read();
	rep(i, 1, n) h[i] = read();
	memset(dp, 0x3f, sizeof dp);
	dp[1] = 0;
	rep(i, 1, n){
		rep(j, 1, k) dp[i+j] = qmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = list(input())
ans = 0
right = n-1
for i in range(n):
    if s[i] == "W":
        while right >= i:
            if s[right] == "R":
                s[right] = "W"
                s[i] = "R"
                ans += 1
                right -= 1
                break
            else:
                right -= 1


print(ans)


Measured memory_bytes: 77520
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define looplt(i,x) for(i=0; i<x; ++i)
#define bsrch(v,x) binary_search(v.begin(), v.end(), x)
#define vecl vector <long long int>
#define pb(x) push_back(x)
const long long int MAX_INT =  10e+10;
typedef long long int ll;

void pvec(vector <ll> &inp)
{
    ll n;
    looplt(n, inp.size()) cout << inp[n] << " ";
    cout << endl;
}

void parr(ll inp[], ll size)
{
    ll n;
    looplt(n, size) cout << inp[n] << " ";
    cout << endl;

}

ll pw(ll a, ll b)
{
    if(b == 0)
        return (1);
    
    ll ans = 1;
    for(ll i=0; i<b; ++i) 
        ans *= a;

    return (ans);
}

bool arrsearch(ll arr[], ll size, ll val)
{
    for(ll i=0; i<size; ++i){
        if(arr[i] == val)
            return true;
    }
    return false;
}

int main()
{   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll t=1, i, k, inp, j, n, m;
    string s;
    //cin >> t;
    looplt(i, t){
        cin >> s;
        ll sum=0;
        
        looplt(k, s.length()){
            sum += s[k] - '0';
            sum = sum % 9;
        }
        if(sum%9==0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}   



Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
	int n;
	int max_, min_;
	min_ = 1000, max_ = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		min_ = min(min_, temp);
		max_ = max(max_, temp);
	}
	cout << max_ - min_ << endl;
	return 0;
}

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

using namespace std;

long long gcd(long long a, long long b) {
    if (b == 0)
        return a;

    return gcd(b, a%b);
}

long long lcm(long long a, long long b) {
    return a/gcd(a,b)*b;
}

int main() {
    int n;
    long long ans = 1LL;

    cin >> n;

    for (int i = 0; i < n; i++) {
        long long t;
        cin >> t;
        ans = lcm(ans, t);
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n;cin>>n;ll ans=1;
    for(int i=1;i<=n;i++){
        ans=ans*i%MOD;
    }
    cout<<ans<<endl;
}

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

int main()
{
    using namespace std;
    
    long n, a, b;
    cin >> n >> a >> b;

    auto solver = [](long n, long a, long b) -> long {
        return (n*a <= b)? n*a : b;
    };

    cout << solver(n, a, b) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
signed main(){
	ic(n) 
	sc(a) sc(b)
	int ans=1;
	if(a[0]==b[0])ans=3;
	else ans=6;
	rep(1,i,n){
		if(a[i]==b[i]){
			if(a[i-1]==b[i-1]){
				ans*=2;
			}
		}
		else{
			if(a[i-1]==b[i-1]){
				ans*=2;
			}
			else if(a[i]!=a[i-1]){
				ans*=3;
			}	
		}
		ans=ans%mod;
	}
	c(ans)
}					

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    int n = input();

    vi a; rep(i,0,n) a.pb(input()); sort(all(a));
    vi b; rep(i,0,n) b.pb(input()); sort(all(b));
    vi c; rep(i,0,n) c.pb(input()); sort(all(c));


    int ans = 0;
    for(int e : b){
        ans += distance(a.begin(), lower_bound(all(a), e)) * distance(upper_bound(all(c), e), c.end());
    }

    print(ans);









    




    







    




   

    
    



    




    




    











    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 3316