akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

int main(){
	ll n,k;cin>>n>>k;
	if(n>=10){
		cout<<k<<endl;
	}else{
		cout<<k+100*(10-n)<<endl;
	}
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[111];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    int ans = 0;
    for (int i=0; i<N;) {
	int j = i;
	while (j<N && A[i] == A[j]) j++;
	ans += (j-i)/2;
	i = j;
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;

	if(a>b||(n==1&&a<b))
		cout<<0<<endl;
	else
		cout<<a+(n-1)*b-1*((n-1)*a+b)+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(x) cerr<<#x": "<<(x)<<endl
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int N = 200010;

int x[N], fth[N];
pll dp[N][2], bst[N];
vector<pii> adj[N];

bool operator <(const pll &p, const pll &q) {
	if(p.fi == -1) return false;
	if(q.fi == -1) return true;
	return p.fi < q.fi || (p.fi == q.fi && p.se < q.se);
}

void update(pll &p, const pll &q) {
	if(q < p) p = q;
}

void update(pll v[2], const pll &q) {
	if(q < v[0]) v[1] = (v[0].se == q.se ? v[1] : v[0]), v[0] = q;
	else if(q.se != v[0].se) update(v[1], q);
}

int root(int a) { return fth[a] ? fth[a] = root(fth[a]) : a; }

bool join(int a, int b) {
	a = root(a);
	b = root(b);
	if(a == b) return false;
	return fth[a] = b, true;
}

void dfsDown(int v, int p = -1) {
	dp[v][0] = dp[v][1] = { -1, -1 };
	
	for(auto e : adj[v]) {
		if(e.fi == p) continue;
		dfsDown(e.fi, v);
		
		if(dp[e.fi][0].fi != -1) update(dp[v], { dp[e.fi][0].fi + e.se, dp[e.fi][0].se });
		if(dp[e.fi][1].fi != -1) update(dp[v], { dp[e.fi][1].fi + e.se, dp[e.fi][1].se });
		update(dp[v], { x[e.fi] + e.se, root(e.fi) });
	}
}

void dfsUp(int v, int p = -1, int w = 0) {
	if(p != -1) {
		if(dp[p][0].fi != -1) update(dp[v], { dp[p][0].fi + w, dp[p][0].se });
		if(dp[p][1].fi != -1) update(dp[v], { dp[p][1].fi + w, dp[p][1].se });
		update(dp[v], { x[p] + w, root(p) });
	}
	
	for(auto e : adj[v]) {
		if(e.fi == p) continue;
		dfsUp(e.fi, v, e.se);
	}
}

ll solve(int n) {
	ll res = 0;
	
	for(int nrcomp = n; nrcomp > 1; ) {
		dfsDown(1);
		dfsUp(1);
		
		memset(bst, -1, sizeof bst);
		for(int i = 1; i <= n; ++i) {
			if(dp[i][0].se != root(i)) update(bst[root(i)], { dp[i][0].fi + x[i], dp[i][0].se });
			else update(bst[root(i)], { dp[i][1].fi + x[i], dp[i][1].se });
		}
		
		for(int i = 1; i <= n; ++i)
			if(root(i) == i && join(i, bst[i].se)) res += bst[i].fi;//, dbg(i), dbg(bst[i]);
		
		nrcomp = 0;
		for(int i = 1; i <= n; ++i) if(root(i) == i) ++nrcomp;
	}
	
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int n, a, b, c;
	
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> x[i];
	for(int i = 1; i < n; ++i) {
		cin >> a >> b >> c;
		adj[a].push_back({b, c});
		adj[b].push_back({a, c});
	}
	
	cout << solve(n) << '\n';
	
	return 0;
}


Measured memory_bytes: 40832
#include <stdio.h>
#define N 1000001
 
int spf[N], u[N], s[17], d, i, k;
char* r = "pairwise";

int gcd(a, b) { return b ? gcd(b, a % b) : a; }

int main(j) {
	while (++i < N)spf[i] = i;
	for (i = 2; i * i < N; i++) {
		for (j = i * i; j < N; j += i) {
			if (spf[j] == j)
				spf[j] = i;
		}
	}
	for (scanf("%*d"); ~scanf("%d", &j); k = 0) {
		d = gcd(d, j);
		for (; j > 1; j /= spf[j]) {
			i = spf[j];
			if (u[i]) r = "setwise";
			s[k++] = i;
		}
		while(k--)u[s[k]] = 1;
	}
	printf("%s coprime\n", d > 1 ? "not" : r);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans=0;
  int cnt=0;
  for (int i = 0; i < s.size(); i++) {
    if(s.at(i)=='I'){
      ++ans;
      cnt=max(cnt,ans);
    }else --ans;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; p++) {
        if (n % p == 0) return false;
    }
    return true;
}

int main() {
    ll x;
    cin >> x;
    while(true) {
        if(is_prime(x)) {
            cout << x << endl;
            return 0;
        }
        else x++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i<b; i++)
typedef long long ll;
int main() {
    ll n; cin>>n;
    ll k= n/ 11;
    ll ans= 2*k;
    ll r=n % 11;
    if(r!=0){ans++;}
    if(r>6){ans++;}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "-1" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll K; cin>>K;
    vector<ll> A(K);
    rep(i,K) cin>>A[i];
    ll ma=2,mi=2;
    repr(i,K-1,0){
        mi=((mi+A[i]-1)/A[i])*A[i];
        ma=((ma/A[i])+1)*A[i]-1;

        if(ma<mi) dame;
    }
    cout<<mi<<" "<<ma <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1024
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

t = ni()
from functools import lru_cache

for _ in range(t):
    n,a,b,c,d = na()

    @lru_cache(None)
    def f(N):
        if N == 0:
            return 0
        if N == 1:
            return d
        ret = d * N
        q, r = divmod(N, 2)
        ret = min(ret, f(q) + a) if r==0 else min(ret, f(q) + a + d, f(q + 1) + a + d)
        q, r = divmod(N, 3)
        ret = min(ret, f(q) + b) if r == 0 else min(ret, f(q) + b + d) if r == 1 else min(ret, f(q+1) + b + d)
        q, r = divmod(N, 5)
        if r == 0:
            ret = min(ret, f(q) + c)
        elif r == 1:
            ret = min(ret, f(q) + c + d)
        elif r == 2:
            ret = min(ret, f(q) + c + d + d)
        elif r == 3:
            ret = min(ret, f(q+1) + c + d + d)
        else:
            ret = min(ret, f(q+1) + c + d)
        return ret
    
    print(f(n))

Measured memory_bytes: 11424
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const int maxn = 1e5+5;
const int mod = 1e9 + 7;
int mu[maxn], pri[maxn], sum[maxn], cnt;
bool vis[maxn];
void mu_table(int N){
    mu[1] = 1;
    for(int i = 2; i <= N; i++){
        if(!vis[i]){
            pri[++cnt] = i;
            mu[i] = -1;
        }
        for(int j = 1; j <= cnt; j++){
            if(i * pri[j] > N)break;
            vis[i * pri[j]] = 1;
            if(i % pri[j] == 0){
                mu[i * pri[j]] = 0;
                break;
            }else mu[i * pri[j]] = -mu[i];
        }
    }
    for(int i = 1; i <= N; i++)sum[i] = sum[i - 1] + mu[i];//此处前缀和是为了整除分块
}
ll pow(ll a, ll b, ll p){
    ll ans = 1;
    while(b){
        if(b & 1)ans = ans * a % p;
        b >>= 1;
        a = a * a % p;
    }
    return ans;
}
ll solve(ll K, ll N){
    ll ans = 0;
    for(int i = 1; i <= K; i++){//gcd值为[1,n]
        int mx = K / i;
        for(int l = 1,r; l <= mx; l = r + 1){
            r = mx/(mx/l);
            ans = (ans + (ll)i * (sum[r] - sum[l - 1]) % mod * pow((mx/l), N, mod) % mod) % mod;
        }
    }
    return ans;
}
int main(){
    mu_table(maxn - 4);
    ll N, K;
    scanf("%lld%lld", &N, &K);
    printf("%lld\n", solve(K, N));
    return 0;
}

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

using namespace std;

void descendingOrderSort(vector<int>& cards);
void swap(int& left, int& right);

int main() {
    int numOfCards = 0;
    cin >> numOfCards;
    vector<int> cards;
    int number;
    for (int i = 0; i < numOfCards; ++i) {
        cin >> number;
        cards.push_back(number);
    }
    
    descendingOrderSort(cards);
    
    int scoreOfAlice = 0;
    for (size_t i = 0; i < cards.size(); i += 2) {
        scoreOfAlice += cards.at(i);
    }
    
    int scoreOfBob = 0;
    for (size_t i = 1; i < cards.size(); i += 2) {
        scoreOfBob += cards.at(i);
    }    
    
    cout << scoreOfAlice - scoreOfBob << endl;
}
        
void descendingOrderSort(vector<int>& cards) {
    for (size_t i = cards.size() - 1; i > 0; --i) {
        for (size_t j = 0; j < i; ++j) {
            if (cards.at(j) < cards.at(j + 1)) {
                swap(cards.at(j), cards.at(j + 1));
            }
        }
    }
}    

void swap(int& left, int& right) {
    int temp = left;
    left = right;
    right = temp;
}

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

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

    int x = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') {
            x++;
        }
        else if (S[i] == 'D') {
            x--;
        }
        ans = max(ans, x);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Vector.Unboxed (Vector, (!))
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed.Mutable (unsafeRead, unsafeWrite)
import qualified Data.Vector.Unboxed.Mutable as UM
import Control.Monad.ST
import Data.STRef

main :: IO ()
main = do
  [n, x] <- readInts
  input <- U.fromList <$> readInts
  print $ solve input x

solve :: Vector Int -> Int -> Int
solve input x = U.last $ U.create $ do
  v <- U.thaw input
  vx <- UM.unsafeGrow v 1
  updateCount vx 0
  forM_ [0 .. (UM.length v - 2)] (\i -> do
    a1 <- unsafeRead vx i
    a2 <- unsafeRead vx (i + 1)
    count <- unsafeRead vx lindex
    let sa = a1 + a2
    let dsax = sa - x
    let da2dsax = a2 - dsax
    if dsax > 0
      then do
        updateCount vx (count + dsax)
        if da2dsax >= 0
          then unsafeWrite vx (i + 1) da2dsax
          else unsafeWrite vx i (a1 + da2dsax) >> unsafeWrite vx (i + 1) 0
      else return ()
    )
  return vx
  where
    lindex = U.length input
    updateCount v count = unsafeWrite v lindex count

vectest :: Vector Int -> Vector Int
vectest input = U.create $ do
  v <- UM.replicate 1000 0
  forM_ [0 .. 999] (\i -> do
    let e = input ! i
    unsafeWrite v i e
    )
  return v

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx


Measured memory_bytes: 5756
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
using i64 = int_fast64_t;
constexpr i64 MAX = 1000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{

public:
  i64 a;

  constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
  constexpr i64 &value() noexcept { return a; }
  constexpr const i64 &value() const noexcept { return a; }
  constexpr modcal operator+(const modcal rhs) const noexcept
  {
    return modcal(*this) += rhs;
  }
  constexpr modcal operator-(const modcal rhs) const noexcept
  {
    return modcal(*this) -= rhs;
  }
  constexpr modcal operator*(const modcal rhs) const noexcept
  {
    return modcal(*this) *= rhs;
  }
  constexpr modcal operator/(const modcal rhs) noexcept
  {
    return modcal(*this) /= rhs;
  }
  constexpr modcal &operator+=(const modcal rhs) noexcept
  {
    a += rhs.a;
    if (a >= modulus)
    {
      a -= modulus;
    }
    return *this;
  }
  constexpr modcal &operator-=(const modcal rhs) noexcept
  {
    if (a < rhs.a)
    {
      a += modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modcal &operator*=(const modcal rhs) noexcept
  {
    a = a * rhs.a % modulus;
    return *this;
  }
  constexpr modcal &operator/=(modcal rhs) noexcept
  {
    i64 exp = modulus - 2;
    while (exp)
    {
      if (exp % 2)
      {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  void COMninit()
  {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
      fac[i] = fac[i - 1] * i % modulus;
      inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
      finv[i] = finv[i - 1] * inv[i] % modulus;
    }
  }
  i64 COMn(i64 n, i64 k)
  {
    if (n < k)
      return 0;
    if (n < 0 || k < 0)
      return 0;
    return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
  }
  constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
  {
    if (n == 0)
      return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1)
      t = t * a;
    return t;
  }
};
using modc = modcal<1000000007>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
modc x,y;
cin >> x.a >> y.a;

i64 m = (2 * x.a - y.a) / 3;
i64 n = (2 * y.a - x.a) / 3;
if((x.a + y.a) % 3 || n < 0 || m < 0){
    cout << 0 << endl;
    return 0;
}
else{
    modc ans = 0;
    ans.COMninit();
    cout << ans.COMn(n + m, n) << endl;
}
}

Measured memory_bytes: 23680
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]

dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

Measured memory_bytes: 311888
n, m = map(int, input().split())
num = [-1 for _ in range(n)]
flag = False
for i in range(m):
    s, c = map(int, input().split())
    if n != 1 and s == 1 and c == 0:
        flag = True
    if num[s - 1] == -1:
        num[s - 1] = c
    elif num[s - 1] != c:
        flag = True

else:
    if flag:
        print(-1)
    else:
        if n != 1 and num[0] == -1:
            num[0] = 1
        for i in range(n):
            if num[i] == -1:
                num[i] = 0
        for i in range(n):
            print(num[i], end="")




Measured memory_bytes: 3064
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
long long int N,A[200200]={},B,C,D,E,K,res=0;
string S[200];
vector<long long int>pl,mi;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>K;
    for(long long int i = 1; i <= N; i++){
        A[i%K]++;
    }
    res=A[0]*A[0]*A[0];
    if(K%2==0){res+=A[K/2]*A[K/2]*A[K/2];}
    cout<<res<<endl;
}    


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
int a[100010],n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int x=a[n],y=a[n],z=a[n]-(x+1)/2;
	for(int i=1;i<n;i++){
		if(abs(a[i]-(x+1)/2)<=z){
			y=a[i];
			z=abs(a[i]-(x+1)/2);
		}
	}
	cout<<x<<" "<<y;
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

class segtree:
    x_unit=0 # 単位元
    x_func=lambda self,a,b:a+b  # 関数
    def __init__(self,n,seq):
        self.n=n
        self.x=[self.x_unit]*(2*n)
        for i,j in enumerate(seq, self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func(self.x[i*2], self.x[i*2+1])
    def update(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func(self.x[i*2], self.x[i*2+1])
    def fold(self,l,r): # 区間[l, r)の合計を取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func(val_l,self.x[l])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func(val_r,self.x[r])
            l //= 2
            r //= 2
        return self.x_func(val_l,val_r)

n,q=map(int,input().split())
*a,=map(int,input().split())
seg=segtree(n,a) 
for i in range(q):
    t,x,y=map(int,input().split())
    if t==0:
        old=seg.fold(x,x+1)
        seg.update(x, old+y)
    else:
        print(seg.fold(x, y))

Measured memory_bytes: 147396
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

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

	int q;
	cin>>q;
	vector<int> ans(q);
	//vector<char> x,y;
	/*if(q>21){
		x.resize(101);
		y.resize(101);
	}*/
	string x,y;
	vector<vector<int>> a;
	rep(aaa,q){
		cin>>x;
		cin>>y;
		int xs=x.size();
		int ys=y.size();
		a.resize(xs+1);
		rep(i,xs+1){
			a[i].resize(ys+1);
		}
		rep(i,xs+1){
			rep(j,ys+1){
				if(i==0 || j==0){
					a[i][j]=0;
				}else if(x[i-1]==y[j-1]){
					a[i][j]=a[i-1][j-1]+1;
				}else{
					a[i][j]=max(a[i-1][j],a[i][j-1]);
				}
			}
		}
		ans[aaa]=a[xs][ys];
	}
	rep(i,q){
		cout<<ans[i]<<endl;
	}
	

}

Measured memory_bytes: 6756
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int counter = 0;
	if (s.at(0) == 'o') {
		counter++;
	}
	if (s.at(1) == 'o') {
		counter++;
	}
	if (s.at(2) == 'o') {
		counter++;
	}
	cout << 700 + counter * 100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}


void solve(){
	
	long double d,t,s;
	cin>>d>>t>>s;
	long double ans=d/s;

	if(ans<=t){
		cout<<"Yes"<<endl;

	}
	else{
		cout<<"No"<<endl;

	}
	












return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>

int main(void)
{
	float weight;
	while (scanf("%f", &weight) != EOF) {
		if (weight > 91)
			puts("heavy");
		else if (weight > 81)
			puts("light heavy");
		else if (weight > 75)
			puts("middle");
		else if (weight > 69)
			puts("light middle");
		else if (weight > 64)
			puts("welter");
		else if (weight > 60)
			puts("light welter");
		else if (weight > 57)
			puts("light");
		else if (weight > 54)
			puts("feather");
		else if (weight > 51)
			puts("bantam");
		else if (weight > 48)
			puts("fly");
		else
			puts("light fly");
	}
	return 0;
}

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

int main() {
 double k,n; cin >> n >> k;
 vector<long long> p(n);

 for(int i=0;i<n;i++){
   cin >> p[i];
 }

  vector<long long> sum(n);
  sum[0]=p[0];
  for(int i=1;i<n;i++){
    sum[i]=p[i]+sum[i-1];
  }
long long stl=sum[k-1];
 for(int i=k;i<n;i++){
   long long pgt=sum[i]-sum[i-k];
   stl=max(stl,pgt);
 }
 double ans=(stl+k)/2.0;
 cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3328
//To Infinity

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s;cin>>s;
    ll k;cin>>k;
    for(int i=0;i<k;i++){
        if(s[i]!='1'){
            cout<<s[i]<<nnn;
            return 0;
        }
    }
    cout<<1<<nnn;
    return 0;
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize(){
  int i;
  for(i = 0 ; i < N ; i++) {row[i] = FREE, col[i] = FREE;}
  for(i = 0 ; i < 2 * N ; i++) {dpos[i] = FREE, dneg[i] = FREE;}
}

void printBoard(){
  int i, j;
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      if(X[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }

  for(j = 0 ; j < N ; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i+1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}
	      
int main(){
  int i, j;
  initialize();

  for(i = 0 ; i < N ; i++)
    for(j = 0 ; j < N ; j++) X[i][j] = false;
  int k;
  cin >> k;

  for(i = 0 ; i < k ; i++){
    int r, c;
    cin >> r >> c;
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}
      
  


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>b){
    a--;
  }
  cout<<a<<"\n";
  return 0;
}

Measured memory_bytes: 3628
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,x):
  if n == 0:
    return 0 if x <= 0 else 1
  elif x <= 1 + a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1] + 1 + f(n-1,x-2-a[n-1])
print(f(n,x))

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 1e4+7;
const int D = 1e2+7;
string k;
int d;
ll mem[N][D][2];

ll dp(int i,int sum,bool b)
{
    ll &ret = mem[i][sum][b];
    if (ret != -1) return ret;
    if (i == 1e4) return (sum == 0);
    // b = 1 : no need for checking
    // b = 0 : we have to check
    ret = 0;
    if (b)
    {
        REP(j,0,9)
        {
            ret = (ret + dp(i+1,(sum+j)%d,1))%MOD;
        }
    }
    else
    {
        REP(j,0,k[i]-'0'-1)
        {
            ret = (ret + dp(i+1,(sum+j)%d,1))%MOD;
        }
        ret = (ret+dp(i+1,(sum+k[i]-'0')%d,0))%MOD;
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
    memset(mem,-1,sizeof mem);
    cin >> k >> d;
    reverse(k.begin(),k.end());
    while(k.size() < 1e4) k.PB('0');
    reverse(k.begin(),k.end());

    cout << (dp(0,0,0)-1+MOD)%MOD << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
long long n,m;
inline long long read()
{
	long long x=0,y=1;char ch=getchar();
	while (ch>'9'||ch<'0'){
		if (ch=='-')y=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*y;
}

int main()
{
	n=read();m=read();
	if (n==1||m==1) printf("1");
	else printf("%lld\n",(n*m+1)/2);
}

Measured memory_bytes: 256
import sys

class alphabet: #Trueなら大文字
    def __init__(self, capitalize):
        self.num = dict() #アルファベットを数字に変換
        self.abc = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"\
            ,"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
        if capitalize: 
            for i in range(26): self.abc[i] = self.abc[i].upper()
        for i, a in enumerate(self.abc): self.num[a] = i


def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    N = len(S)
    AB = alphabet(False)

    if S[0] != "A": print("WA")
    else:
        if S[1] not in AB.abc: print("WA")
        else:
            cCount = 0
            possible = True
            for i in range(2, N-1):
                if S[i] not in AB.abc:
                    if S[i] == "C": cCount += 1
                    else: possible = False
            if not possible: print("WA")
            elif cCount != 1: print("WA")
            else:
                if S[N-1] not in AB.abc: print("WA")
                else: print("AC")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int N;
    
    cin >> N;
    
    auto no1 = N % 10;
    auto no2 = N / 10;
    
    if (no1 == 9 || no2 == 9)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mof = 1e9+7;
int solve(int n,int k)
{
    vector<int> facts;
    int sqrtn = static_cast<int>(sqrt(n));
    for(int i=1;i<=sqrtn;++i)
    {
        facts.push_back(i);
        if(n/i != i)
            facts.push_back(n/i);
    }
    facts.push_back(0);
    sort(facts.begin(),facts.end());
    vector<ll> dp0,dp1;
    dp1.resize(facts.size());
    for(int i=1;i<facts.size();++i)
        dp1[i] = (dp1[i-1] + facts[i] - facts[i-1]) % mof;
    for(int i=2;i<=k;++i)
    {
        dp0 = dp1;
        dp1.resize(dp0.size(),0);
        for(int j=1;j<dp0.size();++j)
        {
            dp1[j] = dp0[facts.size() - j] * (facts[j] - facts[j-1]) % mof;
            dp1[j] += dp1[j-1];
            dp1[j] %= mof;
        }
    }
    return dp1.back();
}
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<solve(n,k)<<endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define N 500009
using namespace std;
typedef long long ll;
int main(void)
{
    //freopen("in.txt","r",stdin);

    ll n,m;
    cin>>n>>m;
    ll s=0,a;
    for(ll i=0;i<m;i++)
    {
        cin>>a;
        s+=a;
    }
    if(s>n) puts("-1");
    else cout<<n-s<<endl;

    //main();
    return 0;
}


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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int n, t, mx, mn;
  
  cin >> n;
  cin >> t;
  mn = t; mx = -1e9;
  for (int i=1; i<n; i++){
    cin >> t;
    mx = MAX(mx,t-mn);
    mn = MIN(mn,t);
  }
  cout << mx << endl;
    
  return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


vector<pll> edge[MAX];
ll d[MAX], d2[MAX];

bool Bellmanford(int start, ll x) {
  FOR(i, 1, n + 1) d[i] = INF;
  d[start] = 0;
  while (true) {
	bool flag = false;
	FOR(i, 1, n + 1) {
	  FOR(j, 0, edge[i].size()) {
		if (d[i] != INF && d[edge[i][j].F] > d[i] + edge[i][j].S) {
		  d[edge[i][j].F] = d[i] + edge[i][j].S;
		  flag = true;
		  if (cnt >= n * x) return true;
		}
	  }
	}
	if (!flag) break;
	cnt++;
  }
  return false;
}

int main(void) {
  ll a, b, c;
  cin >> n >> m;
  FOR(i, 0, m) {
	cin >> a >> b >> c;
	c = -c;
	edge[a].pb(pll(b, c));
  }

  Bellmanford(1,1);
  ans = -d[n];
  FOR(i, 1, n + 1) d2[i] = d[i];
  Bellmanford(1,3);

  if (d[n] != d2[n]) {
	cout << "inf" << endl;
  }
  else {
	cout << -d[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main (){
	int x, y;
	for (1;1;1){
		scanf("%d %d", &x, &y);
		if( x == 0 && y == 0 )break;
		if(x < y){
			printf("%d %d\n", x, y);
		} else {
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    m[a] += b;
  }
  for (auto &i : m) {
    k -= i.sc;
    if (k <= 0) {
      cout << i.fi << '\n';
      return;
    }
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 7500
N,X = gets.split(" ").map { |e| e.to_i }
m = []
all = 0
for i in 0..N-1 do
  mi = gets.to_i
  all += mi
  m << mi
end

cur_x = X-all
count = N

min_m = m.min
count += cur_x/min_m

puts count

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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[,] a = new int[2, n];
        for (int i = 0; i < 2; i++)
        {
            a[i, 0] = sc.NextInt();
            for (int j = 1; j < n; j++)
                a[i, j] = a[i, j - 1] + sc.NextInt();
        }

        int max = a[0,0] + a[1, n - 1];
        for (int i = 1; i < n; i++)
        {
            int res = a[0, i] + a[1, n - 1] - a[1, i - 1];
            if (res > max) max = res;
        }
        Console.WriteLine(max);
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
string a;
int l;
int main() {
	cin>>a;
	l=a.size();
	for(int i=0; i<l; i++) {

		if(a[i]=='C') {
			for(int j=i+1; j<l; j++) {
				if(a[j]=='F') {
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>

using namespace std;
int main()
{
  long long int n;
  cin >> n;
  vector<long long int> nums(n);
  for(decltype(n) i=0; i<n; ++i){
    cin >> nums[i];
  }
  sort(nums.begin(), nums.end());
  nums.push_back(-1);
  
  long long int buf=nums[0];
  int ans = 0;
  int count = 1;
  for(decltype(n) i=1; i<n+1; ++i){
    if(nums[i]==buf){
      count++;
    }else{
      buf=nums[i];
      if(count % 2 == 1) ans++;
      count=1;
    }
  }
  
  if(n==1) ans=1;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

template<typename T>
T max(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())maxi(ret, v[i]);
	return ret;
}

template<typename T>
T min(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())mini(ret, v[i]);
	return ret;
}

bool comp(int a, int b) {
	if (a % 10 == 0)return false;
	if (b % 10 == 0)return true;
	return a % 10 < b % 10;
}

signed main() {
	makei(n);
	makev(v, 5ll);
	sort(all(v));
	int btl = v.front();
	exact_say(5 + ceil((double)n / btl) - 1);
};


Measured memory_bytes: 256
#include<iostream>
#define INF (1 << 30)
using namespace std;
typedef long long ll;

ll p_seq[10], c_seq[10];

int main() {
    ll D, G, p, c, count, sum_g = 0, ans_count = INF;
    cin >> D >> G;
    G /= 100;
    for (int i = 0; i < D; i++) {
        cin >> p >> c;
        p_seq[i] = p;
        c_seq[i] = c;
    }
    for (int i = 0; i < (1 << D); i++) {
        count = 0;
        sum_g = 0;
        for (int j = 0; j < D; j++) {
            if (((i >> j) & 1) == 1) {
                count += p_seq[j];
                sum_g += (j + 1) * p_seq[j] + c_seq[j] / 100;
            }
        }
        if (sum_g < G) {
            for (int j = D - 1; j >= 0; j--) {
                if (((i >> j) & 1) == 0) {
                    for (int k = 1; k < p_seq[j]; k++) {
                        sum_g += j + 1;
                        count++;
                        if (sum_g >= G) break;
                    }
                    break;
                }
            }
        }
        if (sum_g >= G && count < ans_count) ans_count = count;
    }
    cout << ans_count << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::{Read, BufReader};

macro_rules! read {
    ( $( $t:ty ),* ) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            ($(
                {
                    sp.next().unwrap().parse::<$t>().unwrap()
                },
            )*)
        }
    }
}
macro_rules! read_vec {
    ($t:ty) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            let mut ret = vec![];
            for s in sp {
                ret.push(s.parse::<$t>().unwrap());
            }
            ret
        }
    }
}

fn main() {
    let (n, m) = read!(usize, usize);
    let mut ca = vec![false; n + 1];
    let mut cb = vec![false; n + 1];
    for _ in 0..m {
        let (a, b) = read!(usize, usize);
        if a == 1 {
            ca[b] = true;
        }
        if a == n {
            cb[b] = true;
        }
        if b == 1 {
            ca[a] = true;
        }
        if b == n {
            cb[a] = true;
        }
    }
    for i in 1..(n+1) {
        if ca[i] && cb[i] {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}

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

int main() {
	int d[3], n;
	cin >> n;
	d[0] = n % 10;
	d[1] = n % 100 / 10;
	d[2] = n / 100;
	for (int i = 0; i < 3; i++) {
		if (d[i] == 1)
			d[i] = 9;
		else
			d[i] = 1;
	}
	cout << d[2] * 100 + d[1] * 10 + d[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

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

    int count = 0;

    // "000" ~ "999" まで総当たり
    rep(i, 0, 10) rep(j, 0, 10) rep(k, 0, 10)
    {
        string number = "";
        number.push_back(i + '0');
        number.push_back(j + '0');
        number.push_back(k + '0');

        bool f = false;
        bool m = false;
        bool e = false;

        // numberで指定された文字列が、Sの入力値で作成可能か判定
        rep(l, 0, N)
        {
            if (!f && S[l] == i + '0')
            {
                f = true;
                continue;
            }
            if (f && !m && S[l] == j + '0')
            {
                m = true;
                continue;
            }
            if (f && m && !e && S[l] == k + '0')
            {
                ++count;
                break;
            }
        }
    }

    std::cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <deque>
#include <queue>
#include <map>
using namespace std;

#define ii pair <int, int>
#define lli long long
#define pb push_back
#define X first
#define Y second

const int Mod = 1E9 + 7;
const int Inf = 1E9 + 7;
const int N = 2000 + 10;

int n, S;
lli F[N];

void Input()
{

}

void Solve()
{
    cin >> S;
    F[0] = 1;
    for (int i = 0; i <= S; i++) if (F[i] > 0)
    for (int j = 3; j + i <= S; j++) F[i + j] = (F[i + j] + F[i]) % Mod;
    cout << F[S];
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    int testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




Measured memory_bytes: 3608