akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
        #define ll  long long
        #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define rep(i,a,b)  for(ll i=a;i<b;i++)
        #define pb push_back
        #define Max(x,y,z) max(x,max(y,z))
        #define f first
        #define s second
        #define lbd lower_bound
        #define sz(x)       (ll)x.size()
        #define pi 3.1415926536
        #define mod 1000000007
        #define MOD 998244353
        using namespace std;
        void solve()
        {
            ll n,m,k,res=0,l=0,r=0,z,sum1=0,cnt1=0,h,c,x,y;
            string t;
            cin>>n;
            ll ar[n];
            ll temp[n];
            rep(i,0,n) {cin>>ar[i]; temp[i]=ar[i];}
            sort(temp,temp+n);
            ll cnt=0;
            rep(i,0,n){if(temp[i]!=ar[i]) cnt++;}
            if(cnt>2) cout<<"NO";
            else
                cout<<"YES";
            
            
        }
        int main()
        {   
            /*#ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif*/
     
            speed_up
            ll t;
            //cin>>t;
            t=1;
            while(t--)
                solve();
        }

Measured memory_bytes: 256
from collections import deque

INF = -1

n, t, a = map(int, input().split())
t -= 1
a -= 1
g = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(lambda x: int(x) - 1, input().split())
    g[u].append(v)
    g[v].append(u)

def bfs(start):
    dist = [INF] * n
    dist[start] = 0
    q = deque([start])
    while q:
        cur = q.pop()
        for to in g[cur]:
            if dist[to] == INF:
                dist[to] = 1 + dist[cur]
                q.appendleft(to)
    return dist

distT = bfs(t)
distA = bfs(a)
ret = 0
for v in range(n):
    if distT[v] < distA[v]:
        ret = max(ret, distA[v] - 1)
print(ret)

Measured memory_bytes: 29328
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
map<int, int> mp;
int main()
{
   int n;
   cin >> n;
   for(int x, i=0; i<n; i++)
   {
       cin >> x;
       mp[x] ++;
   }
   map<int, int>::iterator it;
   int cnt = 0;
   for(it = mp.begin(); it!=mp.end(); it ++)
   {
       if(it->second % 2 == 1)
        cnt ++;
   }
   cout<<cnt<<endl;
   return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  if ( N % 2 == 0 && S.substr(0, int(N / 2)) == S.substr(int(N / 2), int(N / 2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[200010];
ll n;
ll dp[2][200010];
int main(){
	scanf("%lld %s",&n,&s);
	rep(i,0,n)dp[0][i+1]=dp[0][i]+(s[i]=='#');
	for(int i=n-1;i>=0;i--)dp[1][i]=dp[1][i+1]+(s[i]=='.');
	ll ans=INF;
	rep(i,0,n+1){
		ans=min(ans,dp[0][i]+dp[1][i]);
//		printf("%d %d\n",dp[0][i],dp[1][i]);
	}
	printf("%lld",ans);
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n, m;
	cin >> n;
	v1 s(n);
	rep(i, n){
		int p;
		scanf("%d", &p);
		s.at(i) = p;
	}
	cin >> m;
	v1 t(m);
	rep(i, m){
		int p;
		scanf("%d", &p);
		t.at(i) = p;
	}
	int c = 0;
	rep(i, m){
		rep(j, n){
			if(t.at(i) == s.at(j)){
				c++;
				break;
			}
		}
	}
	printf("%d\n", c);
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, m, x;
int c[12];
int a[12][12];
int ans = INF;

void dfs(vector<bool> b) {
    if ((int)b.size() == n) {
        int cost = 0;
        int p[m] = {};
        rep(i, 0, b.size()) {
            if (b[i] == true) {
                cost += c[i];
                rep(j, 0, m) {
                    p[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(i, 0, m) {
            if (p[i] < x) {
                ok = false;
            }
        }
        if (ok) ans = min(ans, cost);
        return;
    }
    rep(i, 0, 2) {
        b.push_back(i);
        dfs(b);
        b.pop_back();
    }
}

int main() {
    cin >> n >> m >> x;
    rep(i, 0, n) {
        cin >> c[i];
        rep(j, 0, m) cin >> a[i][j];
    }
    vector<bool> b;
    dfs(b);
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)


int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll n=s.size();
    int k=(n-1)/2,p=0,q=0,r=0;
    for(int i=0; i<k/2; i++){
        if(s[i]!=s[k-1-i]){
            p=1;
            break;
        }
    }
    int l=(n+3)/2;
    for(int i=l; i<n; i++){
        if(s[i]!=s[n-i-1]){
            q=1;
            break;
        }
    }
    for(int i=0; i<n; i++){
        if(s[i]!=s[n-i-1]){
            r=1;
            break;
        }
    }
    //cout<<p<<q<<r<<endl;
    if(p==0 && q==0 && r==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    End
}
/* pray for me
Do before die
*/


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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



int main(void) {
	long long int n, k;
	long long int mini = LLINF;

	cin >> n >> k;
	vector<long long int> h(n);
	FOR(i, 0, n-1) {
		cin >> h[i];
	}

	sort(h.begin(), h.end());

	FOR(i, 0, INF) {
		if (i+k-1 > n - 1) {
			break;
		}
		if (h[i + k - 1] - h[i] < mini) {
			mini = h[i + k - 1] - h[i];
		}
	}

	cout << mini << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int dif(int a,int b)
{

	return a-b;
}
int main ()
{
	int a,b,c,d,e,k;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;
	cin>>k;
	if(dif(e,a)<=k)
	{
		cout<<"Yay!";
	}
	else
	{
		cout<<":(";
	}

return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;


int main(){
  int x;
  cin >> x;
  if(x == 7 || 5 == x || 3 == x){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


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

using namespace std;

#define int long long

int n, m, ans;
string s, t;

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> s >> t;
    ans = n * m / __gcd(n, m);

    int N = ans / m, M = ans / n;

    for (int i = 0; i < n; ++i) {
        if ( (i * M) % N == 0) {
            if (s[i] != t[ i * M / N]) return cout << -1, 0;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int P[10005];

int main(){
  int m, nmin, nmax;
  while(1){
    cin >> m >> nmin >> nmax;
    if(m == 0 && nmin == 0 && nmax == 0){
      break;
    }
    for(int i=0;i<m;i++){
      cin >> P[i];
    }

    int res = nmin;
    for (int i=nmin;i<=nmax;i++){
      if(P[res-1]-P[res] <= P[i-1]-P[i]){
	res = i;
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	cout << string(sz(s), 'x') << endl;
	return 0;
}



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

const int MAXN = 200005;

int n;
long long a[MAXN];

int main(){	
	scanf("%d", &n);
	
	long long sum = 0;
	for(int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
		
		sum += a[i];
		a[i] *= 2;
	}
	
	long long cur = 0;
	for(int i = 0; i < n; i++){
		cur += a[i];
		if(cur >= sum){
			if(i == 0)printf("%lld\n", cur - sum);
			else printf("%lld\n", min(cur - sum, sum - (cur - a[i])));
		
			return 0;
		}
	}
	
	printf("%lld\n", sum - (cur - a[n - 1]));

	return 0;
}


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

int main()
{
    //input
    int h,w,i,j;
    cin>>h>>w;
    char field[h][w];
    int num_bomb[h][w]={};
    //input and processing
    for(i = 0; i < h; i++)
    {
        for(j = 0; j < w; j++)
        {
            cin>>field[i][j];
            if(field[i][j]=='#')
            {
                if(i-1>=0 && j-1>=0) num_bomb[i-1][j-1]++;
                if(i-1 >= 0) num_bomb[i-1][j]++;
                if(i-1>=0 && j+1<w) num_bomb[i-1][j+1]++;
                if(j-1 >= 0) num_bomb[i][j-1]++;
                if(j+1 < w) num_bomb[i][j+1]++;
                if(i+1<h && j-1>=0) num_bomb[i+1][j-1]++;
                if(i+1 < h) num_bomb[i+1][j]++;
                if(i+1<h && j+1<w) num_bomb[i+1][j+1]++;
            }
        }
    }
    
    //output
    for(i = 0; i < h; i++)
    {
        for(j = 0; j < w; j++)
        {
            if(field[i][j]=='#') cout<<field[i][j];
            else cout<<num_bomb[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    double s=1e9;
    vector<pll>a(n);
    vector<vector<ll> >b(19,vector<ll>(19));
    ll ans=0;
    rep(i,n){
        string x;cin>>x;
        ll cnt=0;
        ll f=-1;
        rep(j,x.size()){
            if(x[j]=='.'){
                f=j;
            }
        }
        if(f>=0){
            ll m=x.size();
            rep(j,10+f-m){
                x+='0';
            }
        }else{
            rep(j,9)x+='0';
        }
        reverse(all(x));
        //cout<<x<<endl;
        ll d=0;
        ll now=1;
        ll j=0;
        while(j<x.size()){
            if(x[j]=='.'){
                j++;
                continue;
            }
            d+=now*(x[j]-'0');
            now*=10;
            j++;
        }
        ll u=0,v=0;
        while(d%2==0){
            u++;
            d/=2;
        }
        while(d%5==0){
            v++;
            d/=5;
        }
        rep(j,19){
            rep(k,19){
                if(j>=18-u&&k>=18-v){
                    ans+=b[j][k];
                }
            }
        }
        if(u>=18)u=18;
        if(v>=18)v=18;
        b[u][v]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

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

    
    ll n;
    cin>>n;
    cout<<(n-1)*n/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        double n = sc.nextInt();

        double tmp = Math.pow(100, d);
        double ans = 0;

        if(n == 100){
            ans = tmp * 101;
        } else {
            ans = tmp * n;
        }

        System.out.println((int)ans);


//        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();
//        }

//        System.out.println(search(array, 0));
//
    }
//    public static int search(int[] array, int count){
//        int tmpCount = 0;
//        int tmpTwo = 0;
//        int tmpTwoIndex = -1;
//        for(int i=0; i<array.length; i++){
//            if (array[i] % 2 == 0){
//                if(array[i]>tmpTwo){
//                    tmpTwo = array[i];
//                    tmpTwoIndex = i;
//                }
//                tmpCount++;
//            }
//        }
//        if(tmpCount == 0){
//            return count;
//        } else {
//            for(int j=0; j<array.length; j++){
//                if(j == tmpTwoIndex){
//                    array[j] = array[j] / 2;
//                    count++;
//                } else {
//                    array[j] = array[j] * 3;
//                }
//            }
//            return search(array, count);
//        }
//    }
}


Measured memory_bytes: 21716
#include<iostream>
#define ll long long int
using namespace std ;

int main() {
 	ll n , x ; 
  	cin >> n >> x ;
    ll a[n] , sum = 0 , total = 0 , sub = 0 ;
  	for(int i = 0; i < n ; i++)
      	cin >> a[i] ;
  
  	for(int i = 0 ; i < n -1 ; i++) {
     	sum = a[i] + a[i+1] ;
        if(sum > x) {
          sub = sum - x ;	
          total += sub ;
          if(a[i] <= x) {
          	  a[i+1] = x - a[i] ;
          }
          else if(a[i+1] <= sub)
            	a[i+1] = 0 ; 	
        }
    }
  cout << total << "\n" ;
}

Measured memory_bytes: 1024
#149d
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = list(input())

ans = 0
my_hand = list() #my_hand[i]:=r,p,sの場合、～勝てる手を出した。=? の場合、あいこか負けにしました。

for i in range(N):
    
    if i >= K:
        #print(i,T[i],my_hand[i-K])
        
        if T[i] != my_hand[i-K]:
            if T[i] == "r":
                ans += P
                my_hand.append("r")
            elif T[i] == "p":
                ans += S
                my_hand.append("p")
            elif T[i] == "s":
                ans += R
                my_hand.append("s")
        else:
            my_hand.append("?")
            
    else:
        #print(i,T[i],"''")
        if T[i] == "r":
            ans += P
            my_hand.append("r")
        elif T[i] == "p":
            ans += S
            my_hand.append("p")
        elif T[i] == "s":
            ans += R
            my_hand.append("s")
        
print(ans)


Measured memory_bytes: 4792
package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = int(math.MaxInt32)
const INF64 = math.MaxInt64 / 2

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func uniqIntSlice(a []int) []int {
	m := make(map[int]struct{})
	for _, v := range a {
		m[v] = struct{}{}
	}
	u := []int{}
	for k := range m {
		u = append(u, k)
	}
	return u
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

//a:old b:new a>b -> a=b (update) more small
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a>b -> a=b (update) more small
func chmin64(a *int64, b int64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax64(a *int64, b int64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}
type DP struct{
	count int
	s string
}

func main() {
	a := nextInt()
	s := nextStr()
	if a < 3200{
		fmt.Println("red")
		return
	}
	fmt.Println(s)
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from collections import defaultdict

def DD(arg): return defaultdict(arg)
INF = float('inf')

N,M = list(map(int,input().split()))
graph = {i:[] for i in range(N)}
for _ in range(M):
  a,b = list(map(int,input().split()))
  graph[a-1].append(b-1)
  
Q = [i for i in range(N)]
p = [None for i in range(N)]
heiro = []
while Q:
  state = [-1 for i in range(N)]
  Flag = 0
  s = Q.pop()
  if p[s] != None: continue
  p[s] = -1
  q = [s]
  while q:
    flag = 0
    x = q.pop()
    if x < 0:
      state[~x] = 0
      continue
    q.append(~x)
    for y in graph[x]:
      state[x] = 1
      if state[y] == -1:
        p[y] = x
        q.append(y)
      elif state[y] == 0:
        continue
      else:
        p[y] = x
        now = x
        while now != y:
          heiro.append(now)
          now = p[now]
        heiro.append(y)
        flag = 1
        break
    if flag:
      Flag = 1
      break
  if Flag:
    break

def graph_size(g):
  ret = 0
  for k in g:
    ret += len(g[k])
  return ret
def squeeze(l):
  check = [0 for i in range(N)]
  for i in l:
    check[i] = 1
  global graph
  edges = []
  subgraph = {k:[] for k in l}
  data = DD(lambda:DD(int))
  i = 0
  for k in l:
    for y in graph[k]:
      if check[y]:
        subgraph[k].append(y)
        edges.append([0,k,y])
        data[k][y] = i
        i += 1
  graph = subgraph
  s = l[0]
  i = data[p[s]][s]
  edges[i][0] = 1
  now = p[s]
  heiro = [s]
  while now != s:
    heiro.append(now)
    i = data[p[now]][now]
    edges[i][0] = 1
    now = p[now]
  if len(heiro)==len(edges):
    print(len(heiro))
    for x in heiro:
      print(x+1)
    exit()
  else:
    for b,k,y in edges:
      if not b:
        p[y] = k
        now = p[y]
        heiro = [y]
        while now != y:
          heiro.append(now)
          now = p[now]
        squeeze(heiro)

if not heiro:
  print(-1)
else:
  squeeze(heiro)

Measured memory_bytes: 75408
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const int MAX_N = 300005;
long long fact[MAX_N];
long long fact_inv[MAX_N];
long long bin_pow_mod(long long x, long long y) {
  if (x == 0)
    return 0;
  long long prod = 1;
  while (y > 0) {
    if (y & 1) {
      prod = (prod * x) % MOD;
    }
    x = (x * x) % MOD;
    y >>= 1;
  }
  return prod % MOD;
}
void init_fact() {
  fact[0] = 1, fact_inv[0] = 1;
  for (int i = 1; i < MAX_N; ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
    fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
  }
}
ll calc(ll all, ll k) {
  if (k > all) {
    return 0;
  }
  return fact[all] * fact_inv[all - k] % MOD * fact_inv[k] % MOD;
}

int main() {
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  init_fact();

  ll all = (a + b) * n, cnt = 0;
  if (all < k)
    return !printf("%d\n", 0);
  REP(i, n + 1) {
    if (all - a * i < k)
      break;
    if ((all - a * i - k) % b == 0) {
      cnt += calc(n, i) * calc(n, (all - a * i - k) / b) % MOD;
      cnt %= MOD;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(int(1e6))
 
def solve():
    num = {}
    def saiki(N):
        ##なんであれN*Dは移動できる
        res = N*D
        if N == 0:
            return 0
        elif N == 1:
            return D
        if N in num:
            return num[N]
        
        if N%2 == 0:
            res = min(res,saiki(N//2)+A)
        else:##割り切れないとき,近い割り切れる数へと移動し,割り切る.
            res = min(res,saiki((N+1)//2)+A+D,saiki((N-1)//2)+A+D)
        
        if N%3 == 0:
            res = min(res,saiki(N//3)+B)
        else:
            res = min(res,saiki(N//3)+D*(N%3)+B,saiki(N//3+1)+D*(3-N%3)+B)
        
        if N%5 == 0:
            res = min(res,saiki(N//5)+C)
        else:
            res = min(res,saiki(N//5)+D*(N%5)+C,saiki(N//5+1)+D*(5-N%5)+C)
        
        ##メモ化
        num[N] = res
 
        return res
    
    print(saiki(N))
 
for _ in range(int(input())):
    N,A,B,C,D = map(int,input().split())
    solve()

Measured memory_bytes: 20196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int d1 = 0, d2 = 0, d4 = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 != 0)
            d1++;
        if (a[i] % 2 == 0 && a[i] % 4 != 0)
            d2++;
        if (a[i] % 4 == 0)
            d4++;
    }
    if (d2)
    {
        cout << (d1 <= d4 ? "Yes" : "No") << endl;
    }
    else
    {
        cout << (d1 <= d4 + 1 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
#define x first
#define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 1000005
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n,W;cin>>n>>W;
    int w[n+1],v[n+1];
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];
    int dp[2][W+1];
    for(int i=0;i<=W;i++)dp[0][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=W;j++){
            if(j-w[i-1]>=0)
                dp[1][j]=max(dp[0][j],dp[0][j-w[i-1]] + v[i-1]);
            else
                dp[1][j]=dp[0][j];            
        }
        for(int j=1;j<=W;j++)
            dp[0][j]=dp[1][j];
    }
    cout<<dp[1][W];
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll comb[51][51];

void fill(){
	comb[0][0] = 1;
	for(int i = 1; i <= 50; i++){
		comb[i][0] = 1;
		for(int j = 1; j < i; j++) comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
		comb[i][i] = 1;
	}
}

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

	ll n,a,b;
	cin >> n >> a >> b;

	ll v[n];
	rep(i,n) cin >> v[i];

	fill();
	sort(v, v+n, greater<ll>());

	double sm = 0.0;
	rep(i,a) sm += v[i];

	cout << fixed << setprecision(20);
	cout << (1.0 * sm / a) << endl;

	ll cnt1 = 0;
	ll cnt2 = 0;
	rep(i,n){
		if(v[i] == v[a-1]){
			cnt1++;
			if(i < a) cnt2++;
		}
	}

	// 全てv[a-1]を使った場合
	if(cnt2 == a){
		ll ans = 0;
		// FOR(i, a, min(cnt1, b) + 1) ans += comb(cnt1, i);
		for(ll i = a; i <= min(cnt1, b); i++) ans += comb[cnt1][i];
		cout << ans << endl;
		return 0;
	}

	// それ以外
	cout << comb[cnt1][cnt2] << endl;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
  int n,i,j,w=0,r;cin>>n;
  string s;cin>>s;
  ll ans=0;
  i=0;
  j=n-1;
  while(i<j)
  {
      while(i<j&&s[i]=='R')i++;
      while(i<j&&s[j]=='W')j--;
      if(i<j)swap(s[i],s[j]),ans++;
  }
  cout<<ans<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

bool is_valid(char c) {
	return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}

void solve() {
	string s;
	cin >> s;
	int n = (int)s.length();
	int mx = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			if (!is_valid(s[j])) {
				break;
			}
			mx = max(mx,j-i+1);
		}
	}

	cout << mx << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1500
char s[N];
int main()
{
    while(scanf("%s",s)!=EOF)
    {
        int len=strlen(s);
        int i,a,b,c,d;
        a=b=c=d=0;
        for(i=0;i<len;i++)
        {
            if(s[i]=='N') a++;
            if(s[i]=='S') b++;
            if(s[i]=='W') c++;
            if(s[i]=='E') d++;
        }
        if((a!=0&&b!=0&&c!=0&&d!=0)||(a!=0&&b!=0&&c==0&&d==0)||(a==0&&b==0&&c!=0&&d!=0)||(a==0&&b==0&&c==0&&d==0))
            printf("Yes");
        else
            printf("No");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys

h, w = [int(x) for x in sys.stdin.readline().split()]

def devider(h,w):
	if h % 3 == 0 or w % 3 == 0:
		return 0
	else:
		l1 = h // 3
		l2 = (h // 3) + 1
		d1 = something(l1,h,w)
		d2 = something(l2,h,w)
		return min(d1,d2)

def something(l,h,w):
	a = l * w
	nh = h - l
	return aaa(a, nh, w)

def aaa(a,h,w):
	d1 = dev(a, h, w)
	d2 = dev(a, w, h)
	return min(d1,d2)

def dev(a,h,w):
	lb = w // 2
	b = lb * h
	c = (w-lb) * h
	ma = max(a,b,c)
	mi = min(a,b,c)
	return ma - mi

ans = min(devider(h,w), devider(w,h))

print(ans)

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

#define ll long long
using namespace std;

const int N = 405;
int n;
ll a[N], dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int len = 2; len <= n; len++) {
        for(int i = 1; i + len <= n + 1; i++) {
            dp[len][i] = LLONG_MAX;
            for(int j = i + 1; j <= i + len - 1; j++) {
                dp[len][i] = min(dp[len][i], a[i + len - 1] - a[i - 1] + dp[j - i][i] + dp[len - j + i][j]);
            }
        }
    }
    cout << dp[n][1] << endl;
}

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

int main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	int count = 0, count2 = 0;
	rep(i, N) {
		if (S.at(i) == 'a') {
			if (count < A + B) {
				puts("Yes");
				count++;
			}
			else puts("No");
		}
		else if (S.at(i) == 'b') {
			if (count < A + B && count2 < B) {
				puts("Yes");
				count++;
				count2++;
			}
			else puts("No");
		}
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 896
n = int(input())
h = [int(x) for x in input().split()]
i = 0
ans = 0

while sum(h):
    while True:
        if h[i] == 0 and i < n:
            i += 1
        else:
            break

    while True:
        if h[i] != 0:
            h[i] -= 1
            i += 1
        if i >= n or h[i] == 0:
            i = 0
            ans += 1
            break

print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll x;
	cin >> x;
	ll ans = 0, t = 0;
	while (ans < x) {
		t++;
		ans += t;
	}
	cout << t << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll  long long
    #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define rep(i,a,b)  for(ll i=a;i<b;i++)
    #define per(i,a,b)  for(ll i=b-1;i>=a;i--)
    #define pb push_back
    #define Max(x,y,z) max(x,max(y,z))
    #define f first
    #define s second
    #define lbd lower_bound
    #define sz(x)       (ll)x.size()
    #define pi 3.1415926536
    #define mod 1000000007
    #define MOD 998244353
    #define maxi 100000000000000000
    using namespace std;
    const int N=5005;
/*    vector<ll> adj[N];
    bool real_vis[N];
    ll dfs(ll x,bool vis[],bool rec[])
{   //cout<<x<<" ";
    vis[x]=1;
    rec[x]=1;
    for(auto y:adj[x])
        if(!vis[y] && dfs(y,vis,rec)) return true;
        else if(rec[y]) return true;
    rec[x]=false;
    return false;
}*/
    /*bool isprime(ll x)
    {
        for(ll i=2;(i*i)<=x;i++)
        {
            if(x%i==0) return 0;
        }
        return 1;
    }*/
    /*ll power(ll x,ll n)
    {
        ll res=1;
        while(n>0){
        if(n%2) res=(res*x)%mod;
        x=(x*x)%mod;
        n=n/2;}
        return res;
    }*/
    void solve()
    {
                ll n,m,z,h,a,b,c,d,e,x=0,y=0;
                cin>>n;
                cout<<(n*n*n);







    }

            int main()
            {
                speed_up
                ll t=1;
                //cin>>t;
                while(t--)
                    solve();
            }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int x, y, z; cin >> x >> y >> z;
  x -= z;
  auto num = x / (z + y);
  cout << num << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String[] s = S.split("");
        String T = sc.next();
        String[] t = T.split("");
        String ans = "";
        for(int i = 0; i < N; i++) {
            ans = ans + s[i] + t[i];
        }
        System.out.println(ans);
    }
}

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


int main() {
  int n;
  cin >> n;

  vector<int>a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  long long ans = 0;
  int big = 0;

  for (int i = 0; i < n; i++) {
    big = max(big, a.at(i));

    if (big > a.at(i)) ans += (big-a.at(i));
  }

  cout << ans << endl;
  }

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

long long n, x;

vector<long long> brg;
vector<long long> pa;

long long solve(long long n, long long x){
  if(x <= 0) return 0;
  if(n == 0) return 1;
  if(x == 1) return 0;
   
  if(x <= brg.at(n-1) + 1) return solve(n-1, x-1);
  return solve(n-1, x-brg.at(n-1)-2) + pa.at(n-1) + 1;
}

int main(){
  cin >> n >> x;
  
  brg.resize(n+1);
  pa.resize(n+1);
  brg.at(0) = 1;
  pa.at(0) = 1;
  for(int i = 1; i < n+1; ++i){
    brg.at(i) = brg.at(i-1) * 2 + 3;
    pa.at(i) = pa.at(i-1) * 2 + 1;
  }
  
  cout << solve(n, x) << endl;
}

Measured memory_bytes: 256
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        final long INF = 0x7ffffff;
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int R = scanner.nextInt();
        int[] r = IntStream.range(0, R).map(i -> scanner.nextInt() - 1).toArray();
        long[][] dist = new long[N][N];
        Arrays.stream(dist).forEach(array -> Arrays.fill(array, INF));
        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            int c = scanner.nextInt();
            dist[a][b] = dist[b][a] = c;
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    dist[j][k] = Math.min(dist[j][k], dist[j][i] + dist[i][k]);
                }
            }
        }

        long ans = INF;
        Queue<List<Integer>> queue = new ArrayDeque<>();
        queue.add(Collections.emptyList());
        while (!queue.isEmpty()) {
            List<Integer> list = queue.poll();
            if (list.size() == R) {
                long a = 0;
                for (int i = 1, l = list.get(0); i < R; i++) {
                    a += dist[r[l]][r[l = list.get(i)]];
                }
                ans = Math.min(ans, a);
            } else {
                for (int i = 0; i < R; i++) {
                    if (!list.contains(i)) {
                        List<Integer> list1 = new ArrayList<>(list);
                        list1.add(i);
                        queue.add(list1);
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

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

int main(){

    int n, needt, c;
    int out = 1001;

    cin >> n >> needt;

    for(int i = 0;i < n; i++){

        int cost, tim;

        cin >> cost >> tim;

        if(cost < out && tim <= needt)out = cost;


    }

    if(out <= 1000)cout << out << endl;
    else cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const int INF = 1e9 + 10;
const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        sp(6);
        long double x;
        cin >> x;
        cout<<x*x*x/27<<endl;


return 0;
}








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

#define ll long long
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(void) {
		ios::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		int num;
	    cin>>num;
  		
  	if(num%10 ==2 || num%10 ==4 || num%10 ==5 || num%10 ==7 || num%10 ==9 )
      	cout<<"hon\n";
  	else if(num%10==3)
      	cout<<"bon\n";
  	else
      cout<<"pon\n";
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] ch=sc.next().toCharArray();
    int[] anum=new int[26];
    int f=0,e=0;
    if(ch.length%2!=0){
      System.out.println("No");
    }else{
      for(int i=0;i<26;i++){
        anum[i]=0;
      }
      for(char flag='a';flag<='z';flag++){
        for(int i=0;i<ch.length;i++){
          if(flag==ch[i]){
            anum[f]++;
          }
        }
        if(anum[f]%2!=0){
          System.out.println("No");
          e++;
          break;
        }
        f++;
      }
      if(e==0){
        System.out.println("Yes");
      }
    }
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    int L = 1000000;
    vector<int> ans;
    for(int i = max(-L, x - k + 1); i <= min(L, x + k - 1); i++){
        ans.push_back(i);
    }
    for(int ii = 0; ii < ans.size(); ii++){
        if(ii) cout << ' ';
        cout << ans[ii];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    int ans=0;
    for (int i = 0; i < N+1; i++)
    {
        int now=0;
        for (int j = 1; j <=i; j++)
        {
            if(i%j==0)now++;
        }
        if(now==8 and i%2)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int maxn = 100000 + 5;

int n;
int a[3][maxn];
int f[maxn][3];

void plan()
{
    for (int i = 1; i <= n; ++i)
    {
        f[i][0] = max(f[i - 1][1] + a[1][i], f[i - 1][2] + a[2][i]);
        f[i][1] = max(f[i - 1][0] + a[0][i], f[i - 1][2] + a[2][i]);
        f[i][2] = max(f[i - 1][0] + a[0][i], f[i - 1][1] + a[1][i]);
    }
}

int main(int argc, char *argv[])
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    }
    
    //plan
    f[0][0] = f[0][1] = f[0][2] = 0;
    plan();

    int maxResult = INT32_MIN;
    for (int num : f[n])
    {
        maxResult = max(maxResult, num);
    }
    cout << maxResult << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n; cin >> n ;
	int k; cin >> k;
	int h[n+1];
	//h[0]  = 0;
	rep(i,1,n) cin >> h[i];
	int val[n+1] ;
	for(int i=0;i<n+1;i++) val[i] = INF ;
	//val[0]=  0;
	val[1] = 0;
	val[2]= abs(h[2]-h[1]);
	rep(i,3,n){
		for(int j = i-1;j>=i-k;j--){
		    if(j>0){
		        	val[i] = min(val[i],abs(h[i]-h[j]) + val[j]);
		    }
			
			
			
		}
	}
	cout << val[n];
	return 0;
}



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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int main(){
  int N;cin>>N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N);
  for(int i=0;i<N;i++){cin>>A[i];if(i==0)B[i]=A[i];else B[i]=gcd(B[i-1],A[i]);}
  C[N-1]=A[N-1];
  for(int i=N-2;i>=0;i--)C[i]=gcd(C[i+1],A[i]);
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==0)ans=max(ans,C[1]);
    else if(i==N-1)ans=max(ans,B[N-2]);
    else ans=max(ans,gcd(B[i-1],C[i+1]));
  }
  cout<<ans<<endl;
}

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

int main()
{
	int a,b,max;

   max=0;

   cin >> a >> b;

   if(a+b<a-b){
     max=a-b;
   }
   else{
     max=a+b;
   }
      
   if(max<a*b){
      max=a*b;
   }

   cout << max << endl;


	return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;


int main(int ac, char* av[]){
//    auto org = cin.rdbuf();
//    istringstream iss("4 0 1 2 1 2 1 1 3 3");
//    cin.rdbuf(iss.rdbuf());
//    cin.rdbuf(org);

    int N;
    cin >> N;
    if(N >= 1800){
        cout << 1 << endl;
    }else if(N >= 1600){
        cout << 2 << endl;
    }else if(N >= 1400){
        cout << 3 << endl;
    }else if(N >= 1200){
        cout << 4 << endl;
    }else if(N >= 1000){
        cout << 5 << endl;
    }else if(N >= 800){
        cout << 6 << endl;
    }else if(N >= 600){
        cout << 7 << endl;
    }else if(N >= 400){
        cout << 8 << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <stdio.h>

int main(){
  int i,d=0,s=1,n,data[251];
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&data[i]);
for(i=1;i<=n;i++){
printf("node %d: key = %d, ",i,data[i]);
if(i/2)
printf("parent key = %d, ",data[i/2]);
if(2*i<=n)
printf("left key = %d, ",data[2*i]);
if(2*i+1<=n)
printf("right key = %d, ",data[2*i+1]);
printf("\n");
}

return 0;
}


Measured memory_bytes: 2104