akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/nomura2020/tasks/nomura2020_d
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*16
char str[nn];
signed main(){
	scanf("%s",str);
	int n=strlen(str);for(int i=0;i<n;i++) if(str[i]=='?') str[i]='D';
	printf("%s",str);
	return 0;
} 

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
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; }

int main(){
  long long  N;
  cin >> N;
  long long ans = 0;

  // N =  m * n + n を満たす m, n の組が存在するかどうか
  // N = n(m+1)
  // m > n > 0

  for (long long i=1; i * i < N; i++){
    // n = i,  m = N / i - 1
    if (N % i == 0 && N / i - 1 != i){
        ans += N / i - 1;
    }
  }

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


Measured memory_bytes: 256
import sys
import math
S = list(input())
size = len(S)

B_size = sum([ 1 for i in S if i == 'B' ])
if B_size == 0:
    print(0)
    sys.exit()

B_size2 = sum([ i for i,j in enumerate(S) if j == 'B' ])
ans= sum(range(0, size)[-B_size:]) - B_size2
print(ans)

Measured memory_bytes: 12420
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> ans,b;
  int n,tmp,cnt;
  bool is_removed;
  cin >> n;
  cnt=n;
  for(int i=0;i<n;i++){
    cin >> tmp;
    b.push_back(tmp);
  }
  while(true){
    is_removed=false;
    for(int i=b.size()-1;i>=0;i--){
      if(i+1==b[i]){
        is_removed=true;
        ans.push_back(i+1);
        b.erase(b.begin()+i);
        break;
      }
    }
    if(is_removed==false){
      cout <<"-1\n";
      break;
    }
    if(b.size()==0){
      for(int i=ans.size()-1;i>=0;i--){
        cout << ans[i] <<"\n";
      }
      break;
    }
  }
}


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

using i64 = long long;


int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	map<pair<string, string>, int> mp;
	string str, lf, rt;
	i64 ant;
	int n;

	cin >> n >> str;
	lf = str.substr(0, n);
	rt = str.substr(n, 2 * n);

	for (int msk = 0; msk < (1 << n); msk++) {
		string red, blue;
		for (int lg = 0; lg < n; ++lg)
			(((1 << lg) & msk) ? red : blue).push_back(rt[lg]);
		mp[make_pair(red, blue)]+= 1; }

	ant = 0;
	reverse(begin(lf), end(lf));
	for (int msk = 0; msk < (1 << n); ++msk) {
		string red, blue;
		for (int lg = 0; lg < n; ++lg)
			(((1 << lg) & msk) ? red : blue).push_back(lf[lg]);
		ant+= mp[make_pair(blue, red)]; }

	cout << ant << endl;

	return 0; }



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

using namespace std;

int main() {
    int n;
    int key[100];
    string s;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i=0; i<n; i++) {
            cin >> key[i];
        }
        cin >> s;
        for (int i=0; i<(int)s.length(); i++) {
            char c = s[i];
            for (int j=0; j<key[i%n]; j++) {
                if (c == 'a') {
                    c = 'Z';
                }
                else if (c == 'A') {
                    c = 'z';
                }
                else {
                    c--;
                }
            }
            cout << c;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#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; cin>>n;
   vector<int> b(n);
   rep(i,n) cin>>b[i];
   sort(b.begin(),b.end());
   int ans=b[b.size()/2]-b[b.size()/2-1];
   cout<<ans<<endl;
   return 0;
}

   


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int n;
set<int>S;
main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c,x;cin>>c>>x;
    if(c==1)cout<<(S.find(x)!=S.end())<<endl;
    else if(c==0)S.insert(x),cout<<S.size()<<endl;
    else if(c==2)S.erase(x);
    else
    {
      int y;cin>>y;
      auto a=S.lower_bound(x),b=S.upper_bound(y);
      for(auto it=a;it!=b;it++)cout<<*it<<endl;
    }
  }
}



Measured memory_bytes: 12336
import sys
input = sys.stdin.readline
from heapq import heappush,heapify,heappop
k,t=map(int,input().split())
a=list(map(int,input().split()))
b=[]
heapify(b)
ans=[-1]*k
for i in range(t):
    heappush(b,[-a[i],i])
x=heappop(b)
ans[0]=x[1]
x[0]+=1
if x[0]<0:
    heappush(b,x)
for i in range(1,k):
    x=heappop(b)
    if ans[i-1]==x[1] and b:
        y=heappop(b)
        ans[i]=y[1]
        y[0]+=1
        if y[0]<0:
            heappush(b,y)
        heappush(b,x)
    else:
        ans[i]=x[1]
        x[0]+=1
        if x[0]<0:
            heappush(b,x)
cnt=0
for i in range(1,k):
    if ans[i]==ans[i-1]:
        cnt+=1
print(cnt)

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

using namespace std;

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

	int h, w, n;
	cin >> h >> w >> n;

	int sr, sc;
	cin >> sr >> sc;

	string s, t;
	cin >> s >> t;

	int l = 1;
	int r = w;

	int u = 1;
	int d = h;

	bool off = false;
	for(int i = n-1; i >= 0; i--) {
		if(t[i] == 'L') {
			r = min(w, r+1);
		}
		if(t[i] == 'R') {
			l = max(1, l-1);
		}
		if(t[i] == 'U') {
			d = min(h, d+1);
		}
		if(t[i] == 'D') {
			u = max(1, u-1);
		}

		if(s[i] == 'L') {
			l++;
		}
		if(s[i] == 'R') {
			r--;
		}
		if(s[i] == 'U') {
			u++;
		}
		if(s[i] == 'D') {
			d--;
		}

		if(l > r) {
			off = true;
		}
		if(u > d) {
			off = true;
		}
	}

	if(sc < l || sc > r) {
		off = true;
	}
	if(sr < u || sr > d) {
		off = true;
	}

	cout << (off ? "NO" : "YES") << endl;

	return 0;
}


Measured memory_bytes: 920
def readinput():
    n=int(input())
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    e=int(input())
    return n,a,b,c,d,e

def main(n,a,b,c,d,e):
    r=min(a,b,c,d,e)
    m=n//r
    if n%r!=0:
        m+=1
    return m+4

if __name__=='__main__':
    n,a,b,c,d,e=readinput()
    ans=main(n,a,b,c,d,e)
    print(ans)


Measured memory_bytes: 8892
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> pos(n);
	for (int i = 0; i < n; i++) {
		cin >> pos[i];
		pos[i]--;
	}
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		a[i] = (i + 1) * 30000;
		b[i] = (n - i) * 30000;
	}
	for (int i = 0; i < n; i++) {
		a[pos[i]] += i;
	}
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " " ;
		cout << a[i];
	}
	cout << endl;
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << b[i];
	}
	cout << endl;
	return 0;	
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;

const int N = 2e5 + 10;
int n, m, mark[N], deg[2][N];
vector <int> vec, adj[N];
string s;

void dfs(int v) {
	mark[v] = 0;
	for (int i : adj[v])
		if (mark[i]) {
			deg[s[v] - 'A'][i]--;
			if (!deg[s[v] - 'A'][i])
				vec.push_back(i);
		}
}

int main() {
	fill(mark, mark + N, 1);
	
	cin >> n >> m >> s;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		if (v == u) {
			deg[s[v] - 'A'][v]++;
			continue;
		}
		adj[v].push_back(u);
		adj[u].push_back(v);
		deg[s[u] - 'A'][v]++, deg[s[v] - 'A'][u]++;
	}
	
	for (int i = 0; i < n; i++)
		if (!deg[0][i] || !deg[1][i])
			vec.push_back(i);
	
	while (vec.size()) {
		int tmp = vec.back();
		vec.pop_back();
		dfs(tmp);
	}
	
	for (int i = 0; i < n; i++)
		if (mark[i])
//			cout << i + 1 << " ";
			return cout << "Yes", 0;
	cout << "No";
}


Measured memory_bytes: 13316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min(a: &i64, b: &i64) -> i64 {
    if *a <= 0i64 {
        *b
    } else if *b <= 0i64 {
        *a
    } else if *a < *b {
        *a
    } else {
        *b
    }
}

fn max(a: &i64, b: &i64) -> i64 {
    if *a < *b {
        *b
    } else {
        *a
    }
}

fn abs(a: &i64, b: &i64) -> i64 {
    if *a - *b <= 0 {
        *b - *a
    } else {
        *a - *b
    }
}

fn main() {
    input! {
        n: i64
    }
    println!("{}",n*(n+1)/2 - 3*(n/3)*(n/3+1)/2 - 5*(n/5)*(n/5+1)/2 + 15*(n/15)*(n/15+1)/2 );
}

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

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll> C(N);
    vector<vector<ll>> Ass(N);
    for (ll i = 0; i < N; i++) {
        cin >> C[i];
        copy_n(istream_iterator<ll>(cin), M, back_inserter(Ass[i]));
    }

    ll ans = 1e9 + 7;
    for (ll i = 1; i < (1 << N); i++) {
        vector<ll> rikaido(M);
        ll cost = 0;
        for (ll j = 0; j < N; j++) {
            if ((i & (1 << j)) != 0) {
                transform(begin(rikaido), end(rikaido), begin(Ass[j]), begin(rikaido), [](auto a, auto b) { return a + b; });
                cost += C[j];
            }
        }

        if (all_of(begin(rikaido), end(rikaido), [X](auto r) { return r >= X; })) {
            ans = min(ans, cost);
        }
    }

    if (ans == 1e9+7) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

        // Failed to predict input format
        return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define INF (1000000000)

ll d[200][200];
int n, m, R, a, b, c;
int r[8], p[8];

int main(int argc, char **argv) {
	cin >> n >> m >> R;
	REP(i, R) {
		cin >> r[i];
		--r[i];
	}
	REP(i, n) REP(j, n) d[i][j] = INF;
	REP(i, m) {
		cin >> a >> b >> c;
		--a; --b;
		d[a][b] = d[b][a] = c;
	}
	REP(k, n) REP(i, n) REP(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	ll res = INF, t = 0;
	iota(p, p + R, 0);
	for (bool f = true; f; f = next_permutation(p, p + R)) {
		t = 0;
		REP(i, R - 1) t += d[r[p[i]]][r[p[i + 1]]];
		res = min(res, t);
	}
	cout << res << endl;
	return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a + b) < (c + d)){
    cout << "Right" << endl;
  }
  else if ((a + b) == (c + d)){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,x;
vl a,b,s;

int main(){
	cin>>n>>x;
	a=vl(n);
	s=b=vl(n+1);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i-1];
		b[i]=(i==1?4:2*i+1);
	}
	ll res=INF;
	for(int i=1;i<=n;i++){
		ll t=s[n]-s[n-i],I=1;
		for(int j=n;j>0;j-=i){
			int L=max(0,j-i),R=j;
			t+=b[I]*(s[R]-s[L]);
			if(t>=INF) break;
			I++;
		}
		res=min(res,t+i*x);
	}
	cout<<res+n*x<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int w,h,k;
ll num[101][8];//w,h
ll movin[8][8];
ll line[9];
void dp(){
  rep(i,h){
    rep(j,w){
      num[i+1][j] = num[i][j] * movin[j][j];
      if(j != 0){
        num[i+1][j] += num[i][j-1] * movin[j-1][j];
        num[i+1][j] %= mod;
      }
      if(j != w-1){
        num[i+1][j] += num[i][j+1] * movin[j+1][j];
        num[i+1][j] %= mod;
      }
    }
  }
}
int main(){
  cin >> h >> w >> k; // h:height w:sort k:the number of horioznal line
  memset(num,0,sizeof(num));
  num[0][0] = 1;
  line[0] = 1;
  line[1] = 1;
  REP(i,2,w+1){
    line[i] = line[i-1] + line[i-2];
    //MSG(line[i]);
  }
  rep(i,w){
    movin[i][i] = line[i] * line[w-1-i];
    if(i != 0){
      movin[i][i-1] = line[i-1] * line[w-1-i];
    }
    if(i != w-1){
      movin[i][i+1] = line[i] * line[w-2-i];
    }
  }
  dp();
  // rep(i,w){
  //   rep(j,w){
  //     cout << movin[i][j];
  //   }
  //   cout << endl;
  // }
  //
  // rep(i,h+1){
  //   rep(j,w){
  //     cout << num[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << num[h][k-1];
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(s,t);
  SORT(s);
  RSORT(t);
  
  Yes(s<t);
}

Measured memory_bytes: 256
from sys import stdin

# Input data
#stdin = open("input", "r")

n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
dp = [0] * (n + 1)
dp[2] = abs(arr[1] - arr[0])
for i in range(3, n + 1):
    dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i - 2]),
                dp[i - 2] + abs(arr[i - 1] - arr[i - 3]))
print(dp[n])


Measured memory_bytes: 20372
n = gets.to_i
ab =
  readlines.map do |i|
    i.chomp.split.map(&:to_i)
  end.to_a.sort{|a,b|a[1]<=>b[1]}

t = 0
can = true
ab.each do |time, dl|
  t += time
  if t > dl
    can = false
    break
  end
end
puts can ? 'Yes' : 'No'


Measured memory_bytes: 34552
#include<iostream>
#include<map>
using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	map<ll, ll>mp;
	mp[0] = 1;
	ll  ans = 0, now = 0;
	for (int i = 0;i < n;i++) {
		ll a;
		cin >> a;
		now += a;
		ans += mp[now];
		mp[now]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    int a,b;
    cin >> a >> b;
    cout << max(a-b,0) << endl;

    return 0;

}


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

#define _GLIBCXX_DEBUG

int main() {
  int n, z, ans, count_a = 0, count_b = 0;
  vector<int> a;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> z;
    a.push_back(z);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  
   for(int i = 0; i < n; i++) {
     if(i % 2 == 0) count_a += a[i];
     else count_b += a[i];
  }
  
  int x = max(count_a, count_b);
  int y = min(count_a, count_b);
  ans = x - y;
  cout << ans << endl;
}

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;

    int sum = 0;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    int i;
    int count = 0;
    REP(i, N) {
        if(A[i] >= sum / double(4 * M)) {
            count++;
        }
    }
    if(count >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//17
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<queue>
#include<vector>
#include<set>

using namespace std;

struct E{
  string t;
  int d;
};

struct S{
  string v;
  int r,d;
  bool operator<(S a)const{
    return d>a.d;
  }
};

int main(){
  for(int n,mm,cap;cin>>n>>mm>>cap,n|mm|cap;){
    cap*=10;
    string src,dest;
    cin>>src>>dest;
    map<string,vector<E> > m;
    for(int i=0;i<n;i++){
      string c[2];
      int d;
      cin>>c[0]>>c[1]>>d;
      for(int j=0;j<2;j++){
	E ce={c[j^1],d};
	m[c[j]].push_back(ce);
      }
    }
    set<string> gs;
    for(int i=0;i<mm;i++){
      string s;
      cin>>s;
      gs.insert(s);
    }
    priority_queue<S> que;
    S is={src,cap,0};
    que.push(is);
    map<string,map<int,int> > p;
    while(!que.empty()){
      S c=que.top();
      if(c.v==dest)break;
      que.pop();
      map<int,int>::iterator it=p[c.v].lower_bound(c.r);
      if(it!=p[c.v].end()&&it->second<=c.d)continue;
      p[c.v][c.r]=c.d;
      for(int i=0;i<m[c.v].size();i++){
	if(m[c.v][i].d<=c.r){
	  S n={m[c.v][i].t,c.r-m[c.v][i].d,c.d+m[c.v][i].d};
	  if(gs.count(n.v)){
	    n.r=cap;
	  }
	  que.push(n);
	}
      }
    }
    cout<<(que.empty()?-1:que.top().d)<<endl;
  }
  return 0;
}

Measured memory_bytes: 51084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>



using namespace std;

long long a[1005], b[1005], c[1005], s[1005];
int work(int, int);


int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int i;
	long long ans = 0, ma = -1;
	
	int j;
	for (j = 1; j <= n; j++) {
		scanf("%lld%lld%lld", &a[j], &b[j], &c[j]);
	}
	
	
	for (i = 1; i <= 8; i++) {
		
		for (j = 1; j <= n; j++) {
			s[j] = work(i, 1) * a[j] + 
				   work(i, 2) * b[j] + 
				   work(i, 3) * c[j] ;
			
 		}
		sort(s + 1, s + n + 1);
		for (j = n; j >= n - k + 1; j--) {
			ans += s[j];
		}
		ma =max(ans, ma);
		ans = 0;
	}
	cout << ma << endl;
}


int work(int a, int b) {
	if (a == 1) {
		return 1;
	}
	
	if (a == 2) {
		if (b == 3) return -1;
		else return 1;
	}
	
	if (a == 3) {
		if (b == 2) return -1;
		else return 1;
	}
	
	if (a == 4) {
		if (b == 1) return 1;
		else return -1;
	}
	
	if (a == 5) {
		if (b == 1) return -1;
		else return 1;
	}
	
	if (a == 6) {
		if (b == 2) return 1;
		else return -1;
	}
	
	if (a == 7) {
		if (b == 3) return 1;
		else return -1;
	}
	
	if (a == 8) {
		return -1;
	}
	
}

Measured memory_bytes: 256
package main

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

const MAX = 60000
const ROOT = 250

var sc =  bufio.NewScanner(os.Stdin)

func main() {
    var isPrime [MAX]bool
    for i := 2;i < MAX; i++ {
        isPrime[i] = true
    }
    for i := 2;i < ROOT; i++ {
        if isPrime[i] {
            for j := i * i;j < MAX; j+=i {
                isPrime[j] = false
            }
        }
    }
    var minPrime [MAX]int
    var maxPrime [MAX]int
    min := -1
    for i := 0;i < MAX; i++ {
        minPrime[i] = min
        if isPrime[i] {
            min = i
        }
    }
    max := -1
    for i := MAX - 1; i >= 0; i-- {
        maxPrime[i] = max
        if isPrime[i] {
            max = i
        }
    }

    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Printf("%d %d\n", minPrime[n], maxPrime[n])
    }
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int a, b;
    int x[4] = {};
    cin >> a >> b;
    x[a] = 1, x[b] = 1;
    for (int i = 1; i < 4; ++i)
        if (x[i] == 0) cout << i << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

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

int main() {
  int N, n, f = 0;
  cin >> N;
  n = N;
  
  while ( n > 0 ) {
    f += n % 10;
    n = n / 10;
  }
  
  if ( N % f == 0 ) {
    
    cout << "Yes" << endl;
  }
  else {
    
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3600
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def ang(n) Array.new(n){gsmi} end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def cal(sub,d)
  ret = 1
  d.times{|i| ret = ret * (sub+i+1)}
  d.times{|i| ret = ret / (1+i)}
  ret
end

$stdin = File.open('input.txt') if File.exist?('input.txt')
mod = 10**9 + 7
s = gi #
sum = 0
s.times do |i| #1
  sub = s-3*(i+1) #1
  break if sub<0
  sum += cal(sub,i)
end

puts sum%mod


Measured memory_bytes: 15028
#include <stdio.h>

int main()
{
 int N;
 int K;
 int i;
 int count=1;
 scanf("%d %d",&N,&K);

 for(i=0;i<K-1;i++) count=count+2;

 if(count<=N)
 {
  printf("YES\n");
 }else{
  printf("NO\n");
 }

 return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
PII a[N];

bool cmp(PII a, PII b)
{
	if (a.S != b.S) return a.S < b.S;
	else return a.F > b.F;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		int l, r;
		scanf("%d%d", &l, &r);
		l ++ ;
		a[i] = {l, r};
	}
	sort(a, a + m, cmp);
	
	int res = 0, pos = -0x3f3f3f3f;
	for (int i = 0; i < m; i ++ )
		if (a[i].F > pos)
	    {
	        pos = a[i].S;
	        res ++ ;
	    }
	    
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,d,e,f,g,h,t;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    e=a+c;
    f=a+d;
    g=b+c;
    h=b+d;
    int ar[4];
    ar[0]=e;
    ar[1]=f;
    ar[2]=g;
    ar[3]=h;
    int i,j;
    for(i=0;i<4;i++){

    for(j=0;j<3-i;j++){
     if(ar[j]>ar[j+1]){
    t=ar[j];
    ar[j]=ar[j+1];
    ar[j+1]=t;
    }
    }
    }
    printf("%d",ar[0]);

}



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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<62;
const ll mod = 1000000007LL;

ll next_combination(ll sub) {//組み合わせ全列挙に使うやつ
    ll x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<vector<ll>> v(N,vector<ll>(2));
  vector<ll> X(N),Y(N);
  for(ll i = 0LL; i < N; i++) {
    ll x,y;
    cin>>x>>y;
    X[i]=x;
    Y[i]=y;
    v[i][0]=x;
    v[i][1]=y;
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  ll bit = (1LL<<2)-1LL;
  vector<vector<ll>> xp,yp;
  vector<vector<ll>> num(N+1,vector<ll>(N+1));
  for(ll i = 0LL; i < N; i++) {
    for(ll j = 0LL; j < N; j++){
      ll cnt = 0LL;
      for(ll k = 0LL; k < N; k++){
        if(X[i]>=v[k][0]&&Y[j]>=v[k][1]) cnt++;
      }
      num[i+1][j+1]=cnt;
    }
  }
  for(ll i = 0; i < N+1; i++) {
    num[i][0]=0LL;
    num[0][i]=0LL;
  }
  for(;bit<(1LL<<N);bit = next_combination(bit)){
    vector<ll> xx;
    for(ll i = 0LL; i < N; i++){
      if(bit&(1LL<<i)) xx.push_back(i);
    }
    sort(xx.begin(),xx.end());
    xp.push_back(xx);
  }
  bit = (1LL<<2)-1;
  for(;bit<(1LL<<N);bit = next_combination(bit)){
    vector<ll> yy;
    for(ll i = 0LL; i < N; i++){
      if(bit&(1LL<<i)) yy.push_back(i);
    }
    sort(yy.begin(),yy.end());
    yp.push_back(yy);
  }
  ll ans = INF;
  for(auto x:xp){
    for(auto y:yp){
      ll l = x[0],r=x[1],d=y[0],u=y[1];
      ll t = num[r+1][u+1]-num[r+1][d]-num[l][u+1]+num[l][d];
      if(t>=K) chmin(ans,(X[r]-X[l])*(Y[u]-Y[d]));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=[int(input()) for i in range(n)]
if a[0]!=0:
    print(-1)
    quit()
ans=0
for i in range(n-1):
    if a[i+1]-a[i]>1:
        print(-1)
        quit()
    elif a[i+1]-a[i]==1:
        ans+=1
    else:
        ans+=a[i+1]
print(ans)

Measured memory_bytes: 50780
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n);
  rep(i, n) cin >> as[i];
  Sort(as);

  ll sum = 0;
  ll t = 0;
  rep(i, n-1) { 
    sum += as[i];
    if (as[i + 1] > 2 * sum) t = i + 1;
  }
  cout << n - t << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
//-------------------------------------------------------------------------------

intl n,m;
intl a,b,c,d;
string s,t;

void input_var(){
    cin >> s >> t;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    bool f = true;
    rep(i,s.length()){
        if(s[i] != t[i])f = false;
    }
    fp(f);
    return 0;
}

Measured memory_bytes: 3636
//from explanation

#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}

Measured memory_bytes: 2512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int b = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        b ^= a[i];
    }
    for(int i=0;i<n;i++){
        cout << (b^a[i]) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3560
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        if (n == 1) {
            System.out.println(1);
            return;
        }
        Map<Integer, Integer> map = new HashMap<>();
        Set<Integer> set3 = new HashSet<>();
        List<Integer> list = new ArrayList<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            max = Math.max(max, a);
            list.add(a);
            map.merge(a, 1, Integer::sum);
        }
        Collections.sort(list);
        for (int i = 1; i <= max; i++) {
            set3.add(i);
        }
        int ans = 0;
        for (int a : list) {
            if (map.get(a) == 1 && set3.contains(a)) {
                ans++;
            }
            int idx = 1;
            while (a * idx <= max) {
                set3.remove(a * idx);
                idx++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 147644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }

    int dfs(int v = 0) {
        if (edge[v].empty()) return 0;

        priority_queue<int> pq;
        for (const auto& e : edge[v]) {
            int to = e.to;
            pq.push(dfs(to));
        }
        int res = 0, i = 1;
        while (!pq.empty()) {
            int x = pq.top();
            pq.pop();
            res = max(res, x + i++);
        }
        return res;
    }
};

int main() {
    int N;
    cin >> N;
    Graph<int> g(N, 0);
    for (int i = 1; i < N; i++) {
        int a;
        cin >> a;
        a--;
        g.add_edge(a, i, 1, true);
    }
    cout << g.dfs() << endl;
    return 0;
}

Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll m, n, m0, md, n0, nd;
vi sum_m, sum_n;

ll calc(int pm, int pn)
{
	return sum_m[pm] + sum_n[pn] + (m - pm)*(n - pn);
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> m >> n >> m0 >> md >> n0 >> nd;
	vector<int> v(m), w(n);
	v[0] = m0;
	REP(i, m - 1) v[i + 1] = (v[i] * 58 + md) % (n + 1);
	w[0] = n0;
	REP(i, n - 1) w[i + 1] = (w[i] * 58 + nd) % (m + 1);
	sort(ALL(v)); sort(ALL(w));
	sum_m.resize(m + 1); sum_n.resize(n + 1);
	REP(i, m) sum_m[i + 1] = sum_m[i] + v[i];
	REP(i, n) sum_n[i + 1] = sum_n[i] + w[i];
	ll ans = LLONG_MAX;
	int pm = 0, pn = n;
	while (1)
	{
		ll tmp = calc(pm, pn);
		chmin(ans, tmp);
		while (1)
		{
			if (pn == 0) break;
			ll nx = calc(pm, pn-1);
			if (tmp < nx) break;
			pn--;
			tmp = nx;
			chmin(ans, tmp);
		}
		pm++;
		if (pn < 0 || pm > m) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 61460
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
int n,m;
char s[maxn];
int main() {
	scanf("%d",&n);
	double t = n / 3.0;
	printf("%.12lf\n",t * t * t);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin>>N>>X;
  int Z=1,A=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A+=a;
    if(A>X){
      break;
    }
    Z++;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

const long INF = 1L<<60;

long dp[500005];

int main(){
  int n;
  long a,b;
  cin>>n>>a>>b;
  vector<int> v(n);
  rep(i,n) cin>>v[i];

  fill(dp, dp+n+2, INF);
  dp[0] = 0;

  rep(i,n) rep(j,n+1) if(dp[j]< INF && j != v[i]){
    if(j < v[i]){
      dp[v[i]] = min(dp[v[i]], dp[j]);
      dp[j] += a;
    } else {
      dp[j] += b;
    }
  }

  long ans = INF;
  rep(i,n+1) ans = min(ans, dp[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int H, W, M;
  cin >> H >> W >> M;
  vector<int> A(H), B(W);
  vector<P> D(0);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    A[a]++;
    B[b]++;
    D.push_back(P(a, b));
  }
  int ma = *max_element(A.begin(), A.end());
  int mb = *max_element(B.begin(), B.end());
  int al = 0, bl = 0;
  REP(i, A.size()) if (ma == A[i]) al++;
  REP(i, B.size()) if (mb == B[i]) bl++;
  int nme = 0;
  REP(i, D.size()) {
    if (A[D[i].first] == ma && B[D[i].second] == mb) nme++;
  }
  cout << ma + mb - ((al * bl - nme) == 0) << endl;
  int a = 10;
}

Measured memory_bytes: 9784
#include <iostream>
#include <map>
#include <utility>
#include <set>
#include <vector>

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

using ll = long long int;

constexpr ll mod = 1e9 + 7;

class mint
{
    ll num = 0;

public:
    mint(ll x) : num(x) {}

    mint operator+(const mint &rhs)
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs)
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs)
    {
        return (num - rhs.num + mod) % mod;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

mint pow(mint x, int m)
{

    mint re = 1;

    for (int i = 0; i <= 30; ++i)
    {
        if (m & (1 << i))
            re = re * x;
        x = x * x;
    }

    return re;
}

mint inv(mint x)
{

    return pow(x, mod - 2);
}

using P = std::pair<ll, ll>;

P normal(P p)
{

    return (p.first >= 0) ? p : P(-p.first, -p.second);
}

ll gcd(ll a, ll b)
{
    if (a < b)
        std::swap(a, b);
    return (b == 0) ? a : gcd(b, a % b);
}

P red(P p)
{

    ll g = gcd(std::abs(p.first), std::abs(p.second));

    //std::cerr << "DD" << g << std::endl;

    if (p.first == 0)
        return P(0, 1);
    else if (p.second == 0)
        return P(1, 0);
    else
        return normal(P(p.first / g, p.second / g));
}

P inv(P p)
{

    if (p == P(1, 0))
        return P(0, 1);
    return normal(P(p.second, -p.first));
}

std::map<P, int> map;
std::vector<P> vec;
std::set<P> used;

int main()
{

    int n;

    std::cin >> n;

    int cnt = 0;

    rep(i, n)
    {
        ll a, b;

        std::cin >> a >> b;

        if (a == 0 && b == 0)
        {
            ++cnt;
            continue;
        }

        P p = red(P(a, b));

        ++map[p];
        if (!map.count(inv(p)))
            map[inv(p)] = 0;
    }

    for (auto p : map)
    {
        if (!used.count(p.first))
        {
            vec.emplace_back(p.second, map[inv(p.first)]);
            used.insert(p.first);
            used.insert(inv(p.first));
        }
    }

    mint ans = pow(2, n - cnt);

    //mint xx = 1;

    //std::cerr << "DEBUG" << std::endl;

    for (P p : vec)
    {
        //std::cerr << p.first << p.second << std::endl;
        ans = ans * (pow(2, p.first) + pow(2, p.second) - mint(1)) * inv(pow(2, p.first + p.second));
    }

    std::cout << (ans - 1 + cnt)
              << std::endl;

    return 0;
}

Measured memory_bytes: 56208
def showSales sales
  sales.each do |n|
    printf "-" if n == 0
    n.times do
      printf "*"
    end
    puts ""
  end
end

while (n = $stdin.gets.to_i) != 0
  sales = Array.new(10, 0)
  n.times do 
    sales[$stdin.gets.to_i] += 1
  end
  showSales sales
end

Measured memory_bytes: 6084
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    NO_TLE
    int t,n,d,x;
    cin>>n;
    cin>>d>>x;
    while(n--)
    {
        cin>>t;
        x+=(int)ceil(d*1.0/(t*1.0));
    }
    cout<<x<<endl;
    return 0;
}

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

*A, = map(int, input().split())
A.sort(reverse=True)

sum1 = 0
sum2 = 0

for i in range(len(A)):
    if i%2==0:
        sum1 = sum1 + A[i]
    else:
        sum2 = sum2 + A[i]
print(sum1-sum2)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        if (array[0] != 0) {
            System.out.println(-1);
            return;
        }
        
        long count = 0;
        int now = 0;
        for (int i = 0; i < n; i++) {
            int num = array[i];
            if (num > now + 1) {
                System.out.println(-1);
                return;
            } else if (num == now + 1) {
                count++;
            } else if (num == now) {
                count += num;
            } else {
                count += num;
            }
            now = num;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 82516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'


void run(){
    int a; cin >> a;
    cout << a + a * a + a * a * a;
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
//    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 3560
import sys
from operator import itemgetter
input = sys.stdin.readline

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

AB.sort(key=itemgetter(1, 0))

ans = 1
tmp = AB[0][1]-1
for i in range(1, M):
    if AB[i][0] > tmp:
        ans += 1
        tmp = AB[i][1]-1

print(ans)


Measured memory_bytes: 35532
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
const int XP = 1e9 + 7;
char K[1<<17];
int D;
long long dp[103][2],DP[103][2];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>(K+1)>>D;
    dp[0][0]=1; /// dp de D si 0 cifra pusa mai mica ca Ki sau 1 in cazul de egalitate
    int lg=strlen(K+1);
    for(int i=1;i<=lg;++i)
    {
        for(int j=0;j<K[i]-'0';++j)
            for(int k=0;k<D;++k)
                DP[(k+j)%D][1]=(DP[(k+j)%D][1]+dp[k][0])%XP;
        for(int k=0,j=K[i]-'0';k<D;++k)
            DP[(k+j)%D][0]=(DP[(k+j)%D][0]+dp[k][0])%XP;
        for(int j=0;j<10;++j)
            for(int k=0;k<D;++k)
                DP[(k+j)%D][1]=(DP[(k+j)%D][1]+dp[k][1])%XP;
        for(int j=0;j<D;++j)
            for(int k=0;k<2;++k)
        {
            dp[j][k]=DP[j][k]%XP;
            DP[j][k]=0;
        }
    }
    cout<<(XP+dp[0][1]+dp[0][0]-1)%XP;
    return 0;
}


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

int main() {
	int N, P, a;
	int even = 0;
	int odd = 0;
	cin >> N >> P;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a % 2 == 0) even++; else odd++;
	}

	long long answer = 0;

	if (P == 0) { // even
		if (odd == 0) answer = pow(2, even);
		else answer = pow(2, even) * pow(2, (odd - 1)); // 偶数が任意個 * 奇数が偶数個
	} else { // odd
		if (odd == 0) answer = 0;
		else answer = pow(2, even) * pow(2, (odd - 1)); // 偶数が任意個 * 奇数が奇数個
	}

	cout << answer << endl;
}

Measured memory_bytes: 256