akhauriyash/Code-Regression huggingface dataset:
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int MAXN = 1000228;


string s;
int n;
int pre[MAXN], suf[MAXN];


int f(int x) {
	int num = 0, mn = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i-1]=='?')  {
			if (suf[i] + (num + 1) * 2 <=x) {
				num++;
			}
		}
		chkmin(mn, num * 2 + pre[i]);
	}
	return mn;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
	cin >> s;
	n = sz(s);
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i - 1] == '?' || s[i - 1] == '0') {
			pre[i] = pre[i - 1] - 1;
		} else {
			pre[i] = pre[i - 1] + 1;
		}
		chkmax(mx, pre[i]);
	}
	suf[n + 1] = -1e9;
	for (int i = n; i >= 1; i--) {
		suf[i] = max(suf[i + 1], pre[i]);
	}
	cout << min(mx - f(mx), mx + 1 - f(mx + 1)) << '\n';
	return 0; 	
}


Measured memory_bytes: 12172
#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>
#include<unordered_set>
#include<algorithm>

using namespace std;

namespace
{
	int CalcGcd(int x, int y)
	{
		int r;

		// ユーグリッドの互除法
		while ((r = x % y) != 0)  // yで割り切れるまでループ
		{
			x = y;
			y = r;
		}
		return y;
	}
}

#if 1
int main()
{
	int n;
	cin >> n;

	int x;
	cin >> x;

	if (n == 1)
	{
		int a;
		cin >> a;
		int dist = abs(a - x);
		cout << dist << endl;
		return 0;
	}

	int a1;
	int a2;
	cin >> a1;
	cin >> a2;
	int gcd = CalcGcd(abs(a1 - x), abs(a2 - x));
	for (int i = 0; i < n - 2; i++)
	{
		int a;
		cin >> a;
		int dist = abs(a - x);
		gcd = CalcGcd(gcd, dist);
	}

	cout << gcd << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
s = input()
count = 0
for i in range(0, len(s)):
    if i == 0 and s[i] == 'A': continue
    if i == 1 and 97 <= ord(s[i]) <= 122: continue
    if 2 <= i <= len(s) - 2:
        if s[i] == 'C':
            count += 1
            continue
        elif 97 <= ord(s[i]) <= 122: continue
    if count == 0 or count >= 2: break
    if i == len(s) - 1 and 97 <= ord(s[i]) <= 122:
        print("AC")
        exit()
print("WA")

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, L; cin >> N >> L;
  vector<string> S(N); REP(i, N) cin >> S[i];

  sort(all(S));
  REP(i, N) {
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
        public static void main(String[] args) {
		int i = 1;
                Scanner sc = new Scanner(System.in);
		while (true) {
			int num = sc.nextInt();
			if (num == 0) break;
			System.out.printf("Case %d: %d\n", i, num);
			i ++;
		}
	}
}

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

using namespace std;

const int N = 2 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
string s[N];
int b[N][N], w[N][N];
int f[N], g[N], h[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> s[i];

    return true;
}

void solve() {
    auto ans = 1;

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

        for (int j = 1; j < m; ++j)
            b[i][j] = (s[i][j] != s[i][j - 1]);

        for (int j = 0; j < m; ++j) {
            if (i == 0)
                w[i][j] = 1;
            else
                w[i][j] = (b[i][j] ^ b[i - 1][j]);

            if (w[i][j] == 1)
                f[j] = i;
        }

        vector<int> s;

        for (int j = 0; j < m; s.emplace_back(j++)) {
            for (; !s.empty() && f[s.back()] <= f[j]; s.pop_back()) { }
            g[j] = s.empty() ? 0 : s.back();
        }

        s.clear();

        for (int j = m - 1; j >= 0; s.emplace_back(j--)) {
            for (; !s.empty() && f[s.back()] <= f[j]; s.pop_back()) { }
            h[j] = s.empty() ? m : s.back();
            ans = max(ans, (i - f[j] + 1) * (h[j] - g[j]));
        }
    }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 36224
#include "bits/stdc++.h"
//#include <graphics.h>
using namespace std;
#ifdef __attribute__
#define fast __attribute__((optimize(3), target("no-ieee-fp,arch=corei7")))
#else
#define fast
#endif
#define inline fast inline
namespace io
{
#define USE_FREAD_IO
#ifdef USE_FREAD_IO
#define BUF_SIZE 5000010
	char buf[BUF_SIZE]; int cur = BUF_SIZE; FILE *in = stdin;
	inline char gnc()
	{
		if (cur == BUF_SIZE) { fread(buf, BUF_SIZE, 1, in); cur = 0; }
		return buf[cur++];
	}
#else
#define gnc getchar
#endif
	template<typename T>
	inline void gi(T &dx)
	{
		dx = 0;
		int yc = gnc();
		bool nega = false;
		while (yc < '0' || yc > '9') { nega = (yc == '-' ? true : nega); yc = gnc(); }
		while (yc >= '0' && yc <= '9') { dx = (T)(dx * 10 + yc - '0'); yc = gnc(); }
		if (nega) { dx = -dx; }
	}
	void gss(char *c)
	{
		*c = gnc();
		while (!isgraph(*c)) *c = gnc();
		while (isgraph(*c)) *++c = gnc();
		*c = 0;
	}
#if __cplusplus >= 201103l || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103l)
	template<typename T, typename ...Args> inline void gi(T &a, Args &...args)
	{ gi(a); gi(args...); }
#else
	template<typename t1, typename t2> inline void gi(t1 &a, t2 &b) { gi(a); gi(b); }
	template<typename t1, typename t2, typename t3> inline void gi(t1 &a, t2 &b, t3 &c) { gi(a); gi(b); gi(c); }
	template<typename t1, typename t2, typename t3, typename t4> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d) { gi(a); gi(b); gi(c); gi(d); }
	template<typename t1, typename t2, typename t3, typename t4, typename t5> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d, t5 &e) { gi(a); gi(b); gi(c); gi(d); gi(e); }
#endif
}
using namespace io;

int main()
{
	vector<long long> a = { 1,0 };
	int n, p; gi(n, p);
	for (int i = 1; i <= n; ++i) {
		int x; gi(x); x &= 1;
		if (!x) {
			a[0] += a[0];
			a[1] += a[1];
		} else {
			a = { a[0] + a[1], a[1] + a[0] };
		}
	}
	printf("%lld\n", a[p]);
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int N=0;
    int p[50]={};
    int count=0;
    int change=0;
    int max=0;
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    for(int i=0;i<N;i++){
        if(p[i]==i+1){

        }else{
            count++;
        }
    }
    if(count<3){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	vector<bool> cu(10, false);
	int N, K;
	int D;
	cin >> N >> K;
	rep(i, 0, K)
	{
		cin >> D;
		cu[D] = true;
	}

	int cnt = N;
	while (true)
	{
		int tc = cnt;
		bool ok = true;
		while (tc != 0)
		{
			if (cu[tc % 10])ok = false;
			tc /= 10;
		}
		if (ok)
		{
			cout << cnt << endl;
			break;
		}
		cnt++;
	}

	return 0;
}

Measured memory_bytes: 256
l = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
a,b = map(int,input().split())
for i in range(3):
  if a in l[i]:
    A = i
  if b in l[i]:
    B = i
if A == B:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  priority_queue<double> que;
  while (n--) {
    int a; cin >> a;
    que.emplace(a);
  }
  while (m--) {
    double a = que.top(); que.pop();
    que.emplace(a / 2);
  }
  long long ans = 0;
  while (!que.empty()) {
    int a = floor(que.top()); que.pop();
    ans += a;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int X,A,B,C;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);


	int ans = 0;
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			for(int k=0;k<=C;k++){
				if(500*i+100*j+50*k==X) ans++;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
S=input()
if S=="SSS":
    print(0)
else:
    if S=="RSS" or S=="SRS":
        print(1)
    else:
        if S=="SSR" or S=="RSR":
            print(1)
        else:
            if S=="RRS" or S=="SRR":
                print(2)
            else:
                print(3)

Measured memory_bytes: 8944
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	int count = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			count++;
		}
	}
	cout << count << endl;
}


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

using namespace std;

const int INF = 1e9;

int n,ma,mb,i,j,dp[405][405];

int main(){
	scanf("%d%d%d", &n, &ma, &mb);
	
	for(i = 0; i <= 400; i++){
		for(j = 0; j <= 400; j++)
		dp[i][j] = INF;
	}
	
	dp[0][0] = 0;
	
	for(i = 0; i < n; i++){
		int x,y,z;
		scanf("%d%d%d", &x, &y, &z);
		
		for(int ii = 400; ii >= x; ii--){
			for(int jj = 400; jj >= y; jj--)
			dp[ii][jj] = min(dp[ii][jj], dp[ii - x][jj - y] + z);
		}
	}
	
	int res = INF;
	
	for(i = 1; ; i++){
		if(ma * i > 400 || mb * i > 400) break;
		res = min(res, dp[ma * i][mb * i]);
	}
	
	if(res == INF)
	printf("-1\n");
	else
	printf("%d\n", res);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int P=1e9+7,N=(int)(6e5+50)<<2;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int n,ch[N][3],vn,swp[N],ori[N],m,q,res[N];
char s[N]; 

void ins(int x){
	int w=x,v=1;
	lop(i,0,n){
		int y=x%3;
		if(!ch[v][y])ch[v][y]=++vn;
		v=ch[v][y];
		x/=3;
	}
	ori[v]=w;
}
void down(int v){
	if(swp[v]){
		swap(ch[v][1],ch[v][2]);
		swp[v]=0;
		lop(j,0,3)swp[ch[v][j]]^=1;
	}
}
void add(){
	int v=1;
	lop(i,0,n){
		down(v);
		swap(ch[v][0],ch[v][1]);
		swap(ch[v][0],ch[v][2]);
		v=ch[v][0];
	}
}
void dfs(int v,int d,int pwd,int w){
	if(d==n){
		res[ori[v]]=w;
		return;
	}
	down(v);
	lop(j,0,3){
		dfs(ch[v][j],d+1,pwd*3,w+pwd*j);
	}
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	scanf("%d%s",&n,s); 
	m=1; 
	lop(i,0,n)m*=3;
	q=strlen(s); 
	vn=1;
	lop(i,0,m)ins(i); 
	lop(i,0,q){
		if(s[i]=='R')add();
		else swp[1]^=1;
	}
	dfs(1,0,1,0);
	lop(i,0,m)printf("%d ",res[i]); 
	return 0; 
}


Measured memory_bytes: 17784
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]

use std::cmp;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// N M
// input! {
//     N: i32,
//     M: i32,
// }

// N
// a1, ..., aN
// input! {
//     N: i32,
//     A: [i32, N],
// }

// H W
// a11 ... a1W
// ...
// aH1 ... aHW
// input! {
//     H: i32,
//     W: i32,
//     A: [[i32, W], H],
// }

// S
// input! {
//     S: chars,
// }

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
    };

    if cmp::min(A, B) <= C && C <= cmp::max(A, B) {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(void)
{
	char str[300] = {0};
	char buf1[300] = {0};
	int i, n, cmd, str_len;
	
	while(1) {
		memset(str, '\0', sizeof(str));
		scanf("%s", str);
		if (str[0] == '-') break;
		scanf("%d", &n);

		str_len = strlen(str);
		for (i = 0; i < n; ++i) {
			scanf("%d", &cmd);
			memset(buf1, '\0', sizeof(buf1));
			memcpy(buf1, &str[cmd], str_len - cmd);
			memcpy(&buf1[str_len -cmd], str, cmd);
			memcpy(str, buf1, str_len);
		}
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#define heap_max 250
     
int main(){
    int i,heap[heap_max],inHeap;
     
    scanf("%d",&inHeap);
    for(i=1;i<inHeap+1;i++) scanf("%d",&heap[i]);
     
    for(i=1;i<inHeap+1;i++){
        printf("node %d: key = %d,",i,heap[i]);
        if(i/2!=0) printf(" parent key = %d,",heap[i/2]);
        if(2*i<=inHeap) printf(" left key = %d,",heap[2*i]);
        if((2*i+1)<=inHeap) printf(" right key = %d,",heap[2*i+1]);
        printf(" \n");
        }
    return 0;
    }

Measured memory_bytes: 608
n = list(reversed(list(map(int, input()))))
k = len(n)
dp1, dp2 = [0] * k, [0] * k
dp1[0], dp2[0] = n[0], 11-n[0]
for i, x in enumerate(n[1:], 1):
    dp1[i] = min(x+dp1[i-1], x+dp2[i-1])
    dp2[i] = min(11-x+dp1[i-1], 9-x+dp2[i-1])
print(min(dp1[-1], dp2[-1]))

Measured memory_bytes: 98684
from collections import Counter
from operator import itemgetter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

def num(n):
	if n in c.keys():
		return c[n]
	else:
		return 0

candidate = num(0) + num(1) + num(2)
ans = candidate

for i in range(1, 99998):
	candidate -= num(i-1)
	candidate += num(i+2)
	if candidate > ans:
		ans = candidate

print(ans)

Measured memory_bytes: 14564
import sys
input = sys.stdin.readline
N = int(input())
mod = 1000000007
A = [int(i) for i in input().split()]
import fractions
from fractions import gcd
def lcm(x,y) :
    return(x*y) // fractions.gcd(x,y)
k =  A[0]
for i in range(1,N) :
    k = lcm(k,A[i])
sum = 0
for i in range(N) :
    B = k // A[i]
    sum += B
sum = sum % mod
print(sum)

Measured memory_bytes: 5596
#include<iostream>
#include<bitset>
#include<string.h>
using namespace std;
typedef long long ll;
bool vis[401][401];
char mat[401][401];
int H,W;
ll blk, wht;
void dfs(int i, int j){
    vis[i][j] = true;
    int r[] = {1, -1, 0, 0}, c[] = {0, 0, 1, -1};
    int cnt = 0;
    if (mat[i][j] == '#') blk++;
    if (mat[i][j] == '.') wht++;
    for (int x=0;x<4;x++){
        int ni = i + r[x], nj = j + c[x];
        if (ni < H && ni >=0 && nj < W && nj >= 0 && !vis[ni][nj] && mat[ni][nj]!= mat[i][j])
            dfs(ni, nj);
    }
    // cout << "cnt: " << cnt << endl;
}   

int main(void){
    cin >> H >> W;
    for (int i=0;i<H;i++)
        cin >> mat[i];
    memset(vis,false,sizeof(vis));
    ll ans = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            if (vis[i][j]) continue;
            blk = 0;
            wht = 0;
            dfs(i, j);
            ans += blk*wht;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15616
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete

f :: Maybe Int -> Char -> (Maybe Int, Maybe Int)
f _ 'c' = let r = Just 0 in (r, r)
f m '.' = let r = (+1) <$> m in (r, r)

main = do
    [h, w] <- getInts
    replicateM h $ getLine >>= putStrLn . sjoin . map (fromMaybe (-1)) . snd . mapAccumL f Nothing


Measured memory_bytes: 4120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    string s;
    cin >> s;
    s[3] = '8';

    cout << s << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define rep(i,a,n) for(int i = a; i<n; i++)
#define per(i,a,n) for(int i = n-1; i>=a; i--)

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


const int INF = 1e9+7;

int n,in[100];


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

  cin>>n;
  int res = 0;
  rep(i,1,n+1){

    cin>>in[i-1];
    if(i%2 == 1 && in[i-1] % 2 == 1)res++;
  }
  cout<<res<<"\n";


}


Measured memory_bytes: 3548
#include <stdio.h>
void swap(int* x, int* y) {
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

int main(void) {
	// your code goes here
	int a, b, c, tmp;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(a > b) { swap(&a, &b); }
	if(b > c) { swap(&b, &c); }
	if(a > b) { swap(&a, &b); }
	
	printf("%d %d %d\n", a, b, c);	
	
	return 0;
}

Measured memory_bytes: 596
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m; cin >> n >> m; cout << (n-1)*(m-1) << endl;
  
    return 0;
}



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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

typedef pair<int,int> pt;

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

  int n;
  cin>>n;
  vector<pt> red(n);
  for (int i=0; i<n; i++) {
    int x,y; cin>>x>>y;
    red[i].first=y;
    red[i].second=x;
  }

  priority_queue<pt,vector<pt>,greater<pt>> blue;
  for (int i=0; i<n; i++) {
    int x,y; cin>>x>>y;
    blue.push({x,y});
  }

  sort(red.begin(),red.end(),greater<pt>());
  vector<bool> used(n);
  int res = 0;
  while (!blue.empty()) {
    pt p = blue.top(); blue.pop();

    for (int i=0; i<n; i++) {
      pt r = red[i];
      if (r.second < p.first && r.first < p.second && !used[i]) {
	res++;
	used[i]=true;
	break;
      }
    }
  }

  cout<<res<<endl;

  return 0;
}


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

int main(){
    ll k, a, b; cin >> k >> a >> b;
    ll ans=1;
    if(2<b-a && 2<=k-(a-1)){
        k -= a-1;
        ans += k/2*(b-a) + k%2 + a-1;
    }else{
        ans += k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;

int n,a,b;

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	printf("%d %d\n",min(a,b),max(0,a+b-n));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
using namespace std;
#define ll long long int

bool solve(string s){
  if(s[5] == '1') 
  {
    return true;
  }
  else
  {
    if(s[6] == '4' || s[6] == '3' || s[6] == '2' || s[6] == '1' )return false;
    else return true;
  }
}

void output(bool ok){
  if(ok)cout<<"TBD"<<endl;
  else cout<<"Heisei"<<endl;  
}

int main(){ 
  string s;
  cin >> s;
  bool ok = solve(s);
  output(ok);
  return 0;
}


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

int main(){
  int x, ans;
  cin >> x;
  if(x<600)ans = 8;
  else if(x<800)ans = 7;
  else if(x<1000)ans = 6;
  else if(x<1200)ans = 5;
  else if(x<1400)ans = 4;
  else if(x<1600)ans = 3;
  else if(x<1800)ans = 2;
  else ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	if (abs(x - a) < abs(x - b)) printf("A\n");
	else printf("B\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int redsum=0;
  for(int i=0; i<n; i++){
    if('R' == s[i])++redsum;
  }
  if(redsum>n-redsum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int i,n1,n2;
        char o[51],e[51];

        scanf("%s",o);
        scanf("%s",e);

        n1 = 0;
        n2 = 0;
        while(o[n1]!='\0')
                n1++;
        while(e[n2]!='\0')
                n2++;

        if(n1>n2){
                for(i=0;i<n2;i++)
                        printf("%c%c",o[i],e[i]);
                printf("%c",o[n1-1]);
        }
        else{
                for(i=0;i<n1;i++)
                        printf("%c%c",o[i],e[i]);
        }
        printf("\n");

        return 0;
}


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

int main() {
  int a;
  cin >> a;
  if (a % 10 == 2 || a % 10 == 4 || a % 10 == 5 || a % 10 == 7 || a % 10 == 9) {
    cout << "hon";
  }else if (a % 10 == 0 || a % 10 == 1 || a % 10 == 2 || a % 10 == 6 || a % 10 == 8){
    cout << "pon";
  }else {
    cout << "bon";
  }
  return 0;
}

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

int main() {
    long long int n;
    cin>>n;
    long long int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int n,m;cin>>n>>m;

    VVI e(n);
    REP(i,m){
        int a,b;cin>>a>>b;
        a--;
        b--;
        e[a].PB(b);
        e[b].PB(a);
    }

    VI result(n,-1);
    queue<int> q;
    q.push(0);
    result[0]=0;

    while(!q.empty()){
        int now = q.front();
        q.pop();

        for(auto next : e[now]){
            if(result[next]!=-1){
                continue;
            }
            result[next]=now;
            q.push(next);
        }

    }

    REP(i,n){
        if(result[i]==-1){
            cout<<"No"<<endl;
            return;
        }
    }
    
    cout<<"Yes"<<endl;
    FOR(i,1,n){
        cout<<result[i]+1<<endl;
    }





	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 10296
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val V = na(N)
    val C = Array.ofDim[Int](2, 1e5.toInt + 1)
    rep(N) { i =>
      C(i % 2)(V(i)) += 1
    }

    val evenSorted = C(0).zipWithIndex.sortBy(_._1)
    val oddMaxSorted = C(1).zipWithIndex.sortBy(_._1)

    val ans = if (evenSorted.last._2 != oddMaxSorted.last._2) {
      N - evenSorted.last._1 - oddMaxSorted.last._1
    } else {
      N - max(evenSorted.last._1 + oddMaxSorted(oddMaxSorted.length - 2)._1,
        evenSorted(evenSorted.length - 2)._1 + oddMaxSorted.last._1
      )
    }

    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}


Measured memory_bytes: 45004
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

ll K;
int main(){
    ios::sync_with_stdio(false);
    cin >> K;
    
    vector<ll> ans(50, 0);
    REP(i, 50) {
        ans[i] = 49 + K / 50;
        
    }
    
    reverse(ans.begin(), ans.end());
    K %= 50;
    
    REP(i, K) {
        ans[i] += 50;
        REP(j, 50) {
            if (i!=j) ans[j] -= 1;
        }
    }
    
    cout << 50 << endl;
    cout << ans[0];
    FOR(i,1,50) cout << " " << ans[i];
    cout << endl;
    
    return 0;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int T[300010];

int right(int l, int r) { return T[r]-(l>0?T[l-1]:0); }
int left(int l, int r) { return r-l+1-right(l, r); }

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  string str;
  cin >> str;
  rep(i, N) T[i] = str[i]=='E';
  rep(i, N-1) T[i+1] += T[i];
  int m = N;
  rep(i, N) {
    m = min(m, (i>0?left(0, i-1):0) + (i+1<N?right(i+1, N-1):0));
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 1812
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#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>
using namespace std;
const int INF = (int)2e9 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, temp;
  cin >> N;

  vector<int> seq;
  vector<int> slime;

  int n2 = 1 << N;
  for (int i = 0; i < n2; i++) {
    cin >> temp;
    seq.push_back(temp);
  }
  sort(seq.begin(), seq.end());
  slime.push_back(seq.back());
  seq.back() = -INF;
  int cnt;

  for (int i = 0; i < N; i++) {
    vector<int> pre = slime;
    sort(pre.begin(), pre.end());
    cnt = n2 - 1;
    while (pre.size() > 0 && cnt >= 0) {
      if (seq[cnt] != -INF && seq[cnt] < pre.back()) {
        slime.push_back(seq[cnt]);
        pre.pop_back();
        seq[cnt] = -INF;
      }
      cnt--;
    }
    if (pre.size() > 0) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 3316
dish_time = [int(input()) for i in range(5)]
rest=[0,0,0,0,0]
last_min=[]

for j in range(5):
    rest[j] = dish_time[j] - (dish_time[j]//10*10)
    if rest[j] != 0:
        dish_time[j] = (dish_time[j]//10 + 1 ) *10   
        last_min.append(rest[j])

sum_time =  0

for i in range(5):
    sum_time = sum_time + dish_time[i]

if len(last_min) != 0:
    sum_time = sum_time + min(last_min) - 10
    print(sum_time)
else :
    sum_time = sum_time
    print(sum_time)

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }

struct node {
    ll num;
    string all;
};

int main() {
    ll k;
    cin >> k;

    if (k <= 9) {
        cout << k << endl;
        return 0;
    }

    queue<struct node> q;
    rep(i, 1, 10) {
        struct node temp = {i, to_string(i)};
        q.push(temp);
    }

    ll cnt = 0;

    struct node t;
    while (cnt < k) {
        t = q.front(); q.pop();
        rep(i, t.num - 1, t.num + 2) {
            if (i < 0 || i > 9) continue;
            struct node temp = {i, t.all + to_string(i)};
            q.push(temp);
        }
        cnt++;
    }

    cout << t.all << endl;

    return 0;
}


Measured memory_bytes: 12288
#include<iostream>

using namespace std;

int main(){
  int i,j,N,M,C,A[25][25],B[25],c=0,t[25]={};
  cin>>N>>M>>C;
  for(i=0;i<M;i++) cin>>B[i];
  for(i=0;i<N;i++){
    for(j=0;j<M;j++){
      cin>>A[i][j];
      t[i]+=A[i][j]*B[j];
    }
  }
  for(i=0;i<N;i++){
    if(t[i]+C>0) c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stdio.h>
#include<stack> 
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

/*int main() {
	
	stack<int> S;
	char ch;
	int part[2000];
	for ( int i = 0; i < 2000; i++) part[i] = 0;
	int area = 0;
	int j = 0;
	for ( int i = 1; scanf("%c", &ch) != EOF  ; i++) {
		if ( ch == '\\' ) {
		S.push(i);//printf("i=%d ", i);
		}
		else if ( ch == '/') {
			int m = S.top();
			//printf("m=%d i=%d\n", m,i); 
			part[j] += i - m;
			//printf("%d ",part[j]);
			S.pop();
			if ( !S.size() ) {
				area += part[j];
				j++;
			}
		}
	}
	printf("%d\n", area);
	printf("%d", j);
	for ( int i = 0; i < j; i++) {
		printf(" %d", part[i]);
	}
	cout << endl;
	return 0;
	
}*/

int main() {
	stack<int> S1;
	stack<pair<int, int> >S2;
	char ch;
	int sum = 0;
	for ( int i = 0; cin >> ch; i++){
		if ( ch == '\\' ) S1.push(i);
		else if ( ch =='/' && S1.size() > 0 ) {
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a= i - j;
			while (S2.size() > 0 && S2.top().first > j ) {
				a += S2.top().second; S2.pop();
			}
		S2.push(make_pair(j,a));	
		}
	}
	vector<int> ans;
	while ( S2.size() > 0 ) {
		ans.push_back(S2.top().second);
		S2.pop();
	}  
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for ( int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int INF=pow(10,8);
  int N,M,R;
  scanf("%d%d%d",&N,&M,&R);
  vector<int> rv(R);
  for(int i=0;i<R;i++){
    scanf("%d",&rv[i]);
  }
  vector<vector<int>> D(N,vector<int>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      D[i][j]=INF;
    }
  }
  int A,B,C;
  for(int i=0;i<M;i++){
    scanf("%d%d%d",&A,&B,&C);
    D[A-1][B-1]=min(C,D[A-1][B-1]);
    D[B-1][A-1]=min(C,D[B-1][A-1]);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        D[j][k]=min(D[j][k],D[j][i]+D[i][k]);
      }
    }
  }
  int roop=1;
  for(int i=1;i<=R;i++){
    roop*=i;
  }
  sort(rv.begin(),rv.end());
  int P=INF;
  int Q;
  for(int i=0;i<roop;i++){
    Q=0;
    for(int j=0;j<R-1;j++){
      Q+=D[rv[j]-1][rv[j+1]-1];
    }
    P=min(P,Q);
    next_permutation(rv.begin(),rv.end());
  }
  printf("%d",P);
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int S, tep, sum = 0;

	scanf("%d", &S);
	tep = S;

	while (S != 0) {
		sum += S % 10;
		S /= 10;
	}

	if (tep % sum == 0)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int a[110];
ll d[110][100010];
ll md=1e9+7;
int main()
{
	cin >>n>>m;
	for (int i=1;i<=n;i++) cin >>a[i];
	for (int i=0;i<=m;i++) d[0][i]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=m;j++)
		{
			d[i][j]=(d[i-1][j]-(j-a[i]-1>=0 ? d[i-1][j-a[i]-1] : 0))%md;
			if (d[i][j]<0) d[i][j]+=md;
			if (j) d[i][j]+=d[i][j-1];
		}
	}
	cout <<d[n][m]-(m ? d[n][m-1] : 0);
	return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
   string s;
   cin >> s;
   int max_n = 0;
   for(int i=0; i<s.size(); i++){
       int sum = 0;
       if(s.at(i) != 'A' and s.at(i) != 'C' and s.at(i) != 'G' and s.at(i) != 'T'){
           continue;
       }
       sum++;
       for(int j=i+1; j<s.size(); j++){
           if(s.at(j) != 'A' and s.at(j) != 'C' and s.at(j) != 'G' and s.at(j) != 'T'){
               break;
           }
           sum++;
       }
       max_n = max(max_n, sum);
   }

   cout << max_n << endl;
   return 0;
}


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

typedef long long ll;

vector<int> pre,in,post;
int n,pos;

int findx(int root){
    for(int i=0;i<n;i++){
        if(in[i]==root)return i;
    }
    return n;
}


void solve(int l,int r){
    if(l>=r)return;
    int root=pre[pos++];
    int m=findx(root);
    solve(l,m);
    solve(m+1,r);
    post.push_back(root);
}

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

    cin >> n;
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        pre.push_back(k);
    }
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        in.push_back(k);
    }
    solve(0,pre.size());
    for(int i=0;i<n;i++){
        if(i)cout << " ";
        cout << post[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int n;
	while ( cin >> n ){
		if ( n == -1 ) break;

		double x = 1.0, y = 0.0;
		double bottom = 1.0;
		double tan = 1.0 / bottom;
		double angle = 0.0;

		--n;

		while(n > 0){
			y += 1.0 * sin( angle + ( 90.0 * 3.1415926535 / 180.0 ) );
			x += 1.0 * cos( angle + ( 90.0 * 3.1415926535 / 180.0 ) );

			angle += atan( tan );

			bottom = sqrt( (y - 0.0) * (y - 0.0) + (x - 0.0) * (x - 0.0) );
			tan = 1.0 / bottom;

			--n;
		}

		printf("%0.2f\n", x);
		printf("%0.2f\n", y);

	}
	return 0;
}

Measured memory_bytes: 1248