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

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

  int k;
  cin >> k;
  if (k <= 9) {
    cout << k << '\n';
    return 0;
  }
  k -= 9;
  vector<long long> res(9);
  for (int i = 0; i < 9; i++) res[i] = i + 1;
  vector<long long> nex;
  while (true) {
    for (long long &n : res) {
      int d = n % 10;
      n *= 10;
      for (int i = -1; i < 2; i++) {
        int tail = d + i;
        if (tail < 0 || tail > 9) continue;
        nex.emplace_back(n + tail);
        k--;
        if (k == 0) {
          cout << nex[nex.size()-1] << '\n';
          return 0;
        }
      }
    }
    res = nex;
    nex.clear();
  }
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  P((x - a) % b);


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int calc(int x){
  int ans=0;
  while(x>0){
    ans+=x%10;
    x/=10;
  }
  return ans;
}

signed main() {
  int N,A,B;cin>>N>>A>>B;
  int sum=0;
  for(int t=1;t<=N;t++){
    if(calc(t)>=A&&B>=calc(t)){
      sum+=t;
    }
  }
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#else
#define gc() 1
#define max3(a,b,c) max(a,b,c)
#define min3(a,b,c) min(a,b,c)
#endif

typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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



#define MAXIN 100

lint gcd(lint a, lint b) {
	if (a<b) swap(a, b);
	lint r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

inline bool cmp(const pair<int, int>& firstElof, const pair<int, int>& secondElof)
{
	return firstElof.first < secondElof.first;
}
inline bool cmpg(const pair<int, int>& firstElof, const pair<int, int>& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	lint n, m; cin >> n >> m;
	vector<pair<int, int>> a;
	pair<int, int>in;
	rep(i, m) {
		cin >> in.first >> in.second;
		a.push_back(in);
	}
	sort(all(a), cmp);
	
	lint pos1 = 0, pos2 = 0, d1=a[0].first;
	repi(i, 1, m) {
		if (a[i].first == d1)pos2++;
		else {
			sort(a.begin() + pos1, a.begin() + pos2 + 1, cmpg);
			d1 = a[i].first;
			pos1 = i;
			pos2++;
		}
	}
	sort(a.begin() + pos1, a.begin() + pos2 + 1, cmpg);
	

	lint c1 = a[0].first, c2 = a[0].second;
	lint ans = 1;
	rep(i, m) {
		if (c2 <= a[i].first) {
			ans++;
			c1 = a[i].first; c2 = a[i].second;
		}
		else {
			c1 = a[i].first;
			if (c2 > a[i].second)c2 = a[i].second;
		}
	}
	co(ans);
	gc();
}


Measured memory_bytes: 1400
a = Array.new(3){gets.split(" ").map(&:to_i)}
n = gets.to_i
n.times do
  b = gets.to_i
  3.times do |i|
    a[i].map! do |k|
      k == b ? 0 : k
    end
  end
end
flag = false
a.each do |l|
  if l.inject(&:+)  == 0
    flag = true
    break
  end
end
a.transpose.each do |l|
  if l.inject(&:+)  == 0
    flag = true
    break
  end
end
flag = true if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] ==  0) || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] ==  0)
puts flag ? "Yes" : "No"

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;

int main() {
  int N,K;
  cin >> N >> K;
  mint ans = 0;
  vm dp(K+1,0);
  drep(x,K+1) {
    if(!x) break;
    mint res = K/x;
    res = res.pow(N);
    dp[x] = res;
    for(int k=2*x;k<=K;k+=x) {
      dp[x] -= dp[k];
    }
    ans += dp[x]*x;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 4060
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n, c = 0, k = 0;
	int p[55];
	int a = 0, a1, b, b1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (p[i]!=i+1)
			c++;
	}
	if (c <= 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  cin >> s ;
  ll k ;
  cin >> k ;
  ll cnt = 0 ;
  char c ;
  int i =0 ;
  while(i<SZ(s)){
    if(s.at(i)=='1'){
      cnt++; 
    }
    else{
      c = s.at(i) ;
      break ;
    }
    i++ ;
  }
  
  if(k>cnt){
    cout << c <<endl ;
  }
  else{
    cout << 1 <<endl ;
  }
  

  return 0 ;
}



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

int f(int x) {
    if (x%2 == 0) {
        return x/2;
    } else {
        return 3*x + 1;
    }
}

set<int> used;

int main() {
    int s;
    cin >> s;
    used.insert(s);

    int pos = 2;
    while (true) {
        s = f(s);
        if (used.find(s) != used.end()) {
            cout << pos;
            return 0;
        }
        used.insert(s);
		pos++;
    }



    return 0;
}


Measured memory_bytes: 256
n = int(input())
dp = [[0 for i in range(n)] for i in range(2)]
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

dp[0][0] = a1[0]
for i in range(1, n):
    dp[0][i] = dp[0][i - 1] + a1[i]
dp[1][0] = dp[0][0] + a2[0]

for i in range(1, n):
    dp[1][i] = max(dp[0][i] + a2[i], dp[1][i - 1] + a2[i])

print(dp[1][-1])


Measured memory_bytes: 9168
fun main(args: Array<String>) {
    val n=readLine()!!.toInt()
    val ptable = IntArray(n+1)
    for(i in 1..n){
        divide(i).forEach{
            ptable[it]++
        }
    }

    var ans = 1L
    ptable.forEach {
        ans*=it+1
        ans%=1000000007
    }
    println(ans)
}

fun divide(x:Int):List<Int>{
    val list = mutableListOf<Int>()
    var i=2
    var tmp=x
    while(i<=x){
        if(tmp==1) break
        if(tmp%i==0) {
            list.add(i)
            tmp /= i
            continue
        }
        i++
    }
    return list
}



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

int main() {
	string s;
	cin >> s;
	int first, last;
	for (int i = 0;i < s.length();i ++) {
		if (s[i] == 'A') {
			first = i;
			break;
		}
	}
	for (int i = s.length() - 1;i >= 0;i --) {
		if (s[i] == 'Z') {
			last = i;
			break;
		}
	}
	cout << last - first + 1;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、sの中に複数のAがある場合、最も先頭のAを使った方が最も部分文字列が長くなる
同様に複数のZがある場合は最も末尾のZを使った方が部分文字列が長くなる
よって、ループ回して先頭と末尾を取得すれば良いね O(|s|)
*/

Measured memory_bytes: 640
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
char arr[101][101];
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);


    const ll mod = 1e9+7;
    ll ans = 1;
    ll n=RLL();

    fr1{
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;
}


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

int main() {
    string s;
    cin>>s;
    if((s[0]!=s[2]&&(s[0]==s[1]&&s[2]==s[3]))||(s[0]!=s[1]&&(s[0]==s[2]&&s[1]==s[3]))||(s[0]!=s[1]&&(s[0]==s[3]&&s[1]==s[2]))) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


import numpy as np
from numba import njit

N, W_max = ints()
W, V = read_col(N)
W = np.array(W, dtype=np.int64)
V = np.array(V, dtype=np.int64)

'''
dp[i,j] ... 重さの最小 (:iまで考慮したとき、価値がちょうどjのとき)
答えはW以下の数字が入ってるマスの一番左側

更新則
chmin(dp[i+1,j+V[i]] , dp[i, j]+W[i]) #ナップサックに入れた場合
chmin(dp[i+1,j] , dp[i, j]) # ナップサックに入れなかった場合
'''


@njit('(i8, i8, i8[:], i8[:])', cache=True)
def solve(N, W_max, W, V):
    V_max = np.sum(V) + 1
    dp = np.full((N + 1, V_max), 10**12, dtype=np.int64)
    # 初期化
    dp[0][0] = 0  # 一個も選ばず価値が0なら必ず重さも0

    # 更新
    for i in range(N):
        dp[i + 1, :] = np.minimum(dp[i + 1, :], dp[i, :])
        dp[i + 1, V[i]:] = np.minimum(dp[i + 1, V[i]:], dp[i, :-V[i]] + W[i])
        # 以下のコードを高速化
        # for j in range(V_max):
        #     jv = j + V[i]
        #     if jv < V_max:
        #         dp[i + 1, jv] = min(dp[i + 1, jv], dp[i, j] + W[i])
        #     dp[i + 1, j] = min(dp[i + 1, j], dp[i, j])

    # 左から見てく
    for j in range(V_max - 1, -1, -1):
        if np.any(dp[:, j] <= W_max):
            print(j)
            return


solve(N, W_max, W, V)


Measured memory_bytes: 199916
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

string S, T;

void solve(void) {
  cout << T << S << endl;
}

int main(void) {
  cin >> S >> T;
  solve();
  return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
AB = N.times.map{gets.split.map(&:to_i)}

bottle = M
tot = 0
AB.sort_by!{|x| x[0]}.each do |a, b|
  if bottle >= b
    tot += a * b
    bottle -= b   
  else  
    tot += a * bottle 
    break
  end
end

puts tot

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

using namespace std;
using ll = long long;


int main()
{
    string s;
    cin >> s;
    bool res = true;
    int n = s.size();

    for(int i = 0; i < n; i++) {
        if(i & 1 && s[i] != s[1])res = false;
        if(i % 2 == 0 && s[i] != s[0])res = false;
    }
    if(res) {
        cout << "Second" << endl;
        return 0;
    } else {
        if(s[0] != s[n - 1]) {
            cout << (n & 1 ? "First" : "Second") << endl;
        } else {
            cout << (n & 1 ? "Second" : "First") << endl;
        }
    }
}

Measured memory_bytes: 3760
#include <iostream>
#include <string>
using namespace std;
int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    const int dx=tx-sx, dy=ty-sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x;
  cin >> n;
  vector<int> a[n + 1];
  for(int i = 2;i <= n;i++){ //inputs: 1 1 2 2
    cin >> x;
    a[x].push_back(x);
  }
  for(int  i = 1;i <= n;i++){
    cout << a[i].size() << endl;
  }
  return 0;
}

Measured memory_bytes: 14548
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

const int MAX_V = 110;

struct edge{
    int to, cap, cost, rev;
};

int V;
vector<vector<edge>> G(MAX_V);
int h[MAX_V];                   // ポテンシャル h(v):=(s-v間の最短距離)
int dist[MAX_V];                // 最短距離
int prevv[MAX_V], preve[MAX_V]; //直前の頂点と辺

// fromからtoへ向かう容量cap, コストcostの辺をグラフに追加する
void add_edge(int from, int to, int cap, int cost){
    G[from].eb((edge){to, cap, cost, (int)G[to].size()});
    G[to].eb((edge){from, 0, -cost, (int)(G[from].size()-1)});
}

// sからtへの流量fの最小費用流を求める
// 流せない場合は-1を返す
int min_cost_flow(int s, int t, int f){
    int res = 0;
    fill(h, h+V, 0);
    while(f > 0){ // dijkstra
        priority_queue<P, vector<P>, greater<P>> que;
        fill(dist, dist+V, 1e9);
        dist[s] = 0;
        que.push(P(0, s));
        while(que.size()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(dist[v] < p.first) continue;
            for(int i=0; i<G[v].size(); i++){
                edge &e = G[v][i];
                if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }

        if(dist[t] == 1e9){ // これ以上流せない
            return -1;
        }
        for(int v=0; v<V; v++){
            h[v] += dist[v];
        }

        // s-t間最短路に沿って目一杯流す
        int d = f;
        for(int v=t; v!=s; v=prevv[v]){
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    
    return res;
}

int main(){
    int e, f; cin>>V>>e>>f;
    for(int i=0; i<e; i++){
        int s, t, c, d; cin>>s>>t>>c>>d;
        add_edge(s, t, c, d);
    }

    cout << min_cost_flow(0, V - 1, f) << endl;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int n,x[1000],y[1000];
    double D = 0.0,D3 = 0.0;
    cin >> n;
    for (int i = 0; i < n; i++)cin >> x[i];
    for (int i = 0; i < n; i++)cin >> y[i];
    for (int i = 0; i < n; i++){
        D += fabs(x[i]-y[i]);
    }
    printf("%lf\n",D);
    D = 0.0;
    for (int i = 0; i < n; i++){
        D += fabs(x[i]-y[i])*fabs(x[i]-y[i]);
    }
    printf("%lf\n",sqrt(D));
    D = 0.0;
    for (int i = 0; i < n; i++)
    {
        D += fabs(x[i]-y[i])*fabs(x[i]-y[i])*fabs(x[i]-y[i]);
    }
    printf("%lf\n",pow(D,1.0/3.0));
    D = 0.0;
    for (int i = 0;i < n;i++){
        D = (D < fabs(x[i]-y[i]))?fabs(x[i]-y[i]):D;
    }
    printf("%lf\n",D);

return 0;
}
    
    
    
    
    
    


Measured memory_bytes: 3352
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i;
    char s[64];
    scanf("%s",s);
    for(i=0;i<strlen(s)-8;i++){printf("%c",s[i]);}
    printf("\n");
    return 0;
}

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

int main() {
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
    	double x,y;
    	x=(b*f-e*c)/(b*d-a*e);
    	y=(a*f-c*d)/(a*e-b*d);
    	if(x==0)x=0;
    	if(y==0)y=0;
    	printf("%.3lf %.3lf\n",x,y);
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3180
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = input()
out = 0
L = [0 for i in range(n)]

def score(a):
  if a == "r":
    ret = p
  elif a == "s":
    ret = r
  else:
    ret = s
  return (ret)

for i in range(n):
  if i < k:
    out += score(T[i])
  else:
    if T[i] != T[i-k]:
      out += score(T[i])
    elif L[i-k] == 1:
      out += score(T[i])
    else:
      L[i] = 1
  #print("{0},{1}".format(i, out))
print(out)

Measured memory_bytes: 4212
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    int N, K;
    std::cin >> N >> K;

    vector<int> heights(N);

    for (int i = 0; i < N; ++i)
        std::cin >> heights[i];

    std::sort(heights.begin(), heights.end());

    auto it = std::lower_bound(heights.begin(), heights.end(), K);

    std::cout << heights.end() - it << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll n,y;
    while(sf("%lld %lld",&n,&y)==2)
    {
        bool f=false;
        for(ll i=0;i<=n;i++)
        {
            for(ll j=0;j<=n;j++)
            {
                if(i+j<=n)
                {
                    ll k=n-i-j;
                    if(i*10000+j*5000+k*1000==y)
                    {
                        f=true;
                        pf("%lld %lld %lld\n",i,j,k);
                        break;
                    }
                }
            }
            if(f)break;
        }
        if(!f)pf("-1 -1 -1\n");
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
struct node{
	int lst,nxt,c;
}a[233];
int len,h1,t1,h2,t2,nw,er[40],l;
void addh1(){
	a[++len].c=nw;
	a[len].nxt=h1;
	a[h1].lst=len;
	h1=len;
}
void addh2(){
	a[++len].c=nw;
	a[len].nxt=h2;
	a[h2].lst=len;
	h2=len;
}
void addt2(){
	a[++len].c=nw;
	a[len].lst=t2;
	a[t2].nxt=len;
	t2=len;
}
int main(){
	scanf("%lld",&n);
	++n;
	h1=t1=1;h2=t2=2;
	a[1].c=1;a[2].c=1;
	nw=1;len=2;
	for(;n;n/=2)
		er[++l]=n&1ll;
	if(er[l-1]){
		++nw;
		addh1();
		addt2();
	}
	for(l=l-2;l;--l){
		++nw;
		addh1();
		addh2();
		if(er[l]){
			++nw;
			addh1();
			addt2();
		}
	}
	printf("%d\n",len);
	for(int i=h1;i;i=a[i].nxt)
		printf("%d ",a[i].c);
	for(int i=h2;i;i=a[i].nxt)
		printf("%d ",a[i].c);
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>

char prime[10000001];

void SetPrime(int max)
{
	int i, j;
	
	for (i = 4; i <= max; i += 2){
		prime[i] = 1;
	}
	for (i = 3; i * i <= max; i += 2){
		if (prime[i] == 0){
			for (j = i * 2; j <= max; j += i){
				prime[j] = 1;
			}
		}
	}
}

int main(void)
{
	int n;
	
	SetPrime(10000000);
	while (scanf("%d", &n) * n != 0){
		int i;
		
		for (i = n; i >= 10; i--){
			if (prime[i] + prime[i - 2] + prime[i - 6] + prime[i - 8] == 0){
				printf("%d\n", i);
				break;
			}
		}
	}
	
	return 0;
}

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

int main () {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a-x) < abs(b-x)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;

const int mod = 1000000007;

bool ok(int b, int w) {
  rep (i, w - 1) if (((1 << i) & b) != 0 && ((1 << (i + 1)) & b) != 0) return false;
  return true;
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  int dp[H + 1][W + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  rep (h, H) rep (w, W) rep (i, (1 << (W - 1))) if (dp[h][w] != 0 && ok(i, W - 1)) {
    if (w != 0 && (1 << (w - 1)) & i) dp[h + 1][w - 1] = (dp[h + 1][w - 1] + dp[h][w]) % mod;
    else if (w != W - 1 && (1 << w) & i) dp[h + 1][w + 1] = (dp[h + 1][w + 1] + dp[h][w]) % mod;
    else dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % mod;
  }

  cout << dp[H][K - 1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 500000

int H;
int T[M];

void maxHeapify(int i){
  int l,r; 
  int largest;
  int temp;

  l = i*2;
  r = i*2+1;

  if(l<=H && T[l]>T[i])
    largest = l;

  else
    largest = i;
  
  if(r<=H && T[r]>T[largest])
    largest = r;

  if(largest != i){
    temp = T[largest];
    T[largest] = T[i];
    T[i] = temp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=H/2; i>=1; i--)
    maxHeapify(i);
}
    
int main()
{
  int i;

  scanf("%d",&H);

  for(i=1; i<=H; i++){
    scanf("%d",&T[i]);
  }
  
  buildMaxHeap();
  
  for(i=1; i<=H; i++){
    printf(" %d",T[i]);
  }
  printf("\n");
  
  return 0;
}
      



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin>>N;
  int tool[N];
  long long ans=0;
  for(int i=0;i<N;i++)cin>>tool[i];
  
  
  for(int i=1;i<N;i++)
  {
    if(tool[i-1]>tool[i])
    {
      ans+=tool[i-1]-tool[i];
      tool[i]=tool[i-1];
    }
  }
  
  cout<<ans;
  

}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
int ans;
void lcs(){
  string X,Y; cin>>X>>Y;
  int N=X.size();
  int W=Y.size();
  int dp[1100][1100];
  rep(i,N){
    rep(j,W){
      if (X[i]==Y[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  cout<<dp[N][W]<<endl;
}
int main(){
  int K;cin>>K;
  rep(i,K) lcs();
}



Measured memory_bytes: 7476
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n,m;
cin >> n >> m;
n==m ? fin("Yes") : fin("No");

//////////////////////////////////////////////////////
return 0;}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  int n; cin >> n;
  cout << n / 2 + n % 2;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;


string S;



int main()
{
	bool ans = true;
	cin >> S;


	for (unsigned i = 0; i < S.size() && ans; i++) {

		ans = !(S.at(i) == (i % 2 ? 'R' : 'L'));
	}


	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int m[101][101];

void matrixChainMultiplication(int n, int *p){
  int i,j,k,l;
  
  for(i=1; i<n+1; i++){
    m[i][i]=0;
  }
  for(l=2; l<n+1; l++){
    for(i=1; i<n-l+2; i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i; k<j; k++){
	if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
	  m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	}
      }
    }
  }
}

int main(){
  int i,p[101],n;
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }
  matrixChainMultiplication(n,p);
  printf("%d\n", m[1][n]);
  
  return 0;
}

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

using namespace std;

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

	long long b=0;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b=b^a[i];
	}




	for(int i=0;i<n;i++)
	{
		cout<<(b^a[i])<<" ";
	}

	return 0;
}

Measured memory_bytes: 4360
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	VLL P(N + 1, 0);
	in(P, 1, N);
	for (LL n = 1; n <= N; n++) {
		P[n] += P[n - 1];
	}
	LL ans = 0;
	for (LL n = 1; n <= N - K + 1; n++) {
		ans = max(ans, K + P[n + K - 1] - P[n - 1]);
	}
	if (ans & 1)cout << ans / 2 << ".5\n";
	else cout << ans / 2 << "\n";
	return 0;
}


Measured memory_bytes: 1792
N,T = map(int,input().split())
t = list(map(int,input().split()))
on_t=0
all_t=0
for i in range(1,N):
    d = t[i]-t[i-1]
    if T>=d:
        on_t += d
        all_t += d
    else:
        on_t += T
        all_t += d
on_t += T
print(on_t)

Measured memory_bytes: 25200
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int64;
const int MAX_N = 1e5+5;
bool able[MAX_N];
int A[MAX_N];
int solve(int N,int M,int V,int P){
	sort(A+1,A+N+1);
	reverse(A+1,A+N+1);
	for (int i = 1; i <= N; ++i)
		if(A[i]+M >= A[P])
			able[i] = true;

	if(V > P){
		int64 sum = A[P];
		for (int i = P+1; i <= N; ++i){
			if(!able[i])	break;
			able[i] &= sum <= (int64)(i-P)*(A[i]+M) - (int64)(V-P-N+i)*M;
			sum += A[i];
		}
	}

	int ret = 0;
	for (int i = 1; i <= N; ++i)
		if(able[i])
			++ret;
	return ret;
}
int main(){
	int N,M,V,P;
	scanf("%d%d%d%d",&N,&M,&V,&P);
	for (int i = 1; i <= N; ++i)
		scanf("%d", A+i);
	int ans = solve(N,M,V,P);
	printf("%d\n",ans);
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

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

    vi num (4);
    REP(i,4){
     num[i] = S[i] - '0';  
    }
    
    vector<char> op (3);

    REP(i,1<<3){
        int x = num[0];
        
        REP(j,3){
            if((1<<j)&i){
                x += num[j+1];
                op[j] = '+';
            }
            else{
                x -= num[j+1];
                op[j] = '-';
            }
        }

        if(x == 7){
            break;
        }
    }

    REP(i,3){
        cout << num[i] << op[i];
    }
    cout << num[3] << "=7" << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

struct Vector2D{
	double x, y;
};

Vector2D sub_vector(const Vector2D& a, Vector2D& b) {
	Vector2D ret;
	ret.x = a.x - b.x;
	ret.y = a.y - b.y;
	return ret;
}

//?????´?????? true ?????´?????? false
bool hit(Vector2D A, Vector2D B, Vector2D C, Vector2D P) {
	Vector2D AB = sub_vector(B, A);
  Vector2D BP = sub_vector(P, B);

  Vector2D BC = sub_vector(C, B);
  Vector2D CP = sub_vector(P, C);

  Vector2D CA = sub_vector(A, C);
  Vector2D AP = sub_vector(P, A);

  double c1 = AB.x * BP.y - AB.y * BP.x;
  double c2 = BC.x * CP.y - BC.y * CP.x;
  double c3 = CA.x * AP.y - CA.y * AP.x;

  if( ( c1 > 0 && c2 > 0 && c3 > 0 ) || ( c1 < 0 && c2 < 0 && c3 < 0 ) ) {
    return false;
  }

  return true;
}

signed main(void)
{
	double x1,x2,x3,xp,y1,y2,y3,yp;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp) {
		Vector2D a = {x1, y1}, b = {x2, y2}, c = {x3, y3}, p = {xp, yp};
		if(hit(a, b, c, p)) cout << "NO" << endl;
		else cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

ll a[200000];string ans[200000];

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;cin>>n;
    REP(i,n)cin>>a[i];
    ll b=0;REP(i,n)b^=a[i];
    string ans="";
    REP(i,n){ans+=to_string(a[i]^b);ans+=" ";}
    cout<<ans<<endl; 
}

Measured memory_bytes: 14956
_ = map(int,input().split())
l1 = list(map(int,input().split()))

is_app = 1
for i in l1:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            is_app = 0
if is_app == 1:
    print('APPROVED')
else:
    print('DENIED')
    

Measured memory_bytes: 38384
#include<cstdio>
#define N 606
#define p 1000000007
#define ll long long
int a[N],f[N][N],g[N],h[N],i,j,k,m,n;
int main()
{
    scanf("%d%d",&n,&m),n<<=1;
    for(*g=i=1;i<=n;i++)h[a[i]=i]=1;
    for(i=1;i<=m;i++)scanf("%d%d",&j,&k),h[a[k]=j]=h[a[j]=k]=0;
    for(i=2;i<=n;i+=2)g[i]=(ll)(i-1)*g[i-2]%p;
    for(i=1;i<=n;i++)h[i]+=h[i-1];
    for(i=n;i;i--)for(j=i;j<=n;j++)for(f[k=i][j]=g[h[j]-h[i-1]];k<=j&&f[i][j];k++)if(a[k]<i||j<a[k])f[i][j]=0;
    for(i=n;i;i--)for(j=i;j<=n;j++)if(f[i][j])for(k=i;k<j;k++)f[i][j]=(f[i][j]+(ll)(p-f[i][k])*g[h[j]-h[k]])%p;
    for(i=n,k=0;i;i--)for(j=i;j<=n;j++)k=(k+(ll)f[i][j]*g[h[n]-h[j]+h[i-1]])%p;
    return 0*printf("%d\n",k);
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int table[101][101];
    int r, c;
    cin >> r >> c;
    REP(i, r) {
        REP(j, c) {
            cin >> table[i][j];
        }
    }
    int row[100] = {}, column[100] = {}, s = 0;
    REP(i, r) {
        REP(j, c) {
            row[i] += table[i][j];
            column[j] += table[i][j];
            s += table[i][j];
        }
    }
    REP(i, r + 1) {
        REP(j, c + 1) {
            if (j) {
                cout << " ";
            }
            if (i < r && j < c) {
                cout << table[i][j];
            } else if (i < r && j == c) {
                cout << row[i];
            } else if (i == r && j < c) {
                cout << column[j];
            } else {
                cout << s;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
/* In the name of Allah */

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
int arr[MAXN];
int dp[MAXN];
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	dp[1] = 0;
	dp[2] = abs(arr[1] - arr[2]);
	
	for(int i = 3; i <= n; i++){
		dp[i] += min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[ i - 2]));
	}
	
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 1024