akhauriyash/Code-Regression huggingface dataset:
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Data.Maybe (fromMaybe)
import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

-- 有向グラフに閉路があるか判定し、閉路があれば Nothing を返す。
-- 閉路がなければ最長路の長さを返す。
solve :: V.Vector [Int] -> Maybe Int
solve edges = fmap U.maximum $ runST $ runMaybeT $ do
  let !n = V.length edges  -- 頂点の個数
  vec <- UM.replicate n (-2 :: Int) -- -2: new, -1: DFSの最中, 正: チェック済み
  let dfs !x = do
        s <- UM.read vec x
        case s of
          -2 -> do
            -- x を通る閉路があるかチェックする
            UM.write vec x (-1)
            v <- (+ 1) . maximum . (0 :) <$> mapM dfs (edges V.! x)
            UM.write vec x v
            return v
          -1 -> mzero  -- コールスタックのどこかで dfs x が呼ばれている。閉路
          v -> return v
  mapM_ dfs [0..n-1]
  U.unsafeFreeze vec

main = do
  n <- readLn
  xs <- V.replicateM n $ do
    U.map (subtract 1) . U.unfoldrN (n-1) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = n * (n - 1) `quot` 2  -- グラフの頂点数
  let -- (i,j) (0 <= i < j < n) を 0 以上 m 未満の整数値にコードする
      makePair :: Int -> Int -> Int
      makePair i j | i' < j' = n * i' - (i' + 1) * i' `quot` 2 + j' - i' - 1
                   | otherwise = undefined
        where i' = min i j; j' = max i j
  -- 「試合 (i,j) よりも試合 (i',j') の方を後に行う場合に辺 makePair i j → makePair i' j' が存在する」ようなグラフを作る
  let edges :: V.Vector [Int]
      edges = V.create $ do
        e <- VM.replicate m []
        V.forM_ (V.indexed xs) $ \(i,ys) -> do
          U.forM_ (U.zip ys (U.tail ys)) $ \(a,b) -> do
            -- (i,a) -> (i,b)
            let !b' = makePair i b
            VM.modify e (b' :) (makePair i a)
        return e
  print $ fromMaybe (-1) $ solve edges


Measured memory_bytes: 103036
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext()){
            int count = 0;
            int a = scan.nextInt();
            int b = scan.nextInt();
            int sum = a + b;
            while(true){
                if(sum > 0){
                    count++;
                    sum /= 10;
                } else {
                    break;
                }
            }
            System.out.println(count);
        }
        
        scan.close();
    }
}



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


void solve(long long A, long long P){
    cout << floor((A * 3 + P) / 2) << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
struct node {
	int x,id;
	string s;
} a[100001];
bool cmp(const node &a , const node &b) {
	if(a.s==b.s)
		return a.x>b.x;
	else
		return a.s<b.s;
}
char q[100001];
int bj[100001];
main() {
	int n=read();
	for(int i=1; i<=n; i++) {
		cin>>a[i].s,a[i].x=read(),a[i].id=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1; i<=n; i++)
		cout<<a[i].id<<endl;
}


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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> A(N-1);
  for(int i=1; i<N; i++){
    for(int j=i+1; j<=N; j++) A.at(min({abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)})-1)++;
  }
  rep(i, N-1) cout << A.at(i) << endl;
}

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

const int N = 1005;
const int M = 2005;
const int mod = 1e9 + 7;

int binpow(int a, int b) {
	int ret = 1;
	while(b) {
		if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ret;
}

int n, m;
long long X;
vector < pair<int,int> > g[N];
int dep[N], par[N], topar[N];
bool is[M]; // is included in MSTs

// DSU
int dsu[N];
int anc(int p) { return p == dsu[p] ? p : dsu[p] = anc(dsu[p]); }
void join(int p, int q) { dsu[anc(p)] = anc(q); }

struct edge {
	int w; int u; int v; int id;
	bool operator < (const edge &other) const {
		return w < other.w;
	}
} ored[M];
vector <edge> ed;

void dfs(int u) {
	for (auto &e : g[u]) if (e.second != par[u]) {
		par[e.second] = u;
		topar[e.second] = e.first; // weight
		dep[e.second] = dep[u] + 1;
		dfs(e.second);
	}
}

int get_max(int u, int v) {
	if (dep[u] < dep[v]) swap(u, v);
	int ret = 0;
	while(dep[u] > dep[v]) ret = max(ret, topar[u]), u = par[u];
	while(u != v) ret = max(ret, topar[u]), ret = max(ret, topar[v]), u = par[u], v = par[v];
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> X;
	for (int i = 0; i < m; ++i) {
		int u, v, w; cin >> u >> v >> w;
		ored[i] = {w, u, v, i};
		ed.push_back({w, u, v, i});
	}
	sort(ed.begin(), ed.end());
	for (int i = 1; i <= n; ++i) dsu[i] = i;

	long long span = 0;
	for (auto &e : ed) {
		if (anc(e.u) == anc(e.v)) continue;
		join(e.u, e.v);
		g[e.u].push_back(make_pair(e.w, e.v));
		g[e.v].push_back(make_pair(e.w, e.u));
		is[e.id] = true;
		span += e.w;
	}

	dfs(1);

	vector <long long> vec;
	for (int i = 0; i < m; ++i) if (!is[i]) {
		int u = ored[i].u, v = ored[i].v;
		int mx = get_max(u, v);
		vec.push_back(span - mx + ored[i].w);
	}

	int res = 0;
	if (span == X) {
		res = 1LL * (binpow(2, n - 1) - 2) * binpow(2, m - n + 1) % mod;
	}
	sort(vec.begin(), vec.end());

	for (int i = 0; i < vec.size(); ++i) {
		// free: i + 1 -> vec - 1
		if (vec[i] == X) {
			res = (res + binpow(2, vec.size() - i)) % mod;
		}
	}

	if (res < 0) res += mod;

	printf("%d\n", res);
}

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

int main()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string st = "";
    for(int i = 0; i < N; i++)
    {
        st += S[i];
        st += T[i];
    }
    cout << st << endl;
}

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

void func()
{
	int point = 0;
	int out   = 0;
	int hit   = 0;
	string str;

	while(out < 3)
	{
		cin >> str;
		if(str == "OUT"    )
		{
			out++;
		}
		else if(str == "HOMERUN") 
		{
			point += hit+1;
			hit = 0;
		}
		else if(str == "HIT")
		{
			if(hit<3)	hit++;
			else		point++;
		}
	}
	cout << point << endl;
}


int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		func();
	}
	return 0;
}

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

#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

int shizuku(int,int);

int main(){
    int N,X,b,H=0,W=0,count=0,count2=0;
    double d,D;
    int C='A'-'a';
    char op;
    str S,T;
    vc a(4);
    rep(0,4)cin>>a[i];
    int L=(a[0]-'0')*10+(a[1]-'0'),R=(a[2]-'0')*10+(a[3]-'0');
    if(shizuku(L,R)==1)cout<<"YYMM"<<endl;
    elif(shizuku(L,R)==0)cout<<"MMYY"<<endl;
    elif(R<=12&&L<=99&&L>12&&R!=0)cout<<"YYMM"<<endl;
    elif(L<=12&&R<=99&&R>12&&L!=0)cout<<"MMYY"<<endl;
    elif(R<=12&&L<=12&&R!=0&&L!=0)cout<<"AMBIGUOUS"<<endl;
    else cout<<"NA"<<endl;
}
int shizuku(int L,int R){
  if(L==0&&R<=12&&R!=0){
    return 1;
  }
  elif(R==0&&L<=12&&L!=0){
    return 0;
  }
  else return 2;
}


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

int main(){
    int n;
    cin >> n;
    vector <long long> a(n + 1), b(n);
    for (int tsumugi = 0; tsumugi < n + 1; tsumugi++){
        cin >> a[tsumugi];
    }
    for (int matsuri = 0; matsuri < n; matsuri++){
        cin >> b[matsuri];
    }

    long kill = 0;

    //i番目の街について考える
    for (int kaori = 0; kaori < n; kaori++){
        if (a[kaori] >= b[kaori]){  //i街のモンスターを倒しきれない(=余力0)場合
            kill += b[kaori];
        }
        else if (a[kaori] + a[kaori + 1] >= b[kaori]){
            kill += b[kaori];
            a[kaori + 1] -= (b[kaori] - a[kaori]);
        }
        else{
            kill += (a[kaori] + a[kaori + 1]);
            a[kaori + 1] = 0;
        }
    }

    cout << kill << endl;
    return 0;
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i ++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i --)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {T a; K b;};

int main( void ){
	initialize();
	ll N;
	cin >> N;
	vector<int> vec( N);
	double sum = 0;
	rep(i,0,N){
		cin >> vec[i];
		sum += vec[i];
	}
	sum /=N;
	int p = (int)sum;
	if (sum - (int)sum >=0.5)
		p++;
	ll ans = 0;
	rep(i,0,N){
		ans += (vec[i]-p)*(vec[i]-p);
	}
	cout << ans << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	cin.tie( 0 );
	ios::sync_with_stdio( false );
}


Measured memory_bytes: 256
/**
 *    author:  zjsdut
 *    created: 2020/03/10 11:40:20
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  string s;
  scan(s);
  println(string(SZ(s), 'x'));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <random>
#include <unordered_set>
#include <algorithm>
#include <unordered_map>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b = a;
	sort(b.begin(), b.end());
	int ans = 1e9;
	for (int i = 0; i < b.size(); i++) {
		int l = -1, r = 1e9 + 2;
		while (r - l > 1) {
			int m = (l + r) / 2;
			int L = b[i];
			int R = b[i] + m;
			int col = 0;
			vector<int> sz = {0};
			vector<int> tt = {0};
			for (int i = 0; i < n; i++) {
				if (a[i] >= L) {
					sz[sz.size() - 1]++;
					if (a[i] <= R) {
						tt[tt.size() - 1]++;
					}
				}
				else {
					sz.push_back(0);
					tt.push_back(0);
				}
			}
			for (int i = 0; i < tt.size(); i++) {
				if (sz[i] >= k)
					col += min(sz[i] - k + 1, tt[i]);
			}
			if (col >= q)
				r = m;
			else
				l = m;
		}
		ans = min(ans, r);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
import Data.List

divisorsLeq :: Int -> Int -> [Int]
divisorsLeq m n
  | m == 0    = [n, n-1 .. 0]
  | sqrtM > n = divsIn [n, n-1 .. 1]
  | otherwise = reverse (takeWhile (<= n) $ map snd divPairs)
                ++ (if sqrtM * sqrtM == m' then [sqrtM] else [])
                ++ map fst divPairs
  where
    m' = abs m
    sqrtM = ceiling (sqrt $ fromIntegral m' :: Double)
    divsIn xs = [x | x <- xs, m' `mod` x == 0]
    divPairsIn xs = [(x,y) | x <- xs, let (y,r) = m' `divMod` x, r == 0]
    divPairs = divPairsIn [sqrtM, sqrtM-1 .. 1]

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  let mdn = m `div` n
  putStrLn $ show $ head $ divisorsLeq m mdn

Measured memory_bytes: 1020
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,d;
   cin >>a>>b;
   c=1;
   d=1;
   rep(i,1000){
    c *=b;
     if(a<c){
      cout<<d<<endl;
      break;
     }
     if(a==c){
     cout<<d+1<<endl;
      break;
     }
    d++;
   }
     
}


Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    #n = int(input())
    # 整数複数個
    a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    #N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    #N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    #A = [list(map(int, input().split())) for i in range(H)]

    if (b * 10 + c) %4 == 0:
        print("YES")
    else:
        print("NO")

resolve()

Measured memory_bytes: 38384
L, R = map(int, input().split())
mod = 2019
ml = L % mod
mr = R % mod

if ml >= mr:
  print(0)
elif R - L >= 2019:
  print(0)
else:
  temp = 2 * 10 ** 9 + 1
  for i in range(ml, mr + 1):
    for j in range(i + 1, mr + 1):
      temp = min(temp, (i * j) % mod)
  print(temp)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << (b-a-1)*(b-a)/2 - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s;
    cin >> s;
    if(s == "ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int Partition(int*,int, int);
int i, n;

main(){

  int j ,k, A[100000], x;
  
  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  x = Partition(A,0,n-1);

  for(i=0; i<x; i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[x]);

  for(i=x+1; i<n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}

int Partition(int A[], int p, int r){
  
  int  j, k, x;
  x = A[r];
  i = p-1; 

  for(j=p; j<r; j++){
    if(A[j] <= x){
      i = i + 1;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }
  k = A[i+1];
  A[i+1] = A[r];
  A[r] = k;
  return i+1;
}

Measured memory_bytes: 988
import math
n=int(input())
p=[]
p.append(int(input()))
pAdded=[p[0]]
pmax=0
pmaxIndex=0
for i in range(1,n):
    p.append(int(input()))
    pAdded.append(pAdded[i-1]+p[i])
    if pmax<p[i]:
        pmaxIndex=i
        pmax=p[i]
print(pAdded[n-1]-math.floor(p[pmaxIndex]/2))


Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, p;

	void run(){
		for(;;){
			n=sc.nextInt();
			p=sc.nextInt();
			if((n|p)==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		int[] a=new int[n];
		int q=p;
		for(int i=0;; i=(i+1)%n){
			if(q>0){
				a[i]++;
				q--;
			}else{
				q+=a[i];
				a[i]=0;
			}
			if(a[i]==p){
				println(""+i);
				return;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int dt[10];
int main(){
  int n,m;
  while(cin>>n,n){
    rep(i,10)dt[i]=0;
    rep(i,n){
      cin>>m;
      dt[m]++;
    }
    rep(i,10){
      if(dt[i]==0)cout<<'-'<<endl;
      else{
	rep(j,dt[i])cout<<"*";
	cout<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1152
N,L = map(int,input().split())

a = [0]*N
for i in range(1,N+1):
    a[i-1] = L + i-1

mi = 10*100
k = 0
for i in range(N):
    if mi > abs(a[i]):
        mi = abs(a[i])
        k = i

print(sum(a) - a[k])


Measured memory_bytes: 38384
#coding:utf-8
#1_6_A
def counting_sort(array):
    cnt = [0 for i in range(max(array)+1)]
    result = [0 for  i in range(len(array))]

    for j in range(len(array)):
        cnt[array[j]] += 1

    for i in range(1, max(array)+1):
        cnt[i] += cnt[i-1]

    for j in reversed(range(len(array))):
        result[cnt[array[j]]-1] = array[j]
        cnt[array[j]] -= 1

    return result

n = int(input())
numbers = list(map(int, input().split()))
print(' '.join(map(str, counting_sort(numbers))))

Measured memory_bytes: 245640
N, K, Q = [int(i) for i in input().split()]
#print(N, K, Q)

P = [K] * N
#print(P)

for  i in range(Q):
    a = int(input())
    P[a-1] += 1

#print(P)

P_last = [i-Q for i in P]
#print(P_last)

for i in P_last:
    if i <= 0:
        print("No")
    else:
        print("Yes")

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

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

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

vector<vi> graph;
int N;
pair<int, int> getFurthest(int pos) {
    vector<bool> visited (N);
    queue<pair<int, int>> search;
    visited[pos] = true;
    search.push({pos, 0});
    while (true) {
        pair<int, int> cur = search.front(); search.pop();
        int curPos = cur.first;
        int curDist = cur.second;
        for (int n : graph[curPos]) {
            if (!visited[n]) {visited[n] = true; search.push({n, curDist + 1});}
        }
        if (search.empty()) return cur;
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    cin >> N;
    graph.resize(N);
    F0R(i, N-1) {
        int A, B; cin >> A >> B; --A; --B; 
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    pair<int, int> ldiam = getFurthest(0);
    int diam = getFurthest(ldiam.first).second + 1;
    
    if ((diam + 1) % 3 == 0) {    
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}

Measured memory_bytes: 13708
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
LL a,b,c,d,t;
LL gcd(LL x,LL y){
	if(x==0)return y;
	return gcd(y%x,x);
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);t=c*d/gcd(c,d);
	printf("%lld\n",b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-(b/t-(a-1)/t)));
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >>s;
    int x=0,y=0,z=0;
    if(s[0]=='A') x++;
    for(int i=0;i<s.length();i++){
        if(s[i]>='A' && s[i]<='Z') y++;
    }
    for(int i=2;i<=s.length()-2;i++){
        if(s[i]=='C') z++;
    }
    if(x==1 && y==2 && z==1){
        cout <<"AC"<<endl;
    }else{
        cout <<"WA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	int ans = 0;
	rep1(i, n) {
		string s = to_string(i);
		if (s.length() % 2)ans++;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


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

int main() {
	string S;
	int K;
	cin >> S;
	cin >> K;

	vector<string> set;

	for (int i = 0; i < S.size(); i++) {
		for (int j = 1; j <= 5; j++) {
			set.push_back(S.substr(i, j));
		}
	}

	sort(set.begin(), set.end());
	unique(set.begin(), set.end());
	cout << set[K-1] << endl;

	return 0;
}


Measured memory_bytes: 1660
def solve(n, m, a, b):
    E = {i: [] for i in range(n)}
    for u, v in zip(a, b):
        u, v = u-1, v-1
        E[u].append(v)
        E[v].append(u)
    L = list(range(n))
    for s in range(n):
        if L[s] == s:
            L[s] = s
            que = [s]
            while que:
                u = que.pop(0)
                for v in E[u]:
                    if L[v] != s:
                        L[v] = s
                        que.append(v)
    return len(set(L)) - 1
 
n, m = map(int, input().split())
if m == 0:
    a, b = [], []
else:
    a, b = zip(*[map(int, input().split()) for i in range(m)])
print(solve(n,m,a,b))

Measured memory_bytes: 61004
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  deque<int> d;
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int p, q, x;
    cin>>p>>q;
    if (p == 0) {
      cin>>x;
      if (q == 0) {
        d.push_front(x);
      } else {
        d.push_back(x);
      }
    } else if (p == 1) {
      cout << d[q] << endl;
    } else {
      if (q == 0) {
        d.pop_front();
      } else {
        d.pop_back();
      }
    }
  }  
}



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

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

	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;

	string res;
	if (A > B)
		res = "Alice";
	else if (A < B)
		res = "Bob";
	else
		res = "Draw";

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  string s;
  cin >> s;
  char previous = 'a';

  repl(i, 4) {
    if (s[i] == previous) {
      cout << "Bad" << endl;
      return 0;
    }

    previous = s[i];
  }

  cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, R);
  printf("%.10lf", (double)R * 2 * 3.14159265359);
}


Measured memory_bytes: 3784
#include<stdio.h>
#define ll long long
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a / gcd(a,b) * b;}
int main(){
    ll m, n, i, l = 1;
    scanf("%lld%lld",&n,&m);
    ll a[n];
    for(i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        a[i] /= 2;
        l = lcm(l, a[i]);
    }
    for(i = 0; i < n; i++)
        if(l / a[i] % 2 == 0){
            printf("0\n");
            return 0;
        }
    printf("%lld\n",(m / l + 1) / 2);
    return 0;
}

Measured memory_bytes: 896
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int x, a, b;
	cin >> x >> a >> b;

	cout << (abs(x - a) > abs(x - b) ? "B" : "A") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll a;
    cin >> a;
    if (a%1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - a%1000 << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1000000007;
	//constexpr ll P = 998244353;

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d}) << endl;
}

Measured memory_bytes: 3648
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    Sn = sum(list(map(int, list(str(n)))))
    print('Yes' if n % Sn == 0 else 'No')


if __name__ == '__main__':
    main()


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

int main()
{
    ll l, r;
    cin >> l >> r;
    r = min(r, l + 4038);
    int ans = 2018;
    for (ll i = l; i <= r; i++)
    {
        for (ll j = i + 1; j <= r; j++)
        {
            int x = i * j % 2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

void solve() {
    ll n;
    cin >> n;
    ll a[n];
    For(i, 0, n)
        cin >> a[i];
    ll ans = 0;
    sort(a, a + n);
    For(i, 0, n) {
        For(j, i + 1, n){
            For(k, j + 1, n) {
                if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n; cin >>n;
  string s; cin >> s;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  rep(i,n/2){
    if(s[i]!=s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  PYES;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;
 
int n;
ll a,b,s[maxn],f[maxn][2];
int A[maxn],B[maxn];
 
void pd(ll&ret,ll val) {
  ret+=val;
  if(ret>=mod)ret-=mod;
}
 
struct BIT {
  ll c[maxn];
  void init() {
    for(int i = 0;i < maxn;i++)c[i] = 0;
  }
  int lowbit(int x) {
    return x&(-x);
  }
  void add(int x, ll y) {
    while(x<maxn) {
      pd(c[x],y);
      x+=lowbit(x);
    }
  }
  ll sum(int x) {
    ll ret=0;
    while(x>0) {
      pd(ret,c[x]);
      x-=lowbit(x);
    }
    return ret;
  }
} bit[2];
 
int bs(int l,int r, ll val) {
  int ret = -1;
  while(l<=r) {
    int m = (l+r)>>1;
    if(s[m]<=val) {
      ret=m;
      l=m+1;
    } else r=m-1;
  }
  return ret;
}
 
int main() {
  //freopen("in.cpp","r",stdin);
  while(cin>>n>>a>>b) {
  bit[0].init();
  bit[1].init();
  memset(f,0,sizeof(f));
  for(int i=1; i<=n; i++)cin>>s[i];
  s[++n] = 2000000000000000000LL;
  A[1] = B[1] = 1;
  for(int i=2; i<=n; i++) {
    if(s[i]>=s[i-1]+a)A[i]=A[i-1];
    else A[i] = i;
    if(s[i]>=s[i-1]+b)B[i]=B[i-1];
    else B[i] = i;
  }
  for(int i=1; i<=n; i++) {
    if(i==1) {
      f[i][0]=1;
    } else {
      if(B[i-1]==1)pd(f[i][0],1);
      int l = B[i-1]-1,r=i-2;
      l=max(l,1);
      if(r>=l) {
        int pos = bs(l,r,s[i]-a);
        if(pos!=-1) {
          r = min(pos,r);
          ll tmp = bit[1].sum(r);
          tmp=(tmp+mod-bit[1].sum(l-1))%mod;
          pd(f[i][0],tmp);
        }
      }
    }
    bit[0].add(i,f[i][0]);
    int l=A[i],r=i;
    if(i<n) {
      if(l==1)pd(f[i][1],1);
      int pos = bs(1,i-1,s[i+1]-b);
      if(pos!=-1 && pos+1>=l) {
        r = min(r,pos+1);
        if(l == 1) l++;
        if(l<=r) {
        ll tmp=bit[0].sum(r);
        tmp=(tmp+mod-bit[0].sum(l-1))%mod;
        pd(f[i][1],tmp);
      }
      }
    } else {
      ll tmp=bit[0].sum(r);
      tmp=(tmp+mod-bit[0].sum(l-1))%mod;
      pd(f[i][1],tmp);
    }
    bit[1].add(i,f[i][1]);
    //cout<<i<<": "<<f[i][0]<<","<<f[i][1]<<endl;
  }
  cout<<f[n][1]<<endl;
  }
  return 0;
}


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

using namespace std;

int main(){
  char c[5];
  cin >> c;
  cin.ignore();

  int buc[128] = {0};

  for (int i = 0; i < 128; i++){
    buc[i] = 0;
  }

  for(int i = 0; i < 4; i++){
    ++buc[c[i]];
    //cout << buc[c[i]] << endl;
  }

  bool flag = false;
  for (int i = 0; i < 128; i++){
    if((flag == false) && (buc[i] == 2)){
      flag = true;
    } else if((flag == true) && (buc[i] == 2)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << ((s.substr(0, 4) == "YAKI") ? "Yes" : "No") << '\n';

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    p=primes(55555)
    q=[x for x in p if x%5==1]
    print(*q[:n])

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
        if i*i>n:
            break
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

if __name__=="__main__":
    main()

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int a[10];
  rep(i,10)cin>>a[i];
  sort(a,a+10,greater<int>());
  rep(i,3)cout<<a[i]<<endl;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int X = sc.nextInt();
		int Y = sc.nextInt();

		int prc = 0;
		if (X <= Y) {
			prc = C * 2 * X;
			prc += B * (Y - X);
		} else {
			prc = C * 2 * Y;
			prc += A * (X - Y);
		}

		int nrm = 0;
		nrm = A * X + B * Y;

		int onc = 0;
		if(X <= Y) {
			onc = C * 2 * Y;
		} else {
			onc = C * 2 * X;
		}

		int min = Integer.MAX_VALUE;

		if (prc<=nrm) {
			if(prc <= onc) {
				min = prc;
			} else {
				min = onc;
			}
		} else {
			if(nrm <= onc) {
				min = nrm;
			} else {
				min = onc;
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define FOR(a,b,n) for(int a=b;a<=b;a++)
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("d",&a,&b)
#define sccc(a,b,c) scanf("d%d",&a,&b,&c)
#define sccs(s) scanf("%s",s)
#define pccs(s) printf("%s",s)
#define debug printf("---debug---");
#define pcc(a,b) printf("d",a,b)
#define pccc(a,b,c) printf("d%d",a,b,c)
#define pb push_back
typedef long long ll;
const int MAXN_1e5=1e5+5;
const int MAXN_2e5=2e5+5;
const int MAXN_3e5=3e5+5;
const int MAXN_4e5=4e5+5;
const int MAXN_5e5=5e5+5;
const int INF_INT=0x3f3f3f3f;
const long long INT_LL=2e18;
int dp[1<<13];
int temp[5000];
int cost[5000];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        for(int i=1;i<(1<<n);i++)dp[i]=INF_INT;
        memset(temp,0,sizeof(temp));
        for(int i=1;i<=m;i++)
        {
            int num;
            cin>>cost[i]>>num;
            for(int j=1;j<=num;j++)
            {
                int a;
                cin>>a;
                temp[i]|=(1<<(a-1));
            }
        }
        for(int s=0;s<(1<<n);s++)
        {
            for(int i=1;i<=m;i++)
            {
                dp[s|temp[i]]=min(dp[s|temp[i]],dp[s]+cost[i]);
            }
        }
        if(dp[(1<<n)-1]==INF_INT)dp[(1<<n)-1]=-1;
        cout<<dp[(1<<n)-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
N=int(input())
temp=[input().split() for i in range(N)]
A=[[i+1,temp[i][0],int(temp[i][1])] for i in range(N)]
A=sorted(A,key=lambda x:x[2],reverse=True)
A=sorted(A,key=lambda x:x[1])
for i in range(N):
    print(A[i][0])

Measured memory_bytes: 3064
(N,L)=input().split(' ')
N = int ( N )
L = int ( L )
A =[]
B =[]
for i in range ( N ) :
   A.append ( abs ( L + i ) )
   B.append ( L + i )

A.sort()   

if  ( L < 0 ) :
    print ( sum ( B ) + A[0] )

else :
    print ( sum ( B ) - A[0] )


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int n,k;
vecll a;

bool func(ll x){
    vecll b(n),c(n),sumB(n),sumC(n);
    rep(i,n){
        b[i]=(a[i]+x)%x;
    }
    sort(ALL(b));
    rep(i,n)c[i]=(x-b[i])%x;
    rep(i,n){
        sumB[i]=i==0?b[i]:sumB[i-1]+b[i];
        sumC[n-i-1]=i==0?c[n-i-1]:sumC[n-i]+c[n-i-1];
    }
    rep(i,n-1)if(sumB[i]==sumC[i+1] && sumC[i+1]<=k)return true;
    return false;
    
}

int main(){
    n=in();
    k=in();
    a.resize(n);
    ll sum=0,ans=0;
    rep(i,n)sum+=a[i]=in();
    for(ll x=1;x*x<=sum;x++)if(sum%x==0){
        if(func(x))ans=max(ans,x);
        if(func(sum/x))ans=max(sum/x,ans);
    }
    cout<<ans<<endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll GCD(ll A, ll B){
  if (A < B) swap(A, B);
  while (A % B != 0){
    A %= B; swap(A, B);
  }
  return B;
}

int main(){
  int N; cin >> N;
  ll ans; cin >> ans;
  for (int i = 1; i < N; i++){
    ll A; cin >> A;
    ans = GCD(ans, A);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> data(N);
  for (int i=0; i<N; i++){
    std::cin >> data.at(i);
  }
  std::sort(data.rbegin(), data.rend());
  int sum=0;
  for (int i=0; i<K; i++) {
    sum += data.at(i);
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>

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

  bool denied = false;
  for (int i = 0; i < n; i++)
  {
    if (a[i] % 2 == 1)
    {
      continue;
    }
    else
    {
      if ((a[i] % 3 != 0) && (a[i] % 5 != 0))
      {
        denied = true;
      }
    }
  }

  if (denied)
  {
    cout << "DENIED" << endl;
  }
  else
  {
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
# Twitterしない！耳栓！
# 貪欲

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    c = input().rstrip().split()
    a = int(c[0])
    b = float(c[1]) + 10**-7
    b *= 100
    b = int(b)
    res = a*b
    print(int(res//100))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9704
import java.util.Scanner;
public class Main {

	public void run() throws Exception {
		int anw = 0;
		int num = 0;
		String ACGT = "ACGT";
	    Scanner sc = new Scanner(System.in);
	    char[] cs = sc.next().toCharArray();
	    for(int i=0;i<cs.length;i++){
	    	
	    	if(ACGT.indexOf(cs[i]) != -1){
	    		num++;
	    		if(num > anw){
	    			anw = num;
	    		}
	    	}else{	    		
	    		num = 0;
	    	}
	    }
	    
	    
	    System.out.println(anw);
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

}

Measured memory_bytes: 35544
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

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<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int a, b;cin >> a >> b;
    println(a * b);

    return 0;
}


Measured memory_bytes: 3620