akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

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

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   double n, d;
   cin >> n >> d;
   vector<int> x(n), y(n);
   int ans=0;
   rep(i, n){
       cin >> x[i] >> y[i];
   }
   rep(i,n){
       double d1 = pow(x[i],2.0)+pow(y[i],2.0);
       //cout << d1 << " " << x[i] << " " << pow(x[i],2.0) << " " << y[i] << " " << pow(y[i],2.0) << " ";
       d1=sqrt(d1);
       //cout << d1 << endl;
       if(d>=d1) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<vector<ll>> cards(2, vector<ll>(n));
    rep(i, 2) rep(j, n) cin >> cards[i][j];

    vector<vector<ll>> dp(1 << n, vector<ll>(n, INF * 2));
    rep(i, n) dp[1 << i][i] = i;
    rep(mask, (1 << n) - 1) {
        rep(i, n) {
            bool b = mask & (1 << i);
            if (!b) continue;
            bool b2 = dp[mask][i] < INF;
            if (!b2) continue;

            int pc = __builtin_popcount(mask);
            int cur = cards[abs(i - pc - 1) % 2][i];
            rep(x, n) {
                bool b3 = (mask & (1 << x)) == 0;
                if (b3) {
                    int nex = cards[abs(x - pc) % 2][x];
                    int num = __builtin_popcount((mask ^ (0xfffff)) & ((1 << x) - 1));
                    if (nex >= cur) {
                        dp[mask | (1 << x)][x] = min(dp[mask | (1 << x)][x], dp[mask][i] + num);
                    }
                }
            }

        }
    }

    ll mi = INF;
    rep(i, n) cmin(mi, dp[(1 << n) - 1][i]);

    if (mi >= INF) {
        cout << -1 << endl;
    } else {
        cout << mi << endl;
    }


}


Measured memory_bytes: 47360
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const ll LL_MAX = 0x7fffffffffffffff;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    bool flag = false;
    if (a < b)
    {
        flag = (a < c) && (c < b);
    }
    else
    {
        flag = (b < c) && (c < a);
    }
    cout << (flag ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
void main(){
	int a, b;
	readf("%d %d", &a, &b);
	max(a+b, a-b, a*b).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2696
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */


/* Name of the class has to be "Main" only if the class is public. */
public class Main{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner s=new Scanner(System.in);
        int t=s.nextInt();
        String ss=s.next();
        if(t%2==1)
        System.out.println("No");
        else if(!ss.substring(0,t/2).equals(ss.substring(t/2,t)))
        System.out.println("No");
        else
        System.out.println("Yes");
      s.close();
        }
        }

Measured memory_bytes: 21844
import sys
H = []
W = []

for l in sys.stdin:
    Ha, Wa = map(int, l.split())
    if Ha == 0 and Wa == 0:
        break
    H.append(Ha)
    W.append(Wa)

for i, numH in enumerate(H):
    for num in range(numH):
        if (num == 0) or (num % 2 == 0):

            pr1 = ""
            for numW in range(W[i]):
                if (numW == 0) or (numW % 2 == 0):
                    pr1 += "#"
                else:
                    pr1 += "."
            print(pr1)

        else:

            pr2 = ""
            for numW in range(W[i]):
                if (numW == 0) or (numW % 2 == 0):
                    pr2 += "."
                else:
                    pr2 += "#"
            print(pr2)

    print()


Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n, m; cin >> n >> m;
    ll su = 0;
    rep(i, m) {
        int a;
        cin >> a;
        su += a;
    }
    if(n >= su) {
        cout << n-su << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    vi p(n),c(n);
    rep(i,n)cin>>p[i],p[i]--;
    rep(i,n)cin>>c[i];
    int ans=-inf;
    rep(i,n){
        int j=i;
        int s=0;
        int t=0;
        while(true){
            s+=c[j];
            t++;
            j=p[j];
            if(j==i)break;
        }
        int u=0;
        int v=0;
        while(true){
            u+=c[j];
            v++;
            if(v>k)break;
            ans=max(ans,u+max(0ll,s)*((k-v)/t));
            j=p[j];
            if(j==i)break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(x,n) for(int x = 0; x < n; x++)
#define FORR(x,n) for(int x = n-1; x >= 0; x--)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a) ((int)(a).size())
using namespace std;
typedef long long ll;

const int MXN = 9;
int H, W, total = 0;
bool A[MXN][MXN] = {};

bool can(int x, int y, int cnt) {
  if(x >= H || x < 0 || y >= W || y < 0) return false;
  if(!A[x][y]) return false;
  cnt++;
  if(x == H-1 && y == W-1) return cnt == total;
  return can(x+1, y, cnt) || can(x, y+1, cnt);
}

int main(){
  cin >> H >> W;
  FOR(x,H) FOR(y,W) {
    char c; cin >> c;
    A[x][y] = (c == '#');
    total += A[x][y];
  }
  
  cout << (can(0,0,0) ? "Possible\n" : "Impossible\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>

//ios::sync_with_stdio(false);

using namespace std;

const int INF = (1<<30) - 1;

int dh[] = {0, 0, 1, -1};
int dw[] = {1, -1, 0, 0};

int bfs(vector<string>& field, pair<int, int> start, pair<int, int> end){
    int H = field.size();
    int W = field[0].size();
    vector<vector<int> > d(H, vector<int>(W, INF));
    queue<pair<int, int> > nodes;
    
    d[start.first][start.second] = 0;
    nodes.push(start);
    
    while(!nodes.empty()){
        auto node = nodes.front(); nodes.pop();
        for(int i=0; i<4; i++){
            int nh = dh[i] + node.first;
            int nw = dw[i] + node.second;
            
            if(0<=nh&&nh<H && 0<=nw&&nw<W && field[nh][nw] != 'X' && d[nh][nw] == INF){
                d[nh][nw] = d[node.first][node.second] + 1;
                
                if(nh == end.first && nw == end.second)
                    return d[nh][nw];
                
                nodes.push(make_pair(nh, nw));
            }
        }
    }
    return -1;
}

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    
    vector<string> field(H);
    for(int i=0; i<H; i++)
        cin >> field[i];
    
    vector<pair<int, int> > cheeses(N+1);
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char& c = field[i][j];
            if(c == 'S'){
                cheeses[0] = make_pair(i, j);
            }else if(c != '.' && c != 'X'){
                cheeses[c-'0'] = make_pair(i, j);
            }
        }
    }
    
    
    int ans = 0;
    for(int i=0; i<N; i++){
        ans += bfs(field, cheeses[i], cheeses[i+1]);
    }
    
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 6060
A,B,K=map(int,input().split())

for i in range(K):
  if i%2==0:
    A=A-A%2
    A,B=A-A//2,B+A//2
  else:
    B=B-B%2
    A,B=A+B//2,B-B//2
  #print(A,B)
print(A,B)

Measured memory_bytes: 3060
#include <stdio.h>

int serch(int n, int S[], int x) {
	int left = 0;
	int right = n;
	int center;
	while (left < right) {
		center = (left + right) / 2;
		if (S[center] == x) {
			return 1;
		} else if (x < S[center]) {
			right = center;
		} else {
			left = center + 1;
		}
	}
	return 0;
}

int main() {
	int n, q;
	int S[100000];
	int i;
	int key;
	int count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		count += serch(n, S, key);
	}
	printf("%d\n", count);
	return 0;
}



Measured memory_bytes: 2100
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=3e3+5;

int dp[N][N][2];        // (l, r, chance)

vector<int> v;
int n;

int rec(int l,int r,int chance)
{
    if(l>r)
        return 0;

    if(dp[l][r][chance]!=inf)
        return dp[l][r][chance];

    int res=0;

    if(chance==0)
        res=max(v[l]+rec(l+1,r,1),v[r]+rec(l,r-1,1));
    else
        res=min(-v[l]+rec(l+1,r,0),-v[r]+rec(l,r-1,0));

    return (dp[l][r][chance]=res);
}

void solve()
{
    for(int i=0;i<N;++i)
    {
        for(int j=0;j<N;++j)
            dp[i][j][0]=dp[i][j][1]=inf;
    }

    cin>>n;

    v.resize(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int ans=rec(0,n-1,0);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 141568
x = int(input())

pow5 = [i ** 5 for i in range(-1000, 1000)]

for a in range(-1000, 1000):
  for b in range(-1000, 1000):
    if pow5[a + 1000] - pow5[b + 1000] == x:
      print(f"{a} {b}")
      exit(0)


Measured memory_bytes: 9168
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

nums = Counter(A)

if len(nums) <= K:
    print(0)
else:
    ans = 0
    mosts = nums.most_common()[::-1]
    for i in range(len(nums)-K):
        ans += mosts[i][1]
    print(ans)

Measured memory_bytes: 39320
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const int max_n=30,max_m=30;
int k[max_n];
int a[max_n][max_m];
int n,m,ans=0;

void solve(){
    rep(i,k[0]){
        vector<bool> flag(n,false);
        bool p=true;
        for(int j=1;j<n;j++){
            rep(k,max_m){
                if(a[j][k]==a[0][i]){
                    flag[j]=true;
                    break;
                }
            }
        }
        for(int j=1;j<n;j++){
            if(!flag[j]){
                p=false;
                break;
            }
        }
        if(p) ans++;
    }
    cout<<ans;
}

int main(){
    cin>>n>>m;
    rep(i,n){
        cin>>k[i];
        rep(j,k[i]) cin>>a[i][j];
    }
    solve();
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    string s;
    cin >> s;

    if (s.back() != 's')
        s += 's';
    else s += "es";
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
  int N;

  cin >> N;

  long long int l[87];
  l[0] = 2;
  l[1] = 1;

  for (int i = 2; i <= N; i++) {
    l[i] = l[i-1] + l[i-2];
  }

  cout << l[N] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String codes = sc.next();
		sc.close();
		boolean bl = false;
		for(int i=0; i<3; i++) {
			bl = (codes.charAt(i) == codes.charAt(i+1)||bl);
		}
		if(bl) {
			System.out.println("Bad");
		}else {
			System.out.println("Good");
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int INF=1000000000;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int matriks[20][20]={},nodes,edge,total[(1<<15)+5][20]={},harga[(1<<15)+5],temp[20],bentuk[(1<<15)+5],dp[(1<<15)+5][20];
void setINF(){
	for(int i=0;i<(1<<nodes);i++)
	{
		for(int j=0;j<nodes;j++)
			dp[i][j]=INF;
	}
}
int lsone(int state){
	return state&-state;
}
void precomp(){
	for(int state=0;state<(1<<nodes);state++)
	{
		for(int i=0;i<nodes;i++)
		{
			if(state==0)
				total[state][i]=0;
			else
				total[state][i]=total[state-lsone(state)][i]+matriks[i][__builtin_popcount(lsone(state)-1)];
		}
	}
}
int main()
{
	scan(nodes,edge);
	for(int i=1;i<=edge;i++)
	{
		int u,v,weight;
		scan(u,v),scan(weight);
		u--;
		v--;
		matriks[u][v]=weight;
		matriks[v][u]=weight;
	}
	setINF();
	precomp();
	//basecase
	dp[(1<<0)][0]=0;
	for(int state=1;state<(1<<nodes);state++)
	{
		for(int i=0;i<nodes;i++)
		{
			if((state&(1<<i))==0)			//gak valid
			{
				assert(dp[state][i]==INF);
				continue;
			}
			for(int j=0;j<nodes;j++)
			{
				if(state&(1<<j))
					continue;
				if(matriks[i][j]==0)
					continue;
				dp[state|(1<<j)][j]=min(dp[state|(1<<j)][j],dp[state][i]+total[state^(1<<i)][j]);
			}
			int invers=state^((1<<nodes)-1),totalBit=__builtin_popcount(invers);
			for(int j=0;j<totalBit;j++)
			{
				temp[j]=__builtin_popcount(lsone(invers)-1);
				invers-=lsone(invers);
			}
			harga[0]=0;
			bentuk[0]=0;
			for(int mask=1;mask<(1<<totalBit);mask++)
			{
				harga[mask]=harga[mask-lsone(mask)]+total[state^(1<<i)][temp[__builtin_popcount(lsone(mask)-1)]];
				bentuk[mask]=bentuk[mask-lsone(mask)]^(1<<temp[__builtin_popcount(lsone(mask)-1)]);
				assert((state&bentuk[mask])==0);
				dp[state^bentuk[mask]][i]=min(dp[state^bentuk[mask]][i],dp[state][i]+harga[mask]);
			}
		}
	}
	cout<<dp[(1<<nodes)-1][nodes-1]<<endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
ll n, m , k;
cin >> n >> m >> k;
ll ans = 0;
vector<ll>  a(n), b(m+1);
for(ll i = 0; i< n; i++) cin >> a[i];
for(ll i = 0; i< m; i++) cin >> b[i];
b[m] = 1e9+5;
ll c[m+2];
c[0] = 0;
for(ll i = 1; i<=m+1; i++) c[i] = c[i-1]+b[i-1];
for(ll i = 0; i<= n; i++){
   if(i == 0) k -= 0;
   else  k -= a[i-1];
   if(k<0)break;
   ll l =0; ll r = m+1;
   while(r-l>1){
       ll mid = (r + l) /2;
       if(k >= c[mid]) l = mid;
       else r = mid;
   }
  ans = max(i+l, ans);
}
   
cout << ans <<endl;
 return 0;
}

Measured memory_bytes: 7988
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) {
        cin >> b[i];
    }
    vector<int> a(n, 0);
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for (int i = 1; i < n - 1; i++) {
        a[i] = min(b[i - 1], b[i]);
    }
    LL ans = 0;
    rep(i, n) {
        ans += a[i];
        // debug(a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='2'){
            ans++;
        }
    }

    cout<<ans<<endl;



return 0;
}

Measured memory_bytes: 256
try:
    age,money=map(int, input().split())
    assert 0<=age<=100 and 2<=money<=1000 and money%2==0
    if age<=5:
        print('0')
    elif 6<=age<=12:
        print(money//2)
    else:
        print(money)
except AssertionError:
    print('')



Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;


int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	ll a[n];
	ll absMini = (int)1e9 + 10, sum = 0;
	int cntNeg = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += abs(a[i]);
		if(a[i] < 0){
			cntNeg++;
		}

		if((abs(a[i])) < absMini){
			absMini = abs(a[i]);
		}
	}

	if(cntNeg % 2 == 0){
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * absMini << endl;
	}

}	

Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,int> pint;
typedef pair<int,lint> pl;
typedef pair<lint,pair<int,int> > tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int dp[100100];
lint we[100100];
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
vector<tint> ed;
int main()
{
	int n,m,a,b;lint x;
	cin>>n>>m;
	unionf uni(n+10);
	rep(i,n){
		cin>>we[i];
	}
	memset(dp,0,sizeof(dp));
	rep(i,m){
		cin>>a>>b>>x;a--;b--;
		ed.pb(mp(x,mp(a,b)));
	}
	sort(All(ed));
	int out=0;
	rep(i,m){
		x=ed[i].fi;a=ed[i].se.se;b=ed[i].se.fi;
		int y=uni.root(a),z=uni.root(b);
		//cout<<y<<' '<<z<<endl;
		if(y==z){
			if(we[y]<x) out++,dp[y]++;
		}
		else{
			uni.unions(a,b);
			int w=uni.root(a);
			we[w]=we[y]+we[z];
			dp[w]=dp[y]+dp[z];
			if(we[w]<x) out++,dp[w]++;
			else{
				out-=dp[w];dp[w]=0;
			}
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3956
def solve():
  ans = 0
  S = input()
  N = len(S)
  ans = [1]*N
  for i in range(N-1):
    if S[i]=='R':
      if S[i+1]=='R':
        ans[i+2] += ans[i]
        ans[i] = 0
  for i in range(N-1,0,-1):
    if S[i]=='L':
      if S[i-1]=='L':
        ans[i-2] += ans[i]
        ans[i] = 0
  return ans
print(*solve())

Measured memory_bytes: 10400
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 998244353;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;
using mint = static_modint<mod>;
vector<mint> sum(200005);
vector<mint> pw(200005);

struct S {
    int len;
    mint x;
};
S op (S a, S b) {
    return S{a.len+b.len, a.x*pw[b.len]+b.x};
}
S e() {
    return S{0, 0};
}
using F = int;
S mapping(F f, S s) {
    if (f==0) return s;
    return S{s.len, (sum[s.len])*f};
}
F composition(F a, F b) {
    if (a==0) return b;
    return a;
}
F id() {
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;
    vector<S> x(n);
    pw[0] = 1;
    rep(i, n) {
        sum[i+1] = sum[i]*10 + 1;
        pw[i+1] = pw[i] * 10;
        //debug(sum[i+1].val());
    }
    
    rep(i, n) {
        x[i] = S{1, 1};
        //debug(x[i].v.val());
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> g(x);
    //debug(g.prod(0, n).keta);
    rep(qi, q) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        g.apply(l, r, d);
        auto ans = g.prod(0, n);
        //debug(g.get(0).x.val());
        pr(ans.x.val());
    }
    
    return 0;
}


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

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	int N, S;
	cin >> N >> S;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	vector<mint> q(S + 1); 
	mint ans = 0;
	for (int n = 0;n<N;++n) {
		q[0]= q[0] + 1;
		//F =f*(F + 1)
		for (int l = S;l >= 0;--l) {
			if (a[n] + l <= S) {
				q[a[n] + l] += q[l];
			}
		}
		ans += q[S];
	}

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

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
	cin >> p[i];
    }
    if(n == 0){
	cout << x << endl;
	return 0;
    }
    int min = 0;
    int dist = x;
    for(int i = 1; i <= 101; i++){
	bool can = true;
	for(int j = 0; j < n; j++){
	    if(i == p[j]){
		can = false;
		break;
	    }
	}
	if(!can){
	    continue;
	}
	if(dist > abs(x - i)){
	    min = i;
	    dist = abs(x - i);
	}
    }
    cout << min << endl;
    return 0;
}


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

using namespace std;

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

	int n, k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin>>h[i];

	vector<int>dp(n, INT_MAX);
	dp[n-1] = 0;

	for(int i = n - 2; i >= 0; i--) {
		for(int j = 1; j <= k; j++) {
			if(i + j >= n) break;
			dp[i] = min(dp[i], dp[i+j] + abs(h[i] - h[i+j]));
		}
	}

	cout<<dp[0];
}

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


int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> tab(h,vector<char>(w));
  vector<vector<int>> ans(h,vector<int>(w+1));

  rep(i,h) {
    rep(j,w) cin >> tab[i][j];
  }

  int cnt = 0;
  rep(i,h) {
    bool ok = false;
    rep(j,w) {
      if(tab[i][j]=='#') {
        cnt++;
        ok = true;
      }
      ans[i][j] = cnt;
      if(!ok) ans[i][j]++;//まだ#が出ていない
    }
    ans[i][w] = cnt;
    //行に#を含まない時
    if(i!=0&&!ok) { 
      rep(j,w) ans[i][j] = ans[i-1][j];
    }
  }
  for(int i = h-2; i >= 0; i--) {
    if(ans[i][w]==0) rep(j,w) ans[i][j] = ans[i+1][j];
  }

  rep(i,h) {
    rep(j,w) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 4088
import java.io.*;
import java.util.*;
public class Main {
	static int[] d , c;
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int h=sc.nextInt(),n=sc.nextInt();
		d=new int[n];
		c=new int[n];
		for(int i=0;i<n;i++) {
			d[i]=sc.nextInt();
			c[i]=sc.nextInt();
			
		}
		int[]costs=new int[h+1];
		Arrays.fill(costs, 1000000000);
		for(int i=0;i<=h;i++) {
			for(int j=0;j<n;j++) {
				
				costs[i]=Math.min(costs[i], c[j]*((i+d[j]-1)/d[j]));
				
				
			}
		}
		int []memo=new int[h+1];
		Arrays.fill(memo, 1000000000);
		memo[0]=0;
		for(int he=1;he<=h;he++) {
			for(int j=1;j<=h;j++) {
				if(he-j<=0) {
					memo[he]=Math.min(memo[he], costs[j]);
				}
				else {
					memo[he]=Math.min(memo[he], costs[j]+memo[he-j]);
				}
			}
		}
		pw.println(memo[h]);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

int main(void) {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> length;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i-1]) {
            length.push_back(A[i]);
            i++;
        }
        if (length.size() == 2) break;
    }
    if (length.size() == 2) cout << length[0]*length[1] << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, m;
	cin >> n >> m;
	
	vii key(m);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		
		int msk = 0;
		for(int i = 0; i < b; i++) {
			int c;
			cin >> c;
			c--;
			
			msk |= (1 << c);
		}
		
		key[i] = {a, msk};
	}
	
	vi dp((1 << n), inf);
	dp[0] = 0;
	for(int msk = 0; msk < (1 << n); msk++) {
		for(int i = 0; i < m; i++) {
			if(dp[msk] == inf) continue;
			int nmsk = msk | key[i].ss;
			
			dp[nmsk] = min(dp[nmsk], dp[msk] + key[i].ff);
		}
	}
	
	cout << (dp[(1 << n) - 1] == inf ? -1 : dp[(1 << n) - 1]) << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

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

int F[10005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, t;
    cin >> n;
    int p = sqrt(10005);
    for (int i = 1; i < p; i++)
        for (int j = 1; j < p; j++)
            for (int k = 1; k < p; k++)
            {
                t = i * i + j * j + k * k + i * j + j * k + k * i;
                if (t < 10001)
                    F[t]++;
            }
    for (int i = 1; i <= n; i++)
        cout << F[i] << '\n';
}

Measured memory_bytes: 3580
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  let arr = [1, 4, 7, 9];
  let n = line
    .split(/\s/)
    .map(x => parseInt(x))
    .sort((a, b) => a - b);

  let ans = true;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] != n[i]) {
      ans = false;
      break;
    }
  }
  if (ans) console.log("YES");
  else console.log("NO");
});


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  string res;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'B') {
      if (res.size() > 0) res.pop_back();
    }
    else {
      res.push_back(s[i]);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
int main(){
    string S;
    int N;
    cin >> N >> S;
    rep(i,S.size()){
        if(S[i]+N <= (int)'Z')
        cout << char(S[i]+N);
        else cout << char(S[i]+N-26);
    }
    return 0;
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  ll N,K;
  cin >> N >> K;
  vector<double> p(N);
  rep(i,N){
    cin >> p[i];
  }
  vector<double> E(N);//各々のサイコロの期待値の列
  rep(i,N){
    E[i] = (p[i]+1)/2;
  }
  //列EのK個の区間和のうち、MAXを求める
  vector<double> sum(N+1);//Eの累積和 sum[i] = E[0]~E[i]の和
  sum[0] = E[0];
  rep(i,N-1){
    sum[i+1] = sum[i] + E[i+1];
  }
  
  double ans = sum[K-1];//E[0]~E[K-1]のK個の和
  for(int i = 0;i<=N-K-1;i++){
    ans = max(sum[K+i] - sum[i],ans);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
 }

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
void printvec(const vector<int> &v){
  REP(i,v.size()-1) cout << v[i] <<" ";
  cout << v.back() << endl;
}
void insertion_sort(vector<int> &v,int id){
  int val = v[id];
  int j = id;
  RREP(i,id){
    if(v[i]>val){
      v[i+1] = v[i];
      j = i;
    }else break;
  }
  v[j] = val;
  printvec(v);
}
signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  REP(i,n){
    insertion_sort(a,i);
  }

}



Measured memory_bytes: 3088
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int k = scan!int;
    string s = scan;

    if(s.length > k) print(s[0 .. k] ~ "...");
    else print(s);
}



Measured memory_bytes: 3268
str=input()
str=list(str)
N=int(input())
for i in range(N):
    A=list(input().split())
    A[1],A[2]=[int(A[1]),int(A[2])]
    
    if A[0]=="print":
        tmp=[]
        for j in range(A[1],A[2]+1):
            tmp+=str[j]
        print("".join(tmp))
        
    elif A[0]=="reverse":
        tmp=[]
        for j in range(0,A[2]-A[1]+1):
            tmp+=str[A[2]-j]
        for j in range(0,A[2]-A[1]+1):
            str[A[1]+j]=tmp[j]
    elif A[0]=="replace":
        rep=list(A[3])
        for j in range(0,A[2]-A[1]+1):
            str[A[1]+j]=rep[j]


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll k;
	cin>>k;
	unordered_map<ll,ll> m;
	ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout<<a[k-1]<<"\n";	
	
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigDecimal A = new BigDecimal(sc.next());
    BigDecimal B = new BigDecimal(sc.next());
    System.out.println(A.multiply(B).setScale(0, RoundingMode.DOWN));
  }
}


Measured memory_bytes: 27132
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <cmath>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	constexpr sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	constexpr int M = sqrt(1000000000);
	constexpr sieve<M> s;
	int n {in};
	vector<pair<int, int>> a;
	for (int i {}, t {n}; t != 1; i++)
		if (s.v[i] * s.v[i] < t)
			while (t % s.v[i] == 0) {
				t /= s.v[i];
				if (a.size() && a.back().first == s.v[i])
					a.back().second++;
				else
					a.push_back({s.v[i], 1});
			}
		else {
			a.push_back({t, 1});
			break;
		}
	for (auto i: a)
		n -= n / i.first;
	outl(n);
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
using namespace std;
int ans=-1005, a[1005], a1[1005], vis[1005], b1[1005], c1[1005], d1[1005], m, n, q;
int check(){
	int v=0;
	for(int i=1; i<=q; i++){
		if(a[b1[i]]-a[a1[i]]==c1[i]) v+=d1[i];
	}
	return v;
}
void dfs(int k, int x){
	if(k>m){
		ans=max(check(), ans);
		return; 
	}
	for(int i=x; i<=n; i++){
		//if(vis[i]==0){
			a[k]=i;
			//vis[i]=1;
			dfs(k+1, i);
			//vis[i]=0;
		//}
	}
}
int main(){
	cin>> m>> n>> q;
	for(int i=1; i<=q; i++)
		cin>> a1[i]>> b1[i]>> c1[i]>> d1[i];
	dfs(1, 1);
	cout<< ans;
	return 0;
}

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

using ll = long long;

struct node {
    node() : next(2) {}
    vector<unique_ptr<node>> next;
};

void insert(node* p, int i, string const& s) {
    if(i == (int)s.size()) return;
    const int idx = s[i] - '0';
    if(!p->next[idx]) p->next[idx] = make_unique<node>();
    insert(p->next[idx].get(), i + 1, s);
}

int main() {
    ll n, l; cin >> n >> l;
    auto root = make_unique<node>();
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        insert(root.get(), 0, s);
    }

    function<ll(node*, int)> dfs = [&] (node* p, int depth) {
        if(!p->next[0] && !p->next[1]) return 0LL;
        if(p->next[0] && p->next[1]) {
            return dfs(p->next[0].get(), depth + 1) ^ dfs(p->next[1].get(), depth + 1);
        }
        if(p->next[1]) swap(p->next[0], p->next[1]);
        ll cnt = 0, dist = l - depth;
        while(dist % 2 == 0) {
            cnt += 1;
            dist >>= 1;
        }
        return dfs(p->next[0].get(), depth + 1) ^ (1LL << cnt);
    };

    cout << (dfs(root.get(), 0) ? "Alice" : "Bob") << endl;
}

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

int main(){
  int N, L; cin >> N >> L;
  string S[110];
  for(int i = 0; i < N ; i++) cin >> S[i];
  
  sort(S, S + N);
  string ans;
  for(int i = 0; i < N; i++){
    ans += S[i]; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256