akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "fmt"
  "math"
)

func main() {
  var a,b,h,m,c float64
	var arg1,arg2 float64
	fmt.Scan(&a,&b,&h,&m)
  arg1 = 30 * h + float64(360)/float64(12)/float64(60)*m
  arg2 = 6 * m
  arg := math.Abs(arg1-arg2)
  if arg > 180 {
    arg = 360 - arg
  }
  aS := a * a
  bS := b * b
  //fmt.Println(aS,bS)
  that := 2*a*b*math.Cos(math.Pi * (arg/180))
  //fmt.Println(that)
  c = math.Sqrt(aS+bS-that)
  fmt.Println(c)
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    string s;
    cin >> s;
    if (s[0] == s[2])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(i==j) break;
      if(s[i]==s[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }

  cout << "yes" << endl;

  return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s; cin>>s;int ans = 0;
    rep(i,s.size()/2)if(s[i] != s[s.size()-1-i])++ans;
    cout<<ans<<endl;return 0;
}


Measured memory_bytes: 256
import 'dart:io';

main(List<String> args){
  int k=int.parse(stdin.readLineSync());
  String s=stdin.readLineSync();
  if(k<s.length){
    String ans="";
    for(int i=0;i<k;i++){
      ans+=s[i];
    }
    print(ans+"...");
  }
  else{
    print(s);
  }
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];

ll gun(ll x) {
    return (x * x);
}

double dis(ll x, ll y) {
    double res = sqrt(gun(x) + gun(y));
    return res;
}

int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin2(n, p);

    for1(i, n) {
        cin2(x, y);
        if(dis(x, y) <= p) c++;
    }

    cot1(c);

    return 0;
}



Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[200100],y[200100];
string s,str;
int main(){
  cin>>n>>k;
  for(ll i=k;i<=n+1;i++){
    ans+=(i*n-i*i+i+1)%1000000007;
  }
  cout<<ans%1000000007;
  return 0;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	ret := exec(n)

	for i := 1; i <= n; i++ {
		fmt.Printf("%d\n", ret[i])
	}
}

func exec(n int) []int {
	max := sqrt(n)
	ret := make([]int, n+1)
	for x := 1; x < max; x++ {
		for y := 1; y < max; y++ {
			for z := 1; z < max; z++ {
				v := cal(x, y, z)
				if n >= v {
					ret[v]++
				}
			}
		}
	}
	return ret
}

func cal(x, y, z int) int {
	return x*x + y*y + z*z + x*y + x*z + y*z
}

func sqrt(p int) int {
	return int(math.Sqrt(float64(p)))
}


Measured memory_bytes: 2084
# 2019/03/23
# AtCoder Grand Contest 032 - A

# Input
n = int(input())
b = list(map(int, input().split()))
anslist = list()
ngflg = False

for idx6 in range(n):
    maxidx = -1
    for idx7 in range(len(b)):
        if b[idx7] == idx7 + 1:
            maxidx = idx7
    
    if maxidx >= 0:
        anslist.append(b.pop(maxidx))
    else:
        ngflg = True

    if ngflg:
        print(-1)
        break

if ngflg == False:
    for idx4 in range(n-1, -1, -1):
        print(anslist[idx4])


Measured memory_bytes: 3064
//#include "pch.h"
#include <stdio.h>
#include <string.h>
//#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;

	cin >> s;

	bool flag = false;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '7')flag = true;
	}

	if (flag == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,z;
    for(z=0;z<3;z++){
        scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
        g=a*3600;
        h=b*60;
        i=g+h+c;
        j=d*3600;
        k=e*60;
        l=j+k+f;
        m=l-i;
        n=m/3600;
        q=m%3600;
        o=q/60;
        p=q%60;
        printf("%d %d %d\n",n,o,p);
    }

return 0;
}

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

#define inf 2000000009
#define ff first 
#define ss second 
#define ll long long

int main(){
	clock_t beg=clock(); 
	int n,x; cin>>n>>x; 
	int a[n]; for (int i = 0; i < n; ++i)
	{
		cin>>a[i]; 
	}
	sort(a,a+n); 
	int ans=0; 
	int i=0;
	while(i<n){
		x-=a[i]; 
		if(x<0) break; 
		ans++; 
		i++; 
	}
	if(ans==n && x!=0){ ans--; }
	cout<<ans; 

	clock_t end=clock(); 
	fprintf(stderr, "%lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC );
}	

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

using namespace std;

int N, M;
long long int A[100005];

multiset<long long int > S;

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		S.insert(A[i]);
	}

	for (int i = 1; i <= M; i++) {
		auto it = S.end();
		it--;
		long long int tmp = *it;
		S.erase(it);
		S.insert(tmp / 2);
	}

	long long int ans = 0;

	for (auto y : S) { ans += y; }

	cout << ans << endl;

	return 0;
}

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

int main() {
  
  int H, W;
  int i,j;
  string str;
  cin >> H >> W;
  for(i=0;i < W + 2;i++){
    cout << '#';
  }

  cout << endl;
  for(i=0;i < H;i++){
    cin >> str;
    cout << '#' << str << '#';
    cout << endl;
  }

  for(i=0;i < W + 2;i++){
    cout << '#';
  }
  
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
d1 = [A[i][0] - A[i][1] for i in range(n)]
d2 = [A[i][0] + A[i][1] for i in range(n)]

print(max(max(d1) - min(d1), max(d2)-min(d2)))


Measured memory_bytes: 129312
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    const int M = 1000000007;
    int N;
    cin >> N;

    ll P = 1;
    repi(i, 1, N + 1) {
        P *= i;
        P %= M;
    }

    cout << P << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int N=100;

int main(){
    int M[N][N];
    int n,u,v,k;
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) M[i][j]=0;
    }
    for(int i=0;i<n;i++){
        cin >>u >>k;
        u--;
        for(int j=0;j<k;j++){
            cin >>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int m = (1 << n);
	vector<int> a(m);
	for(auto& x : a) cin >> x;
	
	int ans = 0;
	for(int b = 0; b < m; ++b) {
		if (a[b] == 0) {
			for(int i = 0; i < n; ++i) {
				if (!((b >> i) & 1)) continue;
				if (a[b ^ (1 << i)]) {
					cout << -1 << endl;
					return 0;
				}
			}
		} else {
			bool ok = true;
			for(int i = 0; i < n; ++i) {
				if (!((b >> i) & 1)) continue;
				if (a[b ^ (1 << i)]) {
					ok = false;
				}
			}
			if (ok) ++ans;
		}
	}

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



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

const ll p = 31, m = 18014398241046527;
unordered_map<ll,ll> cnt;

ll compute_hash(string& s){
    vector<int> letras(27,0);
    ll pref = 0;
    int n = s.size();
    for(int i=0;i<n;i++){
        letras[s[i]-'a'+1]++;
    }

    for(int j=1;j<27;j++){
        if(letras[j]){
            cnt[(pref*p+j)%m]++;
        }
    }
    for(int i=n-1;i>=0;i--){
        pref = ((pref*p)%m+(s[i]-'a'+1))%m;
        letras[s[i]-'a'+1]--;
        for(int j=1;j<27;j++){
            if(letras[j]){
                cnt[((pref*p)%m+j)%m]++;
            }
        }
    }
    return pref;
}

int main(){
    int n;
    vector<string> arr;
    vector<ll> hs;

    cin >> n;
    arr.assign(n,string());
    hs.assign(n,0);
    cnt.reserve(int(26*1e6)+5);
    for(int i=0;i<n;i++){
        cin >> arr[i];
        hs[i] = compute_hash(arr[i]);
    }

    ll answ = 0;
    for(int i=0;i<n;i++){
        answ += cnt[hs[i]]-1;
    }

    cout << answ << '\n';

    

    return 0;
}

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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())

S = 0

for a in range(K):
    a += 1
    for b in range(K):
        b += 1
        for c in range(K):
            c += 1

            S = S + gcd(a,b,c)

print(S)

Measured memory_bytes: 69628
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  string a;
  cin>>a;
  if(a.at(0)=='9'||a.at(1)=='9'){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool sieve[1000001];

vi factor(int a) {
    vi pri;
    REP(i, 1000000) {
        if (sieve[i]) continue;
        bool f = false;
        while (a % i == 0) {
            if (!f) {
                f = true;
                pri.push_back(i);
            }
            a /= i;
            if (a == 1) return pri;
        }
    }
}

int main() {
    sieve[0] = sieve[1] = true;
    FOR(i, 2, 1000000) {
        if (sieve[i]) continue;
        for (int j = i+i; j < 1000000; j += i) {
            sieve[j] = true;
        }
    }

    int a, b;
    while (cin >> a >> b, a|b) {
        vi pa = factor(a), pb = factor(b);
        if (pa[pa.size()-1] - accumulate(pa.begin(), pa.end()-1, 0) > pb[pb.size()-1] - accumulate(pb.begin(), pb.end()-1, 0)) {
            cout << "a" << endl;
        } else {
            cout << "b" << endl;
        }
    }
}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> d(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		ll a;
		cin >> a;
		d[i] += d[i - 1] + a;
	}

	ll res = 0;
	map<ll, ll> mp;
	for (int i = 1; i <= N; i++) {
		mp[d[i]]++;
		if (d[i] == 0) res++;
	}

	for (auto it = mp.begin(); it != mp.end(); it++) {
		for (int i = 1; i < it->second; i++) {
			res += i;
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }



int main() {
  ll n;
  cin>>n;
  vin a(n),b(n),c(n);
  rep(i,0,n){
    cin>>a[i];
  }
  ll cnt[n];
  rep(i,0,n)cnt[i]=0;///bのi番目から何通りcに向かうか
  
  rep(i,0,n)cin>>b[i];
  rep(i,0,n)cin>>c[i];
  sort(all(a));sort(all(b));sort(all(c));
  ll ans=0;
  rep(i,0,n){
   ll l=-1;
   ll r=n;
    while(r-l>1){
      if(c[(r+l)/2]<=b[i]){
        l=(r+l)/2;
      }
      else{
        r=(r+l)/2;
      }
    }
    cnt[i]=n-r;
  }
  for(ll i=n-1;i>0;i--){
    
    cnt[i-1]+=cnt[i];
   // cout<<cnt[i]<<endl;
  }
  //cout<<cnt[0]<<endl;
  rep(i,0,n){
   ll l=-1;
   ll r=n;
    while(r-l>1){
      if(b[(r+l)/2]<=a[i]){
        l=(r+l)/2;
      }
      else{
        r=(r+l)/2;
      }
    }
    if(r==n)break;
   ans+=cnt[r];
  }
  
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 5072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<long long>A(N);
  vector<vector<long long>>B(M+N,vector<long long>(2));
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>B.at(i).at(1)>>B.at(i).at(0);
  }
  for(int i=M;i<M+N;i++){
    B.at(i).at(1)=1;
    B.at(i).at(0)=A.at(i-M);
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  long long sum=0;
  int count=0;
  for(int i=0;i<M+N;i++){
    int c=0;
    c=count;
    count=count+B.at(i).at(1);
    if(count<=N){
      sum=sum+B.at(i).at(0)*B.at(i).at(1);
    }
    else{
      sum=sum+B.at(i).at(0)*(N-c);
      break;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
int main()
{
	int k, x, cmin, cmax;
	cin >> k >> x;
	cmin = max(-1000000, x - k + 1);
	cmax = min(1000000, x + k - 1);
	for (int i = cmin; i <= cmax; i++)
	{
		cout << i << ' ';
	}
	cout << endl;
}


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

int main() {
  int N, W;
  while (cin >> N >> W && N) {
    int D[20];
    fill(D, D+20, 0);
    int max = 0;
    for (auto i=0; i<N; i++) {
      int v;
      cin >> v;
      int temp = v/W;
      D[temp]++;
      if (temp > max) max = temp;
    }
    int maxh = 0;
    for (auto i=0; i<=max; i++) {
      if (maxh < D[i]) maxh = D[i];
    }
    double sum = 0.01;
    for (auto i=0; i<=max; i++) {
      sum += (double)D[i] / maxh * (double)(max - i) / max;
    }
    cout << fixed << setprecision(6) << sum << endl;
  }
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_105(void) {
	int n;
	cin >> n;

	int cnt = 0;

	for (int i = 1; i <= n; i+=2) {
		int div_cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) div_cnt++;
		}
		if (div_cnt == 8)cnt++;
	}

	cout << cnt << endl;
}

int main()
{
	b_105();
    return 0;
}

Measured memory_bytes: 3528
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {


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

	cout << max(a + b, max(a - b, a*b)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY (1<<30)
int H = 0,A[MAX + 1];
void maxHeapify(int i){
  int tmp,l,r,largest;
  l = 2*i;
  r = 2*i + 1;
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H < 1)return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int tmp;
  if(key < A[i])return;
  A[i] = key;
  while((i > 1) && (A[i/2] < A[i])){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}

void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n')break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }
  return 0;
}



Measured memory_bytes: 5708
n = int(input())
digit = len(str(n))

count = 0
for i in range(digit - 1):
  if (i + 1) % 2 == 1:
    count += 10 ** (i + 1) - (10 ** i)

if digit % 2 == 1:
  count += n - 10 ** (digit - 1) + 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long i,j,k,N;

char S[11],T[11];

int main()
{
  cin>>S>>T;
  N=strlen(S);
  
  for(i=0;i<N;i++)
  {
    if(S[i]!=T[i])
    {
      cout <<"No";
      return 0;
    }
  }
  
  cout<<"Yes";
  
}

Measured memory_bytes: 3616
n,m = gets.chomp.split.map(&:to_i)
s = gets.chomp.split(//).map(&:to_i)

ans = []
cur = n
while cur >= m
  possible = false
  m.downto(1).each do |j|
    # p [cur, j, s[cur-j]]
    if s[cur-j] == 0
      ans.unshift j
      cur -= j
      possible = true
      break
    end
  end

  unless possible
    puts -1
    exit
  end
  # p ans
end

ans.unshift cur if cur > 0
puts ans.join(' ')

Measured memory_bytes: 13564
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
vector<int>V[N];
int n, a[N], f[N];

bool cmp (int a, int b) { return f[a] > f[b]; }

void Dfs (int u) {
	int i = 0;
	for (auto v : V[u]) Dfs(v);
	sort(V[u].begin(), V[u].end(), cmp);
	for (auto v : V[u]) f[u] = max(++i + f[v], f[u]);
}

int main () {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) scanf("%d", &a[i]), V[a[i]].push_back(i);
	Dfs(1);
	printf("%d\n", f[1]);
	return 0;
}

Measured memory_bytes: 12800
import math
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)
# if l:
#     print(0)
#     exit()
if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
elif L == c:
    print(0)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main() {
    int A,B,K;
    cin>>A>>B;
    if((B+A)%2==0){
        K=(A+B)/2;
        cout<<K<<endl;
        return 0;
    }
    cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#define pb push_back
#define MX 1e3
#define mod 1000000009
#define ff first
#define ss second
#define for1(i,n) for(int i=1;i<=n;i++)
#define for0(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned  ll;

int main(int argc, char const *argv[]) {
  int n,temp;
  cin>>n;
  vector<int>v;
  v.pb(1);
  for(int i=2;i<=MX;i++){
    temp = i;
    while(temp<=MX){
      //cout<<temp<<endl;
      temp*=i;
      v.pb(temp);
    }
  }
  sort(v.rbegin(),v.rend());
  for(int i=0;i<v.size();i++){
    if(v[i]<=n){
      cout<<v[i];
      return 0;
    }
  }
  return 0;
}


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

using namespace std;
typedef long long LL;

int a[100010];
int dp[100010];

int main() {
    int n, k;
    cin>>n>>k;
    for (int i=0;i<n;i++) scanf("%d", &a[i]);
    memset(dp,-1,sizeof(dp));
    dp[n-1]=0;
    for (int i=n-1;i>=0;i--) {
        for (int j=1;j<=k;j++) {
            if (i-j>=0 && (dp[i-j]==-1 || dp[i-j]>dp[i]+abs(a[i]-a[i-j]))) dp[i-j]=dp[i]+abs(a[i]-a[i-j]);
        }
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 1024
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(0,a*500+1,500):
    for j in range(0,b*100+1,100):
        for z in range(0,c*50+1,50):
            if i+j+z==x:
                ans+=1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
struct SegtreeRMQ {
    ll n;
    ll inf;
    vector<ll> dat;
 
    void init(ll n_input, ll inf_input){
        inf = inf_input;
        n = 1;
        while(n < n_input)n <<= 1;
        dat.resize(2*n-1);
        for(int i = 0; i<2*n-1; i++) dat[i] = inf;
    }
 
    void update(ll k, ll a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = min(dat[2*k+1], dat[2*k+2]);
        }
    }
 
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b)return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main()
{
    ll n, e, t;
    cin >> n >> e >> t;
    SegtreeRMQ st1, st2;
    ll INF = 1e18;
    st1.init(n+10, INF);
    st2.init(n+10, INF);
    vector<ll> x(n+10);
    for(int i = 1; i <= n; i++) cin >> x[i];
    int pos = 0;
    x[n+1] = e;
    vector<ll> ans(n+10);
    st1.update(0, 0);
    st2.update(0, -2 * x[1]);
    for(int i = 1; i <= n; i++)
    {
        while(x[i] - x[pos+1] > t / 2) pos++;
        ans[i] = min(x[i] + t + st1.query(pos, i, 0, 0, st1.n), 3*x[i] + st2.query(0, pos, 0, 0, st2.n));
        st1.update(i, ans[i] - x[i]);
        st2.update(i, ans[i] - x[i] - 2 * x[i+1]);
    }
    cout << ans[n] + e - x[n] << endl;
}



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

int main() {
	int n;
	cin>>n;
	map<int,int> a;
	rep(i,n){
		int k;
		cin>>k;
		a[k]=1;
	}
	
	if(a.size()==n)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
 }


Measured memory_bytes: 9600
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define swap(a,b) a^=b^=a^=b //二変数を入れ替え//
#define inf 1000000007

void sort(int x[], int left, int right);
int main(void);

//小さい順にソート//
void sort(int x[], int left, int right) {
	int temp[inf], smid, si, sj, sk;
	if (left >= right) return;
	if (left == right - 1) {
		if (x[left] > x[right]) {
			swap (x[left], x[right]);
		}
	return;
	}
	smid = (left + right) / 2;
	sort(x, left, smid);
	sort(x, smid+1, right);
	for (si = left; si <= smid; si++) temp[si] = x[si];
	for (si = smid+1 ; si <= right; si++) temp[si] = x[smid + right + 1 - si];
	si = left;
	sj = right;
	for (sk = left; sk <= right; sk++) {
		if (temp[si] <= temp[sj]) {
			x[sk] = temp[si];
			si=si+1;
		} else {
			x[sk] = temp[sj];
			sj=sj-1;
		}
	}
}

int main(void) {
	// your code goes here
  int x,a,b,c,i,j,k,num=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      if (500*i+100*j<=x && x-500*i-100*j<=50*c) {
        num=num+1;
      } else if (x-500*i-100*j>50*c) {
      } else {
        break;
      }
    }
  }
  printf("%d\n",num);
	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define ld long double
#define li long long int
int main()
{
    li x, y, a, b; cin >> x >> y;
    if ((y - 2 * x) % 2 == 0)
    {
        b = (y - 2 * x) / 2;
        a = x - b;
        if (a >= 0 && b >= 0)
            cout << "Yes";
        else
            cout << "No";
    }
    else
        cout << "No";
}


Measured memory_bytes: 3620
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=1e4+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int k,d,len,dp[N][2][102];string s;
int add(int a,int b){
  a+=b;
  if(a>=M)a-=M;
  return a;
}
int sub(int a,int b){
  return ((a%M)+M-(b%M))%M;
}
int f(int pos=0,int ok=0,int sum=0,int lim=9){
  if(pos==len)return (sum==0);
  if(dp[pos][ok][sum]!=-1)return dp[pos][ok][sum];
  if(ok==0)lim=s[pos]-'0';
  int ans=0;
  rep(i,0,lim){
    if(i==lim and ok==0){
      ans=add(ans,f(pos+1,0,(sum+i)%d));
    }
    else ans=add(ans,f(pos+1,1,(sum+i)%d));
  }
  return dp[pos][ok][sum]=ans;
}
void solve(){
  cin>>s>>d;
  rep(i,0,N-1)rep(j,0,2-1)rep(k,0,102-1)dp[i][j][k]=-1;
  len=s.length();
  cout<<sub(f(),1);
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 20556
#include <stdio.h>
int main(){
  int i,b,n;
  int array[100];
  scanf("%d",&n);
  for(i=n-1;i>=0;i--){
    scanf("%d",&b);
    array[i]=b;
  }
  for(i=0;i<=n-1;i++){
    if(i<n-1){
      printf("%d ",array[i]);
    }
    else if(i==n-1){
      printf("%d\n",array[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

vector<vector<long> > tt;
vector<long> depth;
vector<long> par;
vector<long> child;

void dfs( long curr )
{
    long nSize=(long)tt[curr].size();
    long i;
    for(i=0; i<nSize; i++) {
        long next = tt[curr][i];
        if(depth[next] < 0) {
            depth[next] = depth[curr] + 1;
            par[next]=curr;
        }
        else if(depth[next]==depth[curr]+1) {
            ;  // do nothing
        }
        else if(depth[next]<depth[curr]+1) {
            depth[next]=depth[curr]+1;
            par[next]=curr;
        }
        else {
            ;  // do nothing
        }

        child[next]--;
        if(child[next]==0) {
            dfs( next );
        }
    }

    return;
}


int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    tt.resize(n);
    child.resize(n);

    long i;
    for(i=0; i<n+m-1; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        tt[a-1].push_back(b-1);
        child[b-1]++;
    }

    long root=-1;
    for(i=0; i<n; i++) {
        if(child[i]==0) {
            root=i; break;
        }
    }

    depth.resize(n);
    for(i=0; i<n; i++) {
        depth[i]=-1;
    }
    depth[root]=0;

    par.resize(n);
    for(i=0; i<n; i++) {
        par[i]=-1;
    }

    dfs( root );

    for(i=0; i<n; i++) {
        printf("%ld\n", par[i]+1);
    }
 
    return 0;
}


Measured memory_bytes: 13312
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			
			int[] pArray = new int[n];
//			int[] kArray = new int[n];
			
			int kSum = 0;
			int kMax = 0;
			for(int i = 0 ; i < n ; i++ ) {
				pArray[i] = sc.nextInt();
				
				kSum += pArray[i];
				
				if ( i >= k ) {
					kSum -= pArray[i-k];
				}
//				kArray[i] = kSum;
				
				if ( kSum > kMax ) {
					kMax = kSum;
				}
			}
			
			System.out.println( ((double)kMax + (double)k)/2f );
			
		}
	}
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        for (auto v: x) os << v << ",";
        os << "\b";
    } else os << "[]";
    os << "]";
    return os;
}



int main() {
    FAST;
  //  freopen("in.txt","r",stdin);
    int n;cin>>n;
    if (n==1) {cout << 0; return 0;}
    int W[n],E[n],SW[n],SE[n];
    string s;cin>>s;
    for (int i=0;i<n;i++) {
        if (s[i] == 'E') {
            E[i] = 1;
            W[i] = 0;
        } else {
            E[i] = 0;
            W[i] = 1;
        }
    }
    SE[0]=E[0];SW[0]=W[0];
    for (int i=1;i<n;i++) {
        SE[i] = E[i] + SE[i - 1];
        SW[i] = W[i] + SW[i - 1];
    }
    int m=min(SE[n-1]-SE[0],SW[n-2]);
    for (int i=1;i<n-1;i++){
        m =min (m,SW[i-1]+SE[n-1]-SE[i]);
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 5396
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

low = 1
high = max(A)

while low < high:
    mid = (low + high) // 2

    k = 0
    for a in A:
        v = a // mid
        if a % mid == 0:
            v -= 1
        k += v

    if k <= K:
        high = mid
    else:
        low = mid + 1

print(low)


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int answer = a.at(n - 1) - a.at(0);
    cout << answer << endl;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  string ans = "";
  
  for(ll i=0; i < s.size(); i+=2){
    ans += s[i];
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3736
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll a;cin>>a;
  for(ll i=0;i<s.size();i+=a)cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int value[3][101];
int sum[3][101];
int main() 
{//manpreet
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> value[1][i];
	for (int i = 1; i <= n; i++) cin >> value[2][i];
	for (int i = 0; i <= 2; i++) sum[i][0] = 0;
	for (int i = 0; i <= n; i++) sum[0][i] = 0;
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= n; j++)
			sum[i][j] = max(sum[i][j - 1], sum[i - 1][j]) + value[i][j];
	cout << sum[2][n] << endl;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		Set<String> list = new HashSet<>();
		big:
		for(int i=0;i<str.length();i++){
			for(int ii=i+1;ii<=str.length();ii++){
				if(ii-i>a) continue big;
				list.add(str.substring(i,ii));
			}
		}
		Iterator<String> iter = list.iterator();
		List<String> list1  = new ArrayList<>();
		while(iter.hasNext()){
			String s = iter.next();
			list1.add(s);
		}
		Collections.sort(list1);
		/*Collections.sort(list1, new Comparator<String>(){
			public int compare(String s1, String s2){
				int len1 = s1.length();
				int len2  = s2.length();
				if(len1<len2){
					for(int i=0;i<len1;i++){
						if(s1.charAt(i)<s2.charAt(i)){
							return -1;
						}
						if(s1.charAt(i)>s2.charAt(i)){
							return 1;
						}
					}
					return -1;
				}
				if(len1>len2){
					for(int i=0;i<len2;i++){
						if(s1.charAt(i)<s2.charAt(i)){
							return 1;
						}
						if(s1.charAt(i)>s2.charAt(i)){
							return -1;
						}
					}
					return -1;
				}
				for(int i=0;i<s1.length();i++){
						if(s1.charAt(i)<s2.charAt(i)){
							return -1;
						}
						if(s1.charAt(i)>s2.charAt(i)){
							return 1;
						}
						
					}
				return 0;
			}
		});*/
		
		System.out.println(list1.get(a-1));//return;
		
	}
}

Measured memory_bytes: 25172
def solve(l: list, m: int):
    # sort by price
    l = sorted(l)
    cnt = 0
    mon = 0
    for a, b in l:
        mon += a*b
        cnt += b
        if cnt >= m:
            mon -= (cnt-m)*a
            break
    return mon


def main():
    N, M = map(int, input().split())
    l = []
    for i in range(N):
        a, b = map(int, input().split())
        l.append((a,b))
    print(solve(l, M))


if __name__ == '__main__':
    main()

Measured memory_bytes: 17684
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    string s;
    cin >> s;
    int a, b;
    a = stoi(s.substr(0, 2));
    b = stoi(s.substr(2, 2));

    bool ym = 1 <= b && b <= 12;
    bool my = 1 <= a && a <= 12;

    if (ym && my) {
        cout << "AMBIGUOUS" << endl;
    } else if (ym && !my) {
        cout << "YYMM" << endl;
    } else if (!ym && my) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 h;
    cin >> h;
    auto f = [](auto &&f, i64 x) -> i64 {
        return (x > 1 ? 2 * f(f, x / 2) + 1 : 1);
    };
    cout << f(f, h) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
// ----------------------------------------------------------
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)

static const LL MOD = (LL)1e9 + 7;
static const LL INF = (LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;

	cin >> N;

	cout << N*N*N << endl;


	return 0;

}

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

using namespace std;

typedef long long ll;
const int M=1e6;
vector<ll> e[M];
ll w[M];
ll par[M];
ll root(ll x)
{
        if(par[x]==-1) return x;
        return par[x]=root(par[x]);
}
bool unite(ll x, ll y){
        x=root(x);
        y=root(y);
        if(x==y) return 0;
        par[x]=y;
        return 1;
}
void dfs(ll v, ll p)
{
        for(auto i:e[v])
        {
                if(i==p) continue;
                dfs(i,v);
                if(w[i])
                {
                         cout<<i<<" "<<v<<endl;
                         w[i]^=1;

                }
                else
                {
                        cout<<v<<" "<<i<<endl;
                        w[v]^=1;
                }
        }
}
int main()
{
        memset(par,-1,sizeof par);
        ll n,m,x,y;
        cin>>n>>m;
        if(m&1)
        {
                cout<<-1;
                return 0;
        }
        for(int i=0;i<m;i++)
                {
                        cin>>x>>y;
                        
                        if(unite(x,y))
                        {
                        e[x].push_back(y);
                        e[y].push_back(x);
                        }
                        else
                        {
                                cout<<x<<" "<<y<<endl;
                                w[x]^=1;
                        }
                        
                }
        dfs(1,-1);

}





Measured memory_bytes: 46080
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		try (Scanner sc = new Scanner(System.in);) {
			int a = Integer.parseInt(sc.next());

			if (a < 1200) {
				System.out.println("ABC");
			} else if (a < 2800) {
				System.out.println("ARC");
			} else if (a >= 2800) {
				System.out.println("AGC");
			}
		}

	}
}


Measured memory_bytes: 21712
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int dh[4] = {0, 1, 0, -1};
const int dw[4] = {1, 0, -1, 0};
const int INF = 1e9;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    
    auto bfs = [&] (int sh, int sw) {
        if (S[sh][sw] == '#') return -1;
        vector<vector<bool>> seen(H, vector<bool>(W, false));
        vector<vector<int>> dist(H, vector<int>(W, INF)); dist[sh][sw] = 0;
        queue<pair<int, int>> que;
        que.emplace(sh, sw);
        int ret = -1;
        while (!que.empty()) {
            int h, w; tie(h, w) = que.front(); que.pop();
            if (seen[h][w]) continue;
            seen[h][w] = true;
            for (int i = 0; i < 4; i++) {
                int nh = h + dh[i], nw = w + dw[i];
                if (nh < 0 || nw < 0 || H <= nh || W <= nw) continue;
                if (S[nh][nw] == '#') continue;
                if (seen[nh][nw]) continue;
                dist[nh][nw] = dist[h][w] + 1;
                chmax(ret, dist[nh][nw]);
                que.emplace(nh, nw);
            }
        }
        
        return ret;
    };
    
    int ans = 0;
    
    for (int h = 0; h < H; h++) for (int w = 0; w < W; w++) {
        int res = bfs(h, w);
        chmax(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256