akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;
int dp[10004][1005];
void solve()
{
    int h,n;
    cin>>h>>n;
    int a[n+1],p[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i]>>p[i];
    for(int i=0;i<=n;i++)
        dp[0][i]=0;
    for(int i=1;i<=h;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=INF;
            if(j)
            {
                dp[i][j]=min(dp[i][j],dp[i][j-1]);
                if(a[j]>=i)
                {
                    dp[i][j]=min(p[j],dp[i][j]);
                }
                else
                {
                    dp[i][j]=min(dp[i][j],p[j]+dp[i-a[j]][j]);
                }
            }
        }
    }
    cout<<dp[h][n]<<endl;
}
int32_t main()
{
   
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}




Measured memory_bytes: 78848
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define pb push_back
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k, x;
	cin >> n;
	cin >> k;
	vector<int> co;
	for(int i=0; i<n; i++){
		cin >> x;
		co.pb(x);
	}
	int first = 0, second = 0;
	int todi = 0;
	for(int i=0; i<n; i++){
		first = 2*co[i];
		second = 2*abs(co[i]-k);
		todi += min(first, second);
	}
	cout << todi << endl;
	return  0;
}


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

const int mxn = 200010;

bool reached[mxn];
vector<int> G[mxn];

void dfs(int s, int step){
    if(step < 0) return;
    if(reached[s]) return;
    reached[s] = true;
    for(int nxt : G[s]) {
        dfs(nxt, step-1);
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(1, 2);

    if(reached[N]) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 12144
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using ld = long double;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int N = 200005;
int last[N];
int f[N];
int go[41][N];

bool u[N];
 
signed main()
{
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    fill(last, last + N, n);
    last[0] = -1;
    f[n] = 0;
    for (int i = n - 1; i >= 0; --i)
    {
        if (last[a[i]] == n)
        {
            f[i] = a[i];
        }
        else
        {
            f[i] = f[last[a[i]] + 1];
        }
        last[a[i]] = i;
    }

    for (int x = 0; x < N; ++x)
    {
        go[0][x] = f[last[x] + 1];
//        cout << x << " -> " << f[last[x] + 1] << endl;
    }

    for (int j = 1; j <= 40; ++j)
    {
        for (int x = 0; x < N; ++x)
        {
            go[j][x] = go[j - 1][go[j - 1][x]];
        }
    }
    
    int cur = 0;
    k--;
    for (int j = 40; j >= 0; --j) if (k & (1LL << j))
    {
        cur = go[j][cur];
    }

    vector<int> s;
    for (int i = last[cur] + 1; i < n; ++i)
    {
        if (!u[a[i]])
        {
            u[a[i]] = true;
            s.pb(a[i]);
        }
        else
        {
            u[a[i]] = false;
            while (s.back() != a[i])
            {
                u[s.back()] = false;
                s.pop_back();
            }
            assert(!s.empty());
            s.pop_back();
        }
    }
    for (auto &x : s) cout << x << ' ';

    return 0;
}

Measured memory_bytes: 36980
from operator import itemgetter
N = int(input())
S = [[] for i in range(N)]
for i in range(N):
    a = input().split()
    S[i].append(a[0])
    S[i].append(int(a[1]))
for i in range(N):
    S[i].append(i+1)
S = sorted(S, key=itemgetter(1),reverse=True)
S = sorted(S, key=itemgetter(0))

for i in range(N):
    print(S[i][2])

Measured memory_bytes: 3064
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>

#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;

typedef pair<int , int> P;
typedef long long int ll;
long long int MOD = 1000000007;
long long int ruiseki[200001];
int ncrset(){
  ruiseki[0] = 1;
  for(int i=1;i<200001;i++){
    ruiseki[i] = (ruiseki[i-1] * i) % MOD;
  }
}

long long int powld(long long int x,long long int n){
  long long int ans = 1;
  while(n > 0){
    if((n&1) == 1){
      ans = (ans*x)  % MOD;
    }
    x = (x*x) % MOD;
    n >>= 1;
  }
  return ans % MOD;
}

int ncrgyaku(int n,int r){
  long long int gyakuk,gyakur;
  long long int res = 1,x,y,z;
  y = powld(ruiseki[r],MOD-2);
  z = powld(ruiseki[n-r],MOD-2);
  return (((ruiseki[n]*y) % MOD)*z) % MOD;

}


int main()
{
  ll n,a[100001],l=-1,r=-1,right,left,dup,tmp;
  map<int,int> mp;
  ncrset();
  cin >> n;
  n++;
  REP(i,n){
    cin >> a[i];
    mp[a[i]]++;
    if(mp[a[i]] == 2)
      dup = a[i];
  }
  REP(i,n){
    if(a[i] == dup){
      if(l == -1)
        l = i;
      else if(r == -1)
        r = i;
      else
        break;
    }
  }
  right = n-r-1;
  left = l;
  for(int i=1;i<=n;i++){
    if(i == 1){
      cout << n-1 << endl;
    }else{
      tmp = ncrgyaku(n,i);
      l = left+right >= i-1 ? ncrgyaku(left+right,i-1): 0;
      cout << (tmp - l + 2*MOD) % MOD << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8192
s = input()
t = input()
d = []
for l in [s, t]:
    ptr = 0
    dct = dict()
    for c in l:
        if c not in dct.keys():
            dct[c] = chr(ord("A")+ptr)
            ptr += 1
    d.append([dct[c] for c in l])

print("Yes" if "".join(d[0]) == "".join(d[1]) else "No")


Measured memory_bytes: 12548
# -*- coding: utf-8 -*-
# B -


import sys

# 再起回数上限変更
sys.setrecursionlimit(1000000)

N, K = map(int, input().split())


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out


x = str(Base_10_to_n(N, K))
print(len(x))


Measured memory_bytes: 38256
# coding: utf-8
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n,a,b,k=map(int,input().split())
x=0
y=0
ans=0
mod = 998244353
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

while x<=n:
    if (k-a*x)%b==0:
        ans+=comb(n,x,mod)*comb(n,(k-a*x)//b,mod)
        ans%=998244353
    x+=1
print(ans)

Measured memory_bytes: 40768
#include<iostream>
#include<string>
using namespace std;
int main ()
{
    int n;
    int c=0;
    cin>>n;
    char ch [n];
    cin>>ch;
    for (int i=0; i<n; i++)
    {
        if(ch[i]=='A' && ch[i+1]=='B' && ch[i+2]=='C' )
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3156
sx, sy, tx, ty = list(map(int, input().split()))

ans = 'L'
for _ in range(ty-sy+1): ans += 'U'
for _ in range(tx-sx+1): ans += 'R'
ans += 'DR'
for _ in range(ty-sy+1): ans += 'D'
for _ in range(tx-sx+1): ans += 'L'
ans += 'U'

for _ in range(ty-sy): ans += 'U'
for _ in range(tx-sx): ans += 'R'
for _ in range(ty-sy): ans += 'D'
for _ in range(tx-sx): ans += 'L'

print(ans)


Measured memory_bytes: 3064
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect


"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""


X, Y = map(int,input().split())

if (Y % 2 == 0) and (Y >= 2 * X) and (Y <= 4 * X):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 77584
#include <stdio.h>
int main(){
    double a;
    while(scanf("%lf",&a)!=EOF){
        if(a<=48){
            printf("light fly\n");
        }
        else if(a<=51){
            printf("fly\n");
        }
        else if(a<=54){
            printf("bantam\n");
        }
        else if(a<=57){
            printf("feather\n");
        }
        else if(a<=60){
            printf("light\n");
        }
        else if(a<=64){
            printf("light welter\n");
        }
        else if(a<=69){
            printf("welter\n");
        }
        else if(a<=75){
            printf("light middle\n");
        }
        else if(a<=81){
            printf("middle\n");
        }
        else if(a<=91){
            printf("light heavy\n");
        }
        else printf("heavy\n");
    }
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

bool f(int i) {
	int n = 0;
	while (i) {
		i /= 10;
		n++;
	}
	if (n % 2 != 0) return true;
	else return false;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		if (f(i)) ans++;

	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()    
{    
string s;
char a;
unsigned long long int n,sum=0,l,i=0;  
cin>>s;
l=s.length();    
while(i!=l)    
{  
a=s[i];
n = a;
//cout<<n-48<<"\t";
sum=sum+(n-48);    
i++;
} 
if(sum%9==0){
cout<<"Yes\n";
}
else if(sum%9!=0){
cout<<"No\n";
}
return 0;  
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  vector<int> a(n), b(m);
  for(int & i : a) cin >> i;
  for(int & i : b) cin >> i;
  sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end());
  sort(b.begin(), b.end()); b.erase(unique(b.begin(), b.end()), b.end());
  if(a.size() != n || b.size() != m){
    cout << 0 << endl; return 0;
  }
  const int mod = 1000000007;
  int ans = 1;
  for(int i = n * m; i >= 1; i--){
    int pta = lower_bound(a.begin(), a.end(), i) - a.begin();
    int ptb = lower_bound(b.begin(), b.end(), i) - b.begin();
    if(pta == n || ptb == m) ans *= 0;
    else if(a[pta] == i && b[ptb] == i);
    else if(a[pta] == i) ans = 1ll * ans * (m - ptb) % mod;
    else if(b[ptb] == i) ans = 1ll * ans * (n - pta) % mod;
    else {
      int removed = n * m - i;	
      int area = (m - ptb) * (n - pta);
      area -= removed;
      ans = 1ll * ans * area % mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>


int main (){
    std::string S,T;
    int ans=0;
    std::cin >> S >> T;

    for (int i=0;i<S.size();i++){
        if (S[i]!=T[i]){
            ans++;
        }

    }


    
    std::cout << ans << std::endl;



}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

string solve(int n, map<int, int> mp) {
    if (SZ(mp) > 3) return "No";
    if (mp[0] == n) return "Yes";
    
    // mp.erase(0)の前に
    if (SZ(mp) == 2 && mp[0] == n / 3) return "Yes";
    mp.erase(0);
    
    // 0のみ許可
    if (SZ(mp) == 1) return "No";
    
    if (n % 3 == 0) {
        vector<pii> v;
        for (auto e : mp) {
            v.eb(pii(e.F, e.S));
            //out(e.F << " " << e.S);
        }
        
        if ((v[0].F ^ v[1].F ^ v[2].F) != 0) {
            return "No";
        }
        
        if (v[0].S == v[1].S && v[1].S == v[2].S) return "Yes";
        return "No";
    }
    return "No";
}
int main() {
    int n; cin >> n;
    map<int, int> mp;
    int a[n]; rep(i, n) { cin >> a[i]; mp[a[i]]++; }
    
    out(solve(n, mp));
    
}





Measured memory_bytes: 7808
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(Console.ReadLine());

        var S = Console.ReadLine().ToCharArray();
        var ans = "";
        if (S.Length <= K)
        {

            foreach (var s in S)
            {
                ans += s;
            }
        }
        else
        {
            for (var i = 0; i < K; i++)
            {
                ans += S[i].ToString();
            }
            ans += "...";
        }


        Console.WriteLine(ans);
        Console.ReadLine();
    }


}



Measured memory_bytes: 17684
import java.util.Scanner;

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

        int h1 = Integer.parseInt(sc.next());
        int m1 = Integer.parseInt(sc.next());

        int h2 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());

        int k = Integer.parseInt(sc.next());

        int time = (h2 - h1) * 60 + m2 - m1;

        System.out.println(time - k);

    }
}

Measured memory_bytes: 35684
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key = lambda x:x[1])
work_time = 0
#print(AB)
for ab in AB:
  deadline = ab[1]
  work_time += ab[0]
  if deadline < work_time:
    print("No")
    exit()
print("Yes")
  

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> R(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin>>R.at(i).at(j);
    }
  }
  for(int i=R.size()-1;i>=0;i--){
 	bool isallwhite=true;
    for(int j=0;j<R[0].size();j++){
      if(R.at(i).at(j)=='#')
        isallwhite=false;
    }
    if(isallwhite==true){
      R.erase(R.begin()+i);
    }
  }
  
  for(int i=R[0].size()-1;i>=0;i--){
 	bool isallwhite=true;
    for(int j=0;j<R.size();j++){
      if(R.at(j).at(i)=='#')
        isallwhite=false;
    }
    if(isallwhite==true){
      for(int j=0;j<R.size();j++)
        R[j].erase(R[j].begin()+i);
    }
  }
  
  for (int i = 0; i < R.size(); i++) {
    for (int j = 0; j < R[0].size(); j++) {
      cout<<R.at(i).at(j);
    }
    cout<<endl;
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;

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

       while(true){
        int h = sc.nextInt();
        int w = sc.nextInt();

        if(h == 0 && w == 0) break;

        for(int i= 0; i < h;i++){
           for(int j=0;j<w;j++){
               if((i%2 == 0 && j%2 == 0) || (i%2 == 1 && j%2 == 1)){
                  System.out.print("#");
               }else{
                  System.out.print(".");
               }
           }
           System.out.print("\n");
        }
        System.out.print("\n");

       }
       sc.close();
    }
}


Measured memory_bytes: 38168
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	int a[N], answer = 0;
	for (int i = 0; i < N; ++i){
		int tmp;
		scanf("%d", &tmp);
		while(tmp % 2 == 0){
			tmp = tmp >> 1;
			answer++;
		}
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s = S.length();
  int i=0,j=s/2-1,ib=s/2+1,jb=s-1;
  bool flag = true;
  while(i<=j){
    if(S[i] != S[j] || S[ib] != S[jb] || S[i] != S[ib] || S[j] != S[jb]){
      flag = false;
      break;
    }
    i++;
    ib++;
    j--;
    jb--;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    using namespace std;
    unsigned long N, K, Q;
    cin >> N >> K >> Q;
    vector<unsigned long> point(N);
    for(unsigned long i = 0, A; i < Q; ++i){
        cin >> A;
        ++point[A - 1];
    }
    for(unsigned long i = 0; i < N; ++i)puts(K + point[i] > Q ? "Yes" : "No");
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> v[m+1];
	for(int i=0; i<n; i++){
		ll a, b;
		cin >> a >> b;
		if(a<=m) v[a].push_back(b);
	}

	ll ans=0;
	priority_queue<ll> pq;
	for(int i=1; i<=m; i++){
		for(int j=0; j<v[i].size(); j++){
			pq.push(v[i][j]);
		}
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#include <iomanip>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

LD dis(int x1, int y1, int x2, int y2){
    LD ans = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    return ans;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    int x[10], y[10];
    cin >> n;
    rep(i, n)cin >> x[i] >> y[i];

    vector<int> tmp_case(n);
    for(int i = 0; i < n; i++)tmp_case[i] = i;

    LD ans = 0;
    int zen = 0;
    do{
        LD tmp_dist = 0;
        for(int i = 1; i < n; i++){
            tmp_dist = dis(x[tmp_case[i-1]], y[tmp_case[i-1]], x[tmp_case[i]], y[tmp_case[i]]);
            ans += tmp_dist;
        }
        zen++;
    }while(next_permutation(tmp_case.begin(), tmp_case.end()));

    cout << fixed << setprecision(10) << ans / zen << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b,c,d;
  cin>>k>>a>>b;
  c=a/k;
  d=b/k;
  if(c==d&&!(a%k==0||b%k==0)){
    cout<<"NG"<<endl;
  }
  else{
    cout<<"OK"<<endl;
  }
}


Measured memory_bytes: 3636
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let l: f64 = iterator.next().unwrap().parse().unwrap();
    let x: f64 = l / 3.0;
    let y: f64 = l / 3.0;
    let z: f64 = l - x - y;
    let ans = x * y * z;
    return format!("{:.12}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int s[1100][1100];

int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if((x < A && y < B) || (x >= A && y >= B)) {
                s[y][x] = 0;
            } else {
                s[y][x] = 1;
            }
            cout << s[y][x];
        }
        cout << endl;
    }
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c;cin>>a>>b>>c;
    ll ans = 0;
    if(b>=c){
        ans = b+c;
    }
    else{
        ans = 2*b;
        c -= b;
        ans += min(a+1,c);
    }
    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)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    // REP(i, k) {
    //     if (a != 0) {
    //         ans++;
    //         a--;
    //     } else if (b != 0) {
    //         b--;
    //     } else {
    //         ans--;
    //         c--;
    //     }
    // }
    if (a > k) {
        ans = k;
        k = 0;
    } else {
        k -= a;
        ans += a;
        a = 0;
    }
    if (b > k) {
        k = 0;
    } else {
        k -= b;
        b = 0;
    }
    if (k != 0) ans -= k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define LL long long int

int main(int argc, char** argv) {
    LL n,m,sum;
	cin>>n>>m;//n==s m==c
	if(n>=m) cout<<m/2<<endl;
	else {
		sum=n;
		m=m-(n*2);
		sum+=m/4;
		cout<<sum<<endl;
	}
    return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#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)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

void Main(){
    int N,Q; cin >> N >> Q;
    UnionFind uf(N);
    REP(_,Q){
        int t,u,v; cin >> t >> u >> v;
        if(t == 0){
            uf.unite(u,v);
        }
        else{
            cout << uf.same(u,v) << en;
        }
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 4776
n = gets.to_i

if n <= 1000
  puts 1000 - n
elsif n > 1000
  na = n.to_s.chars.map(&:to_i)
  change = 1000 - na[-3,3].join.to_i
  if change == 1000
    puts 0
  else puts change
  end
end

Measured memory_bytes: 14296
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
long long a,n,ans;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		ans+=a-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
   string n;
  cin >> n ;
  if(n[0]=='7' || n[1]=='7' || n[2]=='7')cout << "Yes" << endl;
  else cout << "No" << endl;
   
}

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

int main(void) {
  char a, b;
  cin >> a >> b;
  string s, d;
  int A, B;
  A = a-'0';
  B = b-'0';
  
  for(int i=0; i<B; i++){
    s += a;
  }
  for(int i=0; i<A; i++){
    d += b;
  }
  
  if(s <= d) cout << s << endl;
  else cout << d << endl;
  
  return 0;
}

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

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

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

int main() {
	constexpr int MAX_N = 10;
	vector<int> height(3, 0);

	for(int i = 0; i < MAX_N; ++i) {
		int h;
		cin >> h;

		for(int j = 0; j < 3; ++j) {
			if(height[j] < h) {
				swap(height[j], h);
			}
		}
	}

	for(const auto &e : height) {
		cout << e << "\n";
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<vector>
#include<cstring>
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G
const int INF=1e9;

int n;
vector<int> rec[100010];
struct Edge{
	int to,nxt,val;
}edge[800010];
int cnt=1,last[200010],S=2e5+1,T=2e5+2,lastcur[200010];
inline void addedge(int x,int y){
//	printf("addedge %d->%d\n",x,y);
	edge[++cnt]=(Edge){y,last[x],1},last[x]=cnt;
	edge[++cnt]=(Edge){x,last[y],0},last[y]=cnt;
}
int dep[200010]; int que[200010],hd,tl;
bool bfs(){
	memset(dep+1,-1,T*sizeof(int)); hd=tl=0;
	dep[S]=1; que[++tl]=S;
	while (hd<tl){
		int u=que[++hd],v;
		for (int i=last[u];i;i=edge[i].nxt)
			if (edge[i].val&&!~dep[v=edge[i].to]){
				dep[v]=dep[u]+1;
				if (v==T) return 1;
				que[++tl]=v;
			}
	}
	return 0;
}
int dfs(int cur,int flw){
//	printf("dfs %d %d\n",cur,flw);
	if (cur==T) return flw;
	int tmp,used=0;
	for (int &i=lastcur[cur],v;i;i=edge[i].nxt)
		if (edge[i].val&&dep[cur]+1==dep[v=edge[i].to]){
			tmp=dfs(v,min(flw-used,edge[i].val));
			edge[i].val-=tmp; edge[i^1].val+=tmp;
			used+=tmp; if (used==flw) return used;
		}
	if (!used) dep[cur]=-1;
	return used;
}
int maxflow(){
	int res=0;
	while (bfs()){
		memcpy(lastcur+1,last+1,T*sizeof(int));
		res+=dfs(S,INF);
	}
	return res;
}
int chosen[100010];
typedef pair<int,int> P;
vector<P> ans;
bool vis[100010];
int main()
{
	n=read();
	for (int i=1;i<n;i++){
		addedge(S,i+1),addedge(i+n,T);
		for (int c=read(),t;c--;){
			t=read(); rec[t].push_back(i);
			addedge(t,i+n);
		}
	}
	if (maxflow()^(n-1)) return puts("-1"),0;
	for (int i=2;i<=n;i++)
		for (int j=last[i],v;j;j=edge[j].nxt)
			if ((v=edge[j].to)>n&&(edge[j].val^1)){
				chosen[v-n]=i; break;
			}
	hd=tl=0; que[++tl]=1; vis[1]=1;
	ans.resize(n); int tot=0;
	while (hd<tl){
		int u=que[++hd],v;
		for (int i=0;i<rec[u].size();i++){
			v=chosen[rec[u][i]];
			if (!vis[v]) vis[v]=1,que[++tl]=v,ans[rec[u][i]]=(P){u,v},tot++;
		}
	}
	if (tot!=n-1) return puts("-1"),0;
	for (int i=1;i<n;i++) printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

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

int main(){
    ll h,w;
    cin >> h >> w;   
    char c[h+2][w+2];
    bool is_visited[h+2][w+2] = {false};
    ll cnt = h*w;
   
    rep(i,0,h+2) rep(j,0,w+2) c[i][j] = '#';

    rep(i,1,h+1){
        rep(j,1,w+1){
            cin >> c[i][j];
            if(c[i][j] == '#') cnt--;
        }
    }

    queue<Pll> q;
    ll d = -LINF;
    is_visited[1][1] = true;
    Pll p = Pll(P(1,1),0);
    q.push(p);
    while(!q.empty()){
        Pll v = q.front();
        q.pop();

        if(v.fs.fs == h && v.fs.sc == w){
            d = v.sc;
            break;
        }

        v.sc++;
        rep(i,0,4){
            v.fs.fs += dx[i]; v.fs.sc += dy[i];
            if(!is_visited[v.fs.fs][v.fs.sc] && c[v.fs.fs][v.fs.sc] == '.') q.push(v);
            is_visited[v.fs.fs][v.fs.sc] = true;
            v.fs.fs -= dx[i]; v.fs.sc -= dy[i];
        }
    }

    if(d != -LINF) cout << cnt  - d - 1 << endl;
    else cout << -1 << endl;
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll t, a;
	ll tr[n], ar[n];
	REP(i, n) cin >> tr[i] >> ar[i];
	t = tr[0];
	a = ar[0];
	FOR(i, 1, n){
		if(tr[i] >= t && ar[i] >= a){
			t = tr[i];
			a = ar[i];
		}
		if(tr[i] >= t && ar[i] < a){
			a = ar[i] * (a / ar[i] + 1 * (a % ar[i] != 0));
			t = (a / ar[i]) * tr[i];
		}
		if(tr[i] < t && ar[i] >= a){
			t = tr[i] * (t / tr[i] + 1 * (t % tr[i] != 0));
			a = (t / tr[i]) * ar[i];
		}
		if(tr[i] < t && ar[i] < a){
			ll a1 = ar[i] * (a / ar[i] + 1 * (a % ar[i] != 0));	
			ll t1 = (a1 / ar[i]) * tr[i];
			ll t2 = tr[i] * (t / tr[i] + 1 * (t % tr[i] != 0));
			ll a2 = (t2 / tr[i]) * ar[i];
			if(a2 < a){
				a = a1;
				t = t1;
			}
			else{
				a = a2;
				t = t2;
			}
		}
	}
	cout << a + t << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
const long long MOD = 1e9+7;
using namespace std;


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

	unsigned int A,B;
	cin >> A >> B;

	if (A<=9 && B<=9 && A*B) {
		cout << A*B << endl;
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))

ans = float('inf')
cumsum = []
sum = 0
for a in A:
    sum += a
    cumsum.append(sum)

l = 0
r = 2
for m in range(1, N-2):
    # left
    P = cumsum[l]
    Q = cumsum[m] - cumsum[l]
    dist = abs(P-Q)
    while True:
        P_ = cumsum[l+1]
        Q_ = cumsum[m] - cumsum[l+1]
        dist_ = abs(P_ - Q_)
        if dist < dist_: break
        P, Q, dist = P_, Q_, dist_
        l += 1

    # right
    R = cumsum[r] - cumsum[m]
    S = cumsum[-1] - cumsum[r]
    dist = abs(S-R)
    while True:
        R_ = cumsum[r+1] - cumsum[m]
        S_ = cumsum[-1] - cumsum[r+1]
        dist_ = abs(R_ - S_)
        if dist < dist_: break
        R, S, dist = R_, S_, dist_
        r += 1

    ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))
print(ans)


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

bool backet(char a){
  if(a=='(')return true;
  if(a==')')return true;
  if(a=='[')return true;
  if(a==']')return true;
  if(a=='{')return true;
  if(a=='}')return true;
  return false;
}

bool check(char a,char b){
  if(a=='(' && b==')')return true;
  if(a=='[' && b==']')return true;
  if(a=='{' && b=='}')return true;
  return false;
}

int main(){
  string s;
  int ans = 0;
  //int n;

  //cin >> n;
  //for(int i=0;i<n;i++){
  while(getline(cin, s)){
    if(s==".")break;
    for(int j=0;j<(int)s.size();j++)
      if(!backet(s[j])){
	s.erase(s.begin()+j);
	j--;
      }

    bool f = true;
    while(f){
      f = false;
      for(int j=0;j<(int)s.size()-1;j++)
	if(check(s[j],s[j+1])){
	  s.erase(s.begin()+j);
	  s.erase(s.begin()+j);
	  j--;
	  f = true;
	}
    }
    if(s.size())cout << "no\n";
    else cout << "yes\n";
    //if(s.size()==0)ans++;
  }
  //cout << ans << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

struct  UndirectedGraph{
    vector<vector<int>> g;
    vector<int> clr;
    vector<int> dis;
    int V;

    UndirectedGraph(int V) : V(V),
    g(vector<vector<int>>(V)),
    clr(vector<int>(V,0))
    {}

    //don't add (v,u) after adding (u,v)
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }


    //二部グラフ判定
    bool dfs_nib(int v,int c){
        clr[v]=c;
        for(auto x:g[v]){
            if(clr[x]==c) return false;
            if(clr[x]==0 && !dfs_nib(x,-c) ) return false;
        }
        return true;
    }
    bool isNib(){
        bool ret=true;
        for(int i=0;i<V;i++)if(clr[i]==0){
            if(!dfs_nib(i,1)){
                ret=false;break;
            }
        }
        return ret;
    }

    //distance
    void bfs(int st){
        dis=vector<int>(V,INF);
        vector<bool> checked(V,false);
        dis[st]=0;
        queue<int> q;
        q.push(st);
        while(!q.empty()){
            auto now=q.front();
            q.pop();
            checked[now]=true;
            for(auto x:g[now])if(!checked[x]){
                dis[x]=dis[now]+1;
                q.push(x);
            }
        }
    }
};

signed main(){
    int n;
    cin>>n;
    UndirectedGraph ug(n);
    char s[n][n];
    rep(i,n){
        rep(j,n){
            char t;cin>>t;
            s[i][j]=t;
            if(t=='1'&&i>j){
                ug.add_edge(i,j);
            }
        }
    }
    if(!ug.isNib()){
        cout<<-1<<endl;
        return 0;
    }

    
    int g[n][n];
    rep(i,n){
        rep(j,n){
            if(s[i][j]=='1'){
                g[i][j]=1;
            }
            else{
                g[i][j]=INF;
            }
        }
    }

    rep(k,n){rep(i,n){rep(j,n){
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    }}}
    int ans=-1;
    for(int st=0;st<n;st++){
        bool f=true;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++)if(s[i][j]=='1'){
                if(abs(g[st][i]-g[st][j])!=1){
                    f=false;
                }
            }
        }
        if(!f) continue;
        int gr=0;
        rep(i,n){
            if(i==st) continue;
            gr=max(gr,g[st][i]);
        }
        gr++;
        ans=max(ans,gr);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int sti(char *p){
  if(p[0]=='B'){
    return(1);
  }else if(p[1]=='C'){
    return(2);
  }
  return(0);
}

int main(){
  int n,a[3],i,j,c[100005],q[100005],f=1,k;
  char s[3];
  scanf("%d",&n);
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%s",&s);
    c[i]=sti(&s);
  }
  switch((long)a[0]+a[1]+a[2]){
    case 0:
      f=0;
      break;
    case 1:
      for(i=0;i<n;i++){
        j=c[i];
        k=(j+1)%3;
        if(a[j]==0){
          if(a[k]==0) break;
          a[j]++;
          a[k]--;
          q[i]=j;
        }else{
          a[k]++;
          a[j]--;
          q[i]=k;
        }
      }
      if(i!=n) f=0;
      break;
    case 2:
      if(a[c[0]]|a[(c[0]+1)%3]){
        for(i=0;i<n;i++){
          j=c[i];
          k=(j+1)%3;
          if(a[j]==0){
            a[j]++;
            a[k]--;
            q[i]=j;
          }else{
            if((a[j]==1)&(a[k]==1)&(i!=n-1)){
              if(c[i+1]==k){
                a[k]++;
                a[j]--;
                q[i]=k;
              }else{
                a[j]++;
                a[k]--;
                q[i]=j;
              }
            }else{
              if(a[j]>a[k]){
                a[k]++;
                a[j]--;
                q[i]=k;
              }else{
                a[j]++;
                a[k]--;
                q[i]=j;
              }
            }
          }
        }
      }else{
        f=0;
      }
      break;
    default:
      if(a[c[0]]|a[(c[0]+1)%3]){
        for(i=0;i<n;i++){
          j=c[i];
          k=(j+1)%3;
          if(a[j]==0){
            a[j]++;
            a[k]--;
            q[i]=j;
          }else{
            if(a[j]>a[k]){
              a[k]++;
              a[j]--;
              q[i]=k;
            }else{
              a[j]++;
              a[k]--;
              q[i]=j;
            }
          }
        }
      }else{
        f=0;
      }
      break;
  }
  if(f){
    printf("Yes\n");
    for(i=0;i<n;i++){
      printf("%c\n",'A'+q[i]);
    }
  }else{
    printf("No");
  }
  return(0);
}

Measured memory_bytes: 2516
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// name.order_of_key (val): returns the no. of values strictly less than val
// *name.find_by_order (k): returns the kth largest element iterator.(0-based)

#define INF32 INT_MAX
#define INF64 LLONG_MAX
#define fir first
#define sec second
#define pr_nl cout<<'\n' 
#define nl '\n' 
#define pb push_back
#define MP make_pair
#define lcm(a,b) ((a*b)/gcd(a,b))
#define SET(a,b) memset(a,b,sizeof(a))
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define fast_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

clock_t strt, ed;
double cpu_time_used;
const ld pi=acos(-1);
long long int MOD = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */


long long int fact(int n);
ll power(ll a,ll b);
const int N=(int)2e5+5;
long long int a[N],dp[N];
int main()
{
	fast_IO;strt = clock();	
//	cout<<fixed<<setprecision(10)<<nl;
    //cerr<<fixed<<setprecision(10)<<nl;
    int n;cin>>n;
    fr(i,1,n) cin>>a[i];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    fr(i,3,n){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<nl;
	ed = clock();cpu_time_used = ((double) (ed - strt)) / CLOCKS_PER_SEC;trace(cpu_time_used);
	return 0;
}
long long int fact(int n)
{
	return((n==0||n==1)?1:(n*fact(n-1)));
}
ll power(ll a,ll b)
{
	ll r=1;
	while(b){
		if(b & 01) r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    let r = cmp::min(b / a, c);
    println!("{}", r);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	int n; cin >> n;

	int a[2][n];
	int dp[2][n];

	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin >> a[i][j];
		}
	}
	dp[0][0] = a[0][0]; 
	dp[1][0] = dp[0][0] + a[1][0];
	for(int j=1;j<n;j++){
		dp[0][j] = dp[0][j-1] + a[0][j];
		dp[1][j] = max(dp[1][j-1],dp[0][j]) + a[1][j];
	}	
	cout << dp[1][n-1] << "\n";

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split()))for i in range(m)][::-1]
w=[i for i in range(n+1)]
s=[1]*(n+1)
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=s[x]
        else:
            w[y]=x
            s[x]+=s[y]
k=[]
ans=n*(n-1)//2
for i in a:
    k.append(ans)
    g=root(i[0])
    h=root(i[1])
    if g!=h:
        c=s[g]
        d=s[h]
        unite(g,h)
        ans-=(c+d)*(c+d-1)//2-c*(c-1)//2-d*(d-1)//2
        unite(g,h)
for i in k[::-1]:
    print(i)

Measured memory_bytes: 35884
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string t; cin >> t;
  rep(i, 6) {
    if(t == s[i]) {
      cout << 6-i << endl;
      return 0;
    }
  }cout << 7 << endl;
}


Measured memory_bytes: 256