akhauriyash/Code-Regression huggingface dataset:
// 難さんすう すーぱーさんすうと呼ぼう
// Mを素因数分解しといて例えばM=12としてM=(2^2) * (3^1)なるが、それぞれの因数をそれぞれの乗数ぶん振り分ける感じにした組み合わせが答え
// N = 3なら [1, 1, 1]の3つのどれかに振り分ける つまり以下
// 因数2を2つ,因数3を1つ を振り分けて、
//			[2^1, 2^1, 2^0], [3^1, 3^0, 3^0]
// 				-> [1*(2^1 * 3^1)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^0)] = 6*2*1 = 12
// あるいは
//			[2^2, 2^0, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^2 * 3^0)] * [1*(2^0 * 3^0)] * [1*(2^0 * 3^1)] = 4*1*3 = 12
// あるいは
//			[2^1, 2^1, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^1 * 3^0)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^1)] = 2*2*3 = 12
//
// 解説の""計算量はNに依らない""が意味不明だけど、説明してくれないので無視
// すーぱーさんすうの世界ではこれを重複組合せと呼ばうらしい 漢字だね 画数が多い
// n種類のものから重複を許してr個選ぶ場合の数 = nHr = (n+r-1)Cr に帰着できるらしい

// nCr mod Pなので気をつける
package main

import (
	"fmt"
	"math"
)

var MOD int

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	arr := factorization(M)
	// arr := primeFactorization(M)
	ans := 1
	MOD = int(math.Pow10(9)) + 7
	for _, v := range arr {
		// ans *= ncrMod(v+N-1, v, MOD) % MOD
		// ans *= comb(v+N-1, v, MOD) % MOD
		// ans = ans * comb(v+N-1, v, MOD) % MOD
		ans = ans * ncrMod(v+N-1, v, MOD) % MOD
	}
	fmt.Println(ans)
}

func factorization(n int) map[int]int {
	a := make(map[int]int)
	for i := 2; i*i <= n; {
		if n%i == 0 {
			a[i]++
			n /= i
		} else {
			i++
		}
	}
	if n > 1 {
		a[n]++
	}
	return a
}

func primeFactorization(x int) map[int]int {
	ret := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			if _, ok := ret[i]; ok {
				ret[i] += 1
			} else {
				ret[i] = 1
			}
		}
	}
	if x > 1 {
		ret[x] += 1
	}
	return ret
}

func ncrMod(n, r, mod int) int {
	// 呼び出すたびにテーブルを作るのは愚
	_n := 1000000
	g1 := make([]int, _n+1)
	g1[0], g1[1] = 1, 1
	g2 := make([]int, _n+1)
	g2[0], g2[1] = 1, 1
	inverse := make([]int, _n+1)
	inverse[0], inverse[1] = 0, 1
	for i := 2; i <= _n; i++ {
		g1[i] = (g1[i-1] * i) % mod
		inverse[i] = mod - inverse[mod%i]*(mod/i)%mod
		g2[i] = (g2[i-1] * inverse[i]) % mod
	}

	return g1[n] * (g2[r] * g2[n-r] % mod) % mod
}

func comb(n, m, MOD int) int {
	return factorial(n, n-m+1, MOD) * pow(factorial(m, 2, MOD), MOD-2, MOD) % MOD
}

func pow(x, n, MOD int) int {
	r := 1
	for ; n > 0; n /= 2 {
		if n%2 == 1 {
			r = r * x % MOD
		}
		x = x * x % MOD
	}
	return r
}

func factorial(n, m, MOD int) int {
	r := 1
	for i := m; i <= n; i++ {
		r = r * i % MOD
	}
	return r
}


Measured memory_bytes: 32768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
signed main() {
	string s; cin >> s;
	int n = s.size();
	vvel dp(4, vel(n + 1,-n-2));
	dp[0][0] = 0;
	int th = 3;
	rep(i, n) {
		for (int j = 0; j <= min(th,i); j++) {
			for (int k = 1; k <= min(th, n - i); k++) {
				if (j != k) { mmax(dp[k][i + k], dp[j][i]+1); }
				else {
					string s1;
					rep(ind, k) { s1 += s[i+ind]; }
					string s2;
					rep(ind, j) { s2 = s[i - ind - 1] + s2; }
					if (s1 != s2) { mmax(dp[k][i + k], dp[j][i] + 1); }
				}
			}
		}
	}
	int ans = 0;
	rep(ind, 3) { mmax(ans, dp[ind+1][n]); }
	cout << ans << endl;
}

Measured memory_bytes: 8324
#include <bits/stdc++.h> 
using namespace std; 
typedef  long long int ll; 
ll FindLCM(ll a, ll b) 
{ 
	return (a * b) / __gcd(a, b); 
} 
 
ll rangeDivisor(ll m, ll n, ll a, ll b) 
{ 
	ll lcm = FindLCM(a, b); 

	ll a_divisor = n / a - (m - 1) / a; 
	ll b_divisor = n / b - (m - 1) / b; 

	// Find common divisor by using LCM 
	ll common_divisor = n / lcm - (m - 1) / lcm; 

	ll ans = a_divisor + b_divisor - common_divisor; 
	return ans; 
} 

int main() 
{ 
      ll m,n,a,b;
      cin>>m>>n>>a>>b;
      cout<<(n-m+1)-rangeDivisor(m,n,a,b);
  	return 0; 
} 


Measured memory_bytes: 256
S = input()[::-1]
while len(S) != 0:
    if S[:5] == "maerd":
        S = S.replace("maerd", "", 1)
    elif S[:5] == "esare":
        S = S.replace("esare", "", 1)
    elif S[:7] == "remaerd":
        S = S.replace("remaerd", "", 1)
    elif S[:6] == "resare":
        S = S.replace("resare", "", 1)
    else:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 3188
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a).most_common()
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)

Measured memory_bytes: 21540
#include <bits/stdc++.h>
#define N 100000
using namespace std;
int n;
int A[2000010],B[2000010];

void Csort(){
  int cnt[N]={};
  for(int i=0;i<n;i++) cnt[A[i]]++;
  for(int i=1;i<N;i++) cnt[i]+=cnt[i-1];
  for(int i=0;i<n;i++) B[cnt[A[i]]--] = A[i];
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) scanf("%d",&A[i]);
  for(int i=0;i<n;i++) assert(A[i]<=10000);
  Csort();
  for(int i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  cout<<endl;
  return 0;
}

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

using namespace std;

#define Rep(b, e, i) for (ll i = b; i <= e; i++)
#define Repr(e, b, i) for (ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++)
		o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 1000010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const ll INFL = 1e15;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

const int MAX_V = 2525;
const int MAX_E = 5252;

struct edge {int from, to; ll cost;};

edge es[MAX_E];

int go[MAX_V];
ll dis[MAX_V];
ll V, E, P;
//ゴールに続く負の閉路が存在すればtrueを返す
bool bellmanford(int s) {
	rep(V, v) dis[v] = INFL;
	dis[s] = 0LL;
	rep(V, i) {
		rep(E, e) {
			const edge &ne = es[e];
			if (dis[ne.from] == INFL) continue;
			if (dis[ne.to] > dis[ne.from] + ne.cost + P) {
				dis[ne.to] = dis[ne.from] + ne.cost + P;
				if (i == V-1 && go[ne.to] == 1) return true;
			}
		}
	}
	return false;
}

void solve(void){
    cin >> V >> E >> P;
    rep(E, e){
        int a, b;ll c;
        scanf("%d %d %lld\n", &a, &b, &c);
        a--; b--;
        es[e] = edge {a, b, -c};
    }
	queue<int> q;
	q.push(V-1);
	memset(go, -1, sizeof(go));
	go[V-1] = 1;
	while(!q.empty())
	{
		int v = q.front();
		q.pop();
		rep(E, e) {
			const edge &ne = es[e];
			if (go[ne.from] == -1 && ne.to == v)
			{
				go[ne.from] = 1;
				q.push(ne.from);
			}
		}
	}
    if (bellmanford(0)) cout << "-1" << endl;
    else cout << max(0LL, -dis[V-1]) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x, y;
    cin >> x >> y;
    int cnt = 1;
    while (x * 2 <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N; cin >> N;
    ll cnt = 0;
    vll A(N); rep(i, N) {
        ll num; cin >> num;
        if (num < 0) cnt++;
        A[i] = abs(num);
    }

    // for (auto elem : A) cout << elem << " "; cout << endl;

    sort(all(A));
    ll ans = accumulate(all(A), 0LL);
    if (cnt % 2) ans -= A[0] * 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
/*In the name of ALLAH, Most Gracious, Most Merciful*/
///     </> : omar_aziz

#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define pii                     pair<ll,ll>
#define vi                      vector<ll>
#define vii                     vector<pii>
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;
ll tc=1;
//ll cnt=0,sum=0,ans=0,res=0,maxi=INT_MIN,mini=INT_MAX,row,col;


void solve()
{
    ll n,d,cnt=0;
    cin>>n>>d;
    while (n--)
    {
        ll a,b;
        cin>>a>>b;
        if (((a*a)+(b*b))<=(d*d))cnt++;
    }
    cout<<cnt<<endl;
}

int32_t main()
{
    FAST_IO();

    //TEST_CASES()
        solve();
}


Measured memory_bytes: 3628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    t = S()
    ans = 0
    s_dict = defaultdict(list)
    for ix, c in enumerate(s):
        s_dict[c].append(ix)
    cur_ix = -1 
    for counter, c in enumerate(t):
        if s_dict.get(c) == None:
            print(-1)
            return
        char_ix_list = s_dict.get(c)
        # cur_ixより大きい値を見つける
        pos = bisect.bisect_right(char_ix_list, cur_ix)
        # cur_ixより大きい値がないとき、リセット
        if pos >= len(char_ix_list):
            ans += len(s)
            cur_ix = char_ix_list[0]
        # cur_ixより大きい値が見つかった時、cur_ixを更新
        else:
            cur_ix = s_dict.get(c)[pos]
        # if last, add cur_ix to answer
        if counter == len(t)-1:
            ans += (cur_ix + 1)
    print(ans)
main()


Measured memory_bytes: 71916
#include <stdio.h>
#include <string.h>
 
int main(){
  int n, f, t = 0, h = 0;
  char c1[101], c2[101];
  scanf("%d", &n);
  while(n--){
    scanf("%s%s", c1, c2);
    f = strcmp(c1, c2);
    if(!f) t++,h++;
    else if(f > 0) t += 3;
    else if(f < 0) h += 3;
  }
  printf("%d %d\n", t, h);
  return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <numeric>
 
using namespace std;

int main(void) {
    string S;
    cin >> S;
    if(S[0]!=S[1] && S[1]!=S[2] && S[2]!=S[3]){
        cout<<"Good"<<endl;
    }else{
        cout<<"Bad"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

# ABC154 E - Almost Everywhere Zero
"""
N = '9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'
K = 3
L = len(N)
"""

N = input()
K = getN()
L = len(N)

def judge(a):
    return a != 0

# N以下の数字で条件を満たす桁がk個のもの
def digit_dp(n, k):
    l = len(n)

    dp = [[[0] * (k + 1) for _ in range(2)] for i in range(l + 1)]
    dp[0][0][0] = 1

    for i in range(l):
        d = int(n[i])

        for j in range(2):
            for d_j in range(10 if j else d + 1):
                for k_j in range(k + 1):
                    if judge(d_j):
                        if k_j + 1 <= k:
                            dp[i + 1][j | (d_j < d)][k_j + 1] += dp[i][j][k_j]
                    else:
                        dp[i + 1][j | (d_j < d)][k_j] += dp[i][j][k_j]

    return dp

dp = digit_dp(N, K)
print(dp[L][0][K] + dp[L][1][K])

# ABC029 D - 1
"""
N = '999999999'
L = len(N)

def judge_2(a):
    return a == 1

# N以下の数字の中で「1が書いてある桁がk個ある数字」がいくつあるか
# 上のものと関数の中身自体は変えていない
def digit_dp_2(n, k):
    l = len(n)

    dp = [[[0] * (k + 1) for _ in range(2)] for i in range(l + 1)]
    dp[0][0][0] = 1

    for i in range(l):
        d = int(n[i])

        for j in range(2):
            for d_j in range(10 if j else d + 1):
                for k_j in range(k + 1):
                    if judge_2(d_j):
                        if k_j + 1 <= k:
                            dp[i + 1][j | (d_j < d)][k_j + 1] += dp[i][j][k_j]
                    else:
                        dp[i + 1][j | (d_j < d)][k_j] += dp[i][j][k_j]

    return dp

dp = digit_dp_2(N, L)

ans = 0
for j in range(L + 1):
    # dp[l]について各j(1のカウント)の通りの数 * j
    ans += (dp[L][0][j] + dp[L][1][j]) * j
print(ans)
"""

Measured memory_bytes: 84248
import math
A,B,N = map(int, input().split())

def calc(x):
    y = math.floor(A * x / B) - A * math.floor(x / B)
    return y

max_v = 0

if N < B:
    max_v = calc(N)
else:
    max_v = calc(B-1)

# for x in range(N+1):
#     print(x,max_v) # x＝Bでさちる
#     max_v = max(max_v, calc(x))

print(max_v)


Measured memory_bytes: 9172
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int t=Integer.parseInt(br.readLine());
            String[] ss=br.readLine().split(" ");
            int A=Integer.parseInt(ss[0]);
            int B=Integer.parseInt(ss[1]);
            int d=A/t;
            int d2=B/t;
            if(d2>d || A%t==0 || B%t==0){
                System.out.println("OK");
            }else{
                System.out.println("NG");
            }

        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}

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

int main(){
	int64_t n, a, b; 
  	cin >> n >> a >> b;
  	
  	int64_t nm = n/(a+b);
  	int64_t nmb = nm * a;
  	if((n - nm*(a+b)) > a){ nmb += a;}
  	else{nmb += (n - nm*(a+b));}
  	
  	cout << nmb << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 2000005
#define INF 1234567890
using namespace std;
int H,a[MAX];
void maheap(int i){
  int l,r,la;
  l = 2*i;
  r=2*i+1;

  if(l<=H&&a[l]>a[i])la=l;
  else la=i;
  if(r<=H&&a[r]>a[la])la=r;

  if(la!=i){
    swap(a[i],a[la]);
    maheap(la);
  }
}
int extract(){
  int mav;
  if(H<1)return -INF;
  mav=a[1];
  a[1]=a[H];
  H--;
  maheap(1);
  return mav;
}
void up(int i,int key){
  if(key<a[i])return;
  a[i]=key;
  while(i>1&&a[i/2]<a[i]){
    swap(a[i],a[i/2]);
    i=i/2;
  }
}
void insert(int key){
  H++;
  a[H]=-INF;
  up(H,key);
}
int main(){
  int key;
  char com[10];
  while(1){
    cin >> com;
    if(com[0]=='e'&&com[1]=='n')break;
    if(com[0]=='i'){
      cin >> key;
      insert(key);
    }
    else{
      cout << extract() << endl;
    }
  }
  return 0;

}

Measured memory_bytes: 6992
x=int(input())
h = 0 if x==0 else int(x/ (60*60))
zan = x - h * 60 * 60
m=0 if zan==0 else int(zan/ 60)
s = zan -m * 60
print(repr(h)+':'+ repr(m) + ':' +repr(s))

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

int main() {
    int r;
    cin >> r;
    
    double ans = 2 * r * PI;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N;
int ans;
vector<int> D,times;
map<int, int> mp;
void dfs(int cur){
    if(cur == N){
        int sz = times.size();
        int tmp = INF;
        rep(i,sz)rep(j,sz){
            if(i >= j)continue;
            int d = abs(times[i] - times[j]);
            chmin(tmp, min(d, 24-d));
        }
        chmax(ans, tmp);
        return;
    }
    rep(j,2){
        int add = (j ? 24 - D[cur]: D[cur]);
        times.push_back(add);
        mp[add]++;
        if(mp[add] == 1){
            dfs(cur+1);
        }
        mp[add]--;
        times.pop_back();
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N;
    D.resize(N);
    rep(i,N)cin>>D[i];
    ans = 0;
    times.push_back(0);
    mp[0]++;
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

T, A = 1, 1
for i in range(N):
  if T >= A:
    if TA[i][0] / TA[i][1] >= T / A:
      a = -1 * ((-1 * A) // TA[i][1])
    else:
      a = -1 * ((-1 * T) // TA[i][0])
  else:
    if TA[i][1] / TA[i][0] >= A / T:
      a = -1 * ((-1 * T) // TA[i][0])
    else:
      a = -1 * ((-1 * A) // TA[i][1])
  T = TA[i][0] * a
  A = TA[i][1] * a
  #print("{0} {1}".format(T, A))

print(T + A)


Measured memory_bytes: 3188
#pragma GCC optimize("Ofast", "unroll-loops")

// #define PRINT

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll mod = 1000000007LL;

int main(void) {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(M);
	for (auto& ai : A) cin >> ai;
	for (auto& bi : B) cin >> bi;
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
#ifdef PRINT
	cout << "sorted A" << endl;
	for (auto ai : A) cout << ai << " ";
	cout << endl << "sorted B" << endl;
	for (auto bi : B) cout << bi << " ";
	cout << endl;
#endif
	// 出現を管理
	map<int, int> appered_A, appered_B;
	for (auto ai : A) {
		if (appered_A[ai]) {
			cout << 0 << endl;
			return 0;
		}
		appered_A[ai] = 1;
	}
	for (auto bi : B) {
		if (appered_B[bi]) {
			cout << 0 << endl;
			return 0;
		}
		appered_B[bi] = 1;
	}
	// 大きい値から確定
	ll res = 1;
	for (int i = N * M; i > 0; --i) {
		ll pos = 1;
		if (!appered_A[i] && !appered_B[i]) {
			ll H = B.end() - lower_bound(B.begin(), B.end(), i);
			ll W = A.end() - lower_bound(A.begin(), A.end(), i);
			pos = H * W - ((ll)N * M - i);
			pos = (pos % mod + mod) % mod;
			res = (res * pos) % mod;
		}
		else if (appered_A[i] && !appered_B[i]) {
			ll H = B.end() - lower_bound(B.begin(), B.end(), i);
			pos = H;
			res = (res * H) % mod;
		}
		else if (!appered_A[i]) { // appered_B[i]
			ll W = A.end() - lower_bound(A.begin(), A.end(), i);
			pos = W;
			res = (res * W) % mod;
		}
#ifdef PRINT
		cout << "Number " << i << " : " << pos << endl;
#endif
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 97236
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

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

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val H = sc.nextInt()
    val W = sc.nextInt()

    val s = new Array[Array[Char]](H)
    for {
      h <- 0 until H
    } s(h) = sc.next.toCharArray

    val INF = H * W
    val d = Array.fill[Int](H, W)(INF)
    val pre = Array.ofDim[Coordinate](H, W)
    val edges = Seq((1, 0), (0, 1), (-1, 0), (0, -1))
    type Coordinate = (Int, Int)
    type Elm = (Int, Coordinate, Coordinate)
    val que = mutable.Queue.empty[Elm]
    visit((0, 0), 0)
    d(0)(0) = 0

    def visit(p: Coordinate, cost: Int): Unit = {
      edges foreach { e =>
        val h = p._1 + e._1
        val w = p._2 + e._2
        if (h >= 0 && h < H && w >= 0 && w < W && s(h)(w) == '.') {
          que.enqueue((cost + 1, p, (h, w)))
        }
      }
    }

    while(que.nonEmpty) {
      val (cost, p0, p) = que.dequeue()
      if (d(p._1)(p._2) > cost) {
        d(p._1)(p._2) = cost
        pre(p._1)(p._2) = p0
        visit(p, cost)
      }
    }

    if (d(H - 1)(W - 1) == INF) println(-1)
    else {
      val minPath = Array.ofDim[Boolean](H, W)
      def step(p: Coordinate): Unit = {
        minPath(p._1)(p._2) = true
        p match {
          case (0, 0) =>
          case _ => step(pre(p._1)(p._2))
        }
      }
      step((H - 1, W - 1))

      val ans = (for {
        h <- 0 until H
        w <- 0 until W
      } yield s(h)(w) == '.' && !minPath(h)(w)).count(identity)

      println(ans)
    }
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


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

    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)
  }
}


Measured memory_bytes: 28540
#include<iostream>
#include<vector>
#include<utility>
#include<cctype>

using namespace std;

int H,W;
char C[50][52];
vector<pair<int,int> > p[256];
bool memed[52][52][52][52];
int mem[52][52][52][52];

int rec(int hy,int hx,int ty,int tx){
  if(ty<hy||tx<hx||C[hy][hx]=='#')return -1e9;
  if(hy==ty&&hx==tx)return 0;
  if(memed[hy][hx][ty][tx]++)return mem[hy][hx][ty][tx];
  int mx=max(rec(hy+1,hx,ty,tx),rec(hy,hx+1,ty,tx));
  if(islower(C[hy][hx])){
    for(auto e:p[toupper(C[hy][hx])]){
      if(ty<e.first||tx<e.second||e.first<hy||e.second<hx)continue;
      int sx=-1e9;
      if(hy+1==e.first&&hx==e.second||hy==e.first&&hx+1==e.second){
	sx=1;
      }else{
	for(int i=0;i<2;i++){
	  for(int j=0;j<2;j++){
	    sx=max(sx,rec(hy+i,hx+(i^1),e.first-j,e.second-(j^1))+1);
	  }
	}
      }
      if(e.first==ty&&e.second==tx){
	mx=max(mx,sx);
      }else{
	for(int i=0;i<2;i++){
	  mx=max(mx,sx+rec(e.first+i,e.second+(i^1),ty,tx));
	}
      }
    }
  }
  return mem[hy][hx][ty][tx]=mx;
}

int main(){
  while(cin>>H>>W,H|W){
    fill(***begin(memed),***end(memed),false);
    for(auto &e:p){
      e.clear();
    }
    for(int i=0;i<H;i++){
      cin>>C[i];
      for(int j=0;j<W;j++){
	p[C[i][j]].emplace_back(i,j);
      }
    }
    int ans=rec(0,0,H-1,W-1);
    cout<<((ans<0)?-1:ans)<<endl;
  }
}
    

Measured memory_bytes: 36928
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;

    const ll x = min(N, B - 1);
    const ll ans = (A * x) / B;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  u32 n, k;
  std::cin >> n >> k;
  if (k == static_cast<u32>(1)) {
    std::cout << static_cast<u32>(0) << std::endl;
  } else {
    std::cout << n - k << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

using ll = long long;

const int MAX_N = 100;
int N;
int a[MAX_N];

void solve()
{
	sort(a, a+N);
	double ans = a[0];
	for(int i=1;i<N;++i){
		ans = (double)(ans + a[i])/2.0;
	}
	printf("%.3lf\n", ans);
}


int main()
{
	cin >> N;
	for(int i=0;i<N;++i)cin >> a[i];
	solve();
	return 0;
}

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

const int N = 2005;

int n, a[N];
bitset<N * N> d;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	d[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d |= d << a[i];
	}
	int s = accumulate(a, a + n, 0);
	for(int i = (s + 1) / 2; i <= s; i++) if(d[i]){ cout << i << endl; return 0; }
}

Measured memory_bytes: 1792
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    auto s = chomp(readln());
    char[] ss;
    for(int i=0;i<s.length;i++){
	ss ~= s[i];
    }
    for(int i=0;i<s.length-4;i++){
	if(ss[i]=='a'&&ss[i+1]=='p'&&ss[i+2]=='p'&&ss[i+3]=='l'&&ss[i+4]=='e'){
	    ss[i] = 'p';
	    ss[i+1] = 'e';
	    ss[i+2] = 'a';
	    ss[i+3] = 'c';
	    ss[i+4] = 'h';
	}else if(ss[i]=='p'&&ss[i+1]=='e'&&ss[i+2]=='a'&&ss[i+3]=='c'&&ss[i+4]=='h'){
	    ss[i] = 'a';
	    ss[i+1] = 'p';
	    ss[i+2] = 'p';
	    ss[i+3] = 'l';
	    ss[i+4] = 'e';
	}
    }

    for(int i=0;i<s.length;i++)
	write(ss[i]);
    writeln();
}

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

typedef long long ll;

ll mod = 1000000007;

vector<pair<ll, ll> > Prime_Factorization_3(ll N) {
    vector<pair<ll, ll> > fac;
    ll N_ = N;
    for (ll i = 2; i*i <= N_; i++) {
        ll c = 0;
        while (N % i == 0) {
            c++;
            N /= i;
        }
        if (c)
            fac.push_back(pair<ll, ll> (i, c));
    }
    if (N > 1) {
        fac.push_back(pair<ll, ll> (N, 1));
    }
    return fac;
}

ll mod_pow(ll a, ll n, ll p) {
    if (n == 1)
        return a;
    if (n%2 == 0) {
        ll t = mod_pow(a, n/2, p);
        return t * t % p;
    }
    else {
        ll t = mod_pow(a, n-1, p);
        return a * t % p;
    }
}



//modpにおけるaの逆元を求める   O(log(p))
//ただし、aとpは互いに素である必要がある。
ll mod_inv(ll a, ll p) {
    return mod_pow(a, p-2, p);
}



//modpにおけるn_C_kを求める     O(k)
//nが巨大(10^9とか)のときはこれが良さそう
//ただし、pはkより大きい素数である必要がある。
//正確にはk以下の自然数が全てpと互いに素である必要がある。
ll combination(ll n, ll k, ll p) {
    ll ans = 1;
    for (ll i = 1; i <= k; i++) {
        ans *= (n-(i-1)) % p * mod_inv(i, p) % p;
        ans %= p;
    }
    return ans;
}


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

    vector<pair<ll, ll> > fac = Prime_Factorization_3(M);

    ll ans = 1;
    for (ll i = 0; i < fac.size(); i++) {
        ll c = combination(fac[i].second + N-1, fac[i].second, mod);
        ans *= c;
        ans %= mod;
    }

    cout << (ans+mod) % mod << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) << "\n";
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> H(N,0);
  for(int i = 0; i < N; i++) cin >> H[i];
  
  int ans = 0;
  int tmp_ans = 0;
  for(int j = 0; j < (N-1); j++){
    if(H[j] >= H[j+1]) tmp_ans++;
    else tmp_ans = 0;
  	if(ans < tmp_ans) ans = tmp_ans;
  }
  
  cout << ans;
}

Measured memory_bytes: 640
// HEADERS //
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <stack>
#include <unordered_map>
#include <bitset>
 
// MISCELLANEOUS //
#define fast_IO() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define gcd __gcd
#define cnt_1 __buitlin_popcount
#define ll long long
#define endl "\n"
#define scn_I(x) scanf("%d",&x)
#define scn_L(x) scanf("%lld",&x) 
#define test(t) cin>>t; while(t--)
#define mem(v,x) memset(v,x,sizeof(v))
 
// LOOPS //
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define irep(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define srep(i,v) for(decltype(v.begin())i=v.begin();i!=v.end();i++)
 
// CONTAINERS //
// #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define msi map<string,int>
#define mll map<ll,ll>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(v) (v).begin(),(v).end()
#define present(v,x) (v).find(x)!=(v).end()
 
// DEBUGGING //
#define dbg() printf("\n**DEBUG**\n") 
#define chk(a) cerr<<endl<<#a<<":"<<a<<endl
#define chk2(a,b) cerr<<endl<<#a<<":"<<a<<"\t"<<#b<<":"<<b<<endl
 
// CONSTANTS //
#define PI acos(-1)
#define M 1000000007
#define N 100005
 
// MAIN //
// using namespace __gnu_pbds; 
using namespace std;
int main()
{
  fast_IO();
  int n; cin>>n; vvi v(n,vi(3));
  rep(i,0,n) cin>>v[i][0]>>v[i][1]>>v[i][2];
  ll dp[n][3]; mem(dp,0);
  rep(i,0,3) dp[0][i]=v[0][i];
  rep(i,1,n)
  {
    dp[i][0]=max(v[i][0]+dp[i-1][1],v[i][0]+dp[i-1][2]);
    dp[i][1]=max(v[i][1]+dp[i-1][2],v[i][1]+dp[i-1][0]);
    dp[i][2]=max(v[i][2]+dp[i-1][0],v[i][2]+dp[i-1][1]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n,k;cin>>n>>k;vector<int> x(n);int sum=0;
  rep(i,n){
    cin >> x[i];
    x[i]>k/2 ? sum += k-x[i] : sum += x[i]; 
  }
  cout <<sum*2;
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    T = input()
    res = [c if c != '?' else 'D' for c in T]
    print(''.join(res))
resolve()

Measured memory_bytes: 81788
n = int(input())
b = list(map(int, input().split()))
a = [b[0]]
if n==1:
    a.append(b[0])
    print(sum(a))
else:
    for i in range(1,n-1):
        a.append(min(b[i],b[i-1]))
    a.append(b[n-2])
    print(sum(a))

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	int temp=0;
	int top[3];
	int lp=0;
	for(lp=0;lp<3;lp++) top[lp]=0;
	
	for(lp=0;lp<10;lp++){
		scanf("%d",&temp);
		if(temp>top[0]){
			top[2]=top[1];
			top[1]=top[0];
			top[0]=temp;
		}else if(temp>top[1]){
			top[2]=top[1];
			top[1]=temp;
		}else if(temp>top[2]){
			top[2]=temp;
		}
	}
	
	printf("%d\n%d\n%d\n",top[0],top[1],top[2]);
	
	return 0;
	
}

Measured memory_bytes: 600
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=500010,inf=1000000;
int f[N][4],cnt[N],tot;
int cal(int tot){
    if (!tot) return 0;
    int i;
    for (i=1;i<=tot;i++){
        if (i==1){
            f[i][0]=f[i][1]=f[i][2]=-inf;
            f[i][3]=0;
            continue;
        }
        f[i][0]=max(max(f[i-1][1],f[i-1][2]),f[i-1][3])+cnt[i];
        if (cnt[i]==1){
            f[i][1]=-inf;
            f[i][2]=-inf;
            f[i][0]=max(f[i][0],max(f[i-1][2]-1,f[i-1][3])+cnt[i-1]);
            f[i][3]=max(max(f[i-1][0],f[i-1][1]),max(f[i-1][2],f[i-1][3]));
        } else{
            f[i][1]=max(max(f[i-1][1],f[i-1][2]),f[i-1][3])+cnt[i]-1;
            f[i][2]=max(f[i-1][2]-1,f[i-1][3])+cnt[i-1];
            f[i][3]=max(max(f[i-1][0],f[i-1][1]),max(f[i-1][2],f[i-1][3]));
        }
    }
    return max(max(f[tot][0],f[tot][1]),max(f[tot][2],f[tot][3]));
}
char s[N];
int main(){
   // freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
    int i,j,n,ans=0;
    scanf("%d",&n);
    scanf("%s",s+2);
    s[0]=s[1]='0';
    for (i=2;i<=n+1;i++)
     if (s[i]=='1'&&s[i-1]=='0'&&s[i-2]=='0'){
        for (j=i,cnt[tot=1]=0;j<=n+1;j++){
            if (s[j]=='0'&&s[j+1]=='0') break;
            if (s[j]=='1') cnt[tot]++; else cnt[++tot]=0;
        }
        if (!cnt[tot]) tot--;
        ans+=cal(tot);
     } else continue;
    cout<<ans<<endl;

    return 0;
}


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

#define fi first
#define se second
#define amen exit(0)

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 1007;
const ll Inf = 100000000000007;

ll b[D][4];
ll a[8][D];

int main()
{
    ll n, m, x1, x2, x3;
    cin >> n >> m;
    for (ll i = 1; i <= n; i++)
    {
        cin >> b[i][0] >> b[i][1] >> b[i][2];
        for (ll mask = 0; mask < 8; mask++)
            for (ll j = 0; j < 3; j++)
                if (mask & 1<<j)
                    a[mask][i] += b[i][j];
                else
                    a[mask][i] -= b[i][j];
    }
    for (ll i = 0; i <= 8; i++)
    {
        sort(a[i] + 1, a[i] + n + 1);
        reverse(a[i] + 1, a[i] + n + 1);
    }

    ll res[8], ans = -Inf;
    memset(res, 0, sizeof(res));
    for (ll i = 0; i < 8; i++)
    {
        for (ll j = 1; j <= m; j++)
            res[i] += a[i][j];
        ans = max(ans, res[i]);
    }
    cout << ans << endl;
    amen;
}


Measured memory_bytes: 384
def power_func(a,b,p):
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

n,m,k = map(int,input().split())

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

s = 0

for x in range(k+1):
    s += (m * power_func(m-1,n-1-x,998244353) * cmb(n-1,x,998244353)) % 998244353
    s %= 998244353
print(s)

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const string str[] = {"AC", "WA", "TLE", "RE"};
int res[4];

int main() {
	int n;
	cin >> n;
	while(n--) {
		string s;
		cin >> s;
		for(int i = 0; i < 4; i++)
			if(s == str[i])
				res[i]++;
	}
	for(int i = 0; i < 4; i++)
		cout << str[i] << " x " << res[i] << '\n';
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  ll X[N], Y[N], P[N]; rep(i,N) cin >> X[i] >> Y[i] >> P[i];
  ll xmin[N][1<<N], ymin[N][1<<N];
  rep(i,1<<N) rep(j,N) {
    xmin[j][i] = abs(X[j]); rep(k,N) if (i&1<<k) xmin[j][i] = min(xmin[j][i], abs(X[k]-X[j]));
    ymin[j][i] = abs(Y[j]); rep(k,N) if (i&1<<k) ymin[j][i] = min(ymin[j][i], abs(Y[k]-Y[j]));
  }
  // rep(i,N) debug(xmin[i],xmin[i]+(1<<N));

  vector<ll> result(N+1,LLINF);
  rep(i,pow(3,N)) {
    ll ti = i, dx = 0, dy = 0, count = 0;
    rep(j,N) {
      if (ti%3==1) { dx += 1<<j; count++; }
      else if (ti%3==2) { dy += 1<<j; count++; }
      ti /= 3;
    }
    ll sum = 0; rep(j,N) sum += min(xmin[j][dx], ymin[j][dy]) * P[j];
    result[count] = min(result[count], sum);
  }
  rep(i,N+1) cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;cin>>s;vector<ll> v(s.size(),0);
  ll pos=0;
  while(pos<s.size()) {
    ll num=0;
    char c=s[pos];
    if (c=='R') {
      while(c==s[pos]) {pos+=1;num+=1;}
      if(num%2==0) {v[pos]+=num/2;v[pos-1]+=num/2;}
      else {v[pos]+=(num-1)/2;v[pos-1]+=(num+1)/2;}
    }
    if (c=='L') {
      ll pos_=pos;
      while(c==s[pos]) {pos+=1;num+=1;}
      if(num%2==0) {v[pos_]+=num/2;v[pos_-1]+=num/2;}
      else {v[pos_]+=(num+1)/2,v[pos_-1]+=(num-1)/2;}
    }
  }
  for (auto i = v.begin(); i != v.end(); i++) cout << *i << " ";
  cout << endl;
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int A[322222];
LL pref[322222], suf[322222];

int main() {
  int N;
  scanf("%d", &N);
  REP(i,3*N) scanf("%d", &A[i]);

  LL su = 0;
  multiset<int> S;
  REP(i,3*N) {
    su += A[i];
    S.insert(A[i]);
    if (S.size() > N) {
      su -= *S.begin();
      S.erase(S.begin());
    }
    pref[i] = su;
  }

  S.clear();
  su = 0;
  FORD(i,3*N,0) {
    su += A[i];
    S.insert(A[i]);
    if (S.size() > N) {
      su -= *S.rbegin();
      S.erase(--S.end());
    }
    suf[i] = su;
  }

  LL best = -1e18;
  FOR(i,N-1,2*N) {
    best = max(best, pref[i] - suf[i+1]);
  }
  printf("%lld\n", best);
}


Measured memory_bytes: 11136
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

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

#define pb push_back
#define mp make_pair
#define mt make_tuple

// 2数の最大公約数
ll getGcdSimple(ll a, ll b)
{
    if (b == 0) return a;
    return getGcdSimple(b, a % b);
}

// 2数の最小公倍数
ll getLcmSimple(ll a, ll b)
{
    return a / getGcdSimple(a, b) * b;
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << getLcmSimple(A, B) << endl;
    

    return 0;
}


Measured memory_bytes: 256