akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL LMAX = 100;

LL ec = 1,to[2000005],cap[2000005],w[2000005],nxt[2000005],hed[1000005] = {0};
void add_edge(LL f,LL t,LL c,LL d){
	++ ec; to[ec] = t; cap[ec] = c; w[ec] = d; nxt[ec] = hed[f]; hed[f] = ec;
	++ ec; to[ec] = f; cap[ec] = 0; w[ec] = -d; nxt[ec] = hed[t]; hed[t] = ec;
}

LL dis[4005],inq[4005],flw[4005];
LL pre[4005],prv[4005];

queue <LL> q;
LL spfa(LL s,LL t){
	memset(dis,INF,sizeof(dis));
	memset(inq,0,sizeof(inq));
	memset(flw,0,sizeof(flw)); prv[t] = -1;
	q.push(s); inq[s] = 1; dis[s] = 0; flw[s] = INF;
	while(!q.empty()){
		LL u = q.front(); q.pop();
		inq[u] = 0;
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(dis[v] > dis[u] + w[i] && cap[i]){
				dis[v] = dis[u] + w[i];
				prv[v] = u; pre[v] = i;
				flw[v] = min(flw[u],cap[i]);
				if(!inq[v]){
					inq[v] = 1;
					q.push(v);
				}
			}
		}
	}
	return prv[t] != -1;
}

LL mxf = 0,mcf = 0;
void mcmf(LL s,LL t){
	while(spfa(s,t)){
		mxf += flw[t];
		mcf += flw[t] * dis[t];
		LL now = t;
		while(now != s){
			cap[pre[now]] -= flw[t];
			cap[pre[now] ^ 1] += flw[t];
			now = prv[now];
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	LL n,x,y,w,S,T;
	cin >> n;
	S = n + n + 5; T = S + 1;
	for(LL i = 1;i <= n;i ++){
		cin >> x >> y >> w;
		add_edge(S,i,w,0);
		add_edge(i,n + n + 1,INF,+ x + y);
		add_edge(i,n + n + 2,INF,+ x - y);
		add_edge(i,n + n + 3,INF,- x + y);
		add_edge(i,n + n + 4,INF,- x - y);
	}
	for(LL i = 1;i <= n;i ++){
		cin >> x >> y >> w;
		add_edge(i + n,T,w,0);
		add_edge(n + n + 1,i + n,INF,- x - y);
		add_edge(n + n + 2,i + n,INF,- x + y);
		add_edge(n + n + 3,i + n,INF,+ x - y);
		add_edge(n + n + 4,i + n,INF,+ x + y);
	}
	mcmf(S,T);
	cout << -mcf << endl;
	return 0;
}
//

Measured memory_bytes: 8704
#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>;
 
const int M = 1000005;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int count = 0;
  int missing;
  missing = 54 - n;
  int card[13][4];//[][0] =S;[][1] =H;[][2] =C;[][4] = D;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 13;j++){
      card[j][i] = 0;//found:1, NOT found:0
    }
  }
  for(int k = 0;k < n;k++){
    char s1;
    int s2;
    cin.ignore();
    cin >> s1 >> s2;
    if(s1 == 'S'){
      card[s2-1][0] = 1;
    }else if(s1 == 'H'){
      card[s2-1][1] = 1;
    }else if(s1 == 'C'){
      card[s2-1][2] = 1;
    }else if(s1 == 'D'){
      card[s2-1][3] = 1;
    }
  }
  for(int i2 = 0;i2 < 4; i2++){
    for(int j2 = 0; j2 < 13; j2++){
      if(card[j2][i2] == 0){
	if(i2 == 0){
	  cout << "S " << j2+1 << endl;
	}else if(i2 == 1){
	  cout << "H " << j2+1 << endl;
	}else if(i2 == 2){
	  cout << "C " << j2+1 << endl;
	}else if(i2 == 3){
	  cout << "D " << j2+1 << endl;
	}
      }
    }
  }
}



Measured memory_bytes: 3072
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 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 euclid (x:i32, y:i32) -> i32 {
    let mut a:i32 = x;
    let mut b:i32 = y;
    let mut dr:i32;//devision remainder
    
    // if a == b { a }

    loop {
        dr = a % b;
        if dr == 0 { 
            return b 
        }
        a = b;
        b = dr;
    }

}

//整数 x, y について、x ≥ y ならば x と y の最大公約数は y と x % y の最大公約数に等しい。
fn main(){
    let x:Vec<i32> = read_vec();
    let a;
    let b;
    if x[0] > x[1] {
        a = x[0];
        b = x[1];
    } else {
        a = x[1];
        b = x[0];
    }
    let ans = euclid(a, b);
    println!("{}", ans);
}




Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if(N<=K) cout << X * N << endl;
  else cout << X * K + (N-K) * Y << endl;
}

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

int main() {
	string s;
	ll k;
	cin >> s >> k;
	k--;
	rep(i, s.size()) {
		if(s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
		if(k == i) {
			cout << s[i] << endl;
			return 0;
		}
	}
	
	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 all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int n,m;cin>>n>>m;
    pair<int,int> s[n];
    pair<int,int> p[m];
    for(int i=0;i<n;i++)cin>>s[i].first>>s[i].second;
    for(int i=0;i<m;i++)cin>>p[i].first>>p[i].second;
    for(int i=0;i<n;i++){
        int min[2]={-1,(int)MOD*MOD};
        for(int j=0;j<m;j++){
            int manhattan=abs(s[i].first-p[j].first)+abs(s[i].second-p[j].second);
            if(manhattan<min[1]){
                min[0]=j+1;
                min[1]=manhattan;
            }
        }
        cout<<min[0]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << (n * (n-1))/2 + (m * (m-1)) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, m, p, wa = 0, ac = 0;
    char c[3];
    string s;
    cin >> n >> m;
    vector<pair<int, int>> aw(n, make_pair(0, 0));
    for(int i = 0; i < m; i++){
        scanf("%d %s", &p, c);
        s = c;
        if(s == "WA") {
            if(aw[p-1].second == 0) {
                aw[p-1].first++;
            }
        }
        if(s == "AC") {
            aw[p-1].second = 1;
        }
    }
    for(int i = 0; i < n; i++) {
        wa += (aw[i].second == 1 ? aw[i].first : 0);
        ac += aw[i].second;
    }
    cout << ac << ' ' << wa << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
    IO;
    int n, k;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += p[i];
    }
    cout<<ans<<endl;
    return 0;

}




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

int main() {
  long X, Y;
  cin >> X >> Y;
  if (X % Y) {
    long ub = 1;
    for (int i = 0; i < 18; i++) ub *= 10;
    for (int i = 1; X * i <= ub; i++) {
      long x = X * i;
      if (x % Y != 0) {
        cout << x << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}

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

 int main() {
   ll N, ans = 1;
   cin >> N;
   map<ll, ll> PF;
   for (ll i = 2; i <= N; i++) {
     ll tmp = i;
     for (ll p = 2; p * p <= tmp; p++) {
         if (tmp % p != 0) continue;
         ll num = 0;
         while (tmp % p == 0) {
            tmp /= p;
            PF[p]++;
         }
     }
     if (tmp != 1) PF[tmp]++;
   }
   for (auto p : PF) ans = ans * (p.second + 1) % MOD;
   cout << ans << endl;
 }


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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


void Main() {
	int N, M; cin >> N >> M;
	auto day = makeVector(100005, 0, 0);
	for (int i = 0; i < N; i++) {
		int A, B; cin >> A >> B;
		if (M-A >= 0) day[M-A].push_back(B);
	}
	priority_queue<int> pq;
	int sum = 0;
	for (int x = M-1; x >= 0; x--) {
		for (auto &d : day[x]) {
			pq.push(d);
		}
		if (!pq.empty()) { sum += pq.top(); pq.pop(); }
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 8568
{-# LANGUAGE
  ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll,
  LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP,
  NoMonomorphismRestriction, GADTs, PatternGuards, MagicHash, UnboxedTuples,
  RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns, PolyKinds,
  TypeFamilies, OverloadedStrings, FlexibleInstances, UndecidableInstances,
  DefaultSignatures, GeneralizedNewtypeDeriving, StandaloneDeriving,
  DeriveGeneric, DeriveFunctor, DeriveDataTypeable, DeriveFoldable,
  DeriveTraversable, DeriveDataTypeable, FlexibleInstances,
  MultiParamTypeClasses #-}
{-# OPTIONS_GHC -O2 #-}

import Prelude
import Data.Monoid
import System.IO
import Control.Applicative
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Lazy.Char8 as BSL
import qualified Data.ByteString.Lazy as BSLW
import qualified Data.ByteString.Builder as BSB
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Generic as VG
import Data.Word

main :: IO ()
main = do
  [k,q] <- map readInt . words <$> getLine
  !ds <- getVecULn k rIntS
  printVecInLines =<< getVecURest q (liftA3 (query ds) rIntL rIntL rIntL)

query :: VU.Vector Int -> Int -> Int -> Int -> Int
query !ds !n !x !m = VU.ifoldr
      (\ !i !dj cont !cnt0 !tot ->
         let !cnt = if i < offCycle then numCycles+1 else numCycles
         in if dj == 0 then (cont $! cnt0 + cnt) tot
                       else cont cnt0 $! tot + dj * cnt)
      (\ !cnt0 !aLast -> (n-1) - (cnt0 + aLast `quot` m - a0 `quot` m))
      dsModded 0 x
  where
    dsModded = VU.map (`rem` m) ds
    !a0 = x
    !(!numCycles,!offCycle) = divMod (n-1) (VU.length ds)

#define IL(f) {-# INLINE f #-}; f

printVecInLines ::
  (VG.Vector v a, ShowAsBuilder a) => v a -> IO ()
IL(printVecInLines) = BSB.hPutBuilder stdout . v2BLines

class ShowAsBuilder a where
  showAsBuilder :: a -> BSB.Builder

instance ShowAsBuilder Int where
  {-# INLINE showAsBuilder #-}
  showAsBuilder = BSB.intDec

v2BLines ::
  (VG.Vector v a, ShowAsBuilder a)
  => v a -> BSB.Builder
{-# INLINE v2BLines #-}
v2BLines
  = VG.foldr (\ a -> (showAsBuilder a <>) . (BSB.char7 '\n' <>)) mempty

IL(getVecULn) :: (VU.Unbox a) =>
  Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
getVecULn n s = VU.unfoldrN n (runStateT s) <$> BS.getLine
IL(getVecURest) :: (VU.Unbox a) =>
  Int -> StateT BSL.ByteString Maybe a -> IO (VU.Vector a)
getVecURest n s = VU.unfoldrN n (runStateT s) <$> BSL.getContents

IL(rIntL) :: StateT BSL.ByteString Maybe Int
rIntL = modify (BSLW.dropWhile isSpecialQuick) *> StateT BSL.readInt
IL(rIntS) :: StateT BS.ByteString Maybe Int
rIntS = modify (BSW.dropWhile isSpecialQuick) *> StateT BS.readInt

isSpecialQuick :: Word8 -> Bool
isSpecialQuick = (< fromIntegral (fromEnum '!'))

readInt :: String -> Int
{-# INLINE readInt #-}
readInt = read


Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int co=0;
  for(int i=0;i<n;i++){
    int nu;
    cin >> nu;
    int f=0;
    for(int i=2;i*i<=nu;i++){
      if(nu%i==0){
	f=1;
	break;
      }
    }
    if(!f)co++;
  }
  cout << co << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

struct UnionFind{
  vector<int> par;

  UnionFind(int n){
    par.resize(n);
    int ii;
    for(ii=0;ii<n;ii++){
      par[ii] = ii;
    }
    
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x,int y){
    int root_x = root(x);
    int root_y = root(y);
    if(root_x == root_y) return;
    par[root_x] = root_y;
  }

  bool same(int x,int y){
    int root_x = root(x);
    int root_y = root(y);
    return root_x == root_y ;
  }
};

int main(){

  long ii,jj,kk;
  vector<int> a;
  int n,q;
  cin >> n >> q;

  UnionFind u(n);

  int com,x,y;
  for(ii=0;ii<q;ii++){
    cin >> com >> x >> y;
    if(com == 0){
      u.unite(x,y);
      //cout << x << " " << y << endl;
    }
    else{
      if(u.same(x,y)){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 3196
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)
    val b = readLine()!!.split(" ").map(String::toInt)
    val c = readLine()!!.split(" ").map(String::toInt)

    var point = 0

    a.forEachIndexed { i, v ->
        point += b[v - 1]
        if (i < n - 1 && a[i + 1] == v + 1) {
            point += c[v - 1]
        }
    }

    println(point)
}

Measured memory_bytes: 37732
import java.util.*;

class Main {
  public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      //動物の数
    int x = sc.nextInt();
    //足の数
    int y = sc.nextInt();
    for(int i = 0; i <= x;i++){
      for(int j = 0; j <= x; j++){
        if(i + j == x && (2 * i + 4 * j == y)){
          System.out.print("Yes");
          return;
        }
      }
    }
    System.out.print("No");
  }
}

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

typedef long long ll;
int main() {
  ll n;
  cin>>n;
  
  vector<ll> a(n);
  bool has_zero = false;
  for(ll i = 0;i < n;i++) { 
    cin>>a[i];
    if(a[i] == 0){
      has_zero = true;
    } 
  }
  
  ll ans= 1;
  for(int i =0;i < n;i++) {
    if(a[i] > 1e18L / ans)
      ans = 1e18L + 1;
    else
    	ans*=a[i];
  }
  
  if(has_zero || ans <= 1e18L){
    cout<<ans;
  }
  else {
    cout<<-1;
  }
  
  return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 9e5+10;
int n;
DD d, x;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(false);
	cout.tie(false);
	cin >> n >> d >> x;
	DD ans = 0;
	for(int i = n; i; i--){
		int t = i * 2;
		ans += d + x * (t - 1) / 2.0;
		d = d * (i - 1) / i + (4 * d + x * 5) / t;
		x= x * (i + 2) / i;
	}
	printf("%.15lf\n", (double)ans);
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c;
int main(){
	cin>>c;
	cout<<char(c+1)<<endl;
	return 0;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long long N, M, K;
    ist >> N >> M >> K;

    vector<long long> A;
    vector<long long> B;

    for (int i = 0; i < N; i++)
    {
        int input;
        ist >> input;
        A.emplace_back(input);
    }

    for (int i = 0; i < M; i++)
    {
        int input;
        ist >> input;
        B.emplace_back(input);
    }

    /* ------- 計算 ------- */
    long long time_sum = 0;
    int a = 0;
    int b = 0;

    while (a < A.size() && time_sum + A.at(a) <= K)
    {
        time_sum += A.at(a);
        a++;
    }

    vector<long long> A_cul_sum_vec;
    vector<long long> B_cul_sum_vec;

    int A_cul_sum = 0;
    A_cul_sum_vec.emplace_back(0);
    for (int i = 0; i < A.size(); i++)
    {
        A_cul_sum += A.at(i);
        A_cul_sum_vec.emplace_back(A_cul_sum);
    }

    int B_cul_sum = 0;
    B_cul_sum_vec.emplace_back(0);
    for (int i = 0; i < B.size(); i++)
    {
        B_cul_sum += B.at(i);
        B_cul_sum_vec.emplace_back(B_cul_sum);
    }

    int can_read_max = 0;
    int j = 0;
    for (int i = a; i >= 0; i--)
    {
        long long B_time = 0;
        long long A_time = A_cul_sum_vec.at(i);

        // while (j < B.size() && A_time + B_time + B.at(j) <= K)
        // {
        //     B_time += B.at(j);
        //     j++;
        // }

        while (j < B_cul_sum_vec.size() && A_cul_sum_vec.at(i) + B_cul_sum_vec.at(j) <= K) 
        {
            j++;
        }
        can_read_max = max(i + j - 1, can_read_max);
        // can_read_max = max(i + j, can_read_max);
    }
    ost << can_read_max << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s;
    cin >> s;
    rep(i,2)if(s[i] != s[i+1]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,k;
string a[101];
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++){
    cout<<a[i];
}




    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct State {
	int x, c;
	bool operator > (const State& s) const { return c > s.c; }
};

int N, p[100010];

int main() {
	cin >> N;
	for_(i,0,N) cin >> p[i];
	
	priority_queue< State, vector< State >, greater< State > > que;
	que.push(State{0, 0});
	
	vector< int > step(N, 1 << 30);
	step[0] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		if (p[s.x] != 0) {
			int nx = s.x + p[s.x];
			if (step[nx] > s.c) {
				step[nx] = s.c;
				que.push(State{nx, s.c});
			}
		} else {
			for_(d,1,7) {
				int nx = s.x + d;
				if (nx < N && step[nx] > s.c + 1) {
					step[nx] = s.c + 1;
					que.push(State{nx, s.c+1});
				}
			}
		}
	}
	
	cout << step[N-1] << endl;
}

Measured memory_bytes: 3616
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int L,R;
int main() {
	cin>>N;
	int total=0;
	for(int i=0;i<N;i++){
		cin>>L>>R;
		total+=R-L+1;
	}

	cout<<total<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int ans=1;
    for(int i=1;i<N;i++){
        bool f=true;
        for(int j=0;j<i;j++){
            if(H[j]>H[i]){
                f=false;
            }
        }
        if(f) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

bool dp[5001][5001];
bool dp2[5001][5001];

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

	int n,k,t;
	vector <int> v;

	cin >> n >> k;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		t = min(t,k);
		v.push_back(t);
	}

//	sort(v.begin(),v.end());

	memset(dp,false,sizeof(dp));
	dp[0][0] = true;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(dp[i][j]==false)
			{
				continue;
			}
			dp[i+1][j] = true;
			if(j + v[i] <= k)
			{
				dp[i+1][j+v[i]] = true;
			}
		}
	}


	memset(dp2,false,sizeof(dp2));
	dp2[n][0] = true;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<=k;j++)
		{
			if(dp2[i+1][j]==false)
			{
				continue;
			}
			dp2[i][j] = true;
			if(j + v[i] <= k)
			{
				dp2[i][j+v[i]] = true;
			}
		}
	}

	int res = 0;
	for(int i=0;i<n;i++)
	{
		bool ok = false;
		for(int j=0;j<k;j++)
		{
			if(dp[i][j]==true || dp2[i+1][j]==true)
			{
				if(j+v[i] >= k)
				{
					ok = true;
					break;
				}
			}
		}
		for(int j=0;j<=k-v[i];j++)
		{
			if(dp[i][j]==true && dp2[i+1][k-v[i]-j]==true)
			{
				ok = true;
				break;
			}
		}
		if(!ok)
		{
			res++;
		}
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 52496
from math import gcd

def main():
    k = int(input())
    g = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            d = gcd(a, b)
            for c in range(1, k + 1):
                g += gcd(c, d)
    print(g)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9028
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n,k=l_in()
A=l_in()

cnt=0
current = 0

memo={0: 0}

while cnt < k:
    n = A[current]-1
    cnt += 1

    if n in memo:
        delta = cnt - memo[n]

        p = (k-cnt)//delta
        cnt += p*delta
    else:
        memo[n] = cnt
    current = n
    
print(current+1)


Measured memory_bytes: 105104
#include <stdio.h>

	int main(void){
		int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	if( 1<a<10000 && 1<b<10000 && 1<c<10000){
	
	  if(a < c && b < c){
		printf("%d\n",a+b);

	}else if(a < b && c < b){
		printf("%d\n",a+c);

	}else if(b < a && c < a){
		printf("%d\n",b+c);

	}else if(a == b || b == c ){
		printf("%d\n",a+b);

	}
	}else{
		printf("Error");
}
}


Measured memory_bytes: 128
class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys_str = ''
        while cur_node != self.nil:
            keys_str += '{0} '.format(cur_node.key)
            cur_node = cur_node.next
        print(keys_str.rstrip())


import sys

d_ll = D_Linked_List()

for i in sys.stdin:
    if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass

d_ll.show_keys()

Measured memory_bytes: 205220
import sys
N, M = map(int,input().split())
s = []
c = []
for m in range(M):
    S, C = map(int,input().split())
    s.append(S)
    c.append(C)


for i in range(10 ** N):
    Str = str(i)

    if len(Str) == N and all([Str[s[m] - 1] == str(c[m]) for m in range(M)]):
        print(Str)
        sys.exit(0)

print(-1)

Measured memory_bytes: 3064
s = input()
if s == 'AKIHABARA' or s == 'AKIHABAR' or s == 'AKIHABRA' or s == 'AKIHABR' or s == 'AKIHBARA' or s == 'AKIHBAR' or s == 'AKIHBRA' or s == 'AKIHBR' or s == 'KIHABARA' or s == 'KIHABAR' or s == 'KIHABRA' or s == 'KIHABR' or s == 'KIHBARA' or s == 'KIHBAR' or s == 'KIHBRA' or s == 'KIHBR':
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9140
#include <stdio.h>

int main(void) {
    int card[4][13] = {};
    int i, j;
    char c, mark[4] = {'S', 'H', 'C', 'D'};
    int n, num;
    
    scanf("%d", &n);
    
    while (n--) {
        scanf(" %c %d", &c, &num);
        num--;
        
        switch(c) {
            case 'S': card[0][num] = 1; break;
            case 'H': card[1][num] = 1; break;
            case 'C': card[2][num] = 1; break;
            case 'D': card[3][num] = 1; break;
        }
    }
    
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 13; j++) {
            if (!card[i][j]) {
                printf("%c %d\n", mark[i], j + 1);
            }
        }
    }
    
    return 0;
}




Measured memory_bytes: 2036
#include <iostream>

using namespace std;

int main(){
  int N,i,j,x;
  cin >> N;
  int f[N][10];
  int p[N][11];
  int ans = -(1<<30);
  int c,cc;
  for(i=0;i<N;i++){
    for(j=0;j<10;j++){
      cin >> f[i][j];
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<11;j++){
      cin >> p[i][j];
    }
  }

  for(i=1;i<(1<<10);i++){
    cc = 0;
    for(x=0;x<N;x++){
      c=0;
      for(j=0;j<10;j++)if((i>>j & 1) && f[x][j])c++;
      cc+=p[x][c];
    }
    if(cc>ans)ans = cc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long N,A,B;
  cin>>N>>A>>B; 
  long ans=N/(A+B)*A;
  long a=N%(A+B);
  if(a>=A){
    cout<<ans+A<<endl;
  }
  else{
    cout<<ans+a<<endl;
  }
 
 
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N;
  cin >> N;
  int s = 0;

  while (N > 0) {
    s += N % 10;
    N /= 10;
  }

  cout << (s == 1 ? 10 : s) << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue> 
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	priority_queue<double,vector<double>,less<double> > q;
	for(int i = 0; i < n; i++){
		double d;
		scanf("%lf",&d);
		q.push(d);
	}
	while(m--){
		double t = q.top();
		q.pop();
		if(t<0.1)break;
		t/=2.0;
		q.push(t);
	}
	long long sum = 0;
	while(!q.empty()){
		double t = q.top();
		q.pop(); 
		sum+=t;
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 1400
use std::io::{self, Read};

pub struct Scanner<R>
where
    R: Read,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: Read,
{
    pub fn new(reader: R) -> Self {
        Scanner { reader: reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::cmp::*;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let a: i32 = sc.next();
    let b: i32 = sc.next();
    let c: i32 = sc.next();

    println!("{}", max(c - (a - b), 0));
}


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

#define MAX 256

char s[MAX][MAX];
int n;

int findMax(int i, int j, int di, int dj){
	int count = 0, res = 0;

	while(0<=i && 0<=j && i<n && j<n){
		if(s[i][j] == '1') count++;
		else{
			res = max(res, count);
			count = 0;
		}
		i += di;
		j += dj;
	}

	return max(res, count);
}

int main(void){
	while(cin>>n && n){
		for(int i=0;i<n;i++) cin>>s[i];

		int ans = -1;
		for(int i=0;i<n;i++){
			ans = max(ans, findMax(i,0,0,1));
			ans = max(ans, findMax(0,i,1,0));
			ans = max(ans, findMax(i,0,1,1));
			ans = max(ans, findMax(0,i,1,1));
			ans = max(ans, findMax(i,n-1,1,-1));
			ans = max(ans, findMax(0,i,1,-1));
		}

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int c[3][3];
    int mn = 0;
    REP(i, 3){
        REP(j, 3){
            cin >> c[i][j];
            mn=max(mn, c[i][j]);
        }
    }
    mn++;
    bool flag=false;
    REP(i, mn){
        REP(j, mn){
            REP(k, mn){
                bool tflag=true;
                REP(l, 3){
                    if(c[l][0]-i != c[l][1]-j || c[l][1]-j != c[l][2]-k) tflag=false;
                }
                if(tflag){
                    flag=true;
                    break;
                }
            }
            if(flag || (i + j) >= mn)break;
        }
        if(flag)break;
    }

    Yes(flag);
}

Measured memory_bytes: 256
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }.sorted().reversed()
    var a = 0
    var b = 0
    repeat(n) {
        if(it % 2 === 0) {
            a += x[it]
        }
        else {
            b += x[it]
        }
    }
    print(a - b)
}

Measured memory_bytes: 37932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

 int n;
 cin >> n;
 int a[n+1];
 rep(i,1,n+1) cin >> a[i];
 a[0] = 0;
 int dp[n+1];
 
 dp[0] = 10005;
 dp[1] = 0;
 for(int i = 2;i<=n;i++){
	 
	 dp[i] = min(dp[i-1] + abs(a[i]- a[i-1]),dp[i-2] + abs(a[i]-a[i-2]));
	 
	// cout << dp[i] << endl;	 
 }
 
 cout << dp[n] <<endl;
   
	   
} 





Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	double a[111],ans=0.0;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		ans += 1.0/a[i];
	}
	printf("%.10lf\n",1.0/ans);
	return 0;
}


Measured memory_bytes: 256
public class Main{
	public static void main(String[] s){
		for(int i=10;++i<100;){
			// System.out.println(i%10==0?"":i/10+"x"+i%10+"="+i/10*(i%10));
			System.out.printf(i%10==0?"":"%dx%d=%d\n",i/10,i%10,i/10*(i%10));
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

int main(){
  long int n , t,r = 0;

  long int total = 0;
  cin >> n >> t;

  for(int i = 1; i <= n; ++i){
    int s;
    cin >> s;

    total += s - r < t ? s - r : t;
    r = s;
  }
  cout << total + t << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for E - Sequence Sum
	var N, X, M int
	fmt.Scan(&N, &X, &M)

	var A, S, sameA int
	var temp int
	A = X
	S += A

	var numBefore, numAfter int
	check := make(map[int]int, M+1)

	var SBefore, SAfter int
	var flag int = 0

	for i := 2; i <= N; i++ {
		temp = (A * A) % M
		A = temp
		S += A
		check[temp]++

		if check[temp] > 2 && flag == 0 {
			numBefore = i
			sameA = temp
			SBefore = S
			flag++
			continue
		} else if flag == 1 && temp == sameA {
			numAfter = i
			SAfter = S
			break
		}
	}

	if flag == 0 {
		fmt.Println(S)
	} else {
		ans := SBefore + (SAfter-SBefore)*((N-numBefore)/(numAfter-numBefore))
		A = sameA
		for i := 1; i <= (N-numBefore)%(numAfter-numBefore); i++ {
			temp = (A * A) % M
			ans += temp
			A = temp
		}
		fmt.Println(ans)
	}

}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    vector<ll> sum(N+1);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum[i+1] = (sum[i] + a[i]) % M;
    }
    // (A_l + ... + A_r) = (A_0 + .. + A_r) - (A_0 + ... + A_{l-1}) mod M == 0;
    // <=> (A_0 + .. + A_r) = (A_0 + ... + A_{l-1}) (mod M)
    map<ll, ll> mp;
    for (int i = 0; i < N+1; i++) mp[sum[i]]++;

    ll ans = 0;
    for (int i = 0; i < N; i++) ans += (mp[sum[i]]--) - 1;
    cout << ans << '\n';
}


Measured memory_bytes: 5760
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) {
    int num;
    cin >> num;
    p.at(i) = num;
  }
  sort(p.begin(), p.end());
  vector<int> check(102, 0);
  rep(i, n) {
    check.at(p.at(i)) = 1;
  }
  vector<int> x_chikasa(102);
  for (int i = 0; i < 102; i++) {
    x_chikasa.at(i) = i-x;
  }
  int min = 1000;
  int min_num = 1000;
  for (int i = 0; i<102; i++) {
    if (check.at(i) == 0) {
      if (abs(x_chikasa.at(i)) < min) {
        min = abs(x_chikasa.at(i));
        min_num = i;
      }
    }
  }
  cout << min_num << endl;
}
      


Measured memory_bytes: 3696
#include <iostream>

using namespace std;

int main(void){

  double w;
  while( cin >> w ){

    if( w <= 48 ) cout << "light fly" << endl;
    else if( 48 < w && w <= 51 ) cout << "fly" << endl;
    else if( 51 < w && w <= 54 ) cout << "bantam" << endl;
    else if( 54 < w && w <= 57 ) cout << "feather" << endl;
    else if( 57 < w && w <= 60 ) cout << "light" << endl;
    else if( 60 < w && w <= 64 ) cout << "light welter" << endl;
    else if( 64 < w && w <= 69 ) cout << "welter" << endl;
    else if( 69 < w && w <= 75 ) cout << "light middle" << endl;
    else if( 75 < w && w <= 81 ) cout << "middle" << endl;
    else if( 81 < w && w <= 91 ) cout << "light heavy" << endl;
    else cout << "heavy" << endl;

  }
  return 0;
}

Measured memory_bytes: 1220
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    
    ans = 0
    for n in range(1, N+1):
        if len(str(n)) % 2:
            ans += 1
    
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = false;

// --------------------------------------------------------------------------------------

// DECLARATIONS
template <typename T> void read(size_t n, T* a);
template <typename T> void read2(size_t n, size_t m, T** a);


// IMPLEMENTATIONS
template <typename T> void read(size_t n, T* a) {
    for (size_t i = 0; i < n; ++i) { std::cin >> a[i]; }
}

template <typename T> void read2(size_t n, size_t m, T** a) {
    for (size_t i = 0; i < n; ++i) {
        a[i] = new int[m];
        for (size_t j = 0; j < m; ++j) { std::cin >> a[i][j]; }
    }
}


using namespace std;

const int alph = 26;

int main(void)
{
    size_t n;
    cin >> n;
    vector<ui> v;
    for (size_t i = 0; i < alph; ++i) {
        v.push_back(0);
    }
    vector<ui> vv;
    for (size_t i = 0; i < alph; ++i) {
        vv.push_back(0);
    }
    {
        string ss;
        cin >> ss;
        for (size_t i = 0; i < ss.size(); ++i) {
            ++v[ss[i] - 'a'];
        }
    }
    for (size_t i = 1; i < n; ++i) {
        string s;
        cin >> s;
        for (size_t j = 0; j < s.size(); ++j) {
            ++vv[s[j] - 'a'];
        }
        for (size_t j = 0; j < alph; ++j) {
            v[j] = std::min(v[j], vv[j]);
            vv[j] = 0;
        }
    }

    for (size_t i = 0; i < alph; ++i) {
        for (size_t j = 0; j < v[i]; ++j) {
            cout << static_cast<char>(i + 'a');
        }
    } cout << '\n';

    return 0;
}


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

// Fermat の小定理を用いた F_mod 上での逆元計算x^(mod-2), 蟻本p115
ll Inverse(ll x){
    ll res = 1;
    int n = mod - 2;
    while(n > 0){
        if(n & 1){
            res = res * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    string L;
    cin >> L;
    int s = L.size();

    // 3の累乗
    vector<ll>x(s);
    x[0] = 1;
    for (int i = 1; i < s; ++i) {
        x[i] = x[i-1] * 3;
        x[i] %= mod;
    }

    ll ans = 1;
    for (int i = s-1; i >= 0; --i) {
        if(L[i] == '1'){
            ans = ans * 2;
            ans %= mod;
            ans = ans + x[s-i-1];
            ans %= mod;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

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 = 1; i <= H ; i++){
            if ( i % 2 == 1){
              for(int j = 1;  j <= W ; j++){
                if ( j % 2 == 1){
                System.out.print("#");}
                else {System.out.print(".");}
                }
              }
            else {
              for(int j = 1;  j <= W ; j++){
                if ( j % 2 == 0){
                System.out.print("#");}
                else {System.out.print(".");}
                }
              }
          System.out.println("");
      }
      System.out.println("");
  }
}
}



Measured memory_bytes: 33392
#include <stdio.h>

int N, A;
int x[51];
long long dp[51][51][2501];
long long ans;

int main(void)
{
	int i, j, k;

	scanf("%d %d", &N, &A);
	for (i = 1; i <= N; ++i)
	{
		scanf("%d", &x[i]);
	}

	dp[0][0][0] = 1;
	for (i = 1; i <= N; ++i)
	{
		for (j = 0; j <= 50 * i; ++j)
		{
			dp[i][0][j] = dp[i - 1][0][j];
		}
		for (k = 1; k <= i; ++k)
		{
			for (j = 0; j < x[i]; ++j)
			{
				dp[i][k][j] = dp[i - 1][k][j];
			}
			for (j = x[i]; j <= 50 * i; ++j)
			{
				dp[i][k][j] = dp[i - 1][k][j] + dp[i - 1][k - 1][j - x[i]];
			}
		}
	}

	for (k = 1; k <= N; ++k)
	{
		ans += dp[N][k][A * k];
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 23216
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int b,a;
  int c=0;
  cin>>c;
  a=c;
  b=c;
  for(int i=1;i<n-1;i++)
  {
    cin>>b;
    if(a>b) {
	c+=b;}
    else c+=a;
       a=b;
  }

  c+=b;
  cout<<c;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	for i in range(100000):
		tmp = i * 1000
		ans = tmp-N
		if ans >= 0:
			print(ans)
			sys.exit()

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n+1),b(n);
  int64_t sb=0;
  for(int i=0;i<n+1;i++){
    cin>>a.at(i);
    sb+=a.at(i);
  }
  for(int i=0;i<n;i++)
    cin>>b.at(i);
  for(int i=0;i<n;i++){
    int x=min(a.at(i),b.at(i));
    a.at(i)-=x;
    b.at(i)-=x;
    x=min(a.at(i+1),b.at(i));
    a.at(i+1)-=x;
    b.at(i)-=x;
  }
  int64_t se=0;
  for(int i=0;i<n+1;i++)
    se+=a.at(i);
  cout<<sb-se<<endl;
}

Measured memory_bytes: 1024