akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;
#define MOD 1000000007

long powMod(long x, long n, long mod){
	if (n == 0) return 1;
	else if (n == 1) return (x % mod);
	else if (n % 2 == 0){
		long t = powMod(x, n/2, mod);
		return (t*t) % mod;
	}
	else{
		return (x*powMod(x, n-1, mod)) % mod;
	}
}

long divMod(long a, long b, long mod){
	long t = powMod(b, mod-2, mod);
	return (a*t) % mod;
}

long r1, r2, c1, c2;
long sr1_c, sr2_c, ans;

int main(){
    cin >> r1 >> c1 >> r2 >> c2;
    sr1_c = r1;
    sr2_c = r2 + 1;
    ans = 0;
    for (int c = 0; c < c2; ++c){
        sr1_c = divMod((sr1_c*(r1 + c + 1)) % MOD, c + 2, MOD);
        sr2_c = divMod((sr2_c*(r2 + c + 2)) % MOD, c + 2, MOD);
        if (c >= c1 - 1){
            ans = (ans + sr2_c) % MOD;
            ans = (ans - sr1_c + MOD) % MOD;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
from heapq import*
n,_,*t=map(int,open(0).read().split())
e=[[]for _ in'_'*n]
for l,r,c in zip(*[iter(t)]*3):e[l-1]+=(c,r-1),
for i in range(n-1):e[i+1]+=(0,i),
d=[0]+[1e18]*n
q=[(0,0)]
while q:
  c,v=heappop(q)
  for b,w in e[v]:
    if b+c<d[w]:
      d[w]=b+c
      heappush(q,(b+c,w))
print(-(d[-2]>1e17)or d[-2])

Measured memory_bytes: 116836
#include <iostream>
#include <complex>
#include <utility>
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,double> C;
int solve(C a, C b){
  if(abs(a.first-b.first) > a.second+b.second) return 4;
  if(abs(a.first-b.first) == a.second+b.second) return 3;
  if(abs(a.first-b.first) > abs(a.second-b.second)) return 2;
  if(abs(a.first-b.first) == abs(a.second-b.second)) return 1;
  return 0;
}

int main(){
  C c1, c2;
  double x, y, r;
  cin >> x >> y >> r;
  c1 = C(P(x,y),r);
  cin >> x >> y >> r;
  c2 = C(P(x,y),r);
  cout << solve(c1,c2) << endl;
}

Measured memory_bytes: 3264
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Colorful Slimes 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int as[MAX_N];
int dp0[MAX_N], dp1[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", &as[i]);

  dp0[0] = 0; dp1[0] = 1;
  for (int i = 1; i < n; i++) {
    if (as[i - 1] == as[i])
      dp0[i] = dp1[i - 1];
    else
      dp0[i] = min(dp0[i - 1], dp1[i - 1]);
    dp1[i] = min(dp0[i - 1], dp1[i - 1]) + 1;
  }

  printf("%d\n", min(dp0[n - 1], dp1[n - 1]));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

void solve()
{
    ll X,A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 256
n = int(input())
ans = float('inf')
for i in range(1, n):
    a = i
    b = n-i
    m = len(str(a))
    l = len(str(b))
    cnt = 0
    for j in range(m):
        cnt += int(str(a)[j])
    for j in range(l):
        cnt += int(str(b)[j])
    ans = min(ans, cnt)

print(ans)



Measured memory_bytes: 9052
using System;
using System.Linq;

namespace abc098b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var maxCount = 0;
            for (var i = 1; i < n; ++i)
            {
                var s1 = s.Take(i);
                var s2 = s.Substring(i, n - i);
                var count = 0;
                for(var c = 'a'; c <= 'z'; ++c)
                {
                    if (s1.Contains(c) && s2.Contains(c)) ++count;
                }
                if (count > maxCount) maxCount = count;
            }
            Console.WriteLine(maxCount);
        }
    }
}


Measured memory_bytes: 13268
#python3
def main():
    n = int(input())
    h = [int(i) for i in input().split()]
    ans = 0
    cnt = 0
    for i in range(n-1):
        if h[i]>=h[i+1]:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)
main()



Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        boolean fl = true;

        if (n == 0) {
            System.out.println(x);
            return;
        }

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        for (int i = 0; i < 300; i++) {
            fl = true;

            for (int j = 0; j < n; j++) {
                if (p[j] == x - i) {
                    fl = false;
                }
            }
            if (fl) {
                System.out.println(x - i);
                return;
            }

            fl = true;
            for (int j = 0; j < n; j++) {
                if (p[j] == x + i) {
                    fl = false;
                }
            }
            if (fl) {
                System.out.println(x + i);
                return;
            }

        }

        sc.close();
    }

}

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

using namespace std;

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

	int sx, sy, tx, ty, Dx, Dy;
	cin >> sx;
	cin >> sy;
	cin >> tx;
	cin >> ty;

	Dx = tx - sx;
	Dy = ty - sy;

	// first
	for(int i = 0; i < Dy; i++)
		cout << "U";
	for(int i = 0; i < Dx; i++)
		cout << "R";

	// second
	for(int i = 0; i < Dy; i++)
		cout << "D";
	for(int i = 0; i < Dx; i++)
		cout << "L";

	// third
	cout << "L";
	for(int i = 0; i < Dy + 1; i++)cout << "U";
	for(int i = 0; i < Dx + 1; i ++)
		cout << "R";
	cout << "D";

	// forth
	cout << "R";
	for(int i = 0; i < Dy + 1; i++)
		cout << "D";
	for(int i = 0; i < Dx + 1; i++)
		cout << "L";
	cout << "U";

	return 0;
}

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

int main() {
  int A,B;
  cin >> A>> B;
  int D = B-A;
  int ans =0;
  
  if(!(D ==0)){
  for(int i=0;i<D+1;i++){
    int E =A%10;
    int F =(A/10)%10;
    int G =(A/1000)%10;
    int H =(A/10000);

    if((E==H)&&(F==G)){
      ans++;
    }

    A++;
  }
  }
  else{
    if(((A%10)==(A/10000)) &&(((A/10)%10)==((A/1000)%10))){
      ans++;
    }
  }
  cout << ans <<endl;
}


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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const ll M = 998244353;
const string END = "\n";

ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n, a[100001];
	cin >> n;
	ll cnt = 0, sum = 0, m = INF;
	rep(i, n){
		cin >> a[i];
		if(a[i] < 0){
			cnt++;
			sum += -a[i];
			m = min(m, -a[i]);
		}else{
			sum += a[i];
			m = min(m, a[i]);
		}
	}
	ll ans = 0;
	if(cnt % 2 == 0){
		ans = sum;
	}else{
		ans = sum - m * 2;
	}

	cout << ans << END;

	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int Maxn=100003;
int N,M,x,y,cnt,ans,f1,f2;
int p[Maxn],f[Maxn];
int getf(int u){
	if(f[u]==u)return u;
	return f[u]=getf(f[u]);
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;++i){
		scanf("%d",&p[i]);
		f[i]=i;
	}
	for(int i=1;i<=M;++i){
		scanf("%d%d",&x,&y);
		f1=getf(x);f2=getf(y);
		if(f1!=f2)f[f1]=f2;
	}
	for(int i=1;i<=N;++i)
		if(getf(i)==getf(p[i]))++ans;
	printf("%d",ans);
}

Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var b = sc.next();
        var dic = new Dictionary<String, String>();
        dic.Add("A", "T");
        dic.Add("T", "A");
        dic.Add("C", "G");
        dic.Add("G", "C");
        WriteLine(dic[b]);
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int tree = scan.nextInt();
		int kazari = scan.nextInt();
		long[] height = new long[tree];

		for(int i=0;i<tree;i++) {
			height[i] = scan.nextLong();
		}
		Arrays.sort(height);

		long min = Long.MAX_VALUE;

		for(int i=0;i<tree-kazari+1;i++) {
			min = Math.min(min,height[i+kazari-1]-height[i]);
		}
		System.out.println(min);
		scan.close();

	}

}


Measured memory_bytes: 50800
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int K;
  int X;
  cin >> K >>X;
  int y=500*K;
  if (y >=X) {
    cout << "Yes"<< endl;
  }
  else {
cout << "No" << endl;
  }
}
 

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>

using namespace std;

const double PI = 3.14159265358979;


int matrix_chain_multi(int p[], int len) {	// 1 2 3 num

	int m[101][101]{};
	const int num = len - 1;
	for (int L = 2; L <= num; L++) {
		
		for (int i = 1; i <= num - L + 1; i++) {
			int j = i + L - 1;
			int minx = INT_MAX;
			for (int k = i; k < j; k++)	{
				minx = min(minx, m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
			m[i][j] = minx;
		}
	}

	return m[1][len - 1];
}

int main() {

	int n; cin >> n;
	n = n + 1;

	int* p = new int[n];		// p[i-1] hang		p[i] lie
	int hang, lie, temp;
	cin >> p[0];
	for (int i = 1; i < n; i++) {
		cin >> p[i];
		if (i != n - 1)
			cin >> temp;
	}
	cout << matrix_chain_multi(p, n) << endl;


	return 0;
}



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

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

    c=0;
  for(int i=0;i<a;i++){
    cin>>A[i];
  }

  for(int i=0;i<a;i++){
    for(int u=0;u<100;u++){
	if(A[i]>0){
      c++;
  for(int j=i;j<a;j++){
    if(A[j]>0){
      A[j]-=1;
    }
    else{
     break;
      
    }
  }
    }
       
  }
  }
    cout<<c<<endl;

  
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] lo = reader.readLine().split(" ");
		int a= Integer.parseInt(lo[0]);
		int b= Integer.parseInt(lo[1]);
		int c= Integer.parseInt(lo[2]);	
		int k = Integer.parseInt(reader.readLine());
		while(b<=a && k>0){
			b=b*2;
			k--;
		}
		while(c<=b && k>0){
			c=c*2;
			k--;
		}
		while(k>0){
			c=c*2;
			k--;
		}
		if(c>b && b>a) System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 32532
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace ID
{

    class City
    {
        public int Order;
        public long Id;
        public City(int o, long i)
        {
            Order = o;
            Id = i;
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var nm = GetArrayIntInput();
                List<City>[] Prefectures = new List<City>[nm[0] + 1];
                for (int i = 1; i <= nm[0]; i++) { Prefectures[i] = new List<City>(); }
                for (int i = 1; i <= nm[1]; i++)
                {
                    var py = GetArrayIntInput();
                    Prefectures[py[0]].Add(new City(i, py[1]));
                }

                var results = new List<City>();
                for (int i = 1; i <= nm[0]; i++)
                {
                    Prefectures[i] = Prefectures[i].OrderBy(p => p.Id).ToList();
                    for (int j = 0; j < Prefectures[i].Count; j++)
                    {
                        Prefectures[i][j].Id = (long)i * 1000000 + j + 1;
                        results.Add(Prefectures[i][j]);
                    }
                }

                foreach (var id in results.OrderBy(r => r.Order).Select(r => r.Id))
                {
                   CWrite(Convert.ToString(id, 10).PadLeft(12, '0'));
                }
            }
        }

        static string[] GetArrayCharInput() => Console.ReadLine().Split();
        static int[] GetArrayIntInput() => Console.ReadLine().StringToIntArray();
        static int GetIntInput() => Console.ReadLine().ToInt();
        static void CWrite(string str) => Console.WriteLine(str);
    }
    

    class SetConsole : IDisposable
    {
        public SetConsole()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
        }
    }

    static class ExtentionsLibrary
    {
        public static int[] StringToIntArray(this string str) =>
            str.Split().Select(int.Parse).ToArray();
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 43348
#include <iostream>
using namespace std;
int main(void){
  string S,T;
  cin >> S;
  cin >> T;
  int M = (int)(S.length());
  int N = (int)(T.length());
  int min = N;
  for(int i=0;i<M-N+1;i++){
      int now = 0;
      for(int j=0;j<N;j++){
          if(S[i+j]!=T[j]){
              now++;
          }
      }
      if(now<min){
          min = now;
      }
  }
  cout << min << endl;
}



Measured memory_bytes: 3592
i=input()
N=len(i)
k=0
for j in range (0,N):
    if i[j]!=i[N-1-j]:
        k+=1
for l in range (0,(N-1)//2):
    if i[l]!=i[(N-3)//2-l]:
        k+=1
for m in range (0,(N-1)//2):
    if i[m+(N+1)//2]!=i[N-1-m]:
        k+=1
if k==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

cnt = int(input())

for i in range(cnt):
    t, x, y = map(int, input().split())
    # 条件1：そもそも届かない
    if t < x + y:
        print("No")
        exit()
    # 条件2：奇数偶数が違うのでぴったり止まれない
    elif t % 2 != (x + y) % 2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define N 100005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef long long int ll;
typedef long int li;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin>>s;
    if(s == "Sunny") cout<<"Cloudy";
    else if(s == "Cloudy") cout<<"Rainy";
    else cout<<"Sunny";
    return 0;
}

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

int main(){
  int N, D, ans=0;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  rep(i, N){
    rep(j, D){
      cin >> X[i][j];
    }
  }

  // ここからソルバー
  // とりあえず全ての組み合わせを試していく
  rep(i, N){
    repi(j, i+1, N){
      int length = 0;
      // 各要素ごとに二乗誤差を測る
      rep(k, D){
        int diff = abs(X[i][k] - X[j][k]);
        length += diff * diff;
      }
      // 平方数になっているかの判断
      // lengthが1のときに備えて範囲は0からlength+1まで
      bool flag = false;
      rep(l, length+1){
        // もし平方数であればflagをtrueに
        if (l*l==length){
          flag = true;
          break;
        }
      }
    // 平方数であればansをインクリメント
    if (flag) ans++;
    }
  }
  // 出力
  cout << ans << endl;
}

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

typedef long long int ll;

ll n;
ll val[25];
ll cost[25];

int main()
{
    cin>>n;

    for(ll i=0;i<n;i++){
        cin>>val[i];
    }
    for(ll i=0;i<n;i++)
        cin>>cost[i];

    ll ans = 0;

    for(ll i=0;i<n;i++){
        if(val[i]>=cost[i]){
            ans+=val[i]-cost[i];
        }
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;
int L1, L2;
string s, t;
pair<int, char> dp[3009][3009];
pair<int, int> par[3009][3009];
vector<char> ans;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	L1 = s.length(); L2 = t.length();
	s = "0" + s; t = "1" + t;
	for (int i = 1; i <= L1; i++) {
		for (int j = 1; j <= L2; j++) {
			if (s[i] == t[j]) {
				dp[i][j].fi = dp[i - 1][j - 1].fi + 1;
				dp[i][j].se = s[i];
				par[i][j] = make_pair(i - 1, j - 1);
			}
			else {
				if (dp[i - 1][j].fi > dp[i][j - 1].fi) {
					dp[i][j].fi = dp[i - 1][j].fi;
					dp[i][j].se = '0';
					par[i][j] = make_pair(i - 1, j);
				}
				else {
					dp[i][j].fi = dp[i][j - 1].fi;
					dp[i][j].se = '0';
					par[i][j] = make_pair(i, j - 1);
				}
			}
		}
	}
	int a = L1, b = L2;
	while (a && b) {
		if (dp[a][b].se != '0') {
			ans.push_back(dp[a][b].se);
		}
		pair<int, int> tmp = par[a][b];
		a = tmp.fi; b = tmp.se;
	}
	for (auto i = ans.rbegin(); i != ans.rend(); i++) cout << *i;
	cout << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 141568
#include <stdio.h>
int main()
{
  long long i,a,b,max,min,a2,b2;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    if(a<b){
      i=a;
      a=b;
      b=i;
    }
    a2=a;
    b2=b;
    while(1){
      if(b2==0){
	max=a2;
	break;
      } else{
	i=a2%b2;
	a2=b2;
	b2=i;
      }
    }
    min=(a/max)*(b/max)*max;
    printf("%lld %lld\n",max,min);
  }
  return 0;
}

Measured memory_bytes: 1024
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto nk = readln.split.to!( int[] );
	auto as = readln.split.to!( int[] );
	writeln( solve( nk[ 1 ], as ) );
}

auto solve( in int k, in int[] as )
{
	auto as_r = as.length - k;
	auto k_r = k - 1;
	auto c = 1 + as_r / k_r;
	auto re = ( as_r % k_r == 0 ) ? 0 : 1;

	return c + re;
}

unittest
{
	assert( solve( 3, [ 2, 3, 1, 4 ] ) == 2 );
	assert( solve( 3, [ 1, 2, 3 ] ) == 1 );
	assert( solve( 3, [ 7, 3, 1, 8, 4, 6, 2, 5 ] ) == 4 );

	assert( solve( 3, [ 7, 3, 6, 8, 4, 1, 2, 5 ] ) == 4 );
	assert( solve( 3, [ 7, 3, 6, 1, 4, 8, 2, 5 ] ) == 4 );
	assert( solve( 3, [ 7, 3, 6, 4, 1, 8, 2, 5 ] ) == 4 );

	assert( solve( 3, [ 7, 3, 8, 1, 4, 6, 2, 5, 9 ] ) == 4 );
	assert( solve( 3, [ 7, 3, 8, 4, 6, 1, 2, 5, 9 ] ) == 4 );
	assert( solve( 3, [ 7, 3, 8, 4, 1, 6, 2, 5, 9 ] ) == 4 );
}


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

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int st=h1*60+m1;
  int fi=h2*60+m2;
  int t=fi-st;
  cout << t-k << endl;
  return 0;
}


Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(10**6)
N = int(input())
Alist = list(map(int, input().split()))
memo = [{} for i in range(N)]

def ddp(cur_N, ai):
    if ai in memo[cur_N]:
        return memo[cur_N][ai]
    if cur_N >=N-1:
        return ai
    aj = Alist[cur_N+1]
    ret = max(ai + ddp(cur_N+1, aj), -1*ai + ddp(cur_N+1, -1*aj))
    memo[cur_N][ai] = ret
    return ret
print(ddp(0, Alist[0]))

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

#define ll long long

#define ull unsigned long long

#define pii pair<int, int>

#define pll pair<ll int, ll int>

#define vi vector<int>

#define vl vector<ll int>

#define ff first

#define ss second

#define pb push_back

#define eb emplace_back

#define debug(n) cout << "DEBUG1 " << n << "\n";

#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";

#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";

#define debug4(n, m, x, y) cout << "DEBUG4 " << n << ' ' << m << ' ' << x << ' ' << y << "\n";

#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)

#define upzero(n) if (n < 0) n = 0

#define alive(n) cout << "Alive here: checkpoint " << n << endl

#pragma GCC optimize("Ofast")

using namespace std;

void yes() {

    cout << "YES\n";

    return;

}

void no() {

    cout << "NO\n";

    return;

}

void out(ll int n) {

    cout << n << endl;

    return;

}

const int mxN = 1e5 + 1;

vi adj[mxN];

bool ck[mxN];

void init() {

    // initialize

    

}

void solve(int case_no) {

    // implementation

    int n,m;

    cin>>n>>m;

    for (int i=0;i<m;i++) {

        int u,v;

        cin>>u>>v;

        adj[u].pb(v);

        adj[v].pb(u);

    }

    int cnt = -1;

    queue<int> q;

    for (int i=1;i<=n;i++) {

        if (!ck[i]){

            q.push(i);

            cnt++;

            while (!q.empty()) {

                int u=q.front();

                q.pop();

                ck[u]=true;

                for (int v : adj[u]) {

                    if (!ck[v]) q.push(v);

                }

            }

        }

    }

    cout<<cnt;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    srand(time(NULL));

    init();

    int t = 1;

//    cin >> t;

    for (int i = 1;i <= t;i++) solve(i);

}

/*

abaaba

*/

Measured memory_bytes: 9012
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		String s=fs.next();
		if(s.charAt(s.length()-1)=='s')
		{
			System.out.println(s+"es");
		}
		else
			System.out.println(s+"s");
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 36596
n = int(input())
vote = {}
v_max = 0
for i in range(n):
    s = input()
    if s not in vote:
        vote[s] = 1
    else:
        vote[s] += 1
    
    if(v_max<vote[s]): v_max = vote[s]

res = []
for k in vote:
    if vote[k]==v_max: res.append(k)

for s in sorted(res):
    print(s)

Measured memory_bytes: 32988
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0) break;
    map<int, int> mp;
    rep(i, n) {
      int d, v;
      cin >> d >> v;
      if (mp[d] < v) mp[d] = v;
    }
    int ans = 0;
    for (auto x : mp) {
      ans += x.second;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n; cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m; cin >> m;
    vector<string> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (a[i] == a[j]) {
                cnt++;
            }
        }
        for (int j = 0; j < m; ++j) {
            if (a[i] == b[j]) {
                cnt--;
            }
        }
        ans = ans < cnt ? cnt : ans;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;


struct SegmentTreemin{
private:
    int n;
    vector<int> node;

public:
    SegmentTreemin(vector<int> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1,INF);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = min(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val){
        x += n-1;
        node[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1){
        if (r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = getmin(a, b, 2*k+1, l , (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2,r);
        return min(vl, vr);
    }
};


struct SegmentTreemax{
private:
    int n;
    vector<int> node;

public:
    SegmentTreemax(vector<int> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1,-INF);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = max(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val){
        x += n-1;
        node[x] = val;
        while(x > 0){
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }

    int getmax(int a, int b, int k=0, int l=0, int r=-1){
        if (r < 0) r = n;
        if(r <= a || b <= l) return -INF;
        if(a <= l && r <= b) return node[k];
        int vl = getmax(a, b, 2*k+1, l , (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2,r);
        return max(vl, vr);
    }
};


int main(){
    int n,k;cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    SegmentTreemin smin(p);
    SegmentTreemax smax(p);
    int ans = 0;
    set<int> st;
    for (int i = 0; i < k; i++) {
        st.insert(p[i]);
    }
    vector<int> cum(n+1,0);
    for (int i = 0; i < n-1; i++) {
        cum[i+1] = cum[i] + (p[i] < p[i+1]);
    }
    vector<bool> f(n,true);
    bool c = false;
    for (int i = 0; i <= n-k; i++) {
        if(cum[i+k-1] - cum[i] == k - 1){
            f[i] = false;
            c = true;
        }
    }
    if(c) ans = 1;
    if(f[0]) ans++;
    for (int i = 1; i <= n-k; i++) {
        ans += f[i] & (!((p[i-1] == smin.getmin(i-1,i-1+k)) && (p[i-1+k] == smax.getmax(i,i+k))));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15344
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  char f[100]={};
  for(int i=0;i<n;i++){
    cout<<s[i]<<t[i];

  }
 
}

Measured memory_bytes: 256
main :: IO ()
main = do
  getLine
  ps <- map read <$> words <$> getLine :: IO [Int]
  print $ sum $ solve ps

solve :: [Int] -> [Int]
solve [] = []
solve [a] = []
solve [a,b] = []
solve (a:b:c:as) = case (compare a b, compare b c) of
                     (LT,LT) -> 1 : solve (b:c:as)
                     (GT,GT) -> 1 : solve (b:c:as)
                     (LT,EQ) -> 1 : solve (b:c:as)
                     (EQ,GT) -> 1 : solve (b:c:as)
                     _ -> 0 : solve (b:c:as)


Measured memory_bytes: 508
// 素因数分解

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

int main(void){
  ll N;
  cin >> N;

  // 素因数とその肩に乗ってる指数のペア
  vector<pair<ll,int>> fs;
  for (ll i = 2; i*i <= N; i++){
    int x = 0;
    while (N%i == 0){
      N /= i;
      x++;
    }
    fs.emplace_back(i,x);
  }
  if (N != 1) fs.emplace_back(N,1);

  int ans = 0;
  for (auto p : fs){
    int x = p.second;
    int b = 1;
    while (b <= x){
      x -= b;
      b++;
      ans ++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19712
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    d=a+b+c;
    if(d>=22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int F(int x){
    int ret=0;
    for(int i=1;i<=x;i++)
        if(x%i==0)
            ret++;
    return ret;
}
int main(){
	//freopen("factor.in","r",stdin);
    //freopen("factor.out","w",stdout);
    int n,tot=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i+=2)
    {
        if(F(i)==8)
            tot++;
    }
    printf("%d\n",tot);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
void find(int n,map<int,int> &mp)
{
    while(n%2==0)
    {
        mp[2]+=1;
        n/=2;
    }
    for(int i=3;i*i<=n;i+=2)
    {
        while(n%i==0)
        {
            mp[i]+=1;
            n/=i;
        }
    }
    if(n>2)
        mp[n]+=1;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
map<int,int> mp;
find(n,mp);
int ans=0;
map<int,int>::iterator it=mp.begin();
for(;it!=mp.end();it++)
{
    int x=it->second;
   /// cout<<x<<endl;
    int cnt=1;
    while(1)
    {
        int r=(cnt*(cnt+1))/2;
        if(r<=x)
            cnt++;
        else
        {
            ans+=cnt-1;
            break;
        }
    }
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
from collections import deque

max_int=int(input().rstrip())

q = deque([1,2,3,4,5,6,7,8,9])

for i in range(max_int):
    int_i = q.popleft()
    i_mod10 = int_i%10 #末尾の数字

    if i_mod10==0:
        q.append(10*int_i+i_mod10)
        q.append(10*int_i+i_mod10+1)
    elif i_mod10==9:
        q.append(10*int_i+i_mod10-1)
        q.append(10*int_i+i_mod10)
    else:
        q.append(10*int_i+i_mod10-1)
        q.append(10*int_i+i_mod10)
        q.append(10*int_i+i_mod10+1)
print(int_i)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int k;
  cin >> k;
  queue<ll> q;
  for(int i = 1; i < 10; i++) {
    q.push(i);
    if (k < 10) {
      cout << k << endl;
      return 0;
    }
  }
  int cnt = 0;
  while(cnt < k) {
    ll x = q.front();
    cnt++;
    if (cnt == k) {
        cout << x << endl;
        return 0;
    }
    q.pop();
    for(int i = -1; i <=1; ++i) {
      int d = x % 10 + i;
      if (d < 0 || d > 9) continue;
      ll nx = x * 10 + d;
      q.push(nx);
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
 
using namespace std;
 
typedef long long ll;
 
ll mod = 1000000007;
 
//nが素数かを判定する関数
bool prime(int n){
  bool x = true;
  for(int i=2;i*i<=n;i++)
    if(n%i==0) x = false;
  return x;
}
 
//a^pを求める関数
ll modpow(ll a,ll p){
  if(p==0) return 1;
  if(p%2==0){
    ll halfP = p/2;
    ll half = modpow(a,halfP);
    return half * half % mod;
  }
  else{
    return a * modpow(a,p - 1) % mod;
  }
}
 
//aCb mod 1000000007を求める
long comb(ll a,ll b){
  if(b>a-b) return comb(a,a-b);
  ll ansMul = 1;
  ll ansDiv = 1;
  for(int i=0;i<b;i++){
    ansMul *= (a-i);
    ansDiv *= (i+1);
    ansMul %= mod;
    ansDiv %= mod;
  }
  ll ans = ansMul * modpow(ansDiv,mod-2) % mod;
  return ans;
}
 
int main(){
  ll N,M;
  cin >> N >> M;
  ll i;
  map<ll,int> mp;
  ll count;
  ll ans = 1;
  for(i=2;i*i<=M;i++){
    if(M%i==0 && prime(i)){
      count = 0;
      while(M%i==0){
        M /= i;
        count++;
      }
      mp[i] += count;
    }
  }
  if(M!=1) mp[M]++;
  for(auto i : mp){
    ans *= comb(i.second + N - 1, i.second);
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
first = max(a)
second = 0
flag = a.count(first) > 1

if a.count(first) > 1:
    for i in a:
        print(first)
else:
    for i in a:
        if i != first and second < i:
            second = i
    for i in a:
        print(first if i != first else second)


Measured memory_bytes: 12532
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    sc.close();
    if (a < 3200) {
      System.out.println("red");
    } else {
      System.out.println(s);
    }
  }
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a;
double huga,ans;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        huga += 1.0/a;
    }
    cout << setprecision(20) << 1.0/huga << endl;
}




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

using namespace std;

int abs(int a) {
    return a >= 0 ? a : -a;
}

int main() {
    int n, z, w;
    cin >> n >> z >> w;

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

    if (n == 1) {
        cout << abs(a[0] - w) << endl;
    } else {
        cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
    }
}


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

using namespace std;

int main()
{
	int n,l;
	cin>>n>>l;
	string s[105];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i;j++){
			if(s[j]>s[j+1]){
				string st=s[j];
				s[j]=s[j+1];
				s[j+1]=st;
			}
		}
	}
	string s2;
	for(int i=1;i<=n;i++){
		s2=s2+s[i];
	}
	cout<<s2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define pb push_back
#define mp make_pair
#define ull unsigned long long int
#define ll long long int
#define ii pair<ll,ll> 
#define vi vector<ll>
#define vii vector<ii>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define eps 1e-10
#define dbs long double

#define INF 1000000000


ll i,j,k,sum=0,ans=1,n;

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


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
	ll W;
	cin>>n>>W;
	vi v(n+1);
	vi w(n+1);
	for(i=1;i<=n;i++)
		cin>>w[i]>>v[i];

	ll k[n+1][W+1];

	for(i=0;i<=n;i++)
	{
		for(j=0;j<=W;j++)
		{
			if(i==0 || j==0)
				k[i][j] = 0;
			
			else if(w[i]<=j)
				k[i][j] = max(v[i]+k[i-1][j-w[i]],k[i-1][j]);
			else
				k[i][j] = k[i-1][j];
		}
	}

	cout<<k[n][W];
}


int main(){
	fastio();
	int t=1;
	//cin>>t;
	 while(t--)
	 	solve();
	return 0;
}

Measured memory_bytes: 79232
#include<iostream>
using namespace std;
int main()
{
 int n,l;
 cin>>n>>l;
 string str[n],temp;
 for(int i=0;i<n;i++)
   cin>>str[i];
  for(int i = 0; i < n-1; ++i)
       for( int j = i+1; j <n; ++j)
       {
          if(str[i] > str[j])
          {
            temp = str[i];
            str[i] = str[j];
            str[j] = temp;
          }
    }
  temp="";
  for(int i=0;i<n;i++)
    temp+=str[i];
  cout<<temp;
  
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

	int n;
	cin>>n;
	vd in(n);
	cin>>in;
	sort(all(in));
	double t=in[0];
	loop(i,1,n)t=(t+in[i])/2;
	cout<<shosu(9)<<t<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	double n;
	vector<double>a;
	int i=0;	
        while(cin>>n){
		a.push_back(n);	             
	}
	double x=a[0];
        double y=a[0];
        for(int i=1;i<a.size();i++){
		x=max(x,a[i]);
		y=min(y,a[i]);
	}
	printf("%.1f\n",x-y);
	return 0;
}

Measured memory_bytes: 1252
n = int(input())
ans = 1000000

for i in range(n+1):
    count = 0
    s = i
    while s > 0:
        count += s % 6
        s //= 6
        
    t = n - i
    while t > 0:
        count += t % 9
        t //= 9
        
    ans = min(ans, count)
    
print(ans)

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

int main(void){
  int n;
  cin >> n;
  if(n < 105){
    cout << 0 << endl;
  }else if(n < 135){
    cout << 1 << endl;
  }else if(n < 165){
    cout << 2 << endl;
  }else if(n < 189){
    cout << 3 << endl;
  }else if(n < 195){
    cout << 4 << endl;
  }else{
    cout << 5 << endl;
  }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([L,R,i])
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][1]+1)-BIT.sum(l[i][0])

for i in range(q):
  print(ans[i])

Measured memory_bytes: 181648
fun main(args: Array<String>) {

    fun pow(n: Int, e: Int): Int {
        return (0 until e).fold(1) { acc, i -> acc * n }
    }

    fun comb(n: Int, k: Int): Int {
        if (k !in (0..n)) return 0
        var r = n
        repeat(k - 1) { r *= n - it - 1 }
        repeat(k - 1) { r /= k - it }
        return r
    }

    val s = readLine()!!
    val k = readLine()!!.toInt()
    val n = s.length

    fun f(i: Int, k: Int, small: Boolean): Int {
        if (i == n) {
            if (k == 0) return 1
            return 0
        }

        if (k == 0) return 1

        if (small) return comb(n - i, k) * pow(9, k)
        
        if (s[i] == '0') return f(i + 1, k, false)

        return f(i + 1, k, true) +
                f(i + 1, k - 1, true) * (s[i] - '1') +
                f(i + 1, k - 1, false)
    }

    println(f(0, k, false))
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll A, B, C, X, Y;
vector<VL> dp;

int main() {
    cin >> A >> B >> C >> X >> Y;
    ll ans1 = A * X + B * Y, ans2 = 2 * C * max(X, Y), ans3 = 2 * C * min(X, Y) + (X > Y ? A * abs(X - Y) : B * abs(X - Y));
    cout << min({ans1, ans2, ans3}) << "\n";
}


Measured memory_bytes: 256