akhauriyash/Code-Regression huggingface dataset:
from itertools import *
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for a,b in combinations(x,2):
  delta = 0
  for i in range(d):
    delta += (a[i] - b[i])**2
  if (delta **0.5).is_integer():
    ans += 1
print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n, k, s;
    cin >> n >> k >> s;

    vector<int> a(n);
    for(int i = 0; i < k; i++) a[i] = s;
    if(s == 1000000000){
        for(int i = k; i < n; i++) a[i] = 1;
    }
    else{
        for(int i = k; i < n; i++) a[i] = s+1;
    }

    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3720
n,*a=map(int,open(0).read().split())
tot=sum(a)
v=[1]
for q in a:
  tot-=q
  vt=min(2*(v[-1]-q),tot)
  if vt<0:
    print(-1)
    exit()
  v.append(vt)
print(sum(v))

Measured memory_bytes: 20072
#include <bits/stdc++.h>
#define forn(i,n) for(int i=0;i<int(n);i++)
#define rforn(i,n) for(int i = int(n) - 1; i >= 0; --i)

using namespace std;
typedef long long ll;

int N;
int arr[200123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> arr[i];
    }

    int i = 0;
    int nxt = 1;
    int cnt = 0;
    for(; i < N; ++i) {
        if (arr[i] == nxt) {
            nxt++;
        }
        else {
            cnt++;
        }
    }
    if (nxt == 1) {
        cout << -1 << '\n';
    }
    else {
        cout << cnt << '\n';
    }


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,K,R,Si,P;
    string S;
    cin>>N>>K>>R>>Si>>P>>S;
    
    
    ll cnt=0;
    REP(i,K){
        S+='?';
    }
    REP(i,S.length()){
        if(S[i]=='r'){
            cnt+=P;
            //s('p')
        }else if(S[i]=='s'){
            cnt+=R;
            //s('r')
        }else if(S[i]=='p'){
            cnt+=Si;
            //s('s')
        }
        if(S[i]==S[i+K]){
            S[i+K]='?';
            //s('n')
        }
    }
    
    cout<<cnt;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

signed main()
{
	int k ;cin>>k;
  string s ;	cin>>s;
  	int n = s.length();
  	if(n <=k )
      cout<<s<<endl;
  	else 
     {   for(int i = 0 ; i < k ;i++)cout<<s[i]; cout<<"..."<<endl;   } 
  




}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int sum = 0;
    int maxWaiting = 0;
    
    for (int i = 0; i < 5; i++) {
      int time = s.nextInt();
      int timeUplift = (time / 10) * 10 + (time % 10 > 0 ? 10 : 0);
      sum += timeUplift;
      maxWaiting = Math.max(maxWaiting, timeUplift - time);
    }
    System.out.println(sum - maxWaiting);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define mod 1000000007
ll mypower(ll a, ll b, ll N)
{
    ll ans = 1;
    while(b)
    {
        if(b%2)
            ans = ans*a%N;
        b=b/2;
        a=a*a%N;
    }
    return ans;
}
void bfs(vector<int> graph[], int v, int par[], int vis[])
{
    queue<int> q;
    q.push(v);
    vis[v] = 1;
    while(q.empty() == false)
    {
        int tp = q.front();
        q.pop();
        for(auto j : graph[tp])
        {
            if(!vis[j])
            {
                vis[j] = 1;
                par[j] = tp;
                q.push(j);
            }
        }
    }
}
#define PI acos(-1)
int main() {
    int n;
    cin >> n;
    int val = n%10;
    if(val == 3)
        cout << "bon";
    else if(val == 2 || val == 4 || val == 5 || val == 7 || val == 9) 
        cout << "hon";
    else
        cout << "pon";
}

Measured memory_bytes: 3560
n = int(input())
a = list( map(int,input().split()) )
b = list( map(int,input().split()) )
c = list( map(int,input().split()) )

score = 0
for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    score += c[ a[i] -1 ]

print( sum(b)+score )

Measured memory_bytes: 3064
s = int(input())
a = [s]
i = 0
while True:
    if a[i]%2==0:
        f = a[i]//2
    else:
        f = 3*a[i]+1
    if f not in a:
        a.append(f)
        i+=1
    else:
        print(i+2)
        break

Measured memory_bytes: 3060
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import Data.List
import Data.Tuple
import Data.Char
import Data.IORef
import Control.Monad

type Graph = MP.Map Int [Int]

toTuple :: B.ByteString -> (Int, Int)
toTuple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
    in
        (a, b)

make es = VU.foldl' step MP.empty (VU.map swap es VU.++ es)
    where
        step m (f,t) =
            case MP.lookup f m of
                Just _ -> MP.adjust (t:) f m
                Nothing -> MP.insert f [t] m

del graph (f,t) =
    let
        graph' = MP.adjust (delete f) t graph
        graph'' = MP.adjust (delete t) f graph' 
    in
        graph''

dfs :: Graph -> VUM.IOVector Bool -> Int -> IO Int
dfs graph table v = do
    r <- VUM.read table (v-1)
    if r 
        then return 0
        else do
            VUM.write table (v-1) True
            (table' :: VU.Vector Bool) <- VU.unsafeFreeze table
            let Just ns = MP.lookup v graph
            let ns' = delete v ns
            if (VU.and table')
                then return 1
                else if (Data.List.null ns')
                    then return 0
                    else do
                        res <- mapM (dfs graph table) ns'
                        return $ Data.List.sum res
                    
main = do
    (n,m) <- toTuple <$> B.getLine
    es <- VU.replicateM m (toTuple <$> B.getLine) 
    let graph = make es
    res <- newIORef (0 :: Int)
    forM_ [0..m-1] $ \i -> do
        tbl <- VUM.replicate n False
        let d = del graph (es VU.! i)
        solve <- dfs d tbl 1
        when (solve == 0) $ modifyIORef' res (+1)
    
    readIORef res >>= print

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int solve(int n);
int main(){
  int n;
  cin >>n;
  cout <<solve(n)<<endl;
  return 0;
}
int solve(int n){
  if(n<=3) return 1;
  if(n%3 == 0) return solve(n/3)+1;
  return solve(n/3+1)+1;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    string a,b;
    cin>>a>>b;
    ll n=a.length();
    ll i,j;
    ll res=0;
    for(i=0;i<n;i++)
    {
       res+=(a[i]!=b[i]);
    }
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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


// 重み付きUnionFind
struct WeightUnionFind {
    static const int Max = 101010;
    int par[Max];
    int ws[Max];

    void init(int n) {
        for (int i = 0; i < Max; ++i) {
            par[i] = -1;
            ws[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] < 0) {
            return x;
        }
        else {
            int parent = find(par[x]);
            ws[x] += ws[par[x]];
            return par[x] = parent;
        }
    }

    int weight(int x) {
        find(x);
        return ws[x];
    }

    void unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (par[y] < par[x]) {
            int tmp = x;
            x = y;
            y = tmp;
            w = -w;
        }
        par[x] += par[y];
        par[y] = x;
        ws[y] = w;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int diff(int x, int y) {
        if (!same(x, y)) return -1e8;
        return weight(y) - weight(x);
    }
    int size(int x) {
        return -par[find(x)];
    }
};

int main() {
    int n, q;
    WeightUnionFind uf;
    while (cin >> n >> q and n and q) {
        uf.init(n);
        rep(i, q) {
            char ch;
            cin >> ch;
            if (ch == '!') {
                int x, y, z;
                x--; y--;
                cin >> x >> y >> z;
                uf.unite(x, y, z);
            }
            else {
                int x, y;
                x--; y--;
                cin >> x >> y;
                if (uf.same(x, y)) {
                    cout << uf.diff(x, y) << endl;
                }
                else {
                    cout << "UNKNOWN" << endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3892
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
    let mut nums:Vec<String> = read_vec();
    let integer:u64 = nums[0].parse().unwrap();
    nums[1].retain(|c| c != '.');
    let fraction:u64 = nums[1].parse().unwrap();
    let res = integer * fraction;
    println!("{}",  res / 100)
}

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

int main(){
	ll n;
	ll y[110];
	string x[110],s;
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i];
	cin>>s;
	bool f=0;
	ll ans=0;
	for(int i=0;i<n;i++){
		if(f)ans+=y[i];
		if(x[i]==s)f=1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
while 1:
    try:
        N=int(input())
        if N==0:break
        matrix = [list(map(int,input().split())) for i in range(N)]
        matrix.append([])
        for i in range(N):matrix[i].append(sum(matrix[i]))
        for j in range(len(matrix)):
            pointer=0
            for k in range(N):
                pointer +=matrix[k][j]
            matrix[N].append(pointer)
        for i in range(N+1):
            for j in range(N+1):
                print(str(matrix[i][j]).rjust(5), end="")
            print()
    except:break


Measured memory_bytes: 5620
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int w;
	cin >> w;
	vector<int> A;
	for(int i = 1; i <= w; i++)A.push_back(i);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		string a, b;
		for(int j = 0; j < (int)s.size(); j++){
			if(s[j] == ','){
				a = s.substr(0, j);
				b = s.substr(j + 1);
				break;
			}
		}
		int x = stoi(a), y = stoi(b);
		x--;
		y--;
		swap(A[x], A[y]);
	}
	for(int i = 0; i < w; i++)cout << A[i] << '\n';
	return 0;
}
// Write Here



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



int main() {
  double res = 0;int n;cin >> n;
  for(int i = 0; i < n; i++) {
    double x; cin >> x; res += 1/x;
  }
  res = 1/res;
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    long double r;
    cin >> r;
    printf("%0.20Lf\n", (long double)(2 * 3.141592653589793238 * r));
    return 0;
}

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

int solve(int n, int k, vector<int>h){
  vector<int>dp(n);
  rep(i,n) dp[i] = INF;
  dp[0] = 0;

  for(int i=0; i<n; i++){
    for (int j=i+1; j<=i+k; j++){
      if (j<n){
        dp[j] = min(
          dp[i] + abs( h[i] - h[j] ),
          dp[j]
        );
      }
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  cout << solve(n,k,h);
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,limitt,mincost;
  cin >> n>>limitt;
  mincost=1001;
  int cost,time;
  for (int i = 0; i < n; i++) {
      cin >> cost>>time;
    if( time<=limitt && cost<mincost )
      {mincost=cost;}
  }
  
  if (mincost==1001){cout<<"TLE";}
  else{cout<<mincost;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,l;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>l;
    rep(i,n){
        a[i]=l+i;
    }
    tmp=LINF;
    rep(i,n){
        tmp=min(tmp,abs(a[i]));
    }
    rep(i,n){
        if(tmp==abs(a[i])){
            tmp=LINF;
        }
        else{
            ans+=a[i];
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
function main(input){
    input = input.split(' ');
    inputA = parseInt(input[0]);
    inputB = parseInt(input[1]);
    inputK = parseInt(input[2]);

    inputA = inputA - inputK;
    if(inputA<0){
        inputB = inputB + inputA;
        inputA = 0;
    } 
    if(inputB<0){
        inputB = 0;
    }

    console.log(inputA+' '+inputB);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<ll> P(n); rep(i, n) cin >> P[i];
  cout << fixed << setprecision(20);
  double sum = 0;
  rep(i, k) sum += P[i]*(P[i]+1)/2/(double)P[i];
  double mx = sum;
  for(int i=k; i<n; i++) {
    sum += P[i]*(P[i]+1)/2/(double)P[i] - P[i-k]*(P[i-k]+1)/2/(double)P[i-k];;
    mx = max(sum, mx);
  }
  cout << mx << "\n";
  return 0;
}


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

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

	if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
		cout << "pon";
	else if(N%10 == 3)
		cout << "bon";
	else
		cout << "hon";
	cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

const int MAXN = 2e5 + 10;

int n, a[MAXN], pos[MAXN], d[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
	memset(pos, -1, sizeof(pos));
	int ans = 0;
	for (int i = 0; i < n; i++){
		d[i] = 1;
		if (a[i] && ~pos[a[i]-1])
			d[i] = max(d[i], d[pos[a[i]-1]] + 1);
		pos[a[i]] = i;
		ans = max(ans, d[i]);
	}
	cout << n-ans << endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(a*b/2);                                                                                                                                                              
    }   
}



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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a;
    cin>> a;

  //  cout<< a* (1+ a*( 1+ a));
  cout<< a+ a*a+ a*a*a;
    nl;


    return 0;
}




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

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> p(N + 1);
    rep(i, N)cin >> p[i + 1];
    rep(i, N)p[i + 1] += p[i];

    ll res = 0;
    rep(i, N - K + 1) {
        res = max(res, p[i + K] - p[i]);
    }
    cout << fixed << setprecision(10) << (double)(res + K) / 2 << endl;

    return 0;
}


Measured memory_bytes: 1792
### subroutines

def greater?(s0, s1)
  sl0 = s0.length
  sl1 = s1.length
  sl0 > sl1 || (sl0 == sl1 && s0 > s1)
end

### main

loop do
  $w, $h = gets.split.map(&:to_i)
  break if ($w | $h) == 0

  $grids = $h.times.map{[]}

  for y in (0...$h)
    line = gets.strip
    for x in (0...$w)
      case line[x]
      when '0'..'9'
        $grids[y][x] = line[x]
      else
        $grids[y][x] = nil
      end
    end
  end
  #p $grids

  max_seq = ''
  dp = $h.times.map{$w.times.map{''}}

  for y in (0...$h)
    for x in (0...$w)
      g = $grids[y][x]
      next if g.nil?

      seq = g

      if x > 0
        seq0 = dp[y][x - 1] + g
        seq = seq0 if greater?(seq0, seq)
      end
      if y > 0
        seq1 = dp[y - 1][x] + g
        seq = seq1 if greater?(seq1, seq)
      end

      next if seq == '0'

      dp[y][x] = seq
      max_seq = seq if greater?(seq, max_seq)
    end
  end

  puts max_seq
end

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;


int main()
{
    fio;

    int n;cin>>n;

    int arr[n+1],frnt[n+1],bak[n+1];
    int gc=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        frnt[i]=__gcd(arr[i],gc);
        gc=frnt[i];
    }
    gc=0;
    for(int i=n-1;i>=0;i--)
    {
        bak[i]=__gcd(arr[i],gc);
        gc=bak[i];
    }
    int mx=-1;
    for(int i=0;i<n;i++){
        if(i==0)gc = bak[1];
        else if(i==n-1) gc = frnt[n-2];
        else gc = __gcd(frnt[i-1],bak[i+1]);
        mx = max(mx,gc);
    }

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


Measured memory_bytes: 4788
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <deque>

using namespace std;

int main(){
	int n;
	int s[10001];
	int t[501];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	int q;
	cin >> q;
	int count = 0;
	for (int i = 0; i < q; i++){
		cin >> t[i];
	}
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++){
			if (t[i] == s[j]){
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

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

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

    int ans = 0;

    for(int i = A; i <= B; i++) {
        string s = to_string(i);
        if(s[0] != s[4] || s[1] != s[3]) continue;
        ans++;
    }

    cout << ans << endl;
}

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();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    double total=0;
    for(int i=0;i<n;i++){
      total+=(double)1/a[i];
    }
    System.out.println((double)1/total);
  }
}

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())

#define REP(a, b) for (int a = 0; a < (b); a++)
#define FOR(a, b, c) for (int a = (b); a <= (c); a++)
#define REPD(a, b) for (int a = (b) - 1; a >= 0; a--)
#define FORD(a, b, c) for (int a = (b); a >= (c); a--)

#define MIN(a, b) (a) = min((a), (b))
#define MAX(a, b) (a) = max((a), (b))

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2> &p) {
  return is >> p.fi >> p.se;
}

const int N = 3003;

int n;
int a[N];
ll dp[N][N];
bool visit[N][N];

ll go(int l, int r) {
  if (l > r) return 0;
  if (visit[l][r]) return dp[l][r];
  int turn = (n - (r - l + 1)) % 2;
  if (turn == 0) {
    dp[l][r] = max(a[l] + go(l + 1, r), a[r] + go(l, r - 1));
  } else {
    dp[l][r] = min(go(l + 1, r) - a[l], go(l, r - 1) - a[r]);
  }
  visit[l][r] = true;
  return dp[l][r];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  REP(i, n) cin >> a[i];
  cout << go(0, n - 1) << endl;
}


Measured memory_bytes: 78592
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(ALL(a));
    ll m=a[n-1];
    ll p=-1;
    rep(i,n){
        if(a[i]!=m && abs(2*a[i]-m)<abs(2*p-m))p=a[i];
    }
    cout<<m<<" "<<p<<endl;
}

Measured memory_bytes: 1024
n=int(input())
list=[[0 for i in range(13)]for j in range(4)]
for aa in range(n):
	x,y=(input().split())
	y=int(y)-1
	if x=='S' :
		list[0][y]=1
	elif x=='H' :
		list[1][y]=1
	elif x=='C' :
		list[2][y]=1
	elif x=='D' :
		list[3][y]=1
for z in range(13):
	if list[0][z]==0:
		print('S '+str(z+1))		
for z in range(13):
	if list[1][z]==0:
		print('H '+str(z+1))
for z in range(13):
	if list[2][z]==0:
		print('C '+str(z+1))
for z in range(13):
	if list[3][z]==0:
		print('D '+str(z+1))


Measured memory_bytes: 5616
#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 repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    int kl = d[n/2-1];
    int kr = d[n/2];
    cout << (kr - kl) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int a, b, c;cin>>a>>b>>c;
    int k;cin>>k;
    if(a<b)  swap(a,b);
    if(a<c) swap(a,c);
    cout<<b + c + a*pow(2,k)<<endl;
    
    return 0;
}







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

long long dp[105][100005] = {};

int main()
{
    int n, weight;
    cin >> n >> weight;
    vector<int> W(n + 1), V(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> W[i] >> V[i];

    for (int i = 1; i <= n; ++i)
    {
        for (int w = 1; w <= weight; ++w)
        {
            if (w >= W[i])
                dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - W[i]] + V[i]);
            else
                dp[i][w] = dp[i - 1][w];
        }
    }

    cout << dp[n][weight] << endl;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i=0;i<m;i++) cin >> x[i];
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(),x.end());
    vector<int> dis(m-1);
    for(int i=0;i<m-1;i++){
        dis[i]=x[i+1]-x[i];
    }
    sort(dis.begin(),dis.end());
    for(int i=0;i<n-1;i++){
        dis.pop_back();
    }
    int ans=0;
    for(int i=0;i<dis.size();i++){
        ans+=dis[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)

#define ll long long

const int MOD = 1e9 + 7;

vector<int> v[200001];
int pos[200001] = {0};

int br = 0;

void dfs(int x) {

    // cout<<"--"<<x<<" "<<l<<"\n";

    br++;
    pos[x] = 1;

    int i;
    for (i=0;i<v[x].size();i++)
    if (pos[v[x][i]] == 0) {
        // pos[v[x][i]] = 1;
        dfs(v[x][i]);
    }

}

int main() {

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

    // freopen("input.in", "r", stdin);

    int n,m;
    cin>>n>>m;
    int i;

    ll baza = 0ll;

    for (i=0;i<m;i++) {
        int a1, b1;
        cin>>a1>>b1;
        v[a1].pb(b1);
        v[b1].pb(a1);
    }

    int max1 = -1;

    for (i=1;i<=n;i++)
    if (pos[i] == 0) {
        br = 0;
        dfs(i);
        // cout<<"\n";
        // cout<<max1<<"\n";
        if (br>max1)
            max1 = br;
    }

    cout<<max1<<"\n";

    return 0;
}

Measured memory_bytes: 21536
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(i64, N, K, Q);

    vector<i64> score(N, K);
    rep(i, Q) {
        var(int, a);
        --a;
        score[a] += 1;
    }

    rep(i, N) {
        score[i] -= Q;
    }

    trace(score);

    rep(i, N) {
        print((score[i] > 0) ? "Yes" : "No");
    }

    return 0;
}


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

#define MAXN 100010
#define ll long long
#define mod 1000000007

using namespace std;

int n;

int a[MAXN];

int main() {
	int f = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				f = 0;
			}
		}
	}
	if (f) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

bool isPrime(ll x)
{   
    bool ans = true;
    if(x == 1) ans = false;
    else{

        for(ll i = 2; i * i <= x; i++){
            if(x % i == 0) ans = false;
        }
    }

    return ans;
}

int main(void)
{
    ll n, k;
    cin >> n >> k;
    vector<ll> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end(), greater<ll>());
    ll ans = 0;
    for(int i = 0; i < k; i++) ans += l[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,ans,c=0;
    scanf("%d",&n);
    while(n!=0)
    {
        ans=n%10;
        if(ans==7)
        {
            c=1;
            break;
        }
        n/=10;
    }
    if(c==1)
    printf("Yes");
    else
    printf("No");
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
	x=0;int f=1;char c=getchar();
	for(;c>'9'||c<'0';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=f;
}
template <typename T> inline void print(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) print(x/10);
	putchar(x%10+48);
}
long long s1[1010010],x,y,z,sum=0;
int main()
{
	read(x);
	for(register int i=1;i<=x;i++)
	{
		read(s1[i]);
		if(s1[i]%2!=0)
			sum++;
	}
	if(sum%2==0)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int main(){
    unsigned long long N, W;
    std::cin >> N >> W;
    std::vector<unsigned long long> w(N + 1);
    std::vector<unsigned long long> v(N + 1);
    for (unsigned i = 1; i < N + 1; ++i) {
        std::cin >> w[i] >> v[i];
    }
    auto C = w[1];
    for (auto &i : w){
        i -= C;
    }
    std::vector<std::vector<std::vector<unsigned long long>>> dp(N + 1,
            std::vector<std::vector<unsigned long long>>(N + 1,
            std::vector<unsigned long long>(3 * N + 1, 0)));
    for (unsigned i = 1; i < N + 1; ++i) {
        for (unsigned j = 1; j < N + 1; ++j) {
            for (unsigned k = 0; k < 3 * N + 1; ++k) {
                if (k >= w[i] && dp[i - 1][j - 1][k - w[i]] + v[i] > dp[i-1][j][k]) {
                    dp[i][j][k] = dp[i-1][j-1][k-w[i]] + v[i];
                } else {
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }
    unsigned long long max = 0;
    for (unsigned i = 1; i <= N; ++i) {
        if (i * C <= W) {
            max = std::max(max, dp[N][i][std::min(3 * N, W - i * C)]);
        }
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 24832
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
//#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	char str[50];
	
	cin >> str;
	
	int len = strlen(str);

	for (int i = len - 1; i >= 0; i--){
		cout << str[i];
	}
	cout << endl;

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1128
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int n,A[MAX],B[MAX],k;

void CountingSort();

int main(){

  int i, j;

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

  CountingSort();
  for(i=1;i<n+1;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
printf("\n");

  return 0;
}

void CountingSort()
{
  int i,j,C[VMAX]={};
  
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
    
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}


Measured memory_bytes: 17412
import java.util.Scanner;
class Main{
	public void Germany() {
		Scanner sc = new Scanner(System.in);
		double r,men,syu;
		double ens = 3.141592653589;
		r = sc.nextDouble();
		men = ens * (r * r);
		syu = 2 * ens * r;
		System.out.printf("%2.6f %2.6f",men,syu);
	}
	    public static void main(String[] args) {
	        new Main().Germany();
	    }
	}

Measured memory_bytes: 19128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int N, M;
    static List<int>[] G; 
    static void INPUT()
    {
        N = NextInt();
        M = NextInt();
        G = new List<int>[N  + 1];
        for (int i = 0; i <= N; i++)
        {
            G[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            var a = NextInt();
            var b = NextInt();
            G[a].Add(b);
            G[b].Add(a);
        }
    }

    static void OUT()
    {
        var que = new Queue<int>();
        var a = new int[N + 1];
        a[1] = -1;
        que.Enqueue(1);
        while(que.Any())
        {
            var p = que.Dequeue();
            foreach(var n in G[p])
            {
                if (a[n] != 0) continue;

                que.Enqueue(n);
                a[n] = p;
            }
        }
        if (a.Skip(2).Any(__ => __ == 0))
        {
            Console.WriteLine("No");
            return;
        }
        Console.WriteLine("Yes");
        Console.WriteLine(string.Join("\n", a.Skip(2)));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 39140
import java.awt.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n+1];
        int[] b=new int[n];
        for(int i=0;i<=n;i++)a[i]=sc.nextInt();
        for(int i=0;i<n;i++)b[i]=sc.nextInt();

        long count=0;

        for(int i=n-1;i>=0;i--){
            for(int j=1;j>=0;j--){

                int x = a[i + j];
                int y = b[i];

                int m=Math.min(y,x);

                count=count+m;
                b[i]=b[i]-m;
                a[i+j]=a[i+j]-m;
            }
        }
        System.out.println(count);

    }

}



Measured memory_bytes: 64796
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll N) {
  cout << "ABC" << N << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
spot_list = list(map(int,input().split()))
max_cost = 0

#maxの計算
for i in range(1,len(spot_list)):
    max_cost += abs(spot_list[i]-spot_list[i-1])
max_cost += abs(spot_list[0])+abs(spot_list[len(spot_list)-1])

spot_list = [0] + spot_list + [0]
for i in range(1,len(spot_list)-1):
    d_pay = abs(spot_list[i-1]-spot_list[i+1]) - (abs(spot_list[i]-spot_list[i-1])+abs(spot_list[i+1]-spot_list[i]))
    print(max_cost+d_pay)


Measured memory_bytes: 13920