akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    string A[1000];
    int dx[4] = {0, -1, 1, 0}, dy[4] = {1, 0, 0, -1};

    for(int i=0;i<H;i++) cin >> A[i];

    queue<pair<int,pair<int,int>>> Q;
    int ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j] == '#'){
                Q.push({0, {i, j}});
            }
        }
    }


    while(!Q.empty()){
        auto tp = Q.front();
        Q.pop();
        for(int i=0;i<4;i++){
            int x = tp.second.first + dx[i], y = tp.second.second + dy[i];
            if(x < 0 || x >= H || y < 0 || y >= W || A[x][y] == '#') continue;
            Q.push({tp.first+1, {x, y}});
            ans = max(ans, tp.first+1);
            A[x][y] = '#';
        }
    }

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

Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("input.txt","r",stdin);freopen("ans.txt","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    lli t,d,sum=0;
    cin>>t>>d;
    while (t--)
    {
        lli a,b;
        cin>>a>>b;
        ld dis=sqrt(a*a+b*b);
        if (dis<=d)
        sum++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3680
def abs(a,b):
    return a-b if a>b else b-a

N=int(input())
A=list(map(int,input().split(' ')))
A.append(0)
skip = []
total = 0
prev = 0
for i in range(len(A)-1):
    diff = abs(prev,A[i])
    total += diff
    skip.append(diff + abs(A[i],A[i+1]) - abs(prev,A[i+1]))
    prev = A[i]
total += abs(A[-1],A[-2])
for i in range(len(skip)):
    print(total - skip[i])

Measured memory_bytes: 61660
#include<stdio.h>
int main(void) {
  int X[4],Y[4];
  scanf("%d %d %d %d",&X[0],&Y[0],&X[1],&Y[1]);
  X[2]=X[1]+Y[0]-Y[1];
  Y[2]=Y[1]-X[0]+X[1];
  X[3]=X[2]+Y[1]-Y[2];
  Y[3]=Y[2]-X[1]+X[2];
  printf("%d %d %d %d\n",X[2],Y[2],X[3],Y[3]);
  return 0;
}

Measured memory_bytes: 128
#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;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;
    return 0;
}

Measured memory_bytes: 256
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
H=acinput()

res="Yes"
H[0]=min(0,H[0])
for i in range(1,N):
    if H[i-1]<H[i]:
        H[i]-=1
    
    if H[i-1]>H[i]:
        res="No"
        break

print(res)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,x;
  cin>>n;
  map<int,int> m;
  for(int i=0;i<n-1;i++){
    cin>>x;
    m[x]++;
  }
  for(int i=1;i<=n;i++) cout<<m[i]<<"\n";
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 321;

int a[N][N], p[N], h[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", a[i]+j);
    }
  }
  int ans = 2e9;
  set<int> s;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      ++h[a[j][p[j]]];
    }
    int hi = max_element(h, h+m+1)-h;
    s.insert(hi);
    ans = min(ans, h[hi]);
    for (int j = 0; j < n; ++j) {
      while (s.count(a[j][p[j]])) ++p[j];
    }
    for (int j = 0; j <= m; ++j) h[j] = 0;
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
    n = abs(n);
    if(n < 10) return 1;
    elif(n < 100) return 2;
    elif(n < 1000) return 3;
    elif(n < 10000) return 4;
    elif(n < 100000) return 5;
    elif(n < 1000000) return 6;
    elif(n < 10000000) return 7;
    elif(n < 100000000) return 8;
    elif(n < 1000000000) return 9;
    else return 10;
}


int main() {
    io();
    
    ull n;
    cin >> n;
    ull total = 0;
    fori(i, n) {
        if((i+1) % 5 != 0 && (i+1) % 3 != 0) {
            total += (i+1);
        }
    }
    cout << total;
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    bool color[8] = {};
    int free = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a >= 3200) free++;
        else color[a / 400] = true;
    }

    int cnt = 0;
    rep(i, 8) {
        if (color[i]) cnt++;
    }

    int mn = max(cnt, 1);
    int mx = min(cnt + free, n);

    cout << mn << " " << mx << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		ArrayList<Integer> ai = new ArrayList<Integer>();
 		ArrayList<Integer> bi = new ArrayList<Integer>();
 		for(int i = 0;i<n;i++){
 			StringTokenizer st = new StringTokenizer(bf.readLine());
 			ai.add(Integer.parseInt(st.nextToken()));
 			bi.add(Integer.parseInt(st.nextToken()));
 		}
 		Collections.sort(ai);
		Collections.sort(bi);
 		if (n%2 == 1){
 			
 			out.println(bi.get(bi.size()/2)-ai.get(ai.size()/2)+1);
 			out.close();
 		}
 		else{
 			double b = (ai.get(ai.size()/2) + ai.get(ai.size()/2-1)+0.0)/2;
 			double c = (bi.get(bi.size()/2) + bi.get(bi.size()/2-1)+0.0)/2;
 			out.println((int)(2*(c-b)+1));
 			out.close();
 		}

	}

}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 55688
#include<iostream>
#include<vector>
using namespace std;
int main(void){
	int n,lw;
	cin>>n>>lw;
	vector<int> v(n,0),w(n,0);
	vector<vector<int> > val(lw+1,vector<int>(2,0));
	for(int i=0;i<n;i++){
		cin>>v[i]>>w[i];
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<=lw;j++){
			if(j>=w[i])
			val[j][1]=max(val[j][0],val[j-w[i]][0]+v[i]);
			else
			val[j][1]=val[j][0];
		}
		for(int j=0;j<=lw;j++){
			val[j][0]=val[j][1];
		}
	}
	cout<<val[lw][0]<<endl;
	

	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i = 0 ; i < n ; i++){
		cin>>a[i];
	}
	vector<int> res(n);
	res[0] = 0;
	res[1] = abs(a[1]-a[0]);
	for(int i = 2 ; i < n ; i++){ 
		int x = INT_MAX;
		for(int j = 1 ; j <=k && i-j>=0 ; j++){
			x = min(x , res[i-j]+abs(a[i]-a[i-j]));
		}
		res[i] = x;
	}
	cout<<res[n-1];
}

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

const int maxn = 100 + 5;

int ch[maxn][maxn];

int main(){
	char c;
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		int u,k,v;
		scanf("%d%d",&u,&k);
		for(int j = 1;j <= k; j++){
			scanf("%d",&v);
			ch[u][v] = 1;
		}
	}
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= n; j++){
			if(j != 1)printf(" ");
			printf("%d",ch[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3216
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int x;
	cin >> x;
	int ans=0;
	ans += (x / 500) * 1000;
	x= x % 500;
	ans += (x / 5)*5;
	print(ans);
}

Measured memory_bytes: 256
n = gets.to_i
ps = gets.split.map(&:to_i)

s_ps = ps.sort

cnt = 0
(0..n-1).each do |i|
  if ps[i] != s_ps[i]
    cnt += 1
  end
end

if cnt <= 2
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 1788
#include<stdio.h>

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

       if(n<=104)
    printf("0\n");
  else if(n<=134)
    printf("1\n");
  else if(n<=164)
    printf("2\n");
  else if(n<=188)
    printf("3\n");
  else if(n<=194)
    printf("4\n");
  else
    printf("5\n");
  return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>
#include<stdlib.h>

int cmp(const int *a,const int *b){
  return *a-*b;
}
int main(){
  int n,l[222];
  scanf("%d",&n);
  n*=2;
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  qsort(l,n,4,cmp);
  int sum=0;
  for(int i=0;i<n;i+=2){
    sum+=l[i];
  }
  printf("%d",sum);
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-       
import math
def is_prime(x):
    if(x%2==0):return 0
    else:
        a = 3
        while(a<=math.sqrt(x)):
            if(x%a==0):return 0
            a += 2
    return 1
 
q = int(input())
MAX = 10**5+2
prime = [0 for i in range(MAX)]
alike = [0 for i in range(MAX)]
num = [0 for i in range(MAX)]
prime[2],prime[3] = 1,1
for i in range(4,MAX):
    prime[i] = is_prime(i)
for i in range(1,MAX-1,2):
    if(prime[i]==1 and prime[(i+1)//2]==1):
        alike[i] = 1
    num[i] = num[i-2]+alike[i]
    num[i+1] = num[i]
for i in range(q):
    l, r = list(map(int,input().split()))
    print(num[r]-num[l-1])

Measured memory_bytes: 59312
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll arr[n];
  fi(0, n) {
    cin >> arr[i];
    arr[i] = abs(m - arr[i]);
  }

  ans = arr[0];
  fi(1, n) {
    ans = gcd(ans, arr[i]);
    if(ans == 1)
      break;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>


void insertionSort(int a[],int n){
    int i,j,v;
    for(i=1;i<n;i++){
        v=a[i];          //v:未ソート部分の先頭
        j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];    //vより大きい要素を後方へ移動
            j--;
        }
        a[j+1]=v;
    }
}

int main(void){
    int n,i,ans;
    scanf("%d",&n);
    int d[n];
    for(i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    insertionSort(d,n);
    ans=d[n/2]-d[n/2-1];
    printf("%d\n",ans);
    //printf("%d %d",d[n/2+1]);
    return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
s = input()

unhappiness = 0
m1, m2 = 0, 0

if s[0] == 'L':
    unhappiness += 1
if s[-1] == 'R':
    unhappiness += 1
i = 0
while i < n and s[i] == 'L':
    i += 1
while i < n:
    h = i
    while i < n and s[i] == 'R':
        i += 1
    if i == n:
        break
    while i < n and s[i] == 'L':
        i += 1
    if h != 0 and i != n:
        m2 += 1
    elif h != 0 or i != n:
        m1 += 1
    unhappiness += 2

if  k <= m2:
    unhappiness -= 2 * k
else:
    unhappiness -= 2 * m2
    k -= m2
    if m1 == 2:
        k -= 1
        unhappiness -= 2
    if k > 0:
        unhappiness = 1
print(n-unhappiness)

Measured memory_bytes: 69284
#include <stdio.h>
#include <math.h>
  
int main() {
	int n,tmp;
	double dev,avg,sum,sum2;
	//printf("check %d\n",cont);
	while(1){
	    //cont += 1;
		//printf("check %d\n",cont);
		sum = 0;
		sum2 = 0;
		tmp = 0;
		scanf("%d",&n);
		if(n == 0) break;
		for (int i = 0; i < n; i++) {
			scanf("%d",&tmp);
			sum  += tmp;
			sum2 += tmp*tmp;
			}
	avg = sum/n;
	dev = sqrt(sum2/n - avg*avg);
	printf("%.8f\n",dev);
	}
}


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

int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int sum=0;
    if(n<k){
        cout << n*x << endl;
    }
    else if(n>=k){
        cout << k*x + (n-k)*y << endl; 
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int n,m,q;
//vector<vector<int>> A(0,vector<int>(n,0));
vector<int> A;
vector<vector<int>> number;
int maxnum=0;
vector<int>a,b,c,d;


in dp(int r,int x){
  in ans=0;
  if(x==n){
    
    in y=0;
    rep(i,q){
      if(A.at(b.at(i)-1)-A.at(a.at(i)-1)==c.at(i))
        y+=d.at(i);
    }
    return y;
  }
  for(int i=r;i<=m;i++){
    A.at(x)=i;
    ans=max(dp(i,x+1),ans);
  }
  return ans;
}

int main(){
  cin>>n>>m>>q;
  A.resize(n);
  a.resize(q);b.resize(q);c.resize(q);d.resize(q);
  rep(i,q)
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
  cout<<dp(1,0)<<endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;

int main(int argc, char* argv[])
{
	using COST_T = ll;
	using NODE_T = int;
	using PAIR_T = pair<COST_T, NODE_T>;

	struct Edge
	{
		NODE_T node;
		COST_T cost;
	};

	const int MAX_NODE_INDEX = 99;
	const COST_T INF_DIST = linf;
	vector<Edge> edges[MAX_NODE_INDEX + 1];
	COST_T dist_ar[MAX_NODE_INDEX + 1];

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int u, k;
		scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++) {
			int v, c;
			scanf("%d%d", &v, &c);
			edges[u].push_back( { v, c } );
		}
	}

	priority_queue<PAIR_T, vector<PAIR_T>, greater<PAIR_T>> pq;
	fill(dist_ar, dist_ar + MAX_NODE_INDEX + 1, INF_DIST);
	NODE_T st = 0;
	dist_ar[st] = 0;
	pq.push(PAIR_T(0, st));
	while(!pq.empty()) {
		COST_T temp_cost = pq.top().first;
		NODE_T node_index = pq.top().second;
		pq.pop();
		if (dist_ar[node_index] < temp_cost) continue;
		for (int next_list_index = 0; next_list_index < (int)edges[node_index].size(); next_list_index++) {
			COST_T new_cost = temp_cost + edges[node_index][next_list_index].cost;
			NODE_T next_index = edges[node_index][next_list_index].node;
			if (dist_ar[next_index] >= new_cost) {
				dist_ar[next_index] = new_cost;
				pq.push(PAIR_T(new_cost, next_index));
			}
		}
	}

	for (int i = 0; i < N; i++) {
		printf("%d %lld\n", i, dist_ar[i]);
	}

	return 0;
}

Measured memory_bytes: 3256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<tuple>
#include<utility>
#include<stdlib.h>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	int n, num = 0, ans = 100;
	cin >> n;
	vector<int> w(n);
	rep(i, 0, n) {
		cin >> w[i];
	}
	int s1 = 0, s2 = 0;
	rep(i, 0, n) {
		s1 += w[i];
	}
	rep(i, 0, n) {
		s1 -= w[n - 1 - i];
		s2 += w[n - 1 - i];
		num = abs(s1 - s2);
		if (num < ans) {
			ans = num;
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
  int n,y;
  cin >> n >> y;
  bool flag = false;
  for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1-i;j++){
          int k = n-i-j;
          if(i*10000+j*5000+k*1000==y){
              cout << i << " " << j << " " << k << endl;
              return 0;
          } 
      }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
print('U'*y+'R'*x+'D'*y+'L'*x+'L'+'U'*(y+1)+'R'*(x+1)+'DR'+'D'*(y+1)+'L'*(x+1)+'U')


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int kMod = 11;

int main(void){
    for(string num; cin >> num, num != "0";){
        vvi dp(num.size(), vi(kMod));

        rep(i, num.size()){
            int cur = num[i] - '0';
            if(cur != 0) dp[i][cur]++;

            if(i == 0) continue;

            rep(j, kMod){
                dp[i][(j * 10 + cur) % kMod] += dp[i - 1][j];
            }
        }

        int res = 0;
        rep(i, num.size()){
            res += dp[i][0];
        }

        cout << res << endl;
    }

	return 0;
}

Measured memory_bytes: 8132
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
 
#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars;h],
  	}
  
  	let mut result = 0;
  	for row_mask in 0..(1 << h) {
      for column_mask in 0..(1 << w) {
          let mut count = 0;
          for row in  0..h {
              for column in 0..w {
                if ((row_mask >> row) & 1) == 0 && ((column_mask >> column) & 1) == 0 && c[row][column] == '#' {
                  count += 1;
                }
              }
          }

          if count == k {
            result += 1;
          }
      }
  	}
	println!("{}", result);
}

Measured memory_bytes: 2204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        long sum = 0;
        for (int i = 0; i < s.length; i++) {
            int x = Integer.parseInt(s[i]);
            sum += x;
        }
        if (sum % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

int main() {
  int n;
  cin >> n;
  double sum = 0;
  rep(i,n) {
    int a;
    cin >> a;
    sum += 1.0/a;
  }
  double ans = 1/sum;
  printf("%.10f\n", ans);
  return 0;
}


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

int n,m,sol;
int d[100005],dp[100005];
vector<int> G[100005];
queue<int> Q;

int main(){

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

        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        ++d[y];

    }

    for(int i=1;i<=n;i++)
        if(d[i]==0)
            Q.push(i);

    while(!Q.empty()){

        int x=Q.front();
        sol=max(sol,dp[x]);
        Q.pop();

        for(int i=0;i<G[x].size();i++){

            dp[G[x][i]]=max(dp[G[x][i]],dp[x]+1);

            --d[G[x][i]];

            if(d[G[x][i]]==0)
                Q.push(G[x][i]);

        }

    }

    cout<<sol;

}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define endl "\n"

int main()
{
	IOS;
	int n,c=0;
	cin >>n;
	int arr[n],arr1[n];
	for(int i=0;i<n;i++)
	{
		cin >>arr[i];
		arr1[i]=arr[i];
	}
	sort(arr1,arr1+n);
	for(int i=0;i<n;i++)
	{
		if((arr[i]^arr1[i])!=0)
			c++;//cout <<(arr[i]^arr1[i])<<" "<<i<<endl;
	}
	if(c==2 || c==0)
		cout <<"YES";
	else
		cout <<"NO";
	cout <<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		Console.WriteLine("{0}",1-(1.0*(n/2)/n));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

using int_ = int;
#define int int_least64_t

const int mod = 1e9+7;

unsigned long long log2i(unsigned long long n) {
  return CHAR_BIT*sizeof(n) - __builtin_clzll(n);
}
constexpr uint32_t mul(uint32_t a, uint32_t b, uint32_t mod) {
  return uint64_t(a)*b%mod;
}
template <typename F> constexpr uint32_t mul(uint32_t a, uint32_t b) {
  return mul(a, b, F::mod);
}
template <typename F> uint32_t add(uint32_t a, uint32_t b) {
  auto res = a+b; return res < F::mod ? res : res-F::mod;
}
template <typename F>
uint32_t sub(uint32_t a, uint32_t b) { return add<F>(a, F::mod-b); }
constexpr uint64_t cpowm(uint64_t base, uint64_t exp, uint64_t mod) {
  return !exp ? 1 : exp%2
    ? mul(base, cpowm(mul(base, base, mod), exp/2, mod), mod)
    : cpowm(mul(base, base, mod), exp/2, mod);
}
uint32_t powm(uint32_t base, uint32_t exp, uint32_t mod) {
  uint32_t res=1;
  for (; exp; exp>>=1, base = mul(base, base, mod))
    if (exp&1)
      res = mul(res, base, mod);
  return res;
}
template <typename F>
uint32_t powm(uint32_t base, uint32_t exp) { return powm(base, exp, F::mod); }
template <typename F> uint32_t inv(uint32_t a) {
  return powm(a, F::mod-2, F::mod);
}
constexpr uint64_t cmodinv(uint64_t a, uint64_t mod) {
  return cpowm(a, mod-2, mod);
}

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  
  int a, b; cin >> a >> b;
  int n = a+b;

  const int half=500000004;
  
  vector<int> inv_powof2;
  inv_powof2.push_back(1);
  for (int i=0; i<=n; ++i)
    inv_powof2.push_back(inv_powof2.back()*half%mod);

  vector<int> fac, fac_inv;
  fac.push_back(1);
  for (int i=1; i<=n; ++i)
    fac.push_back(mul(fac.back(), i, mod));
  for (auto x : fac)
    fac_inv.push_back(cmodinv(x, mod));

  auto nCr = [&](int n, int r) {
               return fac[n]*fac_inv[r]%mod*fac_inv[n-r]%mod;
             };

  vector<int> prefixsum(n+1);
  
  for (int i=1; i<=a; ++i) {
    int prob = nCr(n-i-1, a-i)*inv_powof2[n-i]%mod;
    prefixsum[0] += half*prob%mod;
    prefixsum[n-i] -= half*prob%mod;
    prefixsum[n-i] += prob;
    prefixsum[n] -= prob;
    // for (int j=n-i; j<n; ++j)
    //   p[j] += prob;
    // for (int j=0; j<n-i; ++j)
    //   p[j] += half*prob%mod;
  }
  
  for (int i=1; i<=b; ++i) {
    int prob = nCr(n-i-1, b-i)*inv_powof2[n-i]%mod;
    prefixsum[0] += half*prob%mod;
    prefixsum[n-i] -= half*prob%mod;
    prefixsum[n-i] += 0*prob;
    prefixsum[n] -= 0*prob;
    // for (int j=n-i; j<n; ++j)
    //   p[j] += 0*prob;
    // for (int j=0; j<n-i; ++j)
    //   p[j] += half*prob%mod;
  }
  vector<int> p;
  partial_sum(prefixsum.begin(), prefixsum.end(), back_inserter(p));
  assert(p.back()==0);
  p.pop_back();
  for (auto x : p)
    cout << x%mod << '\n';
}



Measured memory_bytes: 10712
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, Q; cin >> N >> Q;

	vector<pair<int, pii> > eve;
	REP(i, N) {
		int a, b, c; cin >> a >> b >> c;
		eve.push_back(make_pair(a - c, pii(1, c)));
		eve.push_back(make_pair(b - c, pii(-1, c)));
	}
	SORT(eve);
	set<int> S;
	int k = 0;
	REP(i, Q) {
		int D; cin >> D;
		while (k < (int)eve.size() && eve[k].first <= D) {
			if (eve[k].second.first == 1) {
				S.emplace(eve[k].second.second);
				//S.push(eve[k].second.second);
			}
			else {
				S.erase(S.find(eve[k].second.second));
			}
			k++;
		}
		int ans = *S.begin();
		if (ans == 0)ans--;
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 20840
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

int32_t main(){
   boost;
   IO();

   int X,K,D; cin>>X>>K>>D;

   X=abs(X);

   if(X/D>K){
   	cout << X-D*K << endl;
   }
   else{
   	int ans=INF;
   	if((K-X/D)%2==0) ans=min(ans,X%D);
   	if((K-X/D-1)%2==0) ans=min(ans,D-X%D);
   	cout << ans << endl;
   }


	

   return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

int main()
{
	int N, input;
	map<int, bool> m;
	scanf("%d", &N);

	bool isDistinct = true;
	rep(i, N) {
		scanf("%d", &input);
		if (m[input]) {
			isDistinct = false;
			break;
		}
		m[input] = true;
	}

	printf("%s\n", isDistinct ? "YES" : "NO");
	return 0;	
}

Measured memory_bytes: 9600
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int count2(int n) {
    int ret = 0;
    while (n > 0 && n % 2 == 0) {
        n /= 2;
        ret++;
    }
    return ret;
}

void main() {
    readint;
    auto a = readints;
    auto b = a.map!count2;

    int ans = b.reduce!((a, b) => min(a, b));
    writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int main() {
    
    
    int h, w, n;
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    string s, t;
    cin >> s >> t;
    
    sr--;
    sc--;
    int ml = 0;
    int mr = w - 1;
    int mu = 0;
    int md = h - 1;
    
    for (int i = n - 1; i >= 0; --i)
    {
        if (t[i] == 'L')
        {
            mr = min(mr + 1, w - 1);
        }
        if (t[i] == 'R')
        {
            ml = max(ml - 1, 0);
        }
        if (t[i] == 'U')
        {
            md = min(md + 1, h - 1);
        }
        if (t[i] == 'D')
        {
            mu = max(mu - 1, 0);
        }
        
        if (s[i] == 'L')
        {
            ml++;
        }
        if (s[i] == 'R')
        {
            mr--;
        }
        if (s[i] == 'U')
        {
            mu++;
        }
        if (s[i] == 'D')
        {
            md--;
        }
        
        if (mr < ml || md < mu)
        {
            cout << "NO" << endl;
            return 0;
        }
        
    }
    
    if (mr >= sc && ml <= sc && md >= sr && mu <= sr)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	vector<int>dp(n+3,0);
	rep(i,n+2){
		dp[i]=i;
	}
	int at=1;
	while(at<= n){
		at*=6;
		for(int i=0;i<=n-at;i++){
			chmin(dp[i+at],dp[i]+1);
		}
	}
	at=1;
	while (at <= n)
	{
		at *= 9;
		for (int i = 0; i <= n - at; i++)
		{
			chmin(dp[i + at], dp[i] + 1);
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
/*
[abc130] B - Bounding
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100;

int N, X;
int L[MAX_N + 1];

ll solve() {
    int d = 0;
    int ans = 0;
    for (int i = 0; i <= N && d <= X; i++) {
        ans++;
        d += L[i];
    }
    return ans;
}

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
                   JAY KHODIYAR MAA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.      IIT PATNA      ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    fio;
    double l;
    cin>>l;
    l/=3.0;
    cout<<setprecision(9)<<fixed<<(l)*(l)*(l);
    
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        if (n % 111 == 0) {
            System.out.println(n);
        } else {
            System.out.println(111 * (n / 111 + 1));
        }
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> s(H,vector<char>(W));
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      cin>>s.at(y).at(x);
    }
  }
  
  bool flg=true;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      if(s.at(y).at(x)=='#'){
        if(y>0 && s.at(y-1).at(x)=='#'){
          continue;
        }
        if(x>0 && s.at(y).at(x-1)=='#'){
          continue;
        }
        if(y<H-1 && s.at(y+1).at(x)=='#'){
          continue;
        }
        if(x<W-1 && s.at(y).at(x+1)=='#'){
          continue;
        }
        flg=false;
        break;
      }
      if(flg==false){
        break;
      }
    }
  }
  if(flg){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
n,k = map(int,input().split())
a = list(map(int,input().split()))
counter = Counter(a)
cnt = 0

c_value= list(counter.values())
nl = len(c_value)
if nl <= k:
  print(0)
  sys.exit()
  
c_value.sort()
#print(c_value)
do_num = nl - k
for i in range(do_num):
  cnt += c_value[i]
print(cnt)

Measured memory_bytes: 35140
#include <bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long a;
	string s;
	scanf("%lld",&a);
	cin>>s;
	unsigned long long x= (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'); 
	printf("%llu",x*a/100);
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 2001; i <= 2010; ++i)
    {
        x = x * r - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i + 1]) {
      S = S.substr(0,i) + S.substr(i + 1,S.size() - 1 - i);
      i--;
    }
  }
  cout << S.size() - 1 << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<int, int> P;

int main() {
    int H, W, D;
    cin >> H >> W >> D;

    vector<P> A(H * W + 1);
    rep(i, H) {
        rep(j, W) {
            int a;
            cin >> a;
            A[a] = make_pair(i, j);
        }
    }

    vector<int> S(H * W + 1);
    for (int i = D + 1; i <= H * W; i++)
        S[i] = S[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second);

    int Q;
    cin >> Q;
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << S[r] - S[l] << endl;
    }
}

Measured memory_bytes: 2176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	cs := []rune(getString())
	red, blue := count(cs)

	fmt.Println(min(red, blue) * 2)
}

func count(cs []rune) (int, int) {
	color := make(map[rune]int, 2)
	for _, c := range cs {
		color[c]++
	}

	return color['0'], color['1']
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := 200001
	sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    ll A[N];
    REP(i, N) cin >> A[i];

    const int nMap = 31;
    map<ll, ll> m[nMap];
    // m[0]: < 2^0=1
    // m[1]: < 2^1=2
    // ... m[30]: < 2^30

    REP(i, N) {
        ll t = A[i];
        ll j = 0;
        while(t != 0) {
            t /= 2;
            j++;
        }
        if (m[j].find(A[i]) == m[j].end()) {
            m[j][A[i]] = 1;
        }
        else {
            m[j][A[i]]++;
        }
    }

    int nTickets = M;
    for (int i = nMap - 1; i > 0; --i) {
        for (auto itr = m[i].rbegin(); itr != m[i].rend(); ++itr) {
            ll t = itr->first;
            ll count = itr->second;
            if (count <= nTickets) {
                m[i][t] = 0;
                if (m[i - 1].find(t / 2) == m[i - 1].end()) {
                    m[i - 1][t / 2] = count;
                }
                else {
                    m[i - 1][t / 2] += count;
                }
            }
            else {
                m[i][t] = count - nTickets;
                if (m[i - 1].find(t / 2) == m[i - 1].end()) {
                    m[i - 1][t / 2] = nTickets;
                }
                else {
                    m[i - 1][t / 2] += nTickets;
                }
            }
            nTickets -= count;
            if (nTickets <= 0) break;
        }
        if (nTickets <= 0) break;
    }

    ll cost = 0;
    for (int i = 1; i < nMap; ++i) {
        for (auto itr = m[i].begin(); itr != m[i].end(); ++itr) {
            cost += (itr->first) * (itr->second);
        }
    }

    cout << cost << endl;

    return 0;
}


Measured memory_bytes: 12800
str = gets.split
H,W = str[0].to_i, str[1].to_i
pmax = Array.new(W,0)
nmax = Array.new(W,0)
now = Array.new(W,0)
rnow = Array.new(W,0)
max = 0

i = 0
j = 0
k = 0
l = 0
x = 0
while i < H
  str = gets.chomp
  j = 0
  k = 0
  l = 0
  while j < W
    if str[j] == "."
      k += 1
      rnow[j] += 1
      if j == W-1
        x = l
        while x < l+k
          now[x] = k
          nmax[x] = now[x] > nmax[x] ? now[x] : nmax[x]
          x += 1
        end
      end
    else
      x = l
      while x < l+k
        now[x] = k
        nmax[x] = now[x] > nmax[x] ? now[x] : nmax[x]
        x += 1
      end
      now[j] = 0
      l = j+1
      k = 0
      pmax[j] = pmax[j] > nmax[j] + rnow[j] ? pmax[j] : nmax[j] + rnow[j]
      nmax[j] = 0
      rnow[j] = 0
    end
    j += 1
  end
  i += 1
end

j = 0
while j < W
  pmax[j] = pmax[j] > nmax[j] + rnow[j] ? pmax[j] : nmax[j] + rnow[j]
  max = pmax[j] > max ? pmax[j] : max
  j += 1
end

puts max-1

Measured memory_bytes: 3196