akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <string.h>

using namespace std;

int w[1100];
int r[1100];
bool dp[1100][1100];
int used[1100];



int main(void)
{
	int n;
	int max;
	int maxr;
	int sumr,sumw;
	int dis;

	int i1,i2;

	while(1){
		cin>>n;
		if(n==0) break;

		max=0;
		sumr=0;
		sumw=0;
		maxr=-1;

		memset(w,0,sizeof(w));
		memset(r,0,sizeof(r));

		for(i1=0;i1<n;i1++){
			cin>>r[i1]>>w[i1];

			if(max<r[i1]){
				sumr+=max;
				max=r[i1];
				maxr=i1;
			}
			else sumr+=r[i1];

			sumw+=w[i1];
		}

		//cout<<max<<" "<<sumr<<endl;

		if(sumr>=max) {
			sumr+=max;
			cout<<sumr+sumw<<endl;
		}
		else{
			dis=max-sumr;

			for(i1=0;i1<1100;i1++){
				for(i2=0;i2<1100;i2++){
					dp[i1][i2]=false;
				}
			}

			if(w[0]<=dis && 0!=maxr) dp[0][w[0]]=true;

			for(i1=1;i1<n;i1++){
				for(i2=0;i2<=dis;i2++){
					if(dp[i1-1][i2]==true){
						dp[i1][i2]=true;
						if((i2+w[i1])<=dis && i1!=maxr) dp[i1][i2+w[i1]]=true;	
	 				}
				}
				if(w[i1]<=dis && i1!=maxr) dp[i1][w[i1]]=true;
			}

			for(i1=dis;i1>0;i1--){
				if(dp[n-1][i1]==true) break;
			}
			//cout<<dis<<" "<<i1<<" "<<sumr+sumw+max<<endl;
			dis-=i1;

			cout<<sumr+sumw+dis+max<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 200005;
vector<int> a(n);
vector<vector<int>> tree(n,vector<int>());

struct SegmentTree{
        int n;
        vector<ll> node;
        
        SegmentTree(vector<ll> v){
                int sz = v.size();
                n = 1;
                while(n < sz) n *= 2;
                node.resize(2*n-1,0);
                for(int i=0;i<sz;i++) node[i+n-1] = v[i];
                for(int i=n-2;i>=0;i--) node[i] = max(node[2*i+1],node[2*i+2]);
        }
        
        void update(int x,ll val){
                x += n-1;
                node[x] = val;
                while(x > 0){
                        x = (x-1)/2;
                        node[x] = max(node[2*x+1],node[2*x+2]);
                }
        }
        
        ll getmax(int a,int b,int k=0,int l=0,int r=-1){
                if(r < 0) r = n;
                if(r <= a || b <= l) return 0;
                if(a <= l && r <= b) return node[k];
                ll vl = getmax(a,b,2*k+1,l,(l+r)/2);
                ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
                return max(vl,vr);
        }
};

vector<ll> ans(n);
vector<ll> t(n,0);
SegmentTree dp(t);

void dfs(int i,int p=-1){
    ll before = dp.node[a[i]+dp.n-1];
    dp.update(a[i], dp.getmax(0,a[i]) + 1);
    ans[i] = dp.getmax(0,dp.n+1);
    for(int c:tree[i]){
        if(c==p) continue;
        dfs(c,i);
    }
    dp.update(a[i],before);
    return;
}

int main(){
    cin >> n;
    vector<pll> temp(n);
    rep(i,n){
        cin >> temp[i].first;
        temp[i].second = i;
    }
    sort(temp.begin(),temp.end());
    int j = 1;
    rep(i,n){
        a[temp[i].second] = j;
        if(i<n-1){
            if(temp[i].first == temp[i+1].first);
            else ++j;
        }
    }
    
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        --u;--v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    dfs(0);
    
    rep(i,n){
        cout << ans[i] << '\n';
    }

    return 0;
}

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

xset = set([])

for i in range(10000):
    xset.add(i**5)
    xset.add(-i**5)

for xx in xset:
    if xx+x in xset:
        a5 = xx+x
        b5 = xx

if a5 < 0:
    a = -pow(-a5, 0.2)
else:
    a = pow(a5, 0.2)

if b5 < 0:
    b = -pow(-b5, 0.2)
else:
    b = pow(b5, 0.2)

print(int(a), int(b))

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


int main() {
	int n,N=1,a,b;
	vector<int> v;
	cin >> n;
	for(int i=0;i<n;i++){
		N*=2;
	}
	n=N/2;
	
	for(int i=0;i<n;i++){
		cin >> a >> b;
		v.push_back(abs(a-b));
	}
	
	while(n){
		vector<int> v2;
		for(int i=0;i<n;i+=2){
			v2.push_back(abs(v[i]-v[i+1]));
		}
		v=v2;
		if(v2.size()==1){
			cout << v2[0] << endl;
			return 0;
		}
		n/=2;
	}
	
	return 0;
}
 

Measured memory_bytes: 1272
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a,ans;
vector<int> v;
int main(void){
    cin>>n;
    cin>>a;
    v.push_back(a);
    for(int i=1;i<n;i++){
        cin>>a;
        int L=lower_bound(v.begin(),v.end(),a)-v.begin();
        if(L==0){
            v.insert(v.begin(),a);
        }
        else v[L-1]=a;
    }
    cout<<v.size()<<endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int main(){
    int H, W;
    cin >> H >> W;
    string s[H];
    rep(i, H) cin >> s[i];
    rep(i, W + 2) cout << '#';
    cout << endl;
    rep(i, H) cout << '#' << s[i] << '#' << endl;
    rep(i, W + 2) cout << '#';
    cout << endl;
    return 0;
}


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

#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  
  int n, k, count = 0;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  Vsort(p);
  rep(i, k) count += p[i];
  cout << count;

  return 0;
}


Measured memory_bytes: 3636
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
# 文字列には注意


def main():
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]
    if n >= sum(a):
        print(n - sum(a))
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10224
n,m = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.sort()
dif_list = []
for i in range(1,m):
  dif_list.append(x_list[i] - x_list[i-1])
  
dif_list.sort(reverse = True)
if n - 1 >= len(dif_list):
  print(0)
else:
  print(sum(dif_list[n-1:]))

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; string s; cin>>n>>k>>s; s+='-';
	vector<int>v(1,0);
	char c=s.front();
	if(c=='0')v.emplace_back(0);
	for(int i=1,cnt=1;i<=n;++i){
		if(c==s.at(i)){
			++cnt;
		}
		else{
			v.emplace_back(v.back()+cnt);
			c=s.at(i);
			cnt=1;
		}
	}
	int ans=0;
	for(int i=0,dif=min(k+k+1,(int)v.size()-1);i+dif<v.size();++i){
		if(i&1)ans=max(ans,v.at(i+dif)-v.at(i+1));
		else ans=max(ans,v.at(i+dif)-v.at(i));
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 4024
from collections import defaultdict as dd
N,p=map(int,input().split())
s=input()
res=0
dic=dd(int)
c = [0]*(N+1)

if p==2 or p==5:
    for i in range(N):
        now = int(s[N-i-1])%p
        if now==0:
            res += N-i
    print(res)
    exit()

for i in range(N):
    now = int(s[N-i-1])%p
    c[i+1] = (c[i]+pow(10,i,p)*now)%p
for val in c:
    dic[str(val)] += 1
    if dic[str(val)] >= 2:
        res += dic[str(val)]-1
print(res)

Measured memory_bytes: 12308
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a.sort()
s=0;p=0
for i in range(n):
  if s+a[i][1]>=m:
    p+=(m-s)*a[i][0]
    break
  s+=a[i][1]
  p+=a[i][0]*a[i][1]
print(p)

Measured memory_bytes: 27760
#include <iostream>
using namespace std;
int main(void){
   int A,B,C,D;
   cin>>A>>B>>C>>D;
   int t_sec=0;
   if(B>D){
       if(A>=C &&A<D){
           t_sec=D-A;
       }
       else if(A<=C){
           t_sec=D-C;
       }
   }
   else{
       if(C>=A &&C<B){
           t_sec=B-C;
       }
       else if(C<=A){
           t_sec=B-A;
       }
   }
   cout<<t_sec<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll n;
	cin>>n;
	ll a[110000];
	rep(i,0,n)cin>>a[i];
	ll p[110000]={0};
	rep(i,0,n)p[a[i]]++;
	ll m=0;
	if(n>=3) rep(i,0,n-2){
			m=max(m,p[i]+p[i+1]+p[i+2]);
		}
	else if(n==2){
		if(abs(a[0]-a[1])<=2)m=2;
		else m=1;
	}
	else if(n==1) m=1;
	cout<<m;
}

Measured memory_bytes: 1920
import heapq

n=int(input())
a=list(map(int,input().split()))
a=list(map(lambda x : x*(-1),a))

heapq.heapify(a)
total=0
total+=(-1)*heapq.heappop(a)

if n%2==1 :
    for i in range(1,n//2+1) :
        if i==n//2 :
            total+=(-1)*heapq.heappop(a)
        else :
            total+=(-2)*heapq.heappop(a)
    print(total)

else :
    for i in range(1,n//2) :
        total+=(-2)*heapq.heappop(a)
    print(total)


Measured memory_bytes: 31676
#include <stdio.h>
#include <string.h>
int main()
{
	int x=0,N;
	scanf("%d",&N);
	char s[N+1];
	scanf("%s",&s);
	int max=0;
	for(int i=0;i<N;i++){
		if(s[i]=='I'){
			x++;
		}else{
			x--;
		}
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",max);
 	return 0;
}



Measured memory_bytes: 1704
N, L = map(int, input().split())
pi = [L+i-1 for i in range(1, N+1)]
minval = 100 + 200 -1
minindex = 0
for o in range(N):

  if minval>abs(pi[o]):
    minval = abs(pi[o])
    minindex = o

print(sum(pi) - pi[minindex])

Measured memory_bytes: 3060
#include<stdio.h>
#define PI 3.141592653589793
int main(void)
{
    double r, s, l;
    scanf("%lf", &r);
    s = PI * r * r;
    l = 2 * PI * r;
    printf("%lf %lf\n", s, l);
    return 0;
}


Measured memory_bytes: 2044
import math

x = int(input())
if(x == 1):
    print('1')
    exit()

m = 0
for b in range(2, int(math.ceil(math.sqrt(x)))+1):
    p = 2
    while(b ** p <= x):
        p += 1
    if(m < b ** (p-1)):
        m = b ** (p-1)

print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll n; cin >> n;
	if (n & 1) {
		cout << 0 << endl;
		return 0;
	}
	ll cnt2 = 0;
	for (ll a = 2; a <= n; a <<= 1LL) {
		cnt2 += n / a;
	}
	ll cnt5 = 0;
	for (ll a = 10; a <= n; a *= 5LL) {
		cnt5 += n / a;
	}
	cout << min(cnt5, cnt2) << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [int(input()) for i in range(n)]

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(ans - s[i])
            break
    else:
        print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
ll mod = 1000000007;
inline int fast_expo(int base,int power,int modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    // int tmp=ans;
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int INF = (int)1e9;
//=========================CODE STARTS HERE=============================//


int main() {

		fast_cin();
		ll n;
		cin >> n;
		string s, t;
		cin >> s >> t;
		
		fo(i, s.length()) {
			cout << s[i] << t[i];
		}
		cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX_NUM (50001)

void enum_prime(char list[]) {
	int i, j;

	list[0] = list[1] = 0;
	for (i = 2; i < MAX_NUM; i++) {
		list[i] = 1;
	}
	for (i = 2; i < MAX_NUM; i++) {
		if (list[i] == 0)
			continue;
		for (j = i + i; j < MAX_NUM; j += i) {
			list[j] = 0;
		}
		if (MAX_NUM < i * i)
			break;
	}
}

int main() {
	int i, n, n2, cnt;
	char prime_list[MAX_NUM];

	enum_prime(prime_list);
	while (1) {
		scanf("%d ", &n);
		if (n == 0) {
			break;
		}
		cnt = 0;
		if (n % 2 == 0) {
			n2 = n / 2;
			for (i = 0; i < MAX_NUM; i++) {
				if (prime_list[i]) {
					if (i > n2)
						break;
					if (prime_list[n - i])
						cnt += 1;
				}
			}
		}
		else if (prime_list[n - 2]) {
			cnt = 1;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 652
N,A,B,C = map(int,input().split())
S = [input() for _ in [0]*N]

ans = [0]*N
for i,s in enumerate(S):
    if s=="AB":
        if A==B==0:
            print("No")
            break
        elif A==B==1:
            if S[(i+1)%N]=="BC":
                ans[i] = "B"
                B += 1
                A -= 1
            else:
                ans[i] = "A"
                A += 1
                B -= 1
        elif A>=B:
            ans[i] = "B"
            A -= 1
            B += 1
        else:
            ans[i] = "A"
            A += 1
            B -= 1
    elif s=="BC":
        if B==C==0:
            print("No")
            break
        elif B==C==1:
            if S[(i+1)%N]=="AC":
                ans[i] = "C"
                C += 1
                B -= 1
            else:
                ans[i] = "B"
                B += 1
                C -= 1
        elif B>=C:
            ans[i] = "C"
            B -= 1
            C += 1
        else:
            ans[i] = "B"
            B += 1
            C -= 1
    elif s=="AC":
        if A==C==0:
            print("No")
            break
        elif A==C==1:
            if S[(i+1)%N]=="BC":
                ans[i] = "C"
                C += 1
                A -= 1
            else:
                ans[i] = "A"
                A += 1
                C -= 1
        elif A>=C:
            ans[i] = "C"
            A -= 1
            C += 1
        else:
            ans[i] = "A"
            A += 1
            C -= 1
else:
    print("Yes")
    for out in ans:
        print(out)

Measured memory_bytes: 17120
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let vec: Vec<u32> = read_split_line();
    let days: Vec<u32> = read_split_line();
    let n = vec[0];
    let mut sum = 0;
    for day in days {
        sum += day;
    }
    if sum <= n {
        println!("{}", n - sum);
    } else {
        println!("{}", -1);
    }
}

#[allow(dead_code)]
fn read_elem<T: FromStr>() -> T {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_n_elems<T: FromStr>() -> Vec<T> {
    let n = read_elem::<u32>();
    let mut vec: Vec<T> = vec![];
    for _i in 0..n {
        vec.push(read_elem::<T>());
    }
    vec
}

#[allow(dead_code)]
fn read_split_line<T: FromStr>() -> Vec<T> {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
 ll q ; cin>> q;
 while(q--){
  ll a, b; cin>>a>>b ;
  if(a==b) cout<<2*a-2<<endl ;
  else{
    ll x = sqrt(double(a*b)) ;

    if(a*b==x*x) x-- ;
    if(x*(x+1)<a*b) cout<<2*x-1<<endl ;
    else cout<<2*x-2<<endl ;
  }

 }
   return 0 ;
 }



Measured memory_bytes: 3560
def d_2017_like_number():
    Q = int(input())
    I = [[int(i) for i in input().split()] for j in range(Q)]

    def prime_table(n):
        """n 以下の整数がそれぞれ素数かどうかのリスト (エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return is_prime

    def calc_like2017(m, p):
        # i 番目の要素が、1 以上 i 以下の "2017に似た数" の個数となるリストを返す
        # m 以下の素数のリスト p を予め作っておく必要がある
        c = [0] * (m + 1)  # 0番目は0と定義する
        for i in range(3, m + 1, 2):  # 0, 1, 2 は定義上2017に似た数にならない
            if p[i] and p[(i + 1) // 2]:
                c[i] += 1
        for i in range(3, m + 1):
            c[i] += c[i - 1]
        return c

    like2017 = calc_like2017(10**5, prime_table(10**5))
    ans = [like2017[r] - like2017[l - 1] for l, r in I]
    return '\n'.join(map(str, ans))

print(d_2017_like_number())

Measured memory_bytes: 33260
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n; cin >> n;
  ll a[n];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  int k = 1;
  while(a[k]<0) k++;
  k = min(n-1,k);
  vector<ll> x1, y1;
  REP(i,n-k-1){
    x1.push_back(a[0]);
    y1.push_back(a[k+i]);
    a[0] = x1[i]-y1[i];
  }
  vector<ll> x2, y2;
  REP(i,k-1){
    x2.push_back(a[n-1]);
    y2.push_back(a[1+i]);
    a[n-1] = x2[i]-y2[i];
  }
  ll x3 = a[n-1], y3 = a[0];
  cout << x3-y3 << endl;
  REP(i,n-k-1) printf("%lld %lld\n",x1[i],y1[i]);
  REP(i,k-1) printf("%lld %lld\n",x2[i],y2[i]);
  printf("%lld %lld\n",x3,y3);
  return 0;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    vector<ll> d(a[n-1]+10);
    rep(i,a[n-1]+10) d[i]=0;
    rep(i,n){
        if(a[i]!=0){
            d[a[i]-1]++;
            d[a[i]]++;
            d[a[i]+1]++;
        }else{
            d[a[i]]++;
            d[a[i]+1]++;
        }
    }
    sort(ALL(d));
    cout<<d[a[n-1]+9]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    int ans = 0;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k])
                    if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
                        ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3508
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c)>0 for c in '753') else 0
    # 文字列sが七五三数だったら1(カウントするということ)
    for c in '753':
        ret += dfs(s+c)
    return ret
    
print(dfs('0'))

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

using namespace std;

string S, T;
int N;

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

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

using namespace std;

int main() {
    int a, b;

    // input
    cin >> a >> b;

    // process
    int d = a / b;
    int r = a % b;
    double f = (double)a / b;

    // output
    printf("%d %d %.5f\n", d, r, f);

    return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
#include <map>
using namespace std;

long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}

const long long mod = 1000000007;
long long pw[200200] = { 1 };

int main()
{
	map<pair<long long, long long>, pair<int, int> > chk;

	for (int i = 1; i < 200200; i++) pw[i] = (pw[i - 1] * 2) % mod;

	long long a = mod - 1;
	int n; scanf ("%d", &n); while (n--){
		long long x, y;
		scanf ("%lld %lld", &x, &y);
		if (x == 0 && y == 0){ a++; continue; }
		if (make_pair(x, y) < make_pair(0ll, 0ll)) x = -x, y = -y;
		long long g = gcd(abs(x), abs(y));
		x /= g; y /= g;
		if (y > 0) chk[{x, y}].first++;
		else chk[{-y, x}].second++;
	}

	long long r = 1;
	for (auto& p : chk){
		r = r * (pw[p.second.first] + pw[p.second.second] - 1) % mod;
	}

	printf ("%lld\n", (a + r) % mod);

	return 0;
}


Measured memory_bytes: 17220
#include <stdio.h>
int main(){
  int n, q, i, j, count=0;
  int S[10000], T[10000];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(i = 0; i<q; i++){
    scanf("%d", &T[i]);
  }

  
  for(i = 0; i<q; i++){
    for(j =0 ; j<n; j++){
      if(S[j]==T[i]) break;
    }
    if(S[j]==T[i]) count++;
  }

  printf("%d\n", count);

  return 0;
}

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

using namespace std;

const int N = 200043;
const int INF = int(1e9);

int T[4 * N][32];
int A[4 * N][5];
int n, k;

void build(int v, int l, int r)
{
	if(l == r - 1)
	{
		for(int i = 0; i < (1 << k); i++)
		{
			int cur = 0;
			for(int j = 0; j < k; j++)
				if(i & (1 << j))
					cur += A[l][j];
				else
					cur -= A[l][j];
			T[v][i] = cur;
		}
	}
	else
	{
		int m = (l + r) / 2;
		build(v * 2 + 1, l, m);
		build(v * 2 + 2, m, r);
		for(int i = 0; i < (1 << k); i++)
			T[v][i] = min(T[v * 2 + 1][i], T[v * 2 + 2][i]);
	}
}

int query(int v, int l, int r, int L, int R, int x)
{
	if(L >= R) return INF;
	if(L == l && R == r)
		return T[v][x];
	int m = (l + r) / 2;
	return min(query(v * 2 + 1, l, m, L, min(R, m), x), query(v * 2 + 2, m, r, max(L, m), R, x));
}

void upd(int v, int l, int r, int z)
{
	if(l == r - 1)
	{
		for(int i = 0; i < (1 << k); i++)
		{
			int cur = 0;
			for(int j = 0; j < k; j++)
				if(i & (1 << j))
					cur += A[l][j];
				else
					cur -= A[l][j];
			T[v][i] = cur;
		}
	}
	else
	{
		int m = (l + r) / 2;
		if(z < m)
			upd(v * 2 + 1, l, m, z);
		else
			upd(v * 2 + 2, m, r, z);
		for(int i = 0; i < (1 << k); i++)
			T[v][i] = min(T[v * 2 + 1][i], T[v * 2 + 2][i]);
	}
}

int main() 
{ 
	scanf("%d", &n);
	k=2;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < k; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}
	int q;
// 	scanf("%d", &q);
q=1;
	build(0, 0, n);
	for(int i = 0; i < q; i++)
	{
		int t;
// 		scanf("%d", &t);
t=2;
		if(t == 1)
		{
			int z;
			scanf("%d", &z);
			--z;
			for(int j = 0; j < k; j++)
				scanf("%d", &A[z][j]);
			upd(0, 0, n, z);
		}
		else
		{
			int ans = 0;
			int l, r;
// 			scanf("%d %d", &l, &r);
l=1,r=n;
			--l;
			for(int i = 0; i < (1 << (k - 1)); i++)
			{
				int x = query(0, 0, n, l, r, i);
				int y = query(0, 0, n, l, r, ((1 << k) - 1) ^ i);
				ans = max(ans, abs(x + y));
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 73264
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

vector<vector<int> > al(100001);
ll const mod = 1e9 + 7;
ll dp[100001][2];

void dfs(int root, int p){

	dp[root][0] = 1;
	dp[root][1] = 1;
	for(int x: al[root]){
		if(x==p)continue;
		dfs(x,root);
		dp[root][0] = (dp[root][0] * dp[x][1])% mod;
		dp[root][1] = (dp[root][1] * (dp[x][0] + dp[x][1])%mod) % mod;		
	}
}

int main(){
	IOS;
	memset(dp,1,sizeof(dp));
	int n;
	cin >> n;
	int x,y;
	for(int i=1;i<n ; ++i){
		cin >> x >> y;
		al[x].push_back(y);
		al[y].push_back(x);
	}
	dfs(1,-1);
	cout << (dp[1][0] + dp[1][1] + mod) % mod << endl;
}

Measured memory_bytes: 14208
t = [[int(j) for j in input().split()] for i in range(3)]
l = sum(t, [])
N = int(input())
for _ in range(N):
    i = int(input())
    for j in range(9):
        if i == l[j]:
            l[j] = 0
a, b, c, d, e, f, g, h, i = l
if (a == 0 and d == 0 and g == 0) \
or (b == 0 and e == 0 and h == 0) \
or (c == 0 and f == 0 and i == 0) \
or (a == 0 and b == 0 and c == 0) \
or (d == 0 and e == 0 and f == 0) \
or (g == 0 and h == 0 and i == 0) \
or (a == 0 and e == 0 and i == 0) \
or (c == 0 and e == 0 and g == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

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

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

typedef long long int LLI;

void solve()
{
    int n;
    cin>>n;
    int ar[n];
    int tot=0;
    for(int i=0;i<n;++i){
        int num;
        cin>>num;
        ar[i]=num;
        tot^=num;
    }
    for(int i=0;i<n;++i) cout<<(tot^ar[i])<<" ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 4368
<?php 

for ($i=0;$i<10;$i++){
	$row[] = trim(fgets(STDIN)); // STDIN ?????? 1 ???????????????
}
rsort($row);
for($i=0;$i<3;$i++){
	if($i<2){
	echo $row[$i] . "\n";
	}else{
		echo $row[$i];

	}
}
?>

Measured memory_bytes: 15460
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s,t; cin >> s >> t;
    sort(all(s));
    //sort(all(t),greater<string>());
    sort(all(t));
    reverse(all(t));
    yn(s<t);

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100

void push(int);
int pop();

int stack[N],top=0;
int main() {
  char S[N];
  int i,n=0,x,y,z;


  while (scanf("%s",S)!=EOF) {
    if (S[0] == '+') {
      y = pop();
      z = pop();
      push(y+z);
    }
    else if (S[0] == '-') {
      /* code */
      y = pop();
      z = pop();
      push(z-y);
    }
    else if (S[0] == '*') {
      /* code */
      y = pop();
      z = pop();
      push(y*z);
    }
    else if (S[0] >= '0' && S[0] <= '9') {
      x = atoi(S);
      push(x);
    }
  }
  printf("%d\n",stack[top] );
  return 0;
}
void push(int x){
  top++;
  stack[top] = x;
}

int pop(void){
  top--;
  return stack[top+1];
}

Measured memory_bytes: 548
import math
def clock(h, m):
    res = abs((11*m)/2 - (30*h))
    if res>180: res = 360 - res
    return res
a,b, hour, min = map(int,input().split())

angle = clock(hour, min)
angle1 = math.cos(math.radians(angle))
ans = math.sqrt((a*a)+(b*b)-(2*a*b*angle1))
print("%.20f"%ans)


Measured memory_bytes: 62504
#include <iostream>
#include <algorithm>

using namespace std;
pair<int,int> a[100005];
int n,i,ans;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
        if((a[i].second-i)%2)
            ans++;
    cout<<ans/2;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int H1, M1, H2, M2, K; std::cin >> H1 >> M1 >> H2 >> M2 >> K;
  int m1 = H1*60+M1, m2 = H2*60+M2;
  fin(m2 - m1 - K);
  return 0;
}


Measured memory_bytes: 3648
import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)


def split(h):
    pieces = []
    tmp = []
    for i in range(len(h)):
        if h[i] == 0:
            pieces.append(tmp)
            tmp = []
        else:
            tmp.append(h[i])

    pieces.append(tmp)
    return pieces


def f(h):
    if len(h) == 0:
        return 0

    ith = 0
    while True:
        maxh = max(h)
        if maxh == 0:
            break
        for i in range(len(h)):
            h[i] += 1
        ith += 1

    pieces = split(h)

    m = 0
    for piece in pieces:
        m += f(piece)

    return ith + m


def main():
    N = int(input())
    h = list(map(int, input().split()))
    h = [-i for i in h]

    pieces = split(h)

    m = 0
    for piece in pieces:
        m += f(piece)

    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42988
#!/usr/bin/env python3
import sys

def nextSpan(s:str,begin:int):
    current = s[begin]
    r = 1
    for i in range(begin + 1,len(s)):
        if s[i] == current:
            r += 1
        else:
            return (current,r,i)
    return (current,r,len(s))

def getNSeriesSum(n:int):
    return n*(n-1)//2

def solve(S: str):
    currentIndex = 0
    csum = 0
    while True:
        next = nextSpan(S,currentIndex)
        currentIndex = next[2]
        if currentIndex == len(S):
            csum += getNSeriesSum(next[1]+1)
            break
        if next[0] == ">":
            csum += getNSeriesSum(next[1] + 1)
        else:
            nextNext = nextSpan(S,currentIndex)
            if nextNext[1] > next[1]:
                csum += getNSeriesSum(nextNext[1] + 1) + getNSeriesSum(next[1])
            else:
                csum += getNSeriesSum(nextNext[1]) + getNSeriesSum(next[1]+1)
            currentIndex = nextNext[2]
        if currentIndex == len(S):
            break
    print(csum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4224
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cmath>
 
#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)
 
using namespace std;
 
const int MAXN = 800 + 5;
const int DIRX[] =
{ 1, -1, 0, 0 };
const int DIRY[] =
{ 0, 0, 1, -1 };
 
int H, W, K;
int stX, stY;
char mz[MAXN][MAXN];
bool vist[MAXN][MAXN];
 
int answer = 0x7F7F7F7F;
 
void BFS()
{
	queue<pair<pair<int, int>, int> > Q;
	Q.push(make_pair(make_pair(stX, stY), 0));
 
	while (!Q.empty())
	{
		pair<pair<int, int>, int> cur = Q.front();
		Q.pop();
 
		if(vist[cur.first.first][cur.first.second])
			continue;
		vist[cur.first.first][cur.first.second] = true;
 
		int curAns = min(min(cur.first.first - 1, H - cur.first.first),
				min(cur.first.second - 1, W - cur.first.second));
		curAns = (curAns + K - 1) / K;
		answer = min(answer, curAns + 1);
 
		if (cur.second >= K)
			continue;
 
		for (int i = 0; i < 4; i++)
		{
			pair<int, int> newPos = make_pair(cur.first.first + DIRX[i],
					cur.first.second + DIRY[i]);
			if(newPos.first <= 0 || newPos.first > H)
				continue;
			if(newPos.second <= 0 || newPos.second > W)
				continue;
			if(mz[newPos.first][newPos.second] != '#' && !vist[newPos.first][newPos.second])
				Q.push(make_pair(newPos, cur.second + 1));
		}
	}
}
 
int main()
{
 
	//REDIRECT("room");
 
	scanf("%d%d%d", &H, &W, &K);
	for (int i = 1; i <= H; i++)
	{
		scanf("%s", mz[i] + 1);
		for (int j = 1; j <= W; j++)
			if (mz[i][j] == 'S')
				stX = i, stY = j;
	}
 
	BFS();
 
	printf("%d\n", answer);
 
	CLOSEALL();
	return 0;
}

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

class quick_find {
	vector<int> rt;
	vector<vector<int>> vs;
public:
	quick_find(int n) : rt(n), vs(n) {
		for (int i = 0; i < n; i++) rt[i] = i, vs[i].push_back(i);
	}
	bool same(int a, int b) {
		return rt[a] == rt[b];
	}
	void unite(int a, int b) {
		a = rt[a], b = rt[b];
		if (a == b) return;
		if (vs[a].size() < vs[b].size()) swap(a, b);
		for (auto& v : vs[b]) rt[v] = a, vs[a].push_back(v);
	}
	int size(int a) {
		return vs[rt[a]].size();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	quick_find qf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			qf.unite(x, y);
		}
		else {
			printf("%d\n", qf.same(x, y));
		}
	}
	return 0;
}



Measured memory_bytes: 3872
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        int ans = 0;
        for(int i = 1; i < S.Length; i++)
        {
            if (S[i] != S[i - 1])
                ans++;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13244
#C問題
import numpy as np
N, M = map(int, input().split())
L_list = []
R_list = []
for i in range(M):
    L, R = map(int, input().split())
    L_list.append(L)
    R_list.append(R)
if min(R_list) - max(L_list) < 0:
    print(0)
else:
    print(min(R_list) - max(L_list)+1)

Measured memory_bytes: 20040
import sys
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))

ans = -1

if N == 1:
  start, stop = 0, 10  
elif N == 2:
  start, stop = 10, 100
else:
  start, stop = 100, 1000

for i in range(start, stop):
  temp = list(str(i))
  for j in range(N):
    temp[j] = int(temp[j])
  flag = 1
  for j in range(M):
    if temp[l[j][0]-1] != l[j][1]:
      flag = 0
  if flag == 1:
    ans = i
    break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll, ll>
#define ppi pair<int, pii>
#define vpi vector<pii>
#define vpl vector<pll>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18;

struct cmp{
    bool operator() (pii a, pii b){
        if(a.F == b.F) return a.S < b.S;
        return a.F > b.F;
    }
};

ll power(ll x, ll p){
    ll r = 1ll;
    x = x % mod;
    while(p > 0){
        if(p & 1) r = (r * x) % mod;
        p = p >> 1;
        x = (x * x) % mod;
    }
    return r;
}

void solve(){
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R'){
            cnt++;
        }
        else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
    #endif*/
    //freopen("running_on_fumes_chapter_1_input (1).txt", "r", stdin);
    //freopen("Output.txt", "w", stdout);
    int t = 1, p;
    //cin >> t;
    for(p = 1; p <= t; p++){
        //cout << "Case #" << p << ": ";
        solve();
    }
    return 0;
}


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

int main(void){
    int h1, h2, k1, k2;
    cin >> h1 >> h2;
    cin >> k1 >> k2;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x,y;
    x = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
    y = k1*a + k2*b + (k1/10)*c + (k2/20)*d;
    if(x == y){
        cout << "even" << endl;
    }else if(x > y){
        cout << "hiroshi" << endl;
    }else{
        cout << "kenjiro" << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	ll n=s.size();
	ll k; cin>>k;
	char ans='1';
	rep(i,0,min(k,n)){
		if(s[i]!='1'){
			ans=s[i];
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 998244353
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    int a, b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    // init();
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if (A <= 9 && B <= 9) {
            System.out.println(A*B);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
const int N=2009;
char ch[N];
int n;
bitset<N>dp[2][N],a[N];
//int dp[2][N][N];
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(int j=1;j<i;j++)
		{
			a[i][j]=ch[j]-48,a[j][i]=!a[i][j];
		}
	}
	for(int i=1;i<=n;i++)dp[0][i][i]=dp[1][i][i]=1;
	for(int len=2;len<=n;len++)
	{
		for(int i=1;i<=(n-len+1);i++)
		{
			int j=i+len-1;
			if((dp[0][j]&dp[1][i+1]&a[i]).any())dp[0][j][i]=1;
			if((dp[1][i]&dp[0][j-1]&a[j]).any())dp[1][i][j]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)if(dp[0][n][i]&&dp[1][1][i])ans++;
	printf("%d",ans);
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<string> v;
  load(v, n);

  if (set<string>(v.begin(), v.end()).size() != n) {
    pn();
    return 0;
  }

  char last = v[0][v[0].length() - 1];
  for (int i = 1; i < n; ++i) {
    if (last != v[i][0]) {
      pn();
      return 0;
    } else {
      last = v[i][v[i].length() - 1];
    }
  }
  py();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N,A,B,C,D;
  cin >> N >> A>>B>>C>>D;
  string S;
  cin >> S;
  
  bool j=true;
  if(C<D){
    for(int i=A;i<D-2;i++){
      if(S.at(i)=='#' && S.at(i+1)=='#'){
      j=false;
        break;
      }
    }
  }else{
    j=false;
    for(int i=B-2;i<D-1;i++){
      if(S.at(i)=='#'|| S.at(i+1)=='#' || S.at(i+2)=='#'){
      }else{
      j=true;
      break;
      }
    }
  }
  if(j == 0){
    cout << "No" <<endl;
  }else{
    cout <<"Yes" <<endl;
  }
}

Measured memory_bytes: 640
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  ld n;
  cin >> n;
  ld d = n/3.000000000000;
  cout.precision(12);
  cout << d*d*d << endl;
}     


Measured memory_bytes: 256