akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}

void solve(){
    ll a, b;
    cin >> a >> b;
    if(a > b)swap(a, b);
    fo(i, b){
        cout << a;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(void){
  char a, b;
  cin >> a >> b;
  if(a=='H'){
    if(b=='H'){
      cout << "H\n";
    }else{
      cout << "D\n";
    }
  }else{
    if(b=='H'){
      cout << "D\n";
    }else{
      cout << "H\n";
    }
  }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::{Ordering, min};

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut s: Vec<i64>  = Vec::with_capacity(n);
    for _ in 0..n {
        s.push(read());
    }
    let mut s1 = 0;
    let mut s2 = (&s).into_iter().fold(0, |i, sum| sum + i);
    let mut ret: i64 = 10000000;
    for i in 0..n {
        s1 += s[i];
        s2 -= s[i];
        ret = min(ret, (s1 - s2).abs());
    }
    println!("{}", ret);
}


Measured memory_bytes: 4352
from operator import mul

n = int(input())
cof = [1 << x for x in range(10)]
fs = [sum(map(mul, map(int, input().split()), cof)) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]

ans = float('-inf')
for g in range(1, 1024):
   ans = max(ans, sum(p[bin(f & g).count('1')] for f, p in zip(fs, ps)))

print(ans)


Measured memory_bytes: 3064
a=list(input())
b=list(input())

n=len(a)
f=-1

for i in range(n):
    for k in range(n):
        if not a[k]==b[k]:
            break
    else:
        f=1
        break
    if f<0:
        tmp=['0']*n
        tmp[0]=b[n-1]
        for j in range(1,n):
            tmp[j]=b[j-1]
        for k in range(n):
            b[k]=tmp[k]

if f>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,a,b;
	cin >> n >> a >>b;
	int m = n * a;
	m = min(m,b);
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,a;
    cin>>n>>a;
    n%=500;
    if(n<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] w = new String[n];
		for(int i = 0; i < n; i++)w[i] = sc.next();
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				if(w[i].equals(w[j])) {
					System.out.println("No");
					return;
				}
			}
		}
		
		for(int i = 1; i < n; i++) {
			if(w[i - 1].charAt(w[i - 1].length() - 1) 
					!= w[i].charAt(0)){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22612
n = int(input())
xu = [list(map(str,input().split())) for i in range(n)]
ans = 0
for i in range(n):
    if xu[i][1]=='JPY':
        ans += float(xu[i][0])
    else:
        ans += float(xu[i][0])*380000
print(round(ans,6))


Measured memory_bytes: 3060
if __name__ == '__main__':
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    count = 0
    for ia in range(a+1):
        for ib in range(b+1):
            for ic in range(c+1):
                if 500*ia+100*ib+50*ic == x:
                    count = count+1

    print(count)


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main() {
	int n, t, c=0;
	cin >> n;
	while (n--) {
		cin >> t;
		while (~t & 1) {
			t >>= 1;
			++c; 
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int w, h;
	while (cin >> w >> h, w){
		vector<string> cell(h);
		int sx=-1, sy;
		REP(i, h){
			cin >> cell[i];
			if (sx==-1)
			REP(j, w){
				if (cell[i][j] == '@'){
					sx = j;
					sy = i;
					cell[i][j] = '#';
				}
			}
		}
		queue<pair<int, int>> Q;
		Q.push(pair<int, int>(sx, sy));
		int ans = 0;
		while (!Q.empty()){
			ans++;
			pair<int, int> p = Q.front(); Q.pop();
			REP(i, 4){
				if (0 <= p.first + dx[i] && p.first + dx[i] < w && 0 <= p.second + dy[i] && p.second + dy[i] < h&&cell[p.second + dy[i]][p.first + dx[i]] == '.'){
					cell[p.second + dy[i]][p.first + dx[i]] = '#';
					Q.push(pair<int, int>(p.first + dx[i], p.second + dy[i]));
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

int N, M; cin >> N >> M;
VI A(M); invec(A);

i64 shuku = accumulate(ALL(A), (i64)0);
if (N < shuku) {
    cout << "-1\n";
}
else {
    cout << N - shuku << "\n";
}


return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n,t;
    cin >> n >> t;
    vector<P> v;
    
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    int dp[n+1][t];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < t; j++){
            dp[i][j] = 0;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < t; j++){
            dp[i+1][j] = dp[i][j];
            ans = max(ans,dp[i+1][j] + v[i].second);
            if(j - v[i].first >= 0){
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-v[i].first] + v[i].second);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    int apple[n];
    int expect = 0;
    for(int i=0; i<n; i++){
        apple[i] = l + i;
        expect += apple[i];
    }
    if(l>=0){
        cout << expect - apple[0] << endl;
    }
    else if(n <= -l){
        cout << expect - apple[n-1] << endl;
    }
    else{
            cout << expect << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

int N;
int h[100005], dp[100005];

int solve(int idx = 0)
{
    if(idx == N) return 0;

    int & ret = dp[idx];

    if(~ret)return ret;

    return ret = min(
            ((idx + 1) <= N) * (solve(idx + 1) + abs(h[idx] - h[idx + 1])),
            ((idx + 2) <= N) * (solve(idx + 2) + abs(h[idx] - h[idx + 2]))
    );
}
int main(int argc, char const *argv[])
{
	// file();
	fast();

    cin>>N;
    fill(h, h + 100005, INT_MAX);
    for (int i = 0; i < N; ++i)
    {
        cin>>h[i];    
    }
    
    clr(dp, -1);

    cout<<solve();
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
  int a, b;
  char c[128];

  scanf("%d %s %d", &a, c, &b);
  while(c[0] != '?') {
    if (c[0] == '+')
      printf("%d\n", a + b);
    else if (c[0] == '-')
      printf("%d\n", a - b);
    else if (c[0] == '*')
      printf("%d\n", a * b);
    else if (c[0] == '/')
      printf("%d\n", a / b);
    scanf("%d %s %d", &a, c, &b);
     }

  return 0;
}


Measured memory_bytes: 1992
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').ToArray();
            var a = long.Parse(ab[0]);
            var b = long.Parse(ab[1].Replace(".", ""));
            Console.WriteLine(a * b / 100);
        }
    }
}


Measured memory_bytes: 27936
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll x, y, z, K; cin >> x >> y >> z >> K;
  Vll a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  Vll ab;
  rep(i, x) rep(j, y) ab.push_back(a[i]+b[j]);
  sort(all(ab));
  reverse(all(ab));

  Vll abc;
  rep(i, min(x*y, K)) rep(j, z) abc.push_back(ab[i]+c[j]);
  sort(all(abc));
  reverse(all(abc));

  rep(i, K) cout << abc[i] << endl;
  return 0;
}


Measured memory_bytes: 43112
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] a=new int[N];
		for(int i=0; i<N; i++) {
			a[i]=sc.nextInt();
		}

		int cnt=0;

		boolean waru2=true;
		for(int i=0; i<N; i++) {
			waru2=true;
			while(waru2==true) {
				if((a[i]/2)*2==a[i]) {
					a[i]/=2;
					cnt++;
					//そのまま
				}
				else if((a[i]/2)*2!=a[i]) {
					waru2=false;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 34396
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
bool rev = 0;
deque<char> me;
string s, ans;
int q, tt, ff;
char gg;

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

	cin >> s;
	for(auto u : s)
		me.pb(u);

	cin >> q;
	while(q--){
		cin >> tt;
		if(tt == 1){
			rev ^= 1;
			continue;
		}
		cin >> ff >> gg;
		if(ff == 1) {
			if(rev) me.pb(gg);
			else me.push_front(gg);
		}
		else{
			if(rev) me.push_front(gg);
			else me.pb(gg);
		}
		/*for(auto u : me){
			cout << u;
		} cout << endl;*/
	}

	for(auto u : me)
		ans += u;

	if(rev) reverse(ans.begin(), ans.end());
	cout << ans << endl;

	cout.flush();
	return 0;
}

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

int main() {
  int Q, N;
  ll sum = 0;
  cin >> N;

  vector<ll> num(110000, 0);
  for (int i = 0; i < N; i++) {
    ll A; 
    cin >> A;
    sum += A;
    num[A]++;
  }  

  cin >> Q;
  for (int i = 0; i < Q; i++) {
    ll B, C; 
    cin >> B >> C;
    sum += (C - B) * num[B];
    num[C] += num[B];
    num[B] = 0;
    cout << sum << endl;
  }
}

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

int n, k;

int main()
{
    cin >> n >> k;
    vector<char> kodawari(0);
    rep(i, k)
    {
        char c;
        cin >> c;
        kodawari.push_back(c);
    }
    while(true)
    {
        bool flag = false;
        string s = to_string(n);
        for(char x : s)
        {
            for(char y : kodawari)
            {
                if(x == y)
                {
                    flag = true;
                    break;
                }
                if(flag) break;
            }
        }
        if(!flag)
        {
            cout << n << endl;
            break;
        }
        n++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const int MOD = 998244353;

int D[100010]; 
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	if (D[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(D, D + N);
	ll ans = 1;
	int num = 0;
	int before = 1;
	for (int i = 1; i < N; i++) {
		num++;
		if (D[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		else if (D[i] - D[i - 1] >= 2) {
			cout << 0 << endl;
			return 0;
		}
		if (D[i] != D[i + 1]) {
			//cout << i << endl;
			for (int j = 0; j < num; j++) {
				ans *= before;
				ans %= MOD;
			}
			before = num;
			num = 0;
		}
	}
	for (int i = 0; i < num; i++) {
		ans = before;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>
 
#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
ll gcd(ll a,ll b)
{
	if(a<b)
	{
		ll tmp = a;a = b;b = tmp;
	}
	if(b == 0)
		return a;
	else
		return gcd(b,a%b);
}
 
ll f(ll a,ll b)
{
	ll ret = gcd(a,b);
	
	return a/ret*b;
}
 
int main()
{
	int n;
	cin >> n;
	
	ll num[n];
	cin >> num[0];
	ll ret = num[0];
	
	for(int i = 1;i < n;i++)
	{
		cin >> num[i];
		ret = f(ret,num[i]);
	}
	
	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    vector<ll> mo(n+1);
    FOR(b,1,n+1){
      mo[b]=n%b;
    }
    FOR(b,1,n+1){
      if(b<=k){
        continue;
      }
      ans+=((n/b)+1)*(max((ll)0,mo[b]-k+1))+(n/b)*(b-1-max((ll)mo[b],(ll)k-1));
      //out<<b<<' '<<ans<<'\n';
    }
    if(k==0){
        ans=ans-n;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func digitSum(x int) int {
	sum := 0
	for x > 0 {
		sum += x % 10
		x /= 10
	}
	return sum
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n%digitSum(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
/********   In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int h[n], dp[n];
    for (int i = 0; i < n;i++)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    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] << endl;
}
/*
3 4
3 2 1 3
1 9 2 3
9 1 5 4
*/


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

using namespace std;


void sieve(vector<int>& pf) {
	pf[1] = 1; 
    for (int i = 2; i< 1000001; i++) {
        pf[i] = i; 
	}
  
    for (int i = 4; i < 1000001; i += 2) { 
        pf[i] = 2; 
	}
  
    for (int i = 3; i * i < 1000001; i++) { 
        if (pf[i] == i) { 
            for (int j = i * i; j < 1000001; j += i) {
                if (pf[j]==j) {
                    pf[j] = i; 
				}
			}
        } 
    } 
}

set<int> getFactorization(vector<int>& pf, int x) { 
    set<int> ret; 
    while (x != 1) { 
        ret.insert(pf[x]); 
        x = x / pf[x]; 
    } 
    return ret; 
} 

int main() {
	
	vector<int> pf(1000001);
	sieve(pf);
	
	int n;
	scanf("%d", &n);
	int a[n];
	set<int> met;
	map<int, int> count;
	bool ispcp = true;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		set<int> factorization = getFactorization(pf, a[i]);
		for (auto it = factorization.begin(); it != factorization.end(); ++it) {
			if (met.find(*it) != met.end()) {
				ispcp = false;
			}
			met.insert(*it);
			count[*it]++;
		}
	}
	
	if (ispcp) {
		printf("pairwise coprime\n");
		return 0;
	}
	
	bool isscp = true;
	for (auto it = count.begin(); it != count.end(); ++it) {
		if (it->second == n) {
			isscp = false;
			break;
		}
	}
	
	if (isscp) {
		printf("setwise coprime\n");
	} else {
		printf("not coprime\n");
	}

	return 0;
}

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

int main(int argc, char *argv[])
{
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<int, int>> monsters;
    for (int i = 0; i < N; i++) {
        int x, h;
        cin >> x >> h;
        monsters.emplace_back(x, h);
    }
    sort(begin(monsters), end(monsters));
    queue<pair<int, int>> q;
    long long damage = 0;
    long long res = 0;
    for (int i = 0; i < N; i++) {
        auto p = monsters[i];
        long long x = p.first;
        long long h = p.second;
        while (!q.empty() && q.front().first <= x) {
            damage -= q.front().second;
            q.pop();
        }
        h -= damage;
        if (h > 0) {
            long long n = (h + A - 1) / A;
            res += n;
            damage += n * A;
            q.push({x + 2 * D + 1, n * A});
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 2672
n=int(input())
L={}
c=0
for i in range (n):
    s=input()
    if s in L:
        L[s]+=1
    else:
        L.update({s:1})
        c+=1
M=list(L.values())
C=list(L.keys())
b=max(M)
F=[]
for i in range(c):
    if M[i]==b:
        F+=[C[i]]
F.sort()
for i in F:
    print(i)
        
    


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> m(H, vector<char>(W));
    rep(i,H)rep(j,W){
        cin >> m[i][j];
    }
    rep(i,H){
        rep(j,W){
            if (m[i][j] != '#'){
                int cnt = 0;
                for(int k = -1; k <= 1;k++){
                    for(int l = -1; l <= 1;l++){
                        if (i+k >= 0 && i+k < H && j+l >= 0 && j+l < W && m[i+k][j+l] == '#') cnt++;
                    }
                }
                cout << cnt;
            }
            else cout << '#';
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a,b,c=mi()
for i in range(1,b):
    if (b*i + c) % a == 0:
        print("YES")
        exit()
print("NO")


Measured memory_bytes: 3060
#include<iostream>  
#include<cstdio>
#include<stdio.h>
#include<cstring>  
#include<cstdio>  
#include<climits>  
#include<cmath> 
#include<vector>
#include <bitset>
#include<algorithm>  
#include <queue>
#include<map>
using namespace std;
long long int n, ans, i;
int main()
{
	cin >> n;
	ans = 1;
	for (i = 1; i <= n; i++)
	{
		ans = ans*i % 1000000007;
	}
	cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e6 + 5;

char s[MAXN], t[MAXN];

queue<pii> qq;

void solve(){
	int n;
	scanf("%d%s%s", &n, &s[0], &t[0]);
	int ans = 0;
	for(int r = n, l = n, it = 0; ; it++){
		for(r--; r >= 0 && r >= l && t[r] == t[r + 1]; r--);
		if (r < 0){
			break;
		}
		for(l--; l >= 0 && s[l] != t[r]; l--);
		if (l < 0){
			printf("-1\n");
			return;
		}
		while(!qq.empty() && r + it <= qq.front()._1 + qq.front()._2){
			qq.pop();
		}
		if (l == r){
			continue;
		}
		qq.push(mp(l, it));
		ans = max(ans, (int)qq.size());
		
		//printf("%d %d %d\n", it, l, r);
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 10384
import sys
def I():
    return int(sys.stdin.readline().rstrip())

N = I()

if N == 0:
    print(0)
    exit()

ANS = []
r = 0
while True:
    for i in range(10**6):
        if -((2*(4**((i+1)//2)-1))//3) <= N <= (4*(4**(i//2)-1))//3+1:
            for _ in range(r-i-1):
                ANS.append('0')
            ANS.append('1')
            r = i
            break
    N -= (-2)**r
    if N == 0:
        for _ in range(r):
            ANS.append('0')
        break

print(''.join(ANS))

Measured memory_bytes: 62108
public class Main {
    public static void main(String[] args) {

        // ??????????????????????????????.
        java.util.Scanner sc = new java.util.Scanner(System.in);

        // ??????????????????????????? a ????????°??¨?¨???°???????????????.
        // ?????? a ???????????????.
        int tate = sc.nextInt();
        int yoko = sc.nextInt();
        int[][] A = new int[tate][yoko];
        for (int i = 0; i < tate; i ++) {
            for (int j = 0; j < yoko; j ++) { A[i][j] = sc.nextInt(); }
        }

        // ?????? b ???????????????.
        int[] b = new int[yoko];
        for (int i = 0; i < yoko; i ++) { b[i] = sc.nextInt(); }

        // ???????????????????????????.
        for (int i = 0; i < tate; i ++) {
            int sum = 0;
            for (int j = 0; j < yoko; j ++) { sum += b[j] * A[i][j]; }
            System.out.print(sum + "\n");
        }
    }
}

Measured memory_bytes: 40848
n = int(input())

A = list(map(int, input().split()))

s = sum(A)

L = [0 for i in range(10**5 + 1)]

for i in range(n):
  L[A[i]] += 1

q = int(input())

for i in range(q):
  b, c = map(int, input().split())
  s += (c - b) * L[b]
  print(s)
  tmp = L[b]
  L[b], L[c] = 0, tmp + L[c]

Measured memory_bytes: 20988
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

o = input()
e = input()
ans = ""
for i in range(len(o) - 1):
    ans += o[i] + e[i]
if len(o) - len(e) == 0:
    ans += o[-1] + e[-1]
else:
    ans += o[-1]
print(ans)



Measured memory_bytes: 3444
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
  if(u==NIL)return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u) {
  int h1=0, h2=0;
  if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  } else if(T[u].left==NIL&&T[u].right==NIL){
    printf("leaf\n");
  } else{
    printf("internal node\n");
  }
}

int main(){
  int v, l, r, root=0;
  scanf("%d", &n);

  for(int i=0; i<n; i++) T[i].parent=NIL;

  for(int i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(int i=0; i<n; i++) if(T[i].parent==NIL) root=i;
  setDepth(root, 0);
  setHeight(root);
  for(int i=0; i<n; i++) print(i);
  return 0;
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
set<int>n;
int main()
{
	cin>>a>>b>>k;
	for(int s=a;s<=b;s++)
	{
		if(s-a>=k)break;
		n.insert(s);
	}
	for(int s=b;s>=a;s--)
	{
		if(b-s>=k)break;
		n.insert(s);
	}
	for(set<int>::iterator it=n.begin();it!=n.end();it++)cout<<*it<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string S; cin >> S;
    int len = S.length();
    string pS = S.substr(0,len/2);
    string lS = S.substr((len+3)/2-1,len/2);
    string rS = S, rpS = pS, rlS = lS;
    reverse(rS.begin(),rS.end()) ;
    reverse(rpS.begin(),rpS.end()) ;
    reverse(rlS.begin(),rlS.end()) ;
    if(S == rS && pS == rpS && lS == rlS){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){swap(r[a], r[b]);swap(r[b], r[c]);swap(r[c], r[d]);}
    void spin(char c){if (c == 'W') roll(0, 2, 5, 3); else roll(0, 1, 5, 4);}
};
 
int main(){
    char SWS[8]={"NNNWNNN"};
    int n;
    cin >> n;
    Dice D[100];
    for (int i = 0; i < n ; i++) for (int j = 0; j < 6; j++) cin >> D[i].r[j];
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                D[j].spin(SWS[k]);
            }
            for (int k = 0; k < 4; k++){
                int ans = 0;
                for (int l = 0; l < 6; l++) if (D[i].r[l] == D[j].r[l]) ans++;
                if (ans == 6){cout << "No" << endl; return 0;}
                D[j].spin('W');
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
int main()
{

  int S[200000]={0};
  int M;
  int W;
  cin>>M;

  for(int i=0;i<M-1;i++){
    cin>>W;
    S[W-1]++;
  }
   cout<<"";
  for(int i=0;i<M;i++){
   cout<<S[i]<<"\n";
  }
  return 0;
}





Measured memory_bytes: 4408
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  array<int, 26> c;
  for (auto& e : c) cin >> e;
  vector<array<int, 26>> d(D);
  for (auto& r : d)
    for (auto& e : r) cin >> e;
  vector<int> t(D);
  for (auto& e : t) cin >> e, --e;
  int S = 0;
  array<int, 26> last = {};
  for (int i = 0; i < D; ++i) {
    S += d[i][t[i]];
    last[t[i]] = i + 1;
    for (int j = 0; j < 26; ++j) S -= c[j] * (i + 1 - last[j]);
    cout << S << '\n';
  }
}


Measured memory_bytes: 3628
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

priority_queue<long long> q;

long long a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0;i<n;i++) q.push(a[i]);
	int have = m;
	while(have && !q.empty()) {
		long long now = q.top();
		q.pop();
		now /= 2;
		have--;
		if(now) q.push(now);
	}
	long long ans = 0;
	while(!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
string s;
cin>>s;
ll max,min;

for(ll i=0;i<s.length();i++){
if(s[i]=='A'){
min =i;
break;
}
}
for(ll i=0;i<s.length();i++){
if(s[i]=='Z'){
max =i;

}
}
cout <<max-min+1;
return 0;
}

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

int main() {
  int N, K, x;
  int sum;
  
  cin >> N >> K;
  
  rep(i, N){
    cin >> x;
    if(x <= K - x){
      sum += 2*x;
    }else{
      sum += 2*(K - x);
    }
  }
  
  cout << sum << endl;
}

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

using namespace std;

const int MAX_N = 300;

double p[1 + MAX_N][1 + MAX_N][1 + MAX_N];

int main() {
  int n;
  scanf("%d", &n);
  vector<int> count(3, 0);
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    ai--;
    count[ai]++;
  }
  p[count[0]][count[1]][count[2]] = 1;
  double answer = 0;
  for (int three = n; three >= 0; three--) {
    for (int two = n; two >= 0; two--) {
      for (int one = n; one >= 0; one--) {
        int sum = one + two + three;
        if (sum > 0) {
          double waitTime = (double)n / sum;
          answer += p[one][two][three] * waitTime;
          if (two < n && three > 0) {
            p[one][two + 1][three - 1] += three * p[one][two][three] / sum;
          }
          if (one < n && two > 0) {
            p[one + 1][two - 1][three] += two * p[one][two][three] / sum;
          }
          if (one > 0) {
            p[one - 1][two][three] += one * p[one][two][three] / sum;
          }
        }
      }
    }
  }
  printf("%.14lf\n", answer);
  return 0;
}


Measured memory_bytes: 213248
n = int(input())
robos = []
for i in range(n):
    x,l = map(int,input().split())
    robos.append([x-l,x+l])

robos.sort(key= lambda x:x[1])
# print(robos)
edge = -10000000000000
out = 0
for i in range(n):
    if robos[i][0] >= edge:
        out += 1
        edge = robos[i][1]
    else:
        continue

print(out)




Measured memory_bytes: 21336
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	a,b = map(int,input().split())
	g = gcd([a,b])
	l = factorization(g)
	print(len(l)+1)

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 68588
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
int m;

int main()
{
	cin >> m;
	cout << 48 - m;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=s[i+1])
        a++;
    }
    cout<<a<<"\n";
}

Measured memory_bytes: 3728
def merge(A, left, mid, right):
    count = 0
    INF = 1000000000000000000000
    n1 = mid - left
    n2 = right - mid

    L = [A[left+i] for i in range(n1)]
    R = [A[mid+i] for i in range(n2)]
    L.append((INF, INF))
    R.append((INF, INF))

    i, j = 0, 0
    for k in range(left, right):
        count += 1
        # print(L[i][1], R[j][1])
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return count


def merge_sort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        count_left = merge_sort(A, left, mid)
        count_right = merge_sort(A, mid, right)
        count = merge(A, left, mid, right)
        return count + count_right + count_left
    return 0


def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)


def main():
    import copy
    n = int(input())
    A = []
    for _ in range(n):
        a, b = input().split()
        A.append((a, int(b)))

    B = copy.deepcopy(A)

    merge_sort(B, 0, len(B))
    quick_sort(A, 0, n-1)

    # print(A, B)

    if A == B:
        print("Stable")
    else:
        print("Not stable")

    for a in A:
        print(f"{a[0]} {a[1]}")

if __name__ == "__main__":
    main()


Measured memory_bytes: 18232
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n, count=0;
    int L[n];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> L[i];
    }
    if(n<3){
        cout << count << endl;
    }else{
        for(int i=0;i<n-2;i++){
            for(int j=1;j<n-1;j++){
                for(int k=2;k<n;k++){
                    if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
                        if(i<j && j<k){
                            if(L[i]+L[j]> L[k] && L[j]+L[k]>L[i] && L[k]+L[i]> L[j]){
                                count++;
                            }
 
                        }
                    }
                    
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int N = sc.nextInt();
    int d;
    
    if(D==0) {
      if(N==100) {
        d = 101;
      } else {
        d = N;
      }
    } else if(D==1) {
      if(N==100) {
        d=10100;
      } else {
        d = 100 * N;
      }
    } else {
      if(N==100) {
        d = 1010000;
      } else {
        d = 10000 * N;
      }
    }
    System.out.println(d);
  }
}

Measured memory_bytes: 21716
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  long n=Long.parseLong(sc.next());
  long a=Long.parseLong(sc.next());
  n-=1;
  long ans=a;
  for(int i=0;i<n;i++)ans*=(a-1);
  System.out.println(ans);
}
}


Measured memory_bytes: 23124
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, a + b + 1) + b << endl;
}

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


namespace AtCoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            if (S == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}


Measured memory_bytes: 25872
n, m=gets.split.map &:to_i
n, m=m, n if n>m
if m-n>1
    puts 0
else
    mod=10**9+7
    f=->x{(1..x).inject(1){|r, i| r=r*i%mod}}
    puts f[m]*f[n]*(1+n/m)%mod
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int gcd(int a, int b) {
	if (b > a) {
      int tmp = a;
      a = b;
      b = tmp;
    }
  	if (b == 0) return a;
  	return gcd(b, a % b);
}

int main() {
	int n, a, cgcd;
  	cin >> n >> cgcd;
  	for (int i = 1; i < n; i++) {
      cin >> a;
      cgcd = gcd(cgcd, a);
    }
 	cout << cgcd;
  	return 0;
}

Measured memory_bytes: 3196
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
ll n,d;
void solve(){
	scan(n);
	int j=0;
	int mx1=0,mx2=0;
	rep(i,0,n){
		ll t;
		scan(t);
		if(t>mx1){
			mx1 = t;
			j = i;
		}else if(t>mx2){
			mx2 = t;
		}
	}
	rep(i,0,n)if(i==j)cout<<mx2<<endl;else cout<<mx1<<endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1664