akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  constexpr ll SIZE=1ll<<9;
  constexpr ll MAXN=1ll<<18;
  constexpr ll MAXW=100010;

  std::vector<ll> v(MAXN-1,0),w(MAXN-1,0);
  rep(i,0,n)std::cin>>v[i]>>w[i];

  std::vector<std::vector<ll>> dp(SIZE-1,std::vector<ll>(MAXW,0));

  rep(i,w[0],MAXW)dp[0][i]=v[0];

  rep(i,1,SIZE-1){
    rep(j,0,w[i])dp[i][j]=dp[(i-1)/2][j];
    rep(j,w[i],MAXW)dp[i][j]=std::max(dp[(i-1)/2][j],dp[(i-1)/2][j-w[i]]+v[i]);
  }

  ll q;
  std::cin>>q;

  using P=std::pair<ll,ll>;

  while(q--){
    ll a,l;
    std::cin>>a>>l;
    a--;

    if(a<SIZE-1){
      std::cout<<dp[a][l]<<"\n";
      continue;
    }

    std::vector<P> tmp(1,{0,0});
    while(a>=SIZE-1){
      ll m=tmp.size();
      rep(i,0,m){
        if(tmp[i].first+w[a]<=l)tmp.emplace_back(tmp[i].first+w[a],tmp[i].second+v[a]);
      }
      a=(a-1)/2;
    }

    ll ans=0;
    for(const auto& e:tmp){
      chmax(ans,e.second+dp[a][l-e.first]);
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}

Measured memory_bytes: 408680
N, K = map(int, input().split())
H = list(map(int, input().split()))

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)

# for hp in r_H:
#     sum_H += hp

print(sum(r_H))
# print(type(10**9))
# print(type(2*10**14))

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


int main(){
	long long a, b;
	cin>>a>>b;
	long long x;
	cin>>x;
	long long t = a / x * x;
	if(t < a) t += x;
	a = t;
	t = b / x * x;
	b = t;
	if(a > b){
		cout<<0<<endl;
	}
	else if(a == b){
		cout<<1<<endl;
	}
	else{
		t = (b - a) / x + 1;
		cout << t << endl;
	}
}

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

vector<int> bfs(int node, vector<string> &a) {
    int n = a.size();
    vector<int> d(n, n + 1);
    vector<int> color(n, -1);
    d[node] = 0;
    color[node] = 0;

    queue<int> q;

    q.push(node);

    while(not q.empty()) {
        int node = q.front();
        q.pop();
        
        for(int i = 0; i < n; i += 1) {
            if(a[node][i] == '1') {
                if(d[i] >= n) {
                    d[i] = d[node] + 1;
                    color[i] = 1 - color[node];
                    q.push(i);
                }
                if(color[i] != 1 - color[node]) {
                    return vector<int> ();
                }
            } 
        }
    }

    return d;
}

int main() {
    int n; cin >> n;
    vector<string> mat(n);

    for(int i = 0; i < n; i += 1) {
        cin >> mat[i];
    }
    
    int ans = -1;
    for(int i = 0; i < n; i += 1) {
        auto d = bfs(i, mat);
        if(d.empty()) {
            cout << "-1\n";
            return 0;
        }
        ans = max(ans, *max_element(d.begin(), d.end()));
    }

    cout << ans + 1 << "\n";
}

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

int main()
{
  string a,b;
  cin >> a >> b;
  int n=0;
  int i=0;
  while(a[i]!=0)
  {
    if(a[i]!=b[i])
      n++;
    i++;
  }
  cout << n << endl;
}

Measured memory_bytes: 3852
n = int(input())
s = list(input())
mod = 10 ** 9 + 7

if s[0] != "B" or s[-1] != "B":
    print(0)
    exit()

d = {"B": "W", "W": "B"}


def flip(x):
    return d[x]


lr = [1]
for i in range(1, 2 * n):
    if s[i-1] == s[i]:
        lr.append(0)
        s[i] = flip(s[i])
    else:
        lr.append(1)

if sum(lr) != n:
    ans = 0

else:
    l_cnt = 0
    ans = 1
    for e in lr:
        if e:
            l_cnt += 1
        else:
            ans *= l_cnt
            ans %= mod
            l_cnt -= 1

    for i in range(1, n + 1):
        ans *= i
        ans %= mod

print(ans)


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

using namespace std;


int n, cnt[100002], m;

int main()
{
  cin >>n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
  }
  for (int i  = 1; i <= n; i++) {
    if (cnt[i] % 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    vec<ll> h(n);
    vec<bool> yama(n,true);
    rep(i,n) cin>>h[i];
    
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        if(h[a-1]<h[b-1]){
            yama[a-1]=false;
        }
        else if(h[a-1]>h[b-1]){
            yama[b-1]=false;
        }
        else{
            yama[b-1]=false;
            yama[a-1]=false;
        }
    }
    ll sum=0;
    rep(i,n) {
        if(yama[i]==true) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3988
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        Scanner in = new Scanner(System.in);
        String wet = in.next();
        String ans = "Yes";
        for (int i = 0; i <wet.length(); i++) {
            Character c = wet.charAt(i);
            if((i + 1) % 2 == 0) {
                if(c == 'R') {
                    ans = "No";
                    break;
                }
            } else {
                if(c == 'L') {
                    ans = "No";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <sstream>

using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)

//dp[i] = i+1回めに見たときの最小得票数
uint64_t dp[1000];
int N;
int T[1000];
int A[1000];

//uint64_t f(int i)
//{
//	if (i <= 0) {
//		return T[0] + A[0];
//	}
//	uint64_t last_bace = f(i - 1) / (T[i - 1] + A[i - 1]);
//	uint64_t last_T = last_bace * T[i - 1];
//	uint64_t last_A = last_bace * A[i - 1];
//
//	uint64_t new_T = (1 < T[i]) ? (last_T + (T[i] - last_T % T[i])) : (last_T);
//	uint64_t new_A = (new_T / T[i])*A[i];
//	if (last_A <= new_A) {
//	}
//	else {
//		new_A = (1 < A[i]) ? (last_A + (A[i] - last_A % A[i])) : (last_A);
//		new_T = (new_A / A[i])*T[i];
//	}
//	return new_T + new_A;
//}

int main()
{
	std::cin >> N;
	for (size_t i = 0; i < N; ++i)
	{
		std::cin >> T[i] >> A[i];
	}

	dp[0] = T[0] + A[0];
	for (size_t i = 1; i < N; ++i)
	{
		uint64_t last_bace = dp[i - 1] / (T[i - 1] + A[i - 1]);
		uint64_t last_T = last_bace * T[i - 1];
		uint64_t last_A = last_bace * A[i - 1];

		uint64_t new_T = (0 < last_T % T[i]) ? (last_T + (T[i] - last_T % T[i])) : (last_T);
		uint64_t new_A = (new_T / T[i])*A[i];
		if (last_A <= new_A) {
		}
		else {
			new_A = (0 < last_A % A[i]) ? (last_A + (A[i] - last_A % A[i])) : (last_A);
			new_T = (new_A / A[i])*T[i];
		}
		dp[i] = new_T + new_A;
	}

	std::cout << dp[(N - 1)] << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	unsigned long long ans=0;
	vector<pair<int, int>> blue(100), red(100);
	int N,i,j,a,b;
	cin >> N;
	REP(i, N) {
		cin >> a >> b;
		red[i] = make_pair(b, a);
	}
	REP(i, N) {
		cin >> a >> b;
		blue[i] = make_pair(a, b);
	}
	REP(i, N) {
		//cout << red[i].first << " " << red[i].second << endl;
	}
	sort(blue.begin(), blue.begin() + N);
	sort(red.begin(), red.begin() + N, greater<pair<int, int> >());
	REP(i, N) {
	//	cout << red[i].first<< " " << red[i].second<< endl;
	}
	REP(i, N) {
		REP(j, N) {
			if (red[j].first < blue[i].second && red[j].second < blue[i].first) {
				ans++;
				red[j].first = 201; red[j].second = 2 - 1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(prev: usize, used: usize, field: &Vec<Vec<i64>>, rseq: &Vec<usize>) -> i64 {
    let r = rseq.len();
    if used == (1 << r) - 1 {
        return 0;
    }
    let mut ret = 1e+15 as i64;
    for i in 0..r {
        let nused = used | (1 << i);
        if used == nused {
            continue;
        }
        let nret = field[rseq[prev]][rseq[i]] + dfs(i, nused, field, rseq);
        ret = std::cmp::min(ret, nret);
    }
    ret
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let r: usize = read();
    let mut rseq = vec![0 as usize; r];
    for i in 0..r {
        rseq[i] = read::<usize>() - 1;
    }
    let mut field = vec![vec![1e+15 as i64; n]; n];
    for i in 0..n {
        field[i][i] = 0;
    }
    for _ in 0..m {
        let f = read::<usize>() - 1;
        let t = read::<usize>() - 1;
        let c = read::<i64>();
        field[f][t] = c;
        field[t][f] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                field[i][j] = std::cmp::min(field[i][j], field[i][k] + field[k][j]);
            }
        }
    }
    let mut ans = 1e+15 as i64;
    for i in 0..r {
        ans = std::cmp::min(ans, dfs(i, 1 << i, &field, &rseq));
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  std::vector<ll> a(n);

  rep(i,n) cin >> a.at(i);

  ll sum = 0;

  sort(a.begin(),a.end());

  for(ll i = 1 ; i < n; i++) {
    ll current = (n - 1) - floor(i/2);

    sum += a.at(current);
  }

  cout << sum << endl;
}


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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l, r;
    l = stoi(s) / 100;
    r = stoi(s) % 100;
    if (1 <= l && l <= 12 && 1 <= r && r <= 12)
        cout << "AMBIGUOUS" << ln;
    else if (1 <= l && l <= 12)
        cout << "MMYY" << ln;
    else if (1 <= r && r <= 12)
        cout << "YYMM" << ln;
    else
        cout << "NA" << ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[]arr = new long [n];
        for(int i  = 0;i<n;i++)
        {
            arr[i] = sc.nextLong();
        }
        int[]dp = new int[n];
        dp[n-1] = 0;
        int max = 0;
        for(int i = n-2;i>=0;i--)
        {
            dp[i] = arr[i]>=arr[i+1] ? dp[i+1]+1 :0;
            max = Math.max(dp[i] , max);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 56464
import std.stdio, std.typecons;

alias Tuple!(double, double, string) Time;

void main() {
  Time[] times = [
    Time(70.0, 148.0, "E"),
    Time(55.0, 116.0, "D"),
    Time(50.0, 105.0, "C"),
    Time(43.0, 89.0, "B"),
    Time(40.0, 83.0, "A"),
    Time(37.5, 77.0, "AA"),
    Time(35.5, 71.0, "AAA")];
  for(double a, b; readf("%f %f\n", &a, &b);) {
    size_t n = times.length - 1;
    size_t ans = n;
    for(int i = 0; i <= n; i++) {
      if (!(times[i][0] > a && times[i][1] > b)) {ans = i - 1; break;}
    }
    writeln(ans == -1 ? "NA" : times[ans][2]);
  }
}

Measured memory_bytes: 1100
n,m = map(int,input().split())
ans = 'IMPOSSIBLE'
x = [[0] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    x[a].append(b)
    x[b].append(a)
for i in x[1]:
    for j in x[i]:
        if j==n:
            ans = 'POSSIBLE'
print(ans)

Measured memory_bytes: 88552
#include <iostream>
#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 <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int ans[15][15];
int n;
int i, j;

void solve(int x, int y, int k) {
    if(0 <= x && x < n && 0 <= y && y < n) {
        if(ans[x][y] == -1) {ans[x][y] = k; i = x; j = y; return;}
        else solve(x+1,y-1,k);
    }
    else if(x >= n) solve(0,y,k);
    else if(y >= n) solve(x,0,k);
    else if(y < 0) solve(x,n-1,k);
}

int main() {
    while(cin >> n) {
        memset(ans, -1, sizeof(ans));
        int mid = n / 2;
        i = mid + 1; j = mid;
        ans[i][j] = 1;

        rep(k,2,n * n + 1) solve(i+1, j+1, k);

        rep(i,0,n) {
            rep(j,0,n) {
                printf("%4d", ans[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1164
# coding: utf-8


def main():
    n = int(input())
    number_ = list(map(int, input().split(' ')))    

    max_number = max(number_)
    min_number = min(number_)
    min_sums = []
    for p in range(min_number, max_number + 1):
        sum_ = 0
        for x in number_:
            sum_ += (x - p) ** 2
        min_sums.append(sum_)

    print(min(min_sums))

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
string T; bool N = false, E = false, S = false, W = false;
int main() {
	cin >> T;
	for (int i = 0; i < T.size(); i++) {
		if (T[i] == 'N')N = true; if (T[i] == 'E')E = true;
		if (T[i] == 'S')S = true; if (T[i] == 'W')W = true;
	}
	if (N != S || E != W)cout << "No" << endl;
	else { cout << "Yes" << endl; }
	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,d,x,a;cin>>n>>d>>x;
  int ans=x;
  for (int i = 0; i < n; ++i){
  	cin>>a;
    ans+=(d-1)/a+1;
  }
  cout<<ans<<endl;
}


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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowerCnt(const vector<int>& cnrvnSeq)
{
  int nMaxLowerCnt = 0;
  int nBgn = 0;

  while (nBgn < cnrvnSeq.size() - 1)
  {
    int nLowerCnt = 0;
    int nFoward;

    for (nFoward = nBgn; nFoward < cnrvnSeq.size() - 1; nFoward++)
       if (cnrvnSeq[nFoward] >= cnrvnSeq[nFoward + 1])
          nLowerCnt++;
       else
          break;

    nMaxLowerCnt = max(nMaxLowerCnt, nLowerCnt);
    nBgn = nFoward + 1;
  }
  return nMaxLowerCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowerCnt(vnSeq) << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    string s;cin>>s;
    rep(i,4)cout<<s[i];
    cout<<' ';
    for(int i=4;i<12;i++) cout<<s[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
struct edge { int to, cost; };
typedef pair<int, int>P;


int main(){
	int N;
  	cin >>N;
  	int a[N];
  	rep(i,N){
    	cin >>a[i];
    }
  	int memo=1,ans=-1;
  	rep(i,N){
    	if(memo==a[i]){
          if(ans==-1){ans++;}
          memo++;ans++;}
    }
  	if(ans==-1){cout<<-1<<endl;}
  	else{cout<<N-ans<<endl;}
  
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    pair<pair<string, int>, int> store[100];
    string name;
    int score;

    int a;
    cin >> a;
    for (int i = 0; i < a; i++)
    {
        cin >> name >> score;
        store[i] = make_pair(make_pair(name, -score), i);
    }
    sort(store, store + a);

    for (int i = 0; i < a; i++)
    {
        cout << store[i].second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x=int(input())
beki=[0,1]
for i in range(2,1001):
    tmp=i
    while(1):
        tmp*=i
        if tmp<=1000:
            beki.append(tmp)
        else:
            break
beki.sort()
for i in range(len(beki)):
    if beki[i]<=x:
        ans=beki[i]
print(ans)

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

int main() {
  int h,w;
  cin >> h >> w;

  vector<vector<char>> board(h, vector<char> (w));
  vector<vector<int>> visited(h, vector<int> (w, 0));
  rep(i,h) rep(j,w) cin >> board[i][j];

  bool ok = true;
  int curx = 0, cury = 0;
  while (true) {
    visited[curx][cury] = 1;
    if(curx == h - 1 && cury == w - 1) break;
    if(curx + 1 < h && board[curx + 1][cury] == '#') curx++;
    else if(cury + 1 < w && board[curx][cury + 1] == '#') cury++;
    else {
      ok = false;
      break;
    }
  }

  rep(i,h) rep(j,w) {
    if(board[i][j] == '#' && visited[i][j] == 0) ok = false;
  }
  if(ok) cout << "Possible" << '\n';
  else cout << "Impossible" << '\n';
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
  int n,cnt=0;
  scanf("%d",&n);
  for(int i=1;i<n;i++){
    if(n-i==i){

    }else{
      cnt++;
    }
    if(i>=n-i-1){
      break;
    }
  }
  printf("%d",cnt);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		long ww = sc.nextLong();
		long hh = sc.nextLong();
		long xx = sc.nextLong();
		long yy = sc.nextLong();
		
		System.out.print(ww*hh/2.0);
		System.out.print(" "+(xx*2==ww && yy*2==hh ? 1:0));
		
	}
}

Measured memory_bytes: 23636
import math
input()
a=[int(item) for item in input().split()]
b=[int(item) for item in input().split()]
#マンハッタン距離
manhattan=sum([abs(x-y) for x,y in zip(a,b)])
#ユークリッド距離
eucrid=sum([(x-y)**2 for x,y in zip(a,b)])**(1/2)
#3のときの距離
sono3=sum([abs(x-y)**3 for x,y in zip(a,b)])**(1/3)
#チェビシェフ距離
chebyshev=max([abs(x-y) for x,y in zip(a,b)])
print("{}\n{}\n{}\n{}".format(manhattan,eucrid,sono3,chebyshev))


Measured memory_bytes: 5708
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
vector<long long int>v[100007];
long long int dp[100007];
bool visited[100007];
void visit(long long int i)
{
    //cout<<i<<endl;
    visited[i]=1;
    dp[i]=0;
    for(auto x:v[i])
    {
        if(visited[x]==false)
        {
            visit(x);
        }
        dp[i]=max(dp[i],1+dp[x]);
    }
}
void solve()
{
    long long int n,m;cin>>n>>m;
    while(m--)
    {
        long long int a,b;cin>>a>>b;
        v[a].push_back(b);
    }
    for(long long int i=0;i<=n;i++)
    visit(i);
    long long int ans=INT_MIN;
    for(long long int i=0;i<=n;i++)
    {
        //cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 12572
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iil pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define x0 zxcxzcsacasd
#define x1 ghfghujfgfg
#define y0 olkjhdnncvcv
#define y1 bhvgrewm345345435
#define debug(x) std::cerr<<#x<<": "<<(x)<<'\n'
#define all(x) x.begin(), x.end()
using namespace std;
void test_case(){
	int n;
	cin>>n;
	ll amid = 0;
	for(ll a = 1; a <= n; a++){
		for(ll b = 1; b <= n; b++){
			ll c = n - a * b;
			if(c>0)amid++;
			else break;
		}
	}
	cout<<amid<<endl;
}
int main(){
	int t = 1;
	// scanf("%d", &t);
	while(t--)test_case();
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << (x) << "\n"
constexpr int mod = 1000000007;
using namespace std;
int n, k, a[234567];
int f(int p) {
	int cnt = 0;
	for1(i, n)cnt += (a[i] - 1) / p;
	return cnt;
}
signed main() {
	cin >> n >> k;
	for1(i, n)cin >> a[i];
	int l = 0, r = mod;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		if (f(mid) <= k)r = mid;
		else l = mid;
	}
	puts(r);
}

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

int main(){
  int n,q;
  cin>>n>>q;
  stack<int>s[n];
  while(q--){
    int a,b,c;
    cin>>a>>b;
    if(!a){
      cin>>c;
      s[b].push(c);
    }
    else if(a==1){
      if(!s[b].empty())cout<<s[b].top()<<endl;
    }
    else if(!s[b].empty())s[b].pop();
  }
}


Measured memory_bytes: 4356
#include <iostream>
#include <cmath>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n;
    std::cin >> n;
    long long votesT, votesA;
    std::cin >> votesT >> votesA;
    for (int i = 1; i < n; ++i) {
        long long t, a;
        std::cin >> t >> a;
        double prevRatio = (double) votesT / (double) votesA;
        double curRatio = (double) t / (double) a;
        if (curRatio < prevRatio) {
            if (votesT % t != 0) {
                votesT = (votesT / t + 1) * t;
            }
            votesA += votesT / t * a - votesA;
        } else {
            if (votesA % a != 0) {
                votesA = (votesA / a + 1) * a;
            }
            votesT += votesA / a * t - votesT;
        }
    }
    std::cout << votesT + votesA << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector< int > adj[100000];

void dfs(int node, bool vis[],int len[])
{
    vis[node]=true;
    for(int i=0;i<adj[node].size();i++)
    {
        if(!vis[adj[node][i]])
        {
            dfs(adj[node][i],vis,len);
        }
        len[node]=max(len[node],1+len[adj[node][i]]);
    }
}

int main()
{
    int n,e,i,u,v,ans=0;
    cin>>n>>e;
    for(i=0;i<e;i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
    }
    bool vis[n+1];
    memset(vis,false,sizeof vis);
    int len[n+1];
    memset(len,0,sizeof len);
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(i,vis,len);
    }
    for(i=1;i<=n;i++)
    {
        ans=max(ans,len[i]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 8960
from functools import reduce

MOD = 10 ** 9 + 7

n, k = map(int, input().split())
la = list(map(int, input().split()))
la.sort()

f = 1
lf = [1]
for i in range(1, n + 1):
    f = (f * i) % MOD
    lf.append(f)

ii = 1
lii = [0, 1]
fi = 1
lfi = [1, 1]
for i in range(2, n + 1):
    ii = (-lii[MOD % i] * (MOD // i)) % MOD
    fi = (fi * ii) % MOD
    lii.append(ii)
    lfi.append(fi)


def combi(n, k):
    if k < 0:
        return 0
    elif k > n:
        return 0
    else:
        return (lf[n] * lfi[k] * lfi[n - k]) % MOD


def addmod(a, b):
    return (a + b) % MOD


def sumfmax():
    return reduce(addmod, (a * combi(i, k - 1) for i, a in enumerate(la)))


def sumfmin():
    return reduce(addmod, (a * combi(n - i - 1, k - 1) for i, a in enumerate(la)))


answer = (sumfmax() - sumfmin()) % MOD
print(answer)


Measured memory_bytes: 26164
#include<iostream>
#include<algorithm>

using namespace std;

int A, B, K;

int main() {
	cin >> A >> B >> K;

	int now = 0;
	for (int i = min(A, B); i > 0; i--) {
		if (A % i == 0 && B % i == 0)now++;
		if (now == K) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define scf(n) scanf("%lf",&n)

int main()
{
    double x1,y1,x2,y2,r,t,g,h,m1,m2,k,x,y,c1,c2;
    int q;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    scanf("%d",&q);
    while(q--)
    {
        scanf("%lf %lf",&r,&t);
        if(y1==y2)
        {
            x=r;
            y=y1;
        }
        else if(x1==x2)
        {
            x=x1;
            y=t;
        }
        else{
        m1=(y2-y1)/(x2-x1);
        m2=-1/m1;
        c1=-m1*x1+y1;
        c2=-m2*r+t;
        x=(c1-c2)/(m2-m1);
        y=(m2*c1-m1*c2)/(m2-m1);

        //c=(y1-m*x1);
        //k=-(m*t+r);

       // y=(-c-m*k)/(1+m*m);
        //x=(y+c)/m;
        //y=(-m1*y2-m1*m2*x2+m2*y1-m2*m1*x1)/(m1-m2);
       // x=(m2*x2-y2-m1*x1+y1)/(m1-m2);
        }
      //  g=2.0*x-r;
       // h=2.0*y-t;
        printf("%.10lf %.10lf\n",x,y);
    }
}


Measured memory_bytes: 2748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N+1];
		A[0] = 0;
		for(int i = 1; i <= N; i++) {
			A[i] = Integer.parseInt(sc.next());
		}

		long result = 0;
		long temp = 0;
		for(int i = 1; i < A.length; i++) {
			if(A[i] == 0) {
				result += temp / 2;
				temp = 0;
			}else {
				temp += A[i];
			}
		}
		result += temp / 2;

		System.out.println(result);
	}

}


Measured memory_bytes: 24500
import std.stdio;
import std.format;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int popcnt(int x) {
    int Ret = 0;
    foreach (i; 0 .. 16) {
        if (x & (1 << i)) Ret++;
    }
    return Ret;
}

int popCount[1 << 16];
static this() {
    foreach (i; 0 .. (1 << 16)) {
        popCount[i] = popcnt(i);
    }
}

void main() {
    int N, C;
    int[] A, B;
    bool input() {
        scanf("%d %d\n", &N, &C);
        if (N == 0 && C == 0) return false;
        A = new int[N];
        B = new int[C];
        foreach (i; 0 .. N) {
            int bit;
            foreach (j, x; readln.chomp.split(" ").map!(to!int).array) {
                bit |= (x << j);
            }
            A[i] = bit;
        }
        foreach (i; 0 .. C) {
            int bit;
            foreach (j, x; readln.chomp.split(" ").map!(to!int).array) {
                bit |= (x << j);
            }
            B[i] = bit;
        }
        return true;
    }
    void solve() {
        static int dp[2][1<<16];
        memset(dp.ptr, -1, dp.sizeof);
        dp[0][0] = 0;
        foreach (i; 0 .. N) {
            memset(dp[(i + 1) & 1].ptr, -1, dp[(i + 1) & 1].sizeof);
            foreach (j; 0 .. (1 << 16)) {
                if (dp[i & 1][j] == -1) continue;
                int bit = j | A[i];
                foreach (b; B) {
                    dp[(i + 1) & 1][bit & ~b] = max(dp[(i + 1) & 1][bit & ~b], dp[i & 1][j] + popCount[bit & b]);
                }
            }
        }
        writeln(dp[N & 1].reduce!max);
    }
    while (input) solve;
}

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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  int tmp;
  tmp=X;
  X=Y;
  Y=tmp;
  tmp=X;
  X=Z;
  Z=tmp;
  cout << X << " " << Y << " " << Z << endl;
  return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(x2-x1)
y4 = y3-(y2-y1)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String word;
        try {
            word = reader.readLine();
            int num = Integer.parseInt(word);
            int ans = num * num * num;
            System.out.println(ans);
        } catch (IOException e) {
            // TODO ????????????????????? catch ????????????
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // TODO ????????????????????? catch ????????????
                e.printStackTrace();
            }
        }
         
         
    }
}

Measured memory_bytes: 24140
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

using P = pair<ll, ll>;
int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].second >> A[i].first;
    }
    sort(A.begin(), A.end());

    ll now = 0;
    for (int i = 0; i < N; i++) {
        if (now + A[i].second > A[i].first) {
            cout << "No\n";
            return 0;
        } else {
            now += A[i].second;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i)-1 = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

int main()
{
    ll n;
    cin >> n;
    map<ll,ll> mp;
    ll ans = 0;

    REP(i,n){
        ll a;
        cin >> a;
        mp[a-1]++;
        mp[a]++;
        mp[a+1]++;
    }

    for(auto p : mp){
        ans = max(ans, p.second);
    }
    cout << ans << endl;
}


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

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

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	ll n, t, sum = 0,r = 0,q;
	cin >> n >> t;
	rep(i,n){
		cin >> q;
		sum += t;
			sum -= max((ll)0,  r- q);
		r = q + t;
	}
	cout << sum << endl;
	return 0;
}


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

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

using namespace std;

typedef int Weight;
Weight INF = 1000000000;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void dijkstra(Graph &g, Array &d, int s) {
  d.assign(g.size(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while (!que.empty()) {
    Weight dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}

int main() {
  int di[]={1,0,-1,0};
  int dj[]={0,1,0,-1};
  int r,c,m;
  cin>>r>>c>>m;
  vector<string> t(r);
  REP(i,r)cin>>t[i];
  int n=r*c;
  vector<vector<int>> dir(n,vector<int>(n));
  Graph g(n);
  REP(i,r)REP(j,c){
    if(t[i][j] != '.') continue;
    int p=i*c+j;
    REP(k,4){
      int ni=i+di[k];
      int nj=j+dj[k];
      if(ni<0||nj<0||ni>=r||nj>=c) continue;
      int np = ni*c+nj;
      if(t[ni][nj] == '.')
        g[p].push_back((Edge){p, np, 1});
    }
  }
  Matrix dist(n, Array(n));
  REP(i,n) dijkstra(g, dist[i], i);
  REP(i,r)REP(j,c){
    int p=i*c+j;
    REP(k,4){
      int ni=i+di[k];
      int nj=j+dj[k];
      if(ni<0||nj<0||ni>=r||nj>=c) continue;
      int np = ni*c+nj;
      REP(l,n){
        if(dist[p][l] > dist[np][l])
          dir[p][l] = k;
      }
    }
  }
  vector<int> con(n), clg(n), coff(n);
  REP(i,n) cin>>clg[i];
  REP(i,n) cin>>con[i];
  REP(i,n) cin>>coff[i];
  vector<int> q;
  REP(i,m){
    int ri,rj;
    cin>>ri>>rj;
    q.push_back(ri*c+rj);
  }
  vector<int> rm;
  REP(i,m-1){
    int fr = q[i];
    int to = q[i+1];
    for (int j = fr; j != to;) {
      rm.push_back(j);
      int k = dir[j][to];
      j += di[k]*c + dj[k];
    }
  }
  rm.push_back(q.back());
  vector<int> old(n,-1);
  int64_t sum = 0;
  REP(i,rm.size()) {
    int ri=rm[i];
    if (old[ri] == -1)
      sum += con[ri] + coff[ri];
    else {
      int callon = (i-old[ri]) * clg[ri];
      int coffon = con[ri] + coff[ri];
      sum += min(callon, coffon);
    }
    old[ri] = i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 60264
#include <stdio.h>

int main(void){
  int a[100];
  int c;

  c=getchar();
  while(c != '\n'){
    if('a' <= c && c <= 'z'){
      c -= 32;
    }
    printf("%c",c);
    c=getchar();
  }

  printf("\n");

  return 0;

}

Measured memory_bytes: 524
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
x, y = [int(x) for x in input().split()]
if x%y == 0:
	print(-1)
else:
	temp = x
	while(temp%y == 0):
		temp += x
	print(temp)

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

int main() {
    int x, y;
    while(cin >> x){
        cin >> y;
        x = abs(x);
        y = abs(y);
        if(x == 0 && y == 0){
            cout << 0 << endl;
        }
        else if(x <= 1 && y <= 1){
            cout << 1 << endl;
        }
        else if(x == 0 || y == 0){
            cout << x+x%2 + y+y%2 << endl;
        }
        else{
            cout << x/2*2+y/2*2 + (x%2|y%2) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;


int main() {

	ll n, a = 2, b = 1, ans = 3;

	cin >> n;
	if (n == 1)cout << b << endl;
	else if (n == 2)cout << ans << endl;
	else {
		rep(i, 0, n - 2) {
			a = b;
			b = ans;
			ans = a + b;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    double x1,x2,y1,y2,x,y;
    
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    x = x2 - x1;
    y = y2 - y1;
    
    printf("%lf\n" , sqrt(x*x+y*y));
    
    return 0;
}


Measured memory_bytes: 2140
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,a,ot=0,tw=0,fo=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%4==0) fo++;
    else if(a%2==0) tw++;
    else ot++;
  }
  if(tw!=0) ot++;
  if(ot-1<=fo) cout <<"Yes\n";
  else cout <<"No\n";
}


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

int main(){
  
  int i,j,k,n,y,m,d,total_days;

  cin >> n;
  while(n>0){
    n--;
    cin >> y >> m >> d;
    total_days=0;
    for(i = y+1; i < 1000; i++){
      if(i%3==0){
	total_days+=200;
      }else{
	total_days+=195;
      }
    }

    for(i = m+1; i <= 10; i++){
      if(y%3==0){
	total_days+=20;
      }else{
      if(i%2==0){
	total_days+=19;
      }else{
	total_days+=20;
      }
      }
    }

    if(y%3==0 || m%2!=0){
      total_days+=20-d+1;
    }else{
      total_days+=19-d+1;
    }


    cout << total_days << endl;

  }
  return 0;
}

Measured memory_bytes: 1164