akhauriyash/Code-Regression huggingface dataset:
Scanf.scanf "%d" (fun n ->
    let xy = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x + y, x - y)) in

    let rec loop i mi0 mx0 mi1 mx1 =
        if i = n then max (mx0 - mi0) (mx1 - mi1) else
            let x, y = xy.(i) in
            loop (i + 1) (min mi0 x) (max mx0 x) (min mi1 y) (max mx1 y)
    in
    loop 0 max_int min_int max_int min_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 12544
#include<iostream>
using namespace std;
int f(int n){
	if (n<753)
		return 753-n;
	else
		return n-753;
	}
int main(){
	long int s;
	cin>>s;
	int min;
	min=1000;
	while (s>=100){
		if(min>f(s%1000))
			min=f(s%1000);
		s=s/10;
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        Arrays.sort(A);
        System.out.println(A[N-1] - A[0]);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll modpow(ll a,ll b){
  if(b==0){
    return 1;
  }
  else if(b%2==0){
    ll t=modpow(a,b/2);
    return t*t%MOD2;
  }
  else{
    return a*modpow(a,b-1)%MOD2;
  }
}

int main() {
  ll n;
  cin >> n;
  vl a(n),cnt(n);
  bool b=true;
  rep(i,n){
    cin >> a[i];
    if(a[0]!=0){
      b=false;
    }
    else if(i!=0&&a[i]==0){
      b=false;
    }
    else{
      cnt[a[i]]++;
    }
  }
  rep(i,n-1){
    if(cnt[i]==0&&cnt[i+1]!=0){
      b=false;
    }
  }
  if(!b){
    cout << 0 << endl;
  }
  else{
    ll ans=1;
    ll i=0;
    while(cnt[i]!=0){
      ans=ans*(modpow(cnt[i],cnt[i+1]))%MOD2;
      i++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1792
#include <iostream>

void print(std::string str, int a, int b){
  for(int i=a; i<=b; i++){
    std::cout << str[i] << std::flush;
  }
  std::cout << std::endl;
}

std::string reverse(std::string str, int a, int b){
  std::string tmp_str = str.substr(a, b-a+1);
  for(int i=a; i<=b; i++){
    str[i] = tmp_str[b-i];
  }
  return str;
}

std::string replace(std::string str, int a, int b, std::string p){
  for(int i=a; i<=b; i++){
    str[i] = p[i-a];
  }
  return str;
}

int main(){
  std::string str;
  int q;
  std::string op;
  int a, b;
  std::string p;

  std::cin >> str;
  std::cin >> q;

  for(int i=0; i<q; i++){
    std::cin >> op >> a >> b;
    if(op=="replace") std::cin >> p;

    if(op=="print"){
      print(str, a, b);
    }
    else if(op=="reverse"){
      str = reverse(str, a, b);
    }
    else if(op=="replace"){
        str = replace(str, a, b, p);
    }
  }
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n;

signed main() {
    
   cin >> n;
   n -= 1;
   cout << (n * (n+1))/2; 
    
	return 0;
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}


const int mod = (int)1e9 + 7; 
const int maxn = 1e6 + 55;

li f[maxn], dp[maxn];

li calc(int n, int h, int d) {
    f[0] = 1;
    li mult = 0;
    for (int i = 1; i <= n; ++i) {
        f[i] = f[i - 1] * (li)i % mod;
        mult = (mult + f[i]) % mod;
    }
    dp[0] = f[n];
    li s = dp[0];
    for (int i = 1; i <= h; ++i) {
        dp[i] = s * mult % mod;
        if (i == h)
            dp[i] = s;

        s = (s + dp[i]) % mod;
        if (i - d >= 0)
            s = (s - dp[i - d] + mod) % mod;
    }
    return dp[h];
}

void solve(bool __attribute__((unused)) read) {
    int n, h, d;
    cin >> n >> h >> d;
    cout << calc(n, h, d) << "\n";
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define pb push_back
#define INF 1e11
#define mod 11092019
#define eps 1e-15
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
const ll N=2100;
char c;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin>>c;
	if(c>='A'&&c<='Z')
		cout<<"A";
	else
		cout<<"a";
}


Measured memory_bytes: 3648
def main():
  steps = raw_input()
  easy = True
  for i, c in enumerate(steps):
    if (i+1) % 2 == 0:
      if c not in ['L', 'U', 'D']:
        easy = False
        break
    else:
      if c not in ['R', 'U', 'D']:
        easy = False
        break
  print("Yes" if easy else "No")

main()

Measured memory_bytes: 2568
N,X=map(int,input().split())

def n_pati(l):
  val = 1
  for i in range(l):
    val = val*2+1
  return val

def n_layer(l):
  val = 1
  for i in range(l):
    val = val*2+3
  return val

SUM=0
while 1:
  if N==1:
    if X in [0,1]:break
    elif X>=2:
      SUM += min(3,X-1)
      break
  
  L = n_layer(N)
  if X >= L//2:
    SUM += n_pati(N-1)
    X -= n_layer(N-1)+1
    if X==0:
      break
    SUM += 1
    X -= 1
    if X==0:
      break
    N -= 1
  else:
    X -= 1
    N -= 1
    
  if X in [0,1]:break
  
print(SUM)

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

int main(void) {
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << a.at(i);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  int ans = 0;
  if(x == 1) ans+=300000;
  else if(x == 2) ans+= 200000;
  else if(x == 3) ans += 100000;

  if(y == 1) ans+=300000;
  else if(y == 2) ans+= 200000;
  else if(y == 3) ans += 100000;

  if(x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  map<string, int> cnt;
  rep(i, n) cnt[s[i]]++;
  printf("AC x %d \n", cnt["AC"]);
  printf("WA x %d \n", cnt["WA"]);
  printf("TLE x %d \n", cnt["TLE"]);
  printf("RE x %d \n", cnt["RE"]);
  return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    mat c(3, vec(3));
    REP(i,0,3) REP(j,0,3) cin >> c[i][j];

    if(c[0][0]-c[0][1] == c[1][0]-c[1][1] && c[1][0]-c[1][1] == c[2][0]-c[2][1]
    && c[0][1]-c[0][2] == c[1][1]-c[1][2] && c[1][1]-c[1][2] == c[2][1]-c[2][2]
    && c[0][2]-c[0][0] == c[1][2]-c[1][0] && c[1][2]-c[1][0] == c[2][2]-c[2][0]) PR("Yes");
    else PR("No");    

    return 0;
}

/*



*/

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#pragma warning disable

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            /*
            int[] input;

            input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            foreach(int n in input)
                Console.WriteLine("in : " + n);
            */

            //List<int> list = Enumerable.Range(1,30).ToList();
            List<int> list = new List<int>();
            for (int i = 1; i <= 30; i++)
                list.Add(i);

            for(int i = 0; i < 28; i++)
            {
                int n = int.Parse(Console.ReadLine());
                list.Remove(n);
            }

            list.ForEach(x => Console.WriteLine(x));


        }
    }
}

Measured memory_bytes: 9684
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll X;
    cin>>X;
    int a=X%10;
    REP(a,241){
        ll i=a-120;
       REP(b,241){
           ll j=b-120;
           if(X==i*i*i*i*i-j*j*j*j*j){
               cout<<i<<" "<<j;
               return 0;
           }
       } 
    }
    
    
    //cout<<fixed<<setprecision(10)<<cnt;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int ar[200000];
int main()
{
    long long h,mul=1,sum=0;
    cin>>h;
    while(h>1)
    {
        h/=2;
        sum+=mul;
        mul*=2;
    }
    if(h) sum+=mul;
    printf("%lld\n",sum);
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
long long x, y;
int main() {
	cin >> x >> y;
	cout << (-1 <= x - y && x - y <= 1 ? "Brown" : "Alice") << endl;
	return 0;
}

Measured memory_bytes: 764
N, K = map(int, input().split())
D = list(map(int, input().split()))

def isntD(n):
    c = 0
    for i in range(len(str(n))):
        if D.count(int(str(n)[i])) == 1:
            c += 1
    return c
    

while N < 100000:
    if isntD(N) == 0:
        print(N)
        break
    N += 1


Measured memory_bytes: 41436
def main()->None:
    (N, x) = map(int, input().split())
    a = list(map(int, input().split()))
    sorted_a = sorted(a) # 小さい順にならべる
    count = 0 # 何回配ったか
    for d in sorted_a:
        x -= d
        if x < 0:
            break
        count += 1
    # ちょうど配れない、必要な量より多く持ってた時
    if (count == N) and (x > 0):
        print(count-1)
    else:
        print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long power(long long a,long long now) {
	long long ans = 1;
	while (now != 0) {
		if (now % 2 == 1) {
			ans *= a;
			ans %= MAX_MOD;
		}
		now /= 2;
		a *= a;
		a %= MAX_MOD;
	}
	return ans;
}
long long inv(long long a) {
	return power(a, MAX_MOD - 2);
}
long long permutation(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
	}
	return ans;
}
long long combination(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
		ans *= inv(i + 1);
		ans %= MAX_MOD;
	}
	return ans;
}
long long dp[1001][1001];
long long solve(long long a, long long b) {
	if (dp[a][b]) return dp[a][b];
	if (a < b) return 0;
	if (b == 1) return 1;
	return dp[a][b] = (solve(a-1,b-1) + b * solve(a-1,b)) % MAX_MOD;
}
int main() {
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int i = 1; i <= k; ++i) {
		ans += solve(n, i);
		ans %= MAX_MOD;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10008
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 3; i <= n; i += 2){
		int cnt = 0;
		rep3(j,1,i){
			if(i%j==0) cnt++;
		}
		if(cnt==8) ans++;
	}
	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#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--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S; cin >> S;
  REP(i,2){
    if(S[i+1] != S[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long 

int n; 
vector<int>dp(100005,-1),arr(100005);

int recur( int index)
{

    //base case
    if (index == n - 1) return 0;
    if (index >= n) return INT_MAX;

    // look up
    if (dp[index] != -1) return dp[index];

    //recursive case

    int left = recur(index + 1) + abs(arr[index] - arr[index + 1]);

    int right = INT_MAX;
    if (index + 2 < n) right = recur(index + 2) + abs(arr[index] - arr[index + 2]);

    return dp[index] = min(left, right);
}

int32_t main()
{
    fast 
    cin >> n;

    // memset(dp,-1,sizeof dp);

    for (int i = 0; i < n; i++) cin >> arr[i];

    cout << recur(0);

    return 0;

}

Measured memory_bytes: 7892
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n, i, mi = 1000000, ma = -1000000, a;
	long long int sum = 0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a;
		if (mi > a) mi = a;
		if (ma < a) ma = a;
		sum = sum + a;
	}

	cout << mi << " " << ma << " " << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//The Two Men of the Japanese Alps
public class Main{

	int INF = 1<<29;
	Map<Integer, Double>[] map;
	
	double calc(double x1, double y1, double x2, double y2){
		return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		int[] xs = new int[100], ys = new int[100], y = new int[5000];
		double[] x = new double[5000];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Set<Integer> yset = new HashSet<Integer>();
			for(int i=0;i<n;i++){
				xs[i] = sc.nextInt();
				yset.add(ys[i]=sc.nextInt());
			}
			int[] Y = new int[yset.size()];
			int id = 0;
			for(int yy:yset)Y[id++]=yy;
			Arrays.sort(Y);
			id = 0;
			for(int i=0;i+1<n;i++){
				if(ys[i]==ys[i+1]){
					x[id] = xs[i];
					y[id++] = ys[i];
				}
				else if(ys[i]<ys[i+1]){
					for(int j=0;j<Y.length&&Y[j]<ys[i+1];j++){
						if(Y[j]<ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
				else{
					for(int j=Y.length-1;j>=0&&Y[j]>ys[i+1];j--){
						if(Y[j]>ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
			}
			x[id] = xs[n-1];
			y[id++] = 0;
			map = new Map[id];
			for(int i=0;i<id;i++)map[i]=new HashMap<Integer, Double>();
			map[0].put(id-1, 0.);
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(id, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return (int)Math.signum(map[o1[0]].get(o1[1]) - map[o2[0]].get(o2[1]));
				}
			});
			q.add(new int[]{0, id-1});
			double res = INF;
			while(!q.isEmpty()){
				int[] V = q.poll();
				int i = V[0], j = V[1];
				if(i==j){
					res = map[i].get(j); break;
				}
				for(int di=-1;di<=1;di++){
					int ni = i+di;
					if(ni<0 || id<=ni)continue;
					for(int dj=-1;dj<=1;dj++){
						int nj = j+dj;
						if(nj<0 || id<=nj || nj < ni || y[ni]!=y[nj])continue;
						double w = map[i].get(j) + calc(x[i], y[i], x[ni], y[ni]) + calc(x[j], y[j], x[nj], y[nj]);
						if(!map[ni].containsKey(nj) || w < map[ni].get(nj)){
							map[ni].put(nj, w);
							q.add(new int[]{ni, nj});
						}
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
int main()
{	int n,m,s=0,i;
 	cin>>n>>m;
 	int a[n];
 	for(i=0;i<n;i++)
 	{	cin>>a[i]; s+=a[i]; }
 	s=ceil((double)s/(4.0*m));
 	sort(a,a+n,greater<>());
 	//cout<<s;
 	for(i=0;i<n;i++){
 		//cout<<a[i];
 		if(a[i]<s) break; 
 	}
 	if(i<m)
 		cout<<"No\n";
 	else cout<<"Yes\n";
}

Measured memory_bytes: 256
#from abc093/submissions/2330255
q=int(input())
for i in range(q):
    a,b=map(int,input().split())
    c=int((a*b)**0.5)
    if c*(c+1)<a*b: print(2*c-1)
    elif a*b==c*c and a!=b: print(2*c-3)
    else: print(2*c-2)


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

typedef long long int lii;

main() {
  lii x, q, ans;
  cin >> x;
  q = x / 11;
  x -= 11 * q;    // 剰余
  ans = 2 * q;
  ans += (x == 0) ? 0 : 1 + x / 7;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions
A,B,C,D=map(int,input().split())
koubaisuu = C*D//fractions.gcd(C,D)
ans = (B//C-(A-1)//C)+(B//D-(A-1)//D)-(B//koubaisuu-(A-1)//koubaisuu)
print(B-A+1-ans)


Measured memory_bytes: 5304
from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)

Measured memory_bytes: 106736
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

int main()
{
	int m[50] = {}, f[50] = {}, r[50] = {};

	int count = 0;
	while (true)
	{
		cin >> m[count] >> f[count] >> r[count];
		if (m[count] == -1 && f[count] == -1 && r[count] == -1)
			break;
		count++;
	}

	int num_stu = count;
	int *sum_test = new int[num_stu]();
	char *grade = new char[num_stu]();

	for (int i = 0; i < num_stu; ++i)
	{
		sum_test[i] = m[i] + f[i];
		if (m[i] == -1 || f[i] == -1 || sum_test[i] <30)
		{
			grade[i] = 'F';
			continue;
		}

		if (sum_test[i] >= 80)
		{
			grade[i] = 'A';
			continue;
		}
		if (sum_test[i] >= 65)
		{
			grade[i] = 'B';
			continue;
		}
		if (sum_test[i] >= 50)
		{
			grade[i] = 'C';
			continue;
		}

		if (sum_test[i] >= 30)
		{
			if (r[i] >= 50)
				grade[i] = 'C';
			else
				grade[i] = 'D';
		}

	}


	for (int i = 0; i < num_stu; ++i)
		cout << grade[i] << endl;

	return 0;
}





Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll K=1000000007;
int MAX=100000;
int INF=MAX+1;
vector<int> Dis(MAX);
vector<int> Dis2(MAX);

int main (){
    int N;
    int U, V;
    cin>>N>>U>>V;
    U --;
    V --;
    vector<vector<int>> Way(N, vector<int>(0));
    vector<vector<int>> Tree(N-1, vector<int>(2));
    for(int i=0; i<N-1; i++){
        int A, B;
        cin>>A>>B;
        A --;
        B --;
        Way[A].push_back(B);
        Way[B].push_back(A);
        Tree[i][0]=A;
        Tree[i][1]=B;
    }
    for(int i=0; i<N; i++)Dis[i]=-1;
    Dis[V]=0;
  	queue<int> Q;
    Q.push(V);
    while(!Q.empty()){
        int x=Q.front();
        Q.pop();
        int WSize=Way.at(x).size();
        for(int i=0; i<WSize; i++){
            int to=Way[x][i];
            if(Dis[to]==-1){
                Dis[to]=Dis[x]+1;
                Q.push(to);
            }
        }
    }
    
    for(int i=0; i<N; i++)Dis2[i]=-1;
    Dis2[U]=0;
    queue<int> Q2;
    Q2.push(U);
    while(!Q2.empty()){
        int x=Q2.front();
        Q2.pop();
        int WSize=Way.at(x).size();
        for(int i=0; i<WSize; i++){
            int to=Way[x][i];
            if(Dis2[to]==-1){
                Dis2[to]=Dis2[x]+1;
                Q2.push(to);
            }
        }
    }
    
    int Max=0;
  	if(U==V){
      	cout<<0<<endl;
    }
  	else{
  	for(int i=0; i<N; i++){
        if(Dis[i]>Dis2[i]){
            Max=max(Max, Dis[i]);
        }
    }
    cout<<Max-1;
    }
    
}





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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int L;
  cin >> L;
  double d = (double)L / 3;
  cout << d * d * d << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 200100;
int n, m, stx, sty, len;
string s, t;
char d[4] = {'L', 'R', 'U', 'D'};
int dir[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
bool in(int x, int y)
{
	return x > 0 && x <= n && y > 0 && y <= m;
}
bool can(int x)
{
	int nowx = stx, nowy = sty;
	for(int i = 0; i < len; i ++)
	{
		if(s[i] == d[x])
		{
			nowx += dir[x][0];
			nowy += dir[x][1];
			if(!in(nowx, nowy))
				return 1;
		}
		if(t[i] == d[x ^ 1] && in(nowx + dir[x ^ 1][0], nowy + dir[x ^ 1][1]))
		{
			nowx += dir[x ^ 1][0];
			nowy += dir[x ^ 1][1];
		}
	}
	return 0;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> m >> len >> stx >> sty;
	cin >> s >> t;
	for(int i = 0; i < 4; i ++)
		if(can(i))
		{
			cout << "NO" << endl;
			return 0;
		}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, W;
    cin >> H >> W;
    ll ans = H * W;
    if (H == 1 || W == 1) {
        cout << 1 << '\n';
        return;
    }
    if (ans % 2) {
        cout << ans / 2 + 1 << '\n';
    } else {
        cout << ans / 2 << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp
k = gets.to_i

n = 1
idx = nil
s.chars.each.with_index do |c,i|
  
  if c != '1'
    n = c
    idx = i + 1
    break
  end
  
end

if idx && idx <= k
  puts n
else
  puts 1
end

Measured memory_bytes: 1788
function solve()
    N = parse(Int, readline())
    D = []
    for _ = 1:N
        push!(D, parse.(Int, split(readline())))
    end

    cnt = 0
    for i = 1:N
        if D[i][1] == D[i][2] cnt+=1
        else cnt = 0 end
        if cnt >= 3
            println("Yes")
            return 0
        end
    end
    println("No")

end

solve()


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

using namespace std;

typedef long long ll;

int main(){
//	freopen("input.txt","r",stdin);// <--Remove Before Submit
	ll q,h,s,d,n,yen=0,v=1;
	cin >> q >> h >> s >> d >> n;
	if(n >= 2){
		int r = min({q*8,h*4,s*2,d});
		v = n%2;
		yen = r*(n/2);
	}
	if(v==1){
		int w = min({q*4,h*2,s});
		yen += w;
	}
	cout << yen << endl;
}

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

using namespace std;
const int mod=1000000007;

int main(){
    int n, m, p, x;
    int minE = mod;
    cin >> n >> m >> x; //n quyển sách, m algorithms, tối thiểu x algorithms cần học

    //nhập dữ liệu theo format
    vector<vector<int> > a(n, vector<int> (m));
    vector<int> c(n);
    for(int i = 0;i < n;i++){
        cin >> c[i];
        for(int j = 0;j < m;j++){
            cin >> a[i][j];
        }
    }

    //vì giới hạn bài này nhỏ nên ta có thể sử dụng bitmask, time complexity = O(2^n.n.m)
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> u(m, 0);
        int cost = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                cost += c[i];
                for(int j = 0;j < m;j++){
                    u[j] += a[i][j];
                }
            }
        }

        bool isOK = true;
        for(int i = 0;i < m;i++){
            //nếu có một algorithms ko thỏa điểu kiện tối thiểu x thì isOk = false
            if(u[i] < x)
                isOK = false;
        }

        minE = (isOK && cost < minE) ? cost : minE; //cập nhật minE
    }

    if(minE == mod){
        cout << -1 << endl;
    }else{
        cout << minE << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
long long a[100005];
int main()
{
    int n;
    long long c = 1;
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) { cout << 0 << endl; return 0; } }
    for (int i = 0; i < n; i++)
    {
        
        if (c > 1000000000000000000/a[i]) { cout << "-1" << endl; return 0; }
        c *= a[i];
    }
    cout << c << endl;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector<int> Vec;
typedef pair<Vec,int> P;
 
bool check(Vec &v){
  for(int i = 0 ; i < 32 ; i++){
    if((i+1) % 8 == 0) continue;
    if((i/8+1)*10+i%8+1 != v[i]) return false;
  }
  return true;
}
 
int bfs(Vec &start,Vec &space){
  queue<P> Q;
  queue<Vec> S;
  Q.push(P(start,0));
  S.push(space);
  set<Vec> visited;
  visited.insert(start);
 
  while(!Q.empty()){
    P p = Q.front(); Q.pop();
    Vec s = S.front(); S.pop();
    if(check(p.first)) return p.second;
     
    for(int i = 0 ; i < 4 ; i++){
      if(p.first[s[i]-1] % 10 == 7) continue;
      for(int j = 0 ; j < 32 ; j++){
        if(p.first[s[i]-1]+1 == p.first[j]){
          swap(p.first[s[i]],p.first[j]);
          int tmp = s[i]; s[i] = j;
          if(!visited.count(p.first)){
            visited.insert(p.first);
            Q.push(P(p.first,p.second+1));
            S.push(s);
          }
          s[i] = tmp;
          swap(p.first[s[i]],p.first[j]);
        }
      }
    }
  }
  return -1;
}
 
int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    Vec v(32),space;
    for(int i = 0 ; i < 32 ; i++){
      if(i % 8 != 0){
        cin >> v[i];
        if(v[i]%10 == 1){
          v[i] = 0;
          space.push_back(i);
        }
      }else{
        v[i] = (i/8+1)*10+1;
      }
    }
    cout << bfs(v,space) << endl;
  }
  return 0;
}

Measured memory_bytes: 15116
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let A = scan.list::<usize>(N - 1);

    let mut count = vec![0; N + 1];
    for &a in &A {
        count[a] += 1;
    }

    for i in 1..N + 1 {
        println!("{}", count[i]);
    }
}


Measured memory_bytes: 6952
s = input()
n = len(s)

# 求めなくてはいけないアルファベットは、sに含まれているものだけ
abc_kind = set(s)
ans = n
for x in abc_kind:
    # 何も考えず、シミュレーションする
    # xを残すように操作していく
    cnt = 0
    t = s
    while len(t) != t.count(x):
        t = ''.join([x if x in (a, b) else a for a, b in zip(t, t[1:])])
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

Measured memory_bytes: 3064
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn chars() -> Vec<char> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let s: String = read_from(&mut stdin);
    s.chars().collect()
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}

fn main() {
    loop {
        let n: usize = read();
        let m: usize = read();
        let q: usize = read();

        let tokens = readn(q*2+m*2);

        let mut to_l: Vec<_> = vec![HashSet::new(); n + 1];
        let mut to_r: Vec<_> = vec![HashSet::new(); n + 1];
        let mut rails: Vec<(usize, usize, usize)> = (0..m).map(|i| (tokens[i*2], tokens[i*2+1], i)).collect();
        rails.sort();
        let mut rails: VecDeque<_> = rails.iter().cloned().collect();
        for &(l, r, i) in rails.iter() {
            to_l[r].insert((l, i));
            to_r[l].insert((r, i));
        }
        let mut qs: Vec<_> = (0..q).map(|i| {
            let l: usize = tokens[m*2+i*2];
            let r: usize = tokens[m*2+i*2+1];
            (l, r, i)
        }).collect();
        qs.sort();

        let mut ans = vec![0; q];
        for &(ql, qr, i) in qs.iter() {
            while rails.len() > 0 && rails.front().unwrap().0 < ql {
                let (l, r, i) = rails.pop_front().unwrap();
                to_l[r].remove(&(l, i));
                to_r[l].remove(&(r, i));
            }
            let mut cnt = 0;
            for r in ql..qr + 1 {
                cnt += to_l[r].len();
            }
            ans[i] = cnt;
        }

        let mut buf = String::new();
        for e in ans.iter() {
            buf.push_str(&format!("{}\n", e));
        }
        print!("{}", buf);
    }
}


Measured memory_bytes: 47956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  string ans;
  while(n > 0) {
    n--;
    ll c = n % 26;
    ans.push_back(c + 'a');
    n /= 26;
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n;
vec<i64> a;

i32 main()
{
    cin >> n;
    a.resize(3*n);
    times(3*n, i) {
        cin >> a[i];
    }
    sortall(a);
    i64 ans = 0;
    for (i32 i = n; i < 3*n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    long long n = floor(N / (A + B));
    long long rest = N - n * (A + B);
    long long res = n * A + min(rest, A);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
//
int main(){
    long long n;cin>>n;
    n=n-1;
    long long r=n,s=26;
    vector<long long> v;
    int t=0;
    while(r>=0){
       r=r-s;
       s=s*26;
       t++;
       
    }
    rep(i,t){
       long long a;
       a=n%26;
       n=(n-a)/26-1;
       v.push_back(a);
    }
    vector<char> ans;
    rep(i,t){
       int x=v[i]+97;
       ans.push_back((char)x);
    }
   reverse(all(ans));
    for(auto e:ans)cout<<e;
    cout<<endl;
}

Measured memory_bytes: 3628
S = list(input())
T = list(input())
i = int(0)
if S[0] == T[0]:
	i = i + 1
	if S[1] == T[1]:
		i = i + 1
		if S[2] == T[2]:
			i = i + 1
	else:
		if S[2] == T[2]:
			i = i + 1
else:
	if S[1] == T[1]:
		i = i + 1
		if S[2] == T[2]:
			i = i + 1
	else:
		if S[2] == T[2]:
			i = i + 1
print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<long long>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define couta(x) for(auto iter : x) p(iter)
#define yes(x) x ? cout << "Yes" << endl : cout << "No" << endl;
using namespace std;
typedef long long lint;
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector<vector<int> > VVI;
typedef vector<vector<long long> > VVLL;
typedef vector<vector<bool> > VVB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
using UnweightedGraph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
const long long INF = 2000000000ll;
const long double PI = acosl(-1);
const long double EPS = 1e-7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



long long power(long long a, long long b) {return b?power(a*a,b/2)*(b%2?a:1):1;}
long long perm(long long N, long long K){
    long long x=1;
    for(long long i=1;i<=K;i++)
    {
        x=x*(N-i+1);
    }
    return x;
}
long long factorial(long long N) {return perm(N,N);}
long long comb(long long N,long long K) {return factorial(N)/factorial(K)/factorial(N-K);}
long long hcomb(long long N, long long K) {return comb(N+K-1, N-1);}

int dtoi(double d) {return round(d);}

bool isprime(int n) {
    if (n < 2) return false;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

long long mystoll(string s){
    long long ans = 0;
    for (int i = (int) s.length()-1; i >= 0; i--){
        ans += (s[i]-'0') * power(10,s.length()-1-i);
    }
    return ans;
}

template<class T>
long long SUM(T a) {
    long long sum = 0;
    for(auto itr : a) sum += itr;
    return sum;
}

void solve(int64_t R) {
    cout << (LD) R*PI*2<< endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    constexpr char endl = '\n';
    int64_t R;
    cin >> R;
    solve(R);
    return 0;
}


Measured memory_bytes: 3808
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
inside=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      inside+=1
outside=0
for i in range(n):
  for j in range(n):
    if a[i]>a[j]:
      outside+=1
print((k*inside+(k*(k-1)//2)*outside)%mod)



Measured memory_bytes: 9368
#include <iostream>
using namespace std;
 
int main() {
	int x,y;
 
	while(true){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		else if(x<y){
			cout << x << " " << y << endl;
		}
		else{
			cout << y << " " << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2976
from math import sqrt, ceil

N = int(input())

def main():
    n = N
    curr = ceil(sqrt(n))
    while 0 < curr:
        d, q = divmod(n, curr)
        if q == 0:
            ans = len(str(max(curr, d)))
            break
        curr -= 1
    print(ans)
    
if __name__ == '__main__':
    main()

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

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

    long n;
    // vector<int> x;
    cin >> n;

    vector<long> a;
    // long a[n];
    long tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        a.push_back(tmp);
    };
    sort(a.begin(), a.end());
    long max_val = a[n - 1];
    decltype(a)::iterator large_med;
    decltype(a)::iterator small_med;
    decltype(a)::iterator nearest_med;
    auto true_med = static_cast<long>(round(max_val / 2.0));
    large_med  = lower_bound(a.begin(), a.end(), true_med);

    long large_pos = 0;
    for (auto &num : a) {
        if (num == *large_med) break;
        large_pos++;
    }
    // long small_pos = 0;
    // if (large_pos > 0) {
    //     small_pos = large_pos - 1;
    // } else {
    //     small_pos = large_pos;
    // }

    long med_val;
    if (large_pos == n - 1) {
        med_val = a[large_pos - 1];
    } else if (large_pos == 0) {
        med_val = a[large_pos];
    } else if (a[large_pos] - true_med > true_med - a[large_pos - 1]) {
        med_val = a[large_pos - 1];
    } else {
        med_val = a[large_pos];
    }
    cout  << max_val << ' ' << med_val << "\n";

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll LINF = 1e18;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

int main()
{
	ll n,s;
	cin >> n;
	cin >> s;
	ll k = sqrt(n);
	for(ll i=2; i<=k; i++){
		ll t = n;
		ll sum = 0;
		while(t > 0){
			sum += t % i;
			t /= i;
		}
		if(s == sum){
			cout << i << endl;
			return 0;
		}
	}

	for(ll i=k; i>0; i--){
		ll d = s - i;
		ll b = (n-d)/i;
		if(d >= 0 && (n-d)%i == 0 && i < b && d < b ){
			cout << b << endl;
			return 0;
		}
	}
	cout << (n==s ? n+1 : -1) << endl;
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    cout << a[n - 1] - a[0] << endl;
    return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)n; ++i)

using namespace std;

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

    int N;
    cin >> N;
    cout << N / 3 << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,b[102],ans;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
		cin>>b[i];
	ans+=b[1];
	b[n]=1e9;
	for(int i=1;i<n;i++)
		ans+=min(b[i],b[i+1]);
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

ll dp[200000][3];
ll a[200000];
ll b[200000];
ll c[200000];
int main(int argc, const char * argv[]) {
    ll N; cin >>N;
    for(ll i=0;i<N;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    
    for(ll i=1;i<N;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
    
    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;
    
    
 
 
    return 0;
}




Measured memory_bytes: 7680
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int ans = k;
		for (int i = 1; i < n; i++) {
			ans *= (k - 1);
		}
		
		System.out.println(ans);

		
	}
}

Measured memory_bytes: 23764