akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
const int N=1e5+5;
int n,m,k,inv,a[N],b[N],cf[N],c[N],xu[N],f[N][65];
int xjh(int x,int y)
{
	for(int i=62;i>=0;i--)
		if(y&((long long)1<<i))x=f[x][i];
	return x;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		cf[i]=a[i]-a[i-1];
	}
	for(int i=1;i<=n;i++)a[i]=i;
	scanf("%lld%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&b[i]);
		swap(a[b[i]],a[b[i]+1]);
	}
	for(int i=1;i<=n;i++)f[i][0]=a[i];
	for(int i=1;i<=62;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	for(int i=1;i<=n;i++)xu[i]=cf[xjh(i,k)];
	double jia=0.0;
	for(int i=1;i<=n;i++)
	{
		jia=jia+(double)xu[i];
		printf("%.1lf\n",jia);
	}
	return 0;
}

Measured memory_bytes: 56192
import fractions
n,k = map(int,input().split())
a = list(map(int, input().split()))
if k > max(a):
  print("IMPOSSIBLE")
  exit()
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
if k%ans == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 91044
#include <stdio.h>
 
int main()
{
	int x = 0;
	char takahashi[5]; 
	
	scanf("%s", takahashi);
	
	for(int i = 0; i < 4; i++)
	{
		if (takahashi[i] == '+')
		{
			x++;
		}
		else if (takahashi[i] == '-')
		{
			x--;
		}	
	}
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
s = {}

to = 0
for i in range(N):
	st = input()
	st = str(sorted(st))
	if i == 0 or not st in s:
		s[st] = 1
	elif st in s:
		cnt = s[st]
		to += cnt
		s[st] = cnt + 1

print(to)


Measured memory_bytes: 21988
from sys import stdin


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


def factorization(a):
    if a < 2:
        return []
    fac = []
    lim = int(a ** 0.5)
    i = 2
    while a > 1 and i <= lim:
        n = 0
        while a % i == 0:
            a //= i
            n += 1
        if n > 0:
            fac += [(i, n)]
        i += 1
    if a > 1 or fac == []:
        fac += [(a, 1)]
    return fac


a, b = [int(x) for x in stdin.readline().split()]

print(len(factorization(gcd(a, b))) + 1)


Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
n,m = map(int, input().split())
p = list(map(int, input().split()))
xy=[]
for i in range(m):
    tmp = list(map(int,input().split()))
    xy.append(tmp)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(n)

for tmp in xy:
    uf.union(tmp[0]-1,tmp[1]-1)

ans=0
for i in range(n):
    if uf.same(i,p[i]-1):
        ans+=1
print(ans)

Measured memory_bytes: 96016
# Count Order
import itertools
N = int(input())
P = list(map(int, input().split(' ')))
Q = list(map(int, input().split(' ')))

L0 = list(range(1, N+1))
L = list(itertools.permutations(L0))
# print(L)
print(abs(L.index(tuple(P)) - L.index(tuple(Q))))

Measured memory_bytes: 8052
use proconio::*;

fn run() {
    input! {
        n: usize,
        s: String,
    }
    let mut map = std::collections::BTreeMap::new();
    map.insert('R', 0);
    map.insert('G', 1);
    map.insert('B', 2);
    let s: Vec<usize> = s.chars().map(|c| *map.get(&c).unwrap()).collect();
    let mut cnt = [0u64; 3];
    for &k in s.iter() {
        cnt[k] += 1;
    }
    let mut ans = cnt.iter().fold(1, |s, a| s * *a);
    for l in 0..n {
        let mut d = 1;
        while l + 2 * d < n {
            let (a, b, c) = (s[l], s[l + d], s[l + 2 * d]);
            if a != b && b != c && c != a {
                ans -= 1;
            }
            d += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2196
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))



    def get_primenumber(number):  # エラトステネスの篩
        prime_list = []
        search_list = list(range(2, number + 1))
        # search_listの先頭の値が√nの値を超えたら終了
        while search_list[0] <= math.sqrt(number):
            # search_listの先頭の値が√nの値を超えたら終了
            # search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
            head_num = search_list.pop(0)
            prime_list.append(head_num)
            # head_numの倍数を除去
            search_list = [num for num in search_list if num % head_num != 0]
        # prime_listにsearch_listを結合
        prime_list.extend(search_list)
        return prime_list


    def prime_factor_table(n):
        table = [0] * (n + 1)
        for i in range(2, n + 1):
            if table[i] == 0:
                for j in range(i + i, n + 1, i):
                    table[j] = i
        return table

    def prime_factor(n, prime_factor_table):
        prime_count = collections.Counter()

        while prime_factor_table[n] != 0:
            prime_count[prime_factor_table[n]] += 1
            n //= prime_factor_table[n]
        prime_count[n] += 1

        return prime_count

    table = prime_factor_table(10**6+10)

    numset = set()
    for i in A:
        thedic = prime_factor(i, table)
        for l in thedic.keys():
            flag = True
            if l in numset and l != 1:
                flag = False
                break
        if flag:
            tmpset = set(thedic.keys())
            numset |= tmpset
        else:
            break
    if flag:
        print('pairwise coprime')
        sys.exit()
    else:
        flag = True
        theset = set(prime_factor(A[0], table).keys())
        for i in A[1:]:
            thedic = prime_factor(i, table)
            theset = theset & set(thedic.keys())
            if len(theset) == 0:
                print('setwise coprime')
                flag = False
                break
    if flag:
        print('not coprime')



if __name__ == '__main__':
    solve()

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

vector<bool> prime(1000001,true);

void era(){
	prime[0]=false;
	prime[1]=false;
	for(int i=2;i<=1000000;++i){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,p;cin >> n >> p;
	if(n==1){
		cout << p << endl;
		return 0;
	}
	era();
	vector<ll> cnt(1000001);
	for(ll i=2;i<=1000000;++i){
		if(prime[i]){
			while(p%i==0){
				cnt[i]++;
				p/=i;
			}
		}
		if(p==1) break;
	}
	ll ans=1;
	rep(i,1000001){
		if(cnt[i]>=n){
			while(cnt[i]>=n){
				ans*=i;
				cnt[i]-=n;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define Online
#define nowtime (double)clock()/CLOCKS_PER_SEC
void tie()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
}
int main()
{
	tie();
	#ifndef Online
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	for(int i=0;i<n;i++)  cout<<"ACL";
	
	#ifndef Online
	fclose(stdin);
	fclose(stdout);
	#endif
	return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll H, W; cin >> H >> W;

	ll res{INF};
	auto f = [&res](ll H, ll W)
			 {
				 for (ll h1 = 1; h1 < H; ++h1)
				 {
					 ll h2 = H - h1;
					 ll w1 = W/2;
					 ll w2 = W - w1;

					 ll A = W * h1;
					 ll B = h2 * w1;
					 ll C = h2 * w2;
					 
					 res = min(res, max({A, B, C}) - min({A, B, C}));

					 ll h3 = h2/2;
					 ll h4 = h2 - h3;

					 B = h3 * W;
					 C = h4 * W;

					 res = min(res, max({A, B, C})-min({A, B, C}));
				 }
			 };

	f(H, W);
	f(W, H);
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N,W = imn()
wv = [iln() for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        if sum_w - wv[i][0] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-wv[i][0]]+wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[N][W])

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

int main() {
    string s;
    cin >> s;
    
    s = " " + s;
    int n = s.size();
    int cnt = 0;
    rep(i, n) {
        if (i == 0 || i == 1) continue;
        if (s[1] == '1') {
            if (i % 2 == 0 && s[i] == '1') cnt++;
            if (i % 2 == 1 && s[i] == '0') cnt++;
        }
        if (s[1] == '0') {
            if (i % 2 == 0 && s[i] == '0') cnt++;
            if (i % 2 == 1 && s[i] == '1') cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3840
#include<iostream>
#include<list>
#include<string>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>

using namespace std;

int main(void){
    string str;
    int i,j;
    int ia,oa0,oa1;
    cin >> str;
    cin >> ia;
    oa1 = str[0]-'0';
    for(i = 1;i < str.length();i+=2){
        if(str[i] == '+'){
            oa0 = str[i+1]-'0';
            for(i += 2;i < str.length();i+=2){
                if(str[i] == '*')
                    oa0 *= str[i+1]-'0';
                else
                    break;
            }
            i -= 2;
            oa1 += oa0;
        }
        else
            oa1 *= str[i+1]-'0';
    }
    oa0 = str[0]-'0';
    for(i = 1;i < str.length();i+=2){
        if(str[i] == '+')
            oa0 += str[i+1]-'0';
        else
            oa0 *= str[i+1]-'0';
    }
    if(oa0 == ia && oa1 == ia){
        cout << "U" << endl;
    }
    else if(oa0 == ia){
        cout << "L" << endl;
    }
    else if(oa1 == ia){
        cout << "M" << endl;
    }
    else
        cout << "I" << endl;
}

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

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

    for (int i = A; i <= B; i++){
        bool flag = true;

        string si = to_string(i);
        int L = si.length();
        for (int j = 0; j < L; j++){
//            cout << si << endl;
//            cout << si[j] << "-" << si[L-j-1] << endl;
            if(si[j] != si[L-j-1]){
                flag = false;
            }
        }
        if(flag == true){
            cnt++;
        }
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust\n";
	}
	else {
		cout << "win\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }



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


        char q;cin>>q;
        if((int)(q - 'A')  >= 0 && (int)(q - 'A') <= 25){
            cout<<"A\n";
        }
        else{
            cout<<"a\n";
        }
 
   return 0;
}


Measured memory_bytes: 3648
N = int(input())
data = [[int(i) for i in input().split()] for j in range(N)]

dp = [[0,0,0] for i in range(N)]
dp[0] = data[0]


for i in range(1,N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][k] for k in range(3) if j!=k) + data[i][j]

        
print(max(dp[-1])) 

Measured memory_bytes: 44148
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,x=0,ans=0;
  cin >> n;
  vector<ll> l(n),r(n);
  vector<TP> lr(n),rl(n);
  vector<bool> used(n,false);
  for(int i=0;i<n;i++){
    cin >> l[i] >> r[i];
    lr[i] = TP(l[i],r[i],i);
    rl[i] = TP(r[i],l[i],i);
  }
  ll lridx=0,rlidx=0,tmp=0;
  sort(lr.begin(),lr.end(),greater<>());
  sort(rl.begin(),rl.end());
  for(int i=0;i<n;i++){
    if(i%2==0){
      while(used[get<2>(rl[rlidx])]){
        rlidx++;
      }
      used[get<2>(rl[rlidx])] = true;
      ll le = get<1>(rl[rlidx]);
      ll ri = get<0>(rl[rlidx]);
      if(x<le){
        ans += le-x;
        x = le;
      }else if(x>ri){
        ans += x-ri;
        x = ri;
      }
    }else{
      while(used[get<2>(lr[lridx])]){
        lridx++;
      }
      used[get<2>(lr[lridx])] = true;
      ll le = get<0>(lr[lridx]);
      ll ri = get<1>(lr[lridx]);
      if(x<le){
        ans += le-x;
        x = le;
      }else if(x>ri){
        ans += x-ri;
        x = ri;
      }
    }
  }
  ans += abs(x);
  fill(used.begin(),used.end(),false);
  lridx = 0;
  rlidx = 0;
  x = 0;
  for(int i=0;i<n;i++){
    if(i%2){
      while(used[get<2>(rl[rlidx])]){
        rlidx++;
      }
      used[get<2>(rl[rlidx])] = true;
      ll le = get<1>(rl[rlidx]);
      ll ri = get<0>(rl[rlidx]);
      if(x<le){
        tmp += le-x;
        x = le;
      }else if(x>ri){
        tmp += x-ri;
        x = ri;
      }
    }else{
      while(used[get<2>(lr[lridx])]){
        lridx++;
      }
      used[get<2>(lr[lridx])] = true;
      ll le = get<0>(lr[lridx]);
      ll ri = get<1>(lr[lridx]);
      if(x<le){
        tmp += le-x;
        x = le;
      }else if(x>ri){
        tmp += x-ri;
        x = ri;
      }
    }
  }
  tmp += abs(x);
  ans = max(ans,tmp);
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int limit = 50;
int n,m;
int a[limit],b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
  if(visited[v] == true) return;
  
  visited[v] = true;
  for(int v2 = 0;v2<n;v2++){
    if(graph[v][v2]) dfs(v2);
  }
}


int main() {
  cin >> n >> m;
  
  for(int i= 0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]]  = true;
    }
   
  int ans = 0;
      
  for(int  i = 0;i<m;i++){
        graph[a[i]][b[i]] = graph[b[i]][a[i]]  = false;
        
        for(int j =0;j<n;j++){
          visited[j] = false;
        }
        
         dfs(0);
                                  
       bool bridge = false;
       for(int j= 0;j<n;j++){
         if(visited[j] == false) bridge = true;
       }
         if(bridge) ans += 1;
         graph[a[i]][b[i]] = graph[b[i]][a[i]]  = true;
        
      }                          
        cout << ans << endl;
                                    
}

Measured memory_bytes: 256
var str = [];
var count = 0;

function Main(input) {

	input = input.split("");
	
	for(var i = 0;i < 4;i++){
	    str[i] = input[i];
	}
	
	if(str[0]===str[1]){
	    if(str[2]===str[3]&&str[0]!==str[2]&&str[0]!==str[3]&&str[1]!==str[2]&&str[1]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else if(str[0]===str[2]){
	    if(str[1]===str[3]&&str[0]!==str[1]&&str[0]!==str[3]&&str[2]!==str[1]&&str[2]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else if(str[0]===str[3]){
	    if(str[2]===str[1]&&str[0]!==str[2]&&str[0]!==str[1]&&str[3]!==str[2]&&str[1]!==str[3]){
	        console.log("Yes");
	    }else{
	        console.log("No");
	    }
	}else{
        console.log("No");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_N 100005
using namespace std;
typedef pair<int,int> P;
P par[MAX_N];

void init(int n){
  for(int i=0;i<n;i++)
    par[i]=P(i,0);
}

P find(int x){
  if(par[x].first==x)return P(x,0);
  P r=find(par[x].first);
  return par[x]=P(r.first,par[x].second+r.second);
}

void unite(int x,int y,int cost){
  P r1=find(x);
  P r2=find(y);
  if(r1.first==r2.first)return;
  par[r1.first]=P(r2.first,r2.second-r1.second+cost);
}

bool same(int x,int y){return find(x).first==find(y).first;}

int n,m,a,b,cost;
char c;

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    init(n);
    rep(i,m){
      scanf("%c",&c);
      scanf("%c%d%d",&c,&a,&b);
      if(c=='!'){
	scanf("%d",&cost);
	unite(b-1,a-1,cost);
      }else{
	if(!same(a-1,b-1))printf("UNKNOWN\n");
	else printf("%d\n",find(b-1).second-find(a-1).second);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,n;
  cin >> d >> n;
  if(n==100){
    n=101;
  }
  if(d==0){
    cout << n << endl;
  }
  if(d==1){
    cout << n*100 << endl;
  }
  if(d==2){
    cout << n*10000 << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int N;
    static int X;
    static List<Integer> list;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        X = Integer.parseInt(sc.next());

        list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }

        solve();
    }

    static void solve() {
        int sum = list.stream().mapToInt(x -> x).sum();
        int min = Collections.min(list);

        System.out.println(list.size() + ((X - sum) / min));
    }
}

Measured memory_bytes: 27728
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
int gcd(int a, int b) {
    int tmp;
    while (b) {
        tmp = a;
        a = b;
        b = tmp % b;
    }
    return a;
}

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

/* main */
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = lcm(ans, a[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3100
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep (i, n) {
    cin >> s[i];
  }
  vvi mp(n, vi(26, 0));
  rep (i, n) {
    rep (j, (int)s[i].length()) {
      mp[i][s[i][j] - 'a'] += 1;
    }
  }
  vi ans(26, 100);
  rep (i, 26) {
    rep (j, n) {
      ans[i] = min(ans[i], mp[j][i]);
    }
  }
  rep (i, 26) {
    rep (j, ans[i]) {
      printf("%c", 'a' + i);
    }
  }
  printf("\n");



  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  ll x[N],y[N];
  for(int i=0;i<N;i++) cin >> x[i] >> y[i];

  //左上と右下を全探索
  ll ans = 5000000000000000000;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        for(int l=0;l<N;l++){
          int cnt = 0;
          for(int m=0;m<N;m++){
            if(x[m]<=max(x[i],x[j]) && x[m]>=min(x[i],x[j])
                  && y[m]<=max(y[k],y[l]) && y[m]>=min(y[k],y[l])){
              cnt++;
            }
          }

          if(cnt == K){
            ans = min(ans, abs(x[i]-x[j])*abs(y[k]-y[l]));
          }
        }
      }
    }
  }

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


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

int min(int a, int b)
{
	return (a > b) ? b : a;
}

int abs(int a)
{
	return (a < 0) ? -a : a;
}



bool func(int a, int b, int c, int d)
{
	return (a < b) && (b < c) && (c < d);
}

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	int a_ = a + w;
	int b_ = b + w;
	
	int ret;
	if ( func(a, a_, b, b_) || func(b, b_, a, a_) )
	{
		ret = min(abs(a_ - b), abs(b_ - a));
	}
	else
	{
		ret = 0;
	}
	
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

using pil = pair<int, ll>;
void dijkstra(int s, vector<ll> &d, const vector<vector<ll>> &G) {
    queue<int> que;
    fill(All(d), INF);
    d[s] = 0;
    que.push(s);

    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto e : G[v]) {
            if(d[e] == INF) {
                d[e] = d[v] + 1;
                que.push(e);
            }
        }
    }
}

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;
    vector<vector<ll>> G(N, vector<ll>());
    rep(i, N - 1) {
        G[i].pb(i + 1);
        G[i + 1].pb(i);
    }
    G[X].pb(Y);
    G[Y].pb(X);
    map<ll, int> mp;
    rep(i, N) {
        vector<ll> dist(N);
        dijkstra(i, dist, G);
        rep(j, N) mp[dist[j]]++;
    }
    for(int i = 1; i < N; i++) {
        cout << mp[i] / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

vector<int> g[101010];

int dfs(int s) {
        int res = 0;
        vector<int> v;
        for (auto ns : g[s]) v.push_back(dfs(ns));
        sort(rall(v));
        rep(i, v.size()) amax(res, v[i] + i);
        return res + 1;
}

signed main() { 
        int n;
        cin >> n;
        rep(i, n - 1) {
                int a;
                cin >> a;
                a --;
                g[a].push_back(i + 1);
        }
        cout << dfs(0) - 1 << endl;
        return 0;
}               


Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#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 f first
#define s second
#define int long long
signed main(){
	ic(n)
	sc(s)
	int ans=0;
	int it,zy,hy,iti,zyu,hya=0;
	rep(0,i,1000){
		it=50000;
		zy=50000;
		hy=50000;
		iti=i%10;
		zyu=(i%100)/10;
		hya=i/100;
		rep(0,j,n){
			if(s[j]-48==iti){
				it=j;
			}
		}
		for(int k=n;k>=0;k-=1){
			if(s[k]-48==hya){
				hy=k;
			}
		}
		rep(hy+1,l,it){
			if(it==50000){
				break;
			}	
			if(s[l]-48==zyu){
				ans++;
				break;
			}
		}
	}
	c(ans)
}				

Measured memory_bytes: 256
#include <iostream>
#include <malloc.h>


	template<class Elem>
	constexpr Elem Max(const Elem& a, const Elem& b) {
		return (a > b) ? a : b;
	}

	class AllocationFailed {};

	template<class TargetType>
	class DefaultConstructor {
	public:
		static void Construct(TargetType* p) {
			new(p) TargetType();
		}
	};


	template<class ElementType, class ConstructorType = DefaultConstructor<ElementType>>
	class Stack {
	private:
		ElementType* mPointer;
		size_t mSize;
		size_t mReservedSize;

		void ReserveExact(size_t size) {
			if (!size) {
				free(mPointer);
				mReservedSize = 0;
				return;
			}
			if (!mPointer) {
				void* tmp = malloc(sizeof(ElementType) * size);
				if (!tmp) throw AllocationFailed();
				mPointer = (ElementType*)tmp;
				mReservedSize = size;
				return;
			}
			void* tmp = realloc(mPointer, sizeof(ElementType) * size);
			if (!tmp) throw AllocationFailed();
			mPointer = (ElementType*)tmp;
			mReservedSize = size;
		}
		void ReserveWide(size_t size) {
			if (size <= mReservedSize) return;
			if (!mPointer) return ReserveExact(size);
			return ReserveExact(Max(mReservedSize << 1, size));
		}
	public:
		Stack() :
			mPointer(nullptr),
			mSize(0),
			mReservedSize(0) {}
		~Stack() { free(mPointer); }
		void Push(const ElementType& src) {
			ReserveWide(mSize + 1);
			ConstructorType::Construct(mPointer + mSize);
			*(mPointer + mSize) = src;
			mSize++;
		}
		void Pop() {
			mSize--;
		}
		const ElementType& Top() const {
			return *(mPointer + mSize - 1);
		}
		size_t Size() { return mSize; }
	};

int main() {
    try{
	Stack<int> stack;
	while (true) {
		char c; std::cin >> c;
		if (std::cin.eof()) break;
		if (c == '+') {
			int b = stack.Top(); stack.Pop();
			int a = stack.Top(); stack.Pop();
			stack.Push(a + b);
		}
		else if (c == '-') {
			int b = stack.Top(); stack.Pop();
			int a = stack.Top(); stack.Pop();
			stack.Push(a - b);
		}
		else if (c == '*') {
			int b = stack.Top(); stack.Pop();
			int a = stack.Top(); stack.Pop();
			stack.Push(a * b);
		}
		else {
			std::cin.unget();
			int o; std::cin >> o;
			stack.Push(o);
		}
	}
	std::cout << stack.Top() << std::endl;
    }
    catch(...){return 0;}
    return 0;
}





Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main(){
  double a[2],b[2],c[2],m[2][2],inv[2][2],det,ans[2],s,t;
  while(cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1]>>ans[0]>>ans[1]){
    b[0]-=a[0];
    b[1]-=a[1];
    c[0]-=a[0];
    c[1]-=a[1];
    ans[0]-=a[0];
    ans[1]-=a[1];
    m[0][0] = b[0];
    m[1][0] = c[0];
    m[0][1] = b[1];
    m[1][1] = c[1];
    det = m[0][0]*m[1][1]-m[1][0]*m[0][1];
    inv[0][0] = m[1][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][1] = m[0][0]/det;
    s = ans[0]*inv[0][0]+ans[1]*inv[1][0];
    t = ans[0]*inv[0][1]+ans[1]*inv[1][1];
    if(s>0 && t>0 && s+t<1){cout <<"YES\n";}
    else{cout <<"NO\n";}
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int N,M ;
int A[10001];

int main(){

	cin >> N >> M;

	int sum = 0;
	for(int i = 0;i < M;i++){
		cin >> A[i];
		sum += A[i];
	}


	int answer = N - sum;

	if(answer < 0)
		cout << -1<< endl ;
	else
		cout << answer << endl;


	return 0;
}



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

int N;
int a[100001];

int deg[100001] = {0};

// topological sort
int main(){
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d",&a[i]);
		deg[(i+a[i])%N]++;
	}
	
	queue<int> q;
	for(int i = 0; i < N; i++){
		if(deg[i] == 0){
			q.push(i);
		}
	}
	int ans = N;
	while(!q.empty()){
		int t = q.front(); q.pop();
		int idx = (t+a[t])%N;
		deg[idx]--;
		if(deg[idx] == 0){
			q.push(idx);
		}
		ans--;
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(int argc, char const* argv[])
{
	string sp;
	string t;
	cin >> sp >> t;
	set<int> st;
	for(int i = 0; i + t.size() <= sp.size(); i++){
			for(int j = 0; j < t.size(); j++){
					if(sp[i + j] != t[j] && sp[i + j] != '?')break;
					if(j == t.size() - 1){
							st.insert(i);
					}
			}
	}
	if(st.size() == 0){
			cout << "UNRESTORABLE" << endl;
			return 0;
	}
	auto itr = st.end();
	--itr;
	for(int i = 0; i < t.size(); i++){
			sp[*itr + i] = t[i];
	}
	for(int i = 0; i < sp.size(); i++){
			if(sp[i] == '?')sp[i] = 'a';
	}
	cout << sp << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, b;
  cin >> A >> B >> C;
  if (A < C && C < B){
    cout << "Yes" << endl;
  }
  else if (C < A && B < C){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
CD = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

S = N * 2
T = N * 2 + 1

graph = [[] for _ in range(N * 2 + 2)]
for i, (a, b) in enumerate(AB):
    for j, (c, d) in enumerate(CD):
        if a < c and b < d:
            rev = [i, 0]
            edge = [j + N, 1, rev]
            rev.append(edge)
            graph[i].append(edge)
            graph[j + N].append(rev)
for i in range(N):
    rev = [S, 0]
    edge = [i, 1, rev]
    rev.append(edge)
    graph[S].append(edge)
    graph[i].append(rev)
for i in range(N):
    rev = [i + N, 0]
    edge = [T, 1, rev]
    rev.append(edge)
    graph[i + N].append(edge)
    graph[T].append(rev)


def ford_fulkerson(v, t, f, used):
    if v == t:
        return f
    used[v] = True
    for edge in graph[v]:
        to, cap, rev = edge
        if not used[to] and cap > 0:
            d = ford_fulkerson(to, t, min(f, cap), used)
            if d > 0:
                edge[1] -= d
                rev[1] += d
                return d
    return 0


flow = 0
while True:
    f = ford_fulkerson(S, T, INF, [False] * (N * 2 + 2))
    if f == 0:
        break
    flow += f
print(flow)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N, K; cin >> N >> K;
    
    vector<ll> a(N);
    REP(i,N) cin >> a[i];


    for(int i=K; i<N; i++){
        if(a[i] > a[i-K]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 4776
l=%w(8<>@MS 89;>IP ?97:FM D>77CL IC<7>I ]WPKF< lf_ZUA).map{|l|l.bytes.map{|i|i-50}}
def g;gets.split.map &:to_i;end
while 0<n=g[0]
a=g
n,m=[n,g[0]].sort
b=g
c=l[n-1][m-2]
p ([a,b].all?{|i,j|k=i*60+j;1050>k||k>1170}||l[m-1][n-1]>40?c:(c+1)/2)*50
end

Measured memory_bytes: 6108
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

double dist(double x0, double y0, double x1, double y1){
    double dx = x0-x1, dy = y0-y1;
    return sqrt(dx*dx + dy*dy);
}

double area(double a, double b, double c){
    double z = (a+b+c)/2;
    return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(){
    int n = 0;
    double x[22], y[22];
    while(scanf("%lf,%lf\n", &x[n],&y[n])!=EOF) n++;
    double S = 0;
    rep(i,n-2){
        S += area(dist(x[n-1],y[n-1],x[i],y[i]),
                  dist(x[n-1],y[n-1],x[i+1],y[i+1]),
                  dist(x[i],y[i],x[i+1],y[i+1]));
    }
    printf("%.10lf\n",S);
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h;

    int table[n][100] = {0};
    for(int i = 0; i < n; ++i){
        cin >> h;
        for(int j = 0; j < 100; ++j){
            if(0<=j && j<h) table[i][j] = 1;
            else table[i][j] = 0;
        }
    }

    int res = 0;
    bool flg = false;
    for (int i = 0; i < 100; ++i){
        for (int j = 0; j < n; ++j){

            if(table[j][i] == 1) flg = true;
            else{
                if(flg) res++;
                flg = false;
            }
        }
        if(flg) res++;
        flg = false;
    }

    cout << res << endl;


}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		int c=1000-n,ans=0;
		while(c>=500) c-=500,++ans;
		while(c>=100) c-=100,++ans;
		while(c>=50) c-=50,++ans;
		while(c>=10) c-=10,++ans;
		while(c>=5) c-=5,++ans;
		while(c>=1) c-=1,++ans;
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3000
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++11 -D_GLIBCXX_DEBUG d.cpp -od && ./d " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fr(i,n) for(int i=(n);i--;)
#define fv(i,v) f(i,sz(v))

int pref[300*300+10];
pr<int,int> pos[300*300+10];

int dist(pr<int,int> a,pr<int,int> b){
	return abs(a.fi-b.fi)+abs(a.se-b.se);
}

main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int h,w,d;
	cin>>h>>w>>d;
	f(i,h){
		f(j,w){
			int a;
			cin>>a,a--;
			pos[a]={i,j};
		}
	}
	for(int j=d;j<h*w;j++){
		pref[j]=pref[j-d]+dist(pos[j],pos[j-d]);
	}
	int q;
	cin>>q;
	f(i,q){
		int l,r;
		cin>>l>>r,l--,r--;
		cout<<pref[r]-(l>=d?pref[l]:0)<<'\n';
	}
}


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

using namespace std;

vector<int> parents;
vector<int> sizes;

void init(int n) {
    parents = vector<int>(n, 0);
    sizes = vector<int>(n, 1);
    for (int i = 0; i < n; ++i) {
        parents[i] = i;
    }
}

int find(int x) {
    if (parents[x] == x) {
        return x;
    }
    else {
        parents[x] = find(parents[x]);
        return parents[x];
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }

    if (sizes[x] < sizes[y]) {
        parents[x] = y;
    }
    else { // if (sizes[x] >= sizes[y]) {
        parents[y] = x;
    }
    int total = sizes[x] + sizes[y];
    sizes[x] = total;
    sizes[y] = total;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void Main() {
    int N, M;
    cin >> N >> M;
    init(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        unite(a, b);
    }

    set<int> par;
    for (int i = 0; i < N; ++i) {
        par.insert(find(i));
    }
    cout << par.size() - 1 << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 7776
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin>>n;
    int cnt = 0;
    int ans = 0;
    for(int i = 1; i <= n; i+=2) {
        cnt = 0;
        for(int j = 1; j <= i; ++j) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a = 0;
    int b = 0;
    int N;
    for(int i=0; i<3; ++i) {
        cin >> N;
        if(N == 5) ++a;
        else if(N == 7) ++b;
    }
    if(a == 2 && b == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = if (0..S.len()).all(|i|
        ((i + 1) % 2 == 1 && (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) ||
        ((i + 1) % 2 == 0 && (S[i] == 'L' || S[i] == 'U' || S[i] == 'D'))
    ) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
  int x;
  scanf("%d",&x);
  int a=360;
  int b=x;
  int r=a%b;
  while(r!=0){
      a=b;
      b=r;
      r=a%b;
  }
  printf("%d\n",360/b);

  return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];
  sort(ALL(x));
  priority_queue<int, vector<int>, greater<int>> q;
  rep(i,m-1) {
    q.push(abs(x[i] - x[i+1]));
  }
  int ans = 0;
  rep(i,m-1-(n-1)) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

int main(){
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i==0){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
    return(0);
}

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


void solve(long long A, long long P){
    int ans=(3*A+P)/2;
    printf("%d\n",ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
s = gets.chomp
t = gets.chomp
s_hist = Array.new(26, 0)
t_hist = Array.new(26, 0)
n = s.length
for i in 0...n do
  s_hist[s[i].ord - 97] += 1
  t_hist[t[i].ord - 97] += 1
end
puts (s_hist.sort == t_hist.sort) ? "Yes" : "No"


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

int main(){
string str;
  string str1;
  str1="Z";
  int N;
  cin >> N;
  cin >> str;

 rep(i,str.length()){
 	str[i]=str[i]+N;
   if(str[i]>str1[0])str[i]=str[i]-26;
 }
  
  cout << str << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve(string S) {
  int cnt = count(S.begin(), S.end(), '0');
  cout << min((int)S.size() - cnt, cnt) * 2 << endl;
}
 
int main() {
  cout << setprecision(10);
  string S;
  cin >> S;
  solve(S);
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();++i)
    if(s[i]=='A'&&s[i+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}


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

int main()
{
	char arr[101];

	cin >> arr;
	int a = strlen(arr),count = 0;


	if (a%2 == 0)
	{
		int half = a/2;
		for ( int i = 0 ,j = a-1; i <= half-1, j >= half; i++ , j-- )
		{
			if ( arr[i] != arr[j] )
				count++;
		}
	}
	else
	{
		int half = (a-1)/2;
		for ( int i = 0 ,j = a-1; i < half, j > half; i++ , j-- )
		{
			if ( arr[i] != arr[j] )
				count++;
		}
	}

	cout << count;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main(){
	double a ,b, c, S, L, h;
	
	scanf("%lf %lf %lf", &a, &b, &c);
	
	double rad = c/180*M_PI; 
	
	S = a*b*sin(rad)/2.0;
	L = a + b + sqrt(a*a+b*b-2*a*b*cos(rad));
	h = 2*S/a;
	
	printf("%lf\n%lf\n%lf\n", S, L, h);
	
	return 0;
}
	

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

int main(){
    long long A,B;
    cin>>A>>B;
    long long x=B/A;
    long long ans=1;
    while(x>=2){
        ans++;
        x/=2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, sc[3], k;
int dp[100005][3]; //0 for r, 1 for p, 2 for s
string s;
int score(int x, char aga) {
	int t;
	if (aga == 'r') t = 0;
	else if (aga == 'p') t = 1;
	else t = 2;
	if ((t + 1) % 3 == x) return sc[x];
	else return 0;
}
void mxm(int &a, int b) { a = max(a, b); }
int solve(string s) {
	int m = s.length();
	for (int i = 0; i < m; ++i) {
		fill(dp[i], dp[i] + 3, -1);
	}
	for (int i = 0; i < 3; ++i)
		dp[0][i] = score(i, s[0]);
	for (int i = 0; i < m - 1; ++i)
		for (int j = 0; j < 3; ++j)
			if (dp[i][j] >= 0) {
				for (int k = 0; k < 3; ++k)
					if (k != j)
						mxm(dp[i + 1][k], dp[i][j] + score(k, s[i + 1]));
			}
	int ans = 0;
	for (int i = 0; i < 3; ++i)
		mxm(ans, dp[m - 1][i]);
	return ans;
}
int main() {
	cin >> n >> k >> sc[0] >> sc[2] >> sc[1] >> s;
	for (int i = 0; i <= n; ++i) fill(dp[i], dp[i] + 3, -1);
	int ans = 0;
	for (int i = 0; i < k; ++i) {
		string t = "";
		for (int j = i; j < n; j += k) t += s[j];
		ans += solve(t);
	}
	cout << ans << endl;
}

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

int N, W;
int w[110], v[110];
long long num[40010];
int n;
long long num2[40010];
int n2;
int memo[110][30010];

int bsrch(long long ww)
{
	int l = 0;
	int r = n2-1;
	int mm;
	while(l<=r){
		mm = (l+r)/2;
		if(ww > num2[mm])
			l = mm+1;
		else if(ww < num2[mm])
			r = mm-1;
		else
			return mm;
	}
}

void solve()
{
	int i, j;
	n = 0;
	for(i=0; i<N; i++){
		for(j=0; j<=300; j++){
			num[n] = i*w[0] + j;
			n ++;
		}
	}
	sort(num, num+n);
	n2 = 1;
	num2[0] = num[0];
	for(i=1; i<n; i++){
		if(num[i] != num[i-1]){
			num2[n2] = num[i];
			n2 ++;
		}
	}
	for(i=0; i<N; i++){
		for(j=0; j<n2; j++)
			memo[i][j] = -1000000010;
	}
	memo[0][0] = 0;
	for(i=0; i<N; i++){
		for(j=0; j<n2; j++){
			int val = memo[i][j];
			if(val > memo[i+1][j])
				memo[i+1][j] = val;
			long long ww = num2[j]+w[i];
			if(ww > W)
				continue;
			int jj = bsrch(ww);
			val += v[i];
			if(val > memo[i+1][jj])
				memo[i+1][jj] = val;
		}
	}
	int res = 0;
	for(i=0; i<n2; i++){
		if(memo[N][i] > res)
			res = memo[N][i];
	}
	printf("%d\n", res);
}

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

Measured memory_bytes: 12928