akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

using namespace std;

const int mod = 1e9+7;

int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

const int N = 100005;

int n, x[N];
int fat[N], ifat[N];

int C(int i, int j) {
	if(j > i) return 0;
	return mul(mul(fat[i], ifat[j]), ifat[i - j]);
}

int id[N];
int mark[N];
int used[N];
int brute() {
	for(int i = 0; i < n; i++) id[i] = i;

	int ans = 0;
	do {
		for(int i = 0; i < n; i++) mark[i] = 1;
		for(int i = 0; i < n - 1; i++) {
			int j = id[i];
			mark[j] = 0;
			while(mark[j] == 0) {
				ans += x[j + 1] - x[j];
				used[j]++;
				if(j == 1 and id[i] == 0) {
					eprintf("> %d:", id[i]);
					for(int k = 0; k < n-1; k++) {
						eprintf(" %d", id[k]);
					}
					eprintf("\n");
				}
				if(ans >= mod) ans -= mod;
				j++;
			}
		}

	} while(next_permutation(id, id + n - 1));
	return ans;
}

int p[N];

int main() {

	fat[0] = ifat[0] = 1;
	for(int i = 1; i < N; i++) {
		fat[i] = mul(i, fat[i - 1]);
		ifat[i] = fexp(fat[i]);
	}

	scanf("%d", &n);

	for(int i = 0; i < n; i++) scanf("%d", x + i);

	for(int len = 2; len <= n - 1; len++) {
		p[len] = mul(mul(C(n - 1, len), fat[len - 1]), fat[n - 1 - len]);
		p[len] = add(p[len], p[len - 1]);
	}

	int ans = 0;
	for(int i = 0; i + 1 < n; i++) {
		int tmp = fat[n - 1];
		/*for(int len = 2; len <= i + 1; len++) {
			tmp = add(tmp, mul(mul(C(n - 1, len), fat[len - 1]), fat[n - 1 - len]));
		}*/
		tmp = add(tmp, add(p[i + 1], mod - p[1]));
		ans = add(ans, mul(x[i + 1] - x[i], tmp));
		eprintf("tmp[%d] = %d\n", i, tmp);
	}

	printf("%d\n", ans);
	eprintf("%d\n", brute());
	for(int i = 0; i + 1 < n; i++) {
		eprintf("used[%d] = %d\n", i, used[i]);
	}
}


Measured memory_bytes: 1792
import math
n = int(input())
A = list(map(int, input().split()))

def l(x):
  k = 0
  while True:
    if x % 2==0:
      k += 1
      x = x//2
    else:
      break
  return(k)

ans = 0
for i in range(n):
  ans += l(A[i])
  
print(ans)

Measured memory_bytes: 4148
import bisect
from collections import deque
n=int(input())
a=deque([int(input())])
for i in range(n-1):
    t=int(input())
    b=bisect.bisect_left(a, t)
    if b==0:
        a.appendleft(t)
    else:
        a[b-1]=t
    #print(a)
print(len(a))

Measured memory_bytes: 7284
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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 % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 



int main() {
	int ans = 0;
	int M,D; cin >> M >> D;

	for (int m = 1; m <= M; m++)
	{
			for (int d = 1; d <= D; d++)
			{
				if(d%10 >= 2 and d/10 >= 2 and (d%10)*(d/10) == m){ans++;}
			}
			
	}
	



	cout << ans << endl;
	}


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

int n;
vector<int> a;

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);

    sort(a.begin(), a.begin()+n, std::greater<int>());
    
    int alice=0, bob=0;

    for (int i = 0; i < n; ++i)
    {
        if (i%2 == 0)
        {
            alice += a.at(i);
        } else {
            bob += a.at(i);
        }
    }

    cout << alice - bob << endl;
}

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


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if ((b-a)%2==0){
    ll minnum = n-a;
    minnum = min(minnum,(b-a)/2);
    minnum = min(minnum,b-1);
    cout << minnum << endl;
  }
  else{
    ll minnum = n-a;
    minnum = min(minnum,b-1);
    minnum = min(minnum,(b-a-1)/2+min(a,n-b+1));
    cout << minnum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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 <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>
#include <assert.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const int MAXN = 2 * 100000;
int a[MAXN + 1];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    ll sum2 = 0;
    ll ans = 1e18;
    for(int i = 0; i < n - 1; i++) {
        sum -= a[i];
        sum2 += a[i];
        ans = min(ans, abs(sum - sum2));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

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

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

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

inline void print() { cout << "\n"; }

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

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

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, a, b, c, d);
    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) {
            print("Yes");
            return 0;
        }

        a -= d;
        if (a <= 0) {
            print("No");
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int K;
    cin >> K;
    //v[i]:=(i)桁の数
    vector<ll> v[11];
    rep2(i, 1, 9) v[1].pb(i);
    rep2(i, 2, 10){
        for(auto &e: v[i-1]){
            ll tmp = e*10+(e%10);
            v[i].pb(tmp);
            if(e%10 != 0) v[i].pb(tmp-1);
            if(e%10 != 9) v[i].pb(tmp+1);
        }
    }
    //for(auto &e: v[2]) cout << e << endl;
    vector<ll> all;
    rep2(i, 1, 10){
        for(auto &e: v[i]) all.pb(e);
    }
    sort(all.begin(), all.end());
    cout << all[K-1] << endl;
}

Measured memory_bytes: 4084
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();

        int ans = n;
        for (int i = 0; i <= n; i++) {
            ans = Math.min(ans, count(i, 6) + count(n - i, 9));
        }

        System.out.println(ans);
    }

    private int count(int money, int radix) {
        char array[] = Integer.toString(money, radix).toCharArray();

        int cnt = 0;
        for (int i = 0; i < array.length; i++) {
            cnt += array[i] - '0';
        }

        return cnt;
    }

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


Measured memory_bytes: 43216
n = int(input())
a,b = map(int,input().split())
p_list = list(map(int,input().split()))
p_list.sort()
ans = 0
dum1 = 0
dum2 = 0
dum3 = 0
for i in p_list:
    if i <= a:
        dum1 += 1
    if a+1 <= i <= b:
        dum2 += 1
    if i >= b+1:
        dum3 += 1
print(min(dum1,dum2,dum3))

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

using namespace std;

const int N = 100005;

int v[N], n;
int cnt[N][2];

int a[N], b[N];

int main(){

    scanf("%d", &n);

    for(int i = 0; i < n; i++) scanf("%d", v+i);

    for(int i = 0; i < n; i++)
        cnt[ v[i] ][i % 2]++;

    for(int i = 0; i < N; i++) a[i] = b[i] = i;
    sort(a, a+N, [](int q, int w){
        return cnt[q][0] > cnt[w][0];
    });
    
    sort(b, b+N, [](int q, int w){
        return cnt[q][1] > cnt[w][1];
    });

    if(a[0] != b[0]){
        printf("%d\n", n - (cnt[ a[0] ][0] + cnt[ b[0] ][1]));
    }
    else{
        int ans = n;
        ans = min(ans, n - (cnt[ a[1] ][0] + cnt[ b[0] ][1]));
        ans = min(ans, n - (cnt[ a[0] ][0] + cnt[ b[1] ][1]));
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 2684
A=int(input())
l=[]
ans=""
for i in range(A):
   B=list(input())
   l.append(B)
ar_l=["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"]
for i in ar_l:
   min_count=float("INF")
   for j in l:
      min_count=min(min_count,j.count(i))
   ans+=i*min_count
print(ans)

Measured memory_bytes: 3064
S = input()
a = 100 * int(S[0]) + 10 * int(S[1]) + int(S[2])
diff = abs(a - 753)
for i in range(1, len(S)-2):
    a = 100 * int(S[i]) + 10 * int(S[i+1]) + int(S[i+2])
    diff_new = abs(a - 753)
    if diff_new < diff:
        diff = diff_new
        
print(diff)

Measured memory_bytes: 3060
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

int main(void) {

	int A = 0, B = 0, C = 0, X = 0, Y = 0;
	int ans1 = 0, ans2 = 0,ans3 = 0;

	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
	
	{
		ans1 += (X * 2) * C;
		ans1 += (X > Y ? 0 : Y - X) * B;
	}
	{
		ans2 += (Y * 2) * C;
		ans2 += (Y > X ? 0 : X - Y) * A;
	}
	{
		ans3 += X * A;
		ans3 += Y * B;
	}
	printf("%d\n", (ans1 > (ans2 > ans3 ? ans3 : ans2) ? (ans2 > ans3 ? ans3 : ans2) : ans1));
	return 0;
}

Measured memory_bytes: 760
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	a := nextInt()
	b := nextInt()

	aa := n * a
	if aa > b {
		fmt.Println(b)
		return
	}

	fmt.Println(aa)
}


Measured memory_bytes: 640
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>

long long PRIME = 1e9 + 7;
using namespace std;

vector<vector<int>> E;

long long gcd(long long A, long long B){
    if(A > B){
        std::swap(A, B);
    }

    while(A != 0){
        long long q = B % A;
        B = A;
        A = q;
    }

    return B;
}

void prime_division(long long N, set<long long>& setN){
    while(N % 2 == 0){
        N /= 2;
        setN.insert(2);
    }

    long long max_num = sqrt(N);
    long long num = 3;

    while(num <= max_num){
        if(N % num == 0){
            N /= num;
            max_num = sqrt(N);
            setN.insert(num);
        }
        else{
            num += 2;
        }
    }

    setN.insert(N);
    setN.insert(1);
}


int main(){ 
    long long A, B;
    cin >> A >> B;

    long long gcd_ = gcd(A, B);
    set<long long> result;

    prime_division(gcd_, result);
    cout << result.size();

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

map<ll,ll> pfact(ll n) {
  map<ll,ll> ret;
  while(n%2==0) {ret[2]++;n/=2;}
  for(ll i=3;i*i<=n;i+=2) {
    while(n%i==0) {ret[i]++;n/=i;}
  }
  if(n!=1) ret[n]=1;
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1;cin>>n;
  map<ll,ll> n_map=pfact(n-1);
  if(n_map.size()>0) {
    ll val=1;
    for(auto p:n_map) val*=(p.second+1);
    ans+=val-1;
  }
  for(ll k=2;k*k<=n;++k) {
    ll n_=n,div=0;
    while(n_%k==0) {n_/=k;div++;}
    if(div>0&&n_%k==1) ans++;
  }
  print(ans);
  return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef unsigned long long ull;
const ull p=1000000007;
string S,T;

signed main(){
    ull power[26];
    power[0]=1;
    for(int i=1;i<26;i++)power[i]=power[i-1]*p;

    cin>>S>>T;
    vector<ull>hs;
    for(int i=min(S.size(),T.size());i>0;i--){
        ull h=0;
        hs.clear();
        for(int j=0;j+1<i;j++){
            h+=power[T[j]-'a'];
        }
        for(int j=i-1;j<T.size();j++){
            h+=power[T[j]-'a'];
            hs.pb(h);
            h-=power[T[j-i+1]-'a'];
        }

        sort(all(hs));

        h=0;
        for(int j=0;j+1<i;j++){
            h+=power[S[j]-'a'];
        }
        for(int j=i-1;j<S.size();j++){
            h+=power[S[j]-'a'];
            if(binary_search(all(hs),h)){
                cout<<i<<endl;
                return 0;
            }
            h-=power[S[j-i+1]-'a'];
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		String matrix[][] = new String[h][w];
		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

		int dp[][] = new int[h][w];

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (matrix[i][j].equals("#")) {
					dp[i][j] = 0;
				} else {
					if (i - 1 < 0 && j - 1 < 0) {
						dp[i][j] = 1;
					} else if (i - 1 < 0) {
						dp[i][j] = (dp[i][j - 1]) % 1000000007;
					} else if (j - 1 < 0) {
						dp[i][j] = (dp[i - 1][j]) % 1000000007;
					} else {
						dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;
					}
				}
			}
		}

		System.out.println((dp[h - 1][w - 1]) % 1000000007);
	}
}


Measured memory_bytes: 114216
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k;
	int ans=0;
	cin >>k;
	ans = k / 2 * ((k +1)/ 2 );
	cout<<ans<<endl;
}

Measured memory_bytes: 3580
S=input()
T=input()
d={}

for k,v in zip(S,T):
  if d.get(k)!= None and d.get(k)!=v:
    print('No')
    exit()
  d[k]=v

if len(set(d.values())) == len(d):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,b,c,q,a[100009],na[100009];long long sum;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		na[a[i]]++;
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>b>>c;
		sum+=na[b]*(c-b);
		na[c]+=na[b];
		na[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
// 298 round - 534 B
int main() {
	
	unsigned long long a,b,aa,ba,price;
	cin>>a>>b;
	
	aa= ceil(a/0.08);
	ba=ceil(b/0.1);
	price=max(aa,ba);
	
    if((price*8)/100==a && price/10==b)
        cout<<price;
    else
        cout<<-1;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define int long long

using namespace std;
unordered_map<int,bool>used;
int a[100001];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
    cout<<n*n*n;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC116C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
#print(hoge)
x=[]
sum=0
for i in range(0,m-1):
	x.append(hoge[i+1]-hoge[i])
	sum+=hoge[i+1]-hoge[i]
x.sort(reverse=True)

#print(x)

sc=0
for i in range(0,min(n-1,len(x))):
	sc+=x[i]

print(sum-sc)



Measured memory_bytes: 14464
#include <iostream>
#include <string>
#include <map>
using namespace std;

struct PairStringInfo 
{
	int count = 0;
	int first_pos;
	int second_pos;
};

int main() {
	int N;
	string S;
	cin >> N >> S;
	
	map<char, PairStringInfo> map_PairString;

	for (int i = 0; i < S.size(); i++) {;
			auto key_itr = map_PairString.find(S[i]);
			if (key_itr != map_PairString.end()) {//アルファベットが２回目以降
				key_itr->second.second_pos = i;
				key_itr->second.count++;
			}
			else {//アルファベットが１回目
				map_PairString[S[i]].first_pos = i;
				map_PairString[S[i]].second_pos = i;
				map_PairString[S[i]].count++;
			}
	}

	int max_num_types_satisfy_condition = 0;
	for (int separated_line_pos = 1; separated_line_pos <= N; separated_line_pos++) {
		int num_types_satisfy_condition = 0;
		for (auto itr = map_PairString.begin(); itr != map_PairString.end(); itr++) {
			if (itr->second.count > 1) {
				bool first_flag = false;
				bool second_flag = false;
				if (itr->second.first_pos < separated_line_pos)first_flag = true;
				if (itr->second.second_pos >= separated_line_pos)second_flag = true;
				if (first_flag == true && second_flag == true) {
					num_types_satisfy_condition++;
				}
			}
			if (num_types_satisfy_condition > max_num_types_satisfy_condition) max_num_types_satisfy_condition = num_types_satisfy_condition;
		}
	}
	cout << max_num_types_satisfy_condition << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述

    int N, K;
    cin >> N >> K;

    vector<int> h;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        h.push_back(temp);
    }

    int ans=0;
    REP(i,N){
        if(h[i] >= K) ans++;
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
char c[2005];
vector<int> v[2005];
int ans=0;
pair<pii,int> dfs(int x,int f){
   // printf("%d\n",x);
    vector<pair<pii,int>> tv;
    LL sum=0,cnt=0;;
    for(auto it:v[x]){
        if(it!=f){
            tv.pb(dfs(it,x));
            sum+=tv.back().x.y;
            cnt+=tv.back().y;
        }
    }
    LL ok=1,Min=sum;
    for(auto it:tv){
        if(it.x.y*2>sum){
            LL tsum=sum-it.x.y;
            if(tsum<it.x.x){
                ok=0;
                Min=it.x.x-tsum;
            }
        }
    }
    if(ok){
        Min=Min&1;
    }
    if(c[x]=='1')cnt++;
    return mp(mp(Min+cnt,sum+cnt),cnt);
}
bool query(int x){
    vector<pair<pii,int> > tv;
    LL sum=0;
    for(auto it:v[x]){
        tv.pb(dfs(it,x));
        sum+=tv.back().x.y;
    }
    LL ok=1;
    for(auto it:tv){
        if(it.x.y*2>sum){
            LL tsum=sum-it.x.y;
            if(tsum<it.x.x){
                ok=0;
            }
        }
    }
    if(ok&&sum%2==0){
        ans=sum/2;
        return true;
    }
    return false;
}
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",c+1);
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
    }
    int res=2e9;
    for(int i=1;i<=n;i++){
        ans=0;
        if(query(i)){
            res=min(ans,res);
        }
    }
    if(res==2e9)res=-1;
    printf("%d\n",res);
}
/*
230
0.5 0.5
0.5 0.25
0.25 0.125
0.25
*/

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long K)
{
    double ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ll cnt = 0;
        ll tmp = i;
        while (tmp < K)
        {
            tmp *= 2;
            cnt++;
        }
        ans += (double)(1 / (N * pow(2, cnt)));
    }

    cout << fixed << setprecision(10) << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        count += 0
    elif A[i] == B[i] or B[i] == C[i] or A[i] == C[i]:
        count += 1
    else:
        count += 2
print(count)

Measured memory_bytes: 3060
# ダミーノード'0'を設定 ※※※
# AtCoder Beginner Contest 168
# https://atcoder.jp/contests/abc168/tasks/abc168_d

import sys
input = sys.stdin.readline

n, m =  map(int, input().split()) # nは頂点の数、mは辺の数
pic = [[] for _ in range(n+1)] # 隣接リスト_初期化 ※※※

for _ in range(m): # 隣接リスト_取り込み
    a, b = map(int, input().split())
    pic[a].append(b) # ※※※
    pic[b].append(a) # ※※※

from collections import deque

def BFS(u): # 'u'を開始位置として各頂点までの距離を探索する関数_dis → 親ノードを探索して'ans'に記録
    queue = deque([u]) # dequeオブジェクトとして初期化、初期値は開始位置の'u'のみ
    dis = [None] * (n+1) # uからの距離を全ノード分初期化 ※※※
    dis[u] = 0 # 開始位置'u'の距離は'0'
    ans = [-1] * (n+1) # 親ノードを記録する
    while queue:
        v = queue.popleft() # 'v'に探索候補のノードを popleft
        for i in pic[v]: # pic[v]: 探索候補のノードに隣接するノードのリスト
            if ans[i] == -1: # 親ノードを記録
                ans[i] = v
            if dis[i] is None:
                dis[i] = dis[v]
                queue.append(i)
    return ans

tmp = BFS(1) # ここは開始位置'1'
print('Yes')
for j in tmp[2:]:
    print(j) # ※※※


Measured memory_bytes: 34820
import math
 
 
def insertionsort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt
 
 
def shellsort(A, n):
    G = []         
    gap = 1
    while gap <= math.ceil(n / 3):
        G.append(gap)
        gap = gap * 3 + 1
    G = G[::-1]
    m = len(G)
    print(m)
    print(*G)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(A, n, G[i])
    print(cnt)
 
 
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellsort(A, n)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47564
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}
pub fn read_and_parse<T: std::str::FromStr>() -> T {
    read_line!().trim().parse().ok().unwrap()
}
fn main() {
    let n: u64 = read_and_parse();
    let mut ans: u64 = 0;

    ans += n * (n + 1) / 2;
    ans -= (n/3) * (n/3 + 1) / 2 * 3;
    ans -= (n/5) * (n/5 + 1) / 2 * 5;
    ans += (n/15) * (n/15 + 1) / 2 * 15;

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


Measured memory_bytes: 2148
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

cumulative_sums = [0]

H.each do |h|
  cumulative_sums.push [cumulative_sums.last, h].max
end

cumulative_sums.shift

count = 0
H.each_with_index do |height, i|
  count += 1 if height == cumulative_sums[i]
end

puts count


Measured memory_bytes: 1788
function Main(s) {
  var s = s.split("\n");
  var n = Number(s[0]);
  var a = s[1].split(" ").map(e => Number(e));
  var arr = [];
  for (var i = 0; i < n - 1; i++) {
    if (a[i] != a[i + 1]) {
      arr.push(a[i]);
    }
  }
  arr.push(a[n - 1]);
  var start = 0;
  var ans = 1;
  if (arr.length <= 2) {
    console.log(ans);
  } else {
    for (var i = 1; i < arr.length - 1; i++) {
      if ( (arr[start] < arr[i] && arr[i] > arr[i + 1]) || (arr[start] > arr[i] && arr[i] < arr[i + 1])) {
        ans++;
        start = i + 1;
        i++;
      }
    }
    console.log(ans);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28128
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 3852
#include<stdio.h>

int main(){
   int a,b,c=0,d=0;
   
   scanf("%d %d", &a, &b);
   for(int i=0;i<=a;i++){
       if(((double)b-2*i)/4==a-i){
           c++;
       }
   }
   for(int i=0;i<=a;i++){
       if(((double)b-4*i)/2==a-i){
           d++;
       }
   }
    if(c>0&&d>0){
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

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


string s;

ll rez(ll sum, ll sofar, int cur ){
    if(cur==s.length())
        return sum+sofar;
    return rez(sum+sofar,s[cur]-'0',cur+1)+rez(sum,sofar*10+s[cur]-'0',cur+1);
}

int main()
{
    cin>>s;
    cout<<rez(0,s[0]-'0',1);
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	res := 800*N - (N / 15 * 200)
	fmt.Println(res)

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

int main(){
  string o,e;
  cin>>o>>e;
  for(int i=0; i<e.size(); i++){
    cout<<o[i];
    cout<<e[i];
  }
  if(o.size()>e.size())cout<<o[o.size()-1];
  cout<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int d_[5100];

int main(){
	long long int k, q;
	cin >> k >> q;
	for(int i = 0; i < k; i++){
		cin >> d_[i];
	}
	for(int loop = 0; loop < q; loop++){
		long long int n, x, m;
		cin >> n >> x >> m;
		long long int d[5100];
		long long int S = 0, S0 = 0, S1 = 0;
		for(int i = 0; i < k; i++){
			d[i] = d_[i] % m;
			S += d[i];
			if(d[i] == 0){
				S0 += 1;
			}
			// cout << d[i] << " ";
		}
		// cout << S << endl;
		n -= 1;
		long long int num = n / k, rem = n % k;
		long long int c1 = S / m, c2 = S % m;
		S = c2 * num % m + x % m;
		for(int i = 0; i < rem; i++){
			S += d[i];
			if(d[i] == 0){
				S1 += 1;
			}
		}
		// cout << S0 << " " << S1 << endl;
		cout << n - (c1 * num + c2 * num / m + S / m + S0 * num + S1) << endl;
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	printf("%.9f %d", w * h / 2.0, (x*2 == w && y*2 == h) ? 1 : 0);
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=2;i*i<=2*n;i++){
    for(int j=2;i*i+j*j<=2*n;j++){
      for(int k=2;i*i+j*j+k*k<=2*n;k++){
        if(i*i+j*j+k*k<=2*n){
          if((i+j-k)%2==0&&(i+j-k)>0&&(i-j+k)%2==0&&(i-j+k)>0&&(-i+j+k)%2==0&&(-i+j+k)>0){
            a[(i*i+j*j+k*k)/2-1]++;
          }
        }
      }
    }
  }
  rep(i,n) cout<<a[i]<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<lli,lli> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){__
	lli n;
	cin >> n;
	lli ans = 0ll;
	vi used(n+1);
	if(n == 1){
		ans++;
	}
	for(int i=0; i < n-1; i++){
		lli u,v;
		cin >> u >> v;
		if(!used[u])
			ans+= 1ll * u * (n-u+1);
		if(!used[v])
			ans+= 1ll * v * (n-v+1);
		used[u] = used[v] = 1;
		ans-= 1ll * min(u,v) * (n- max(u,v)+1);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4004
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int n , k, x, y;
  cin >> n >> k >> x >> y;

  int p = min(k,n);

  cout << x*p + (n-p) * y << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding utf-8 -*-

antena = [int(input()) for _ in range(5)]
k = int(input())

frag = True
for i in range(5):
    for j in range(5):
        if abs(antena[i] - antena[j]) > k:
            frag = False
print('Yay!' if frag else ':(') 

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

int A[1000000], n;

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
  }

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( *lower_bound(A, A + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3548
s = list(input())
k = int(input())

l = []
for i in range(len(s)):
    for y in range(k):
#        print(''.join(s[i:i+y+1]))
        if not ''.join(s[i:i+y+1]) in l:
            l.append(''.join(s[i:i+y+1]))

l.sort()
if not l:
    print(s[0])
else:
    print(l[k-1])


Measured memory_bytes: 4072
#include<iostream>
using namespace std;
int water(int t,int t1,int t2){
  int w;
  if(t2-t1>=t) w=t;
  else w= t2-t1;
  return w;
}
int main(){
  int n,t_cnt=0;
  long long int T;
  cin >> n >> T;
  int t[n];
  for(int i=0;i<n;i++){
    cin >> t[i];
  }

  for(int i=1;i<n;i++){
    t_cnt+=water(T,t[i-1],t[i]);
  }
  t_cnt+=T;
  cout << t_cnt<<endl;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}


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

  for(;;) {
    int n;
    cin >> n;
    if(n == 0) return 0;
    n++;
    vi dp(n);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i = 3; i < n; i++) {
      dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
    }
    int ans = ceil(dp[n-1], 10);
    ans = ceil(ans, 365);
    cout << ans << endl;
  }
}


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

const int INF = 1e18 +100;

int main(){
    int n;
    cin >> n;
    vector<P>a(n);
    rep(i,n){
        int x,len;
        cin >> x >> len;
        a[i].first=x+len;
        a[i].second=x-len;
    }
    // a.first(アーム右側を基準にソート)
    sort(all(a));
    int ans=0;
    int rr=-INF;
    rep(i,n){
        if(a[i].second>=rr){
            ++ans;
            rr=a[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

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




Measured memory_bytes: 2084
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int m1,m2,d1,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m1==1||m1==3||m1==5||m1==7||m1==8||m1==10||m1==12){
		if(d1==31){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	}else if(m1==2)
		if(d1==28){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	else if(m1==4||m1==6||m1==9||m1==11){
		if(d1==30){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    scanf(" %d%d",&a,&b);
    if((1<=a&&a<=1000)&&(1<=b&&b<=100))
        {
        if((a+b)%3==0||a%3==0||b%3==0){printf("Possible");}
        else {printf("Impossible");}
    }
    return 0;
}


Measured memory_bytes: 128
while True:
    a = input().split(' ')
    if a[0] == '-1' and a[1] == '-1' and a[2] == '-1':
        break
    elif int(a[0]) == -1 or int(a[1]) == -1:
        print('F')
    elif int(a[0]) + int(a[1]) >= 80:
        print('A')
    elif 65 <= int(a[0]) + int(a[1]) < 80:
        print('B')
    elif 50 <= int(a[0]) + int(a[1]) < 65:
        print('C')
    elif 30 <= int(a[0]) + int(a[1]) < 50:
        if int(a[2]) >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Measured memory_bytes: 7696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];

    int ans=0;
    for(int i=0;i<n-1;i++){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    if(p[n-1]==n){
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  unordered_map<int, int> mp;
  int x = 0;
  mp[x] = 0;
  V<> dp(n + 1);
  for (int i = 0; i < n; ++i) {
    x ^= 1 << s[i] - 'a';
    dp[i + 1] = dp[i] + 1;
    if (mp.count(x)) dp[i + 1] = min(dp[i + 1], dp[mp[x]]);
    for (int j = 0; j < 26; ++j) {
      if (mp.count(x ^ 1 << j)) dp[i + 1] = min(dp[i + 1], dp[mp[x ^ 1 << j]] + 1);
    }
    mp[x] = i + 1;
  }
  cout << max(dp[n], 1) << '\n';
}

Measured memory_bytes: 9436
// AOJ 2170: Marked Ancestor
// 2018.1.2 bal4u@uu

#include <stdio.h>

int p[100003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

//	while ((c = getchar_unlocked()) < '0');
	c = getchar_unlocked();
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int find(int v)
{
	if (v == p[v]) return v;
	return find(p[v]);
}

int main()
{
	int N, Q, i, cmd, v;
	long long ans;

	while (N = in()) {
		Q = in();
		p[1] = 1; for (i = 2; i <= N; i++) p[i] = in();

		ans = 0;
		for (i = 0; i < Q; i++) {
			cmd = getchar_unlocked(); getchar_unlocked();
			v = in();
			if (cmd == 'M') p[v] = v;
			else ans += find(v);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2244
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] arr = in.next().toCharArray();

            int l = 0;
            int r = n - 1;
            long ans = 0;
            while (l < r) {
                if (arr[l] > arr[r]) {
                    ans++;
                    l++;
                    r--;
                } else if (arr[l] < arr[r]) {
                    l++;
                    r--;
                } else {
                    if (arr[l] == 'W') {
                        r--;
                    } else {
                        l++;
                    }
                }
            }

            out.println(ans);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 37744