akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using lint = long long;

lint func(lint& n) {
    lint total{}; lint fives{ 5 };
    while (fives > n) {
        total += n / fives;
        fives *= 5;
    }
    return total;
}

lint func2(lint& n, lint& fives) {
    lint total{}; lint seconds{ 2 };
    while (seconds > fives || seconds > n) {
        total += n / seconds;
        seconds *= 2;
    }
    return total;
}

int main() {
    lint N; std::cin >> N;
    if (N % 2 == 1) { std::cout << 0 << std::endl; return 0; }
    lint ans{};
    N /= 2;
    while (N > 0) {
        ans += N / 5;
        N /= 5;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3604
import java.io.File

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val s = readLn()
    println(if (s[2] == s[3] && s[4] == s[5]) "Yes" else "No")
}


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

int main(){
	
	int f[5];
	
	for(int i=0;i<5;i++)
		cin>>f[i];
	
	sort(f,f+5,greater<int>());
	
	cout<<f[0];
	for(int i=1;i<5;i++)
		cout<<" "<<f[i];
	cout<<endl;
}

Measured memory_bytes: 1176
N = int(input())
A = list(map(int,input().split()))
r = [1]
for i in range(N):
    r.append(r[i]*2)

if N == 0 and A[0] != 1:
    print(-1)
    exit()

if A[N] == 0:
    print(-1)
    exit()


p = 0
for i in range(N):
    if A[i] != 0:
        p += A[i]
    p = p * 2 
    r[i+1] -= p
    if r[i] < A[i]:
        print(-1)
        exit()
    if i == N-1 and r[i+1] < A[i+1]:
        print(-1)
        exit()


for i in range(N):
    r[i] -= A[i]


q = A[N]
ans = q

for i in range(N):
    q = min(q,r[N-1-i]) + A[N-1-i]
    ans += q
print(ans)


Measured memory_bytes: 670972
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int d, t, s; cin >> d >> t >> s;
    cout << ((d <= t*s)?"Yes":"No") << endl;
}

Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        n: usize,
        x: [usize; n],
    }
    let p: usize = (x.iter().sum::<usize>() + (n / 2)) / n;
    let ans: usize = x.iter().map(|i| (i - p).pow(2)).sum();
    println!("{}", ans);
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    string s;
    cin >> s;

    int n = s.size();

    vector<int> a(n+1);

    loop(i, n){
        if(s[i] == '<'){
            a[i+1] = max(a[i]+1, a[i+1]);
        }
    }

    for(int i = n-1;i >= 0;i--){
        if(s[i] == '>'){
            a[i] = max(a[i+1]+1, a[i]);
        }
    }

    ll ans = 0;
    loop(i, n+1){
        ans += a[i];
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2820
#include<iostream>
#include<algorithm>
#include<set>


using namespace std;


int main(){

    int a[3];

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

    sort(a, a + 3);
    
    int d1 = a[1]-a[0], d2;
    int ans = 0;

    if(d1%2 != 0){
         a[0]++; a[2]++;
         ans += 1;
         d1--;
     }
     
    d2 = a[2]-a[1];
    ans += (d1/2 + d2);
    
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
///////////////////////////////////////////////////////////
int n;
vector<int> v;

int main() {
  cin >> n;
  rep(i, 0, n) {
    int q, p;
    cin >> q;
    if (q != 2) {
      cin >> p;
    }
    if (q == 0) v.push_back(p);
    if (q == 1) cout << v[p] << '\n';
    if (q == 2) v.pop_back();
  }
}


Measured memory_bytes: 3924
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    cout << "square1001" << endl;
    return 0;
}



Measured memory_bytes: 2924
#include <iostream>
using namespace std;
int main(){
  int a, b, req;
  char op;
  while(op != '?'){
    cin >> a >> op >> b;
    if(op == '?'){
      break;
    }
    
    if(op == '+'){
      req = a + b;
    } else if(op == '-'){
      req = a - b;
    } else if(op == '*'){
      req = a * b;
    } else if(op == '/'){
      req = a / b;
    }
    cout << req << endl;
  }

}


Measured memory_bytes: 3080
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			char trump = sc.next().charAt(0);
			if (trump == '#')
				break;
			String[][] cards = new String[4][13];
			for (int i = 0; i < 4; i++)
				for (int j = 0; j < 13; j++)
					cards[i][j] = sc.next();
			int ns = -6;
			int ew = -6;
			int leader = 0;
			for (int turn = 0; turn < 13; turn++) {
				char suit = cards[leader][turn].charAt(1);
				int winner = 0;
				for (int i = 1; i < 4; i++) {
					char wsuit = cards[winner][turn].charAt(1);
					char isuit = cards[i][turn].charAt(1);
					if (wsuit != isuit) {
						if (isuit == trump || (isuit == suit && wsuit != trump))
							winner = i;
					} else {
						int wnum = getInt(cards[winner][turn].charAt(0));
						int inum = getInt(cards[i][turn].charAt(0));
						if (wnum < inum)
							winner = i;
					}
				}
				leader = winner;
				if (leader % 2 == 0)
					ns++;
				else
					ew++;
			}
			if (ns > ew)
				System.out.println("NS " + ns);
			else
				System.out.println("EW " + ew);
		}
		sc.close();
	}

	static int getInt(char c) {
		if (c == 'A')
			return 14;
		if (c == 'K')
			return 13;
		if (c == 'Q')
			return 12;
		if (c == 'J')
			return 11;
		if (c == 'T')
			return 10;
		return c - '0';
	}
}

Measured memory_bytes: 24788
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[15],t[15];
  char cmpt[15];
  int lens,lent;
  scanf("%s", s);
  scanf("%s", t);
  lens = strlen(s);
  lent = strlen(t);
  strncpy(cmpt,t,lent-1);
  cmpt[lent-1] = '\0';
  if(strcmp(s,cmpt) == 0){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

template<typename T>
int bin(int lo, int hi, T f){
	while(lo+1 < hi){
		int mi = (lo+hi)/2;
		if(f(mi)) hi = mi;
		else lo = mi;
	}
	return hi;
}

struct MQ {
	int fr, to;
	vi p;
	deque<int> ko;
	MQ(vi _p){
		fr = 0;
		to = 0;
		p = _p;
	}
	void ri(){
		int x = p[to++];
		while(!ko.empty() && ko.back() > x)
			ko.pop_back();
		ko.push_back(x);
	}
	void le(){
		int x = p[fr++];
		if(ko[0] == x) ko.pop_front();
	}
	int get_min(){
		return ko[0];
	}
};
struct QM {
	int fr, to;
	vi p;
	deque<int> ko;

	QM(vi _p){
		fr = sz(_p);
		to = sz(_p);
		p = _p;
	}
	void ri(){
		int x = p[--to];
		if(ko[0] == x) ko.pop_front();
	}
	void le(){
		int x = p[--fr];
		while(!ko.empty() && ko.back() < x)
			ko.pop_back();
		ko.push_back(x);
	}
	int get_max(){
		return ko[0];
	}
};

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

	int n, k;
	cin >> n >> k;

	vi p(n);
	trav(x, p) cin >> x;

	vi fram(n), bak(n);
	rrep(i,0,n)
		fram[i] = i==n-1 ? i : p[i]>p[i+1] ? i : fram[i+1];
	rep(i,0,n)
		bak[i] = i==0 ? i : p[i]<p[i-1] ? i : bak[i-1];


	vi le(n-k+1), ri(n-k+1);

	MQ mq(p);
	rep(i,0,n-k+1){
		int m = fram[i];
		if(m >= i+k-1) continue;
		while(mq.to < i+k) mq.ri();
		while(mq.fr < m+1) mq.le();
		int val = mq.get_min();
		le[i] = bin(i-1, m, [&](int x){
			return p[x] > val;
		});
	}

	QM qm(p);
	rrep(i,0,n-k+1){
		int m = bak[i+k-1];
		if(m <= i) continue;
		while(qm.fr > i) qm.le();
		while(qm.to > m) qm.ri();
		int val = qm.get_max();
		ri[i] = bin(m, i+k, [&](int x){
			return p[x] > val;
		});
	}

	

	set<pii> res;
	rep(i,0,n-k+1){
		res.insert({le[i], ri[i]});
	}
	cout << sz(res) << endl;
}


Measured memory_bytes: 15088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, D, A; cin >> N >> D >> A;
    vector<pair<int, ll>> vec(N);
    rep(i, N) {
        ll X, H;
        cin >> X >> H;
        vec[i] = make_pair(X, H);
    }
    sort(ALL(vec));
    vector<int> vec_right(N);
    rep(i, N) {
        int ok = i, ng = N;
        while(abs(ok-ng) > 1) {
            int mid = (ok+ng)/2;
            if (vec[mid].first - vec[i].first <= 2*D) ok = mid;
            else ng = mid;
        }
        vec_right[i] = ng;
    }
    vector<ll> point_sum(N+1);
    ll ans = 0;
    rep(i, N) {
        if (point_sum[i] >= vec[i].second) {
            point_sum[i+1] += point_sum[i];
            continue;
        }
        ll tmp = (vec[i].second - point_sum[i])%A ? (vec[i].second - point_sum[i])/A + 1 : (vec[i].second - point_sum[i])/A;
        ans += tmp;
        point_sum[i] += tmp*A;
        point_sum[vec_right[i]] -=  tmp*A;
        point_sum[i+1] += point_sum[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 8784
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF = 1 << 30;
#define MOD 998244353
using namespace std;

int main() {
    int n, k, ans=0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x >= abs(k - x))ans += abs(k - x);
        else ans += x;
    }
    cout << ans*2 << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0, cnt = 0;
  for(int i=0; i<n; ++i){
    if(s[i] == 'T'){
      if(cnt) --cnt;
      else ans += 2;
    }else{
      ++cnt;
    }
  }
  cout << ans << endl;
}

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

    int n,W;
    int w[110],v[110];
    ll dp[110][100010];

int main() {
    

    cin>>n>>W;
    rep(i,n) {
        cin>>w[i]>>v[i];
      }

    dp[n-1][0]=0;

    for(int i=n-1;i>=0;i--) {
        for(int j=0;j<=W;j++) {
            if(j<w[i]) {
                dp[i][j]=dp[i+1][j];
            }
            else {
                dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[0][W]<<endl;

 return 0;
}

Measured memory_bytes: 80256
#include<stdio.h>
#include<string.h>
int main(){
  char s[10];
  scanf("%s",s);
  if(strcmp(s,"Sunny")==0)
    printf("Cloudy\n");
  else if(strcmp(s,"Cloudy")==0)
    printf("Rainy\n");
  else
    printf("Sunny\n");
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int num[3],max[3] = {0,0,0},maxj;
	scanf("%d %d %d",&num[0],&num[1],&num[2]);
	for(int i = 0;i < 3; ++i){
      maxj = 0;
		for (int j = 0;j < 3; ++j)
		{
			if(max[i] < num[j]){
              max[i] = num[j];
              maxj = j;
            }
		}
      num[maxj] = 0;
	}
	printf("%d\n",max[0] * 10 + max[1] + max[2]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <cmath>
#include <string>
#include <float.h>
using namespace std;

int main()
{
	int a;
	int b;
	cin>>a;
	cin>>b;
	if((a+b)==15){
	
		cout<<"+";
	}else if((a*b)==15){
		cout<<"*";
	}else{
		cout<<"x";
	}


}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL fact[100005];
const LL MOD = 1000000007;

int main()
{
	fact[0] = 1;
	for (int i = 1; i <= 100000; i++) {
		fact[i] = i * fact[i - 1];
		fact[i] %= MOD;
	}

	int n, m;
	scanf("%d %d", &n, &m);
	if (n < m) swap(n, m);

	if (n > m + 1) {
		printf("0\n");
		return 0;
	}

	if (n == m) {
		LL ans = 1;
		ans = (fact[n] * fact[m]) % MOD;
		ans = (ans * 2) % MOD;
		printf("%lld\n", ans);
	}
	else {
		LL ans = 1;
		ans = (fact[m] * fact[n]) % MOD;
		printf("%lld\n", ans);
	}
	return 0;
}


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

int main()
{
	int b1, b2, b3;

	cin >> b1 >> b2 >> b3;

	if (b1 * b2 * (1 - b3) || (1 - b1) * (1 - b2) * b3)
		cout << "Open" << endl;
	else
		cout << "Close" << endl;

	return 0;
}


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

signed main(){
    int N,Y;
    cin >>N>>Y;
    int x,y,z;
    x=y=z=-1;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            int k=N-i-j;
            if(k>=0 && 10000*i+5000*j+k*1000==Y){
                x=i;
                y=j;
                z=k;
            }
        }
    }
    cout <<x<<" "<<y<<" "<<z <<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvii vector<vector<ii>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b

using namespace std;

void print();
template <typename T, typename... Args>
void print(T x, Args... args);

void solve() {
    string s;
    cin >> s;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')print(3);
    else if(s[0] == 'R' && s[1] == 'R')print(2);
    else if(s[1] == 'R' && s[2] == 'R')print(2);
    else if(s == "SSS")print(0);
    else print(1);
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

void print() { cout << "\n"; }
template <typename T, typename... Args>
void print(T x, Args... args) {
    if(sizeof...(args)){
        cout << x << ' ';
        print(args...);
    }else{
        cout << x << '\n';
    }
}

Measured memory_bytes: 3648
#include<cstdio>
//#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
map<string, int> dp;
int d[] = {1, -1, 4, -4};
void bfs()
{
    dp["01234567"] = 0;
    queue<string> que;
    que.push("01234567");
    while(que.size()){
        string now = que.front();  //这里的string用法和python太像了~~~
        que.pop();
        int p;
        for(int i = 0; i < 8; i++){
            if(now[i] == '0'){
                p = i;
                break;
            }
        }
        for(int i = 0; i < 4; i++){
            int np = p + d[i];
            if(np >= 0 && np < 8 && !(p == 3 && i == 0) && !(p == 4 && i == 1)){
                string next = now;
                swap(next[np], next[p]);
                if(dp.find(next) == dp.end()){
                    dp[next] = dp[now] + 1;
                    que.push(next);
                }
            }
        }
    }
}
int main()
{
    bfs();
    int _;
    while(scanf("%d", &_) == 1){
        string s;
        s = '0' + _;
        for(int i = 0; i < 7; i++){
            scanf("%d", &_);
            s += '0' + _;
        }
        printf("%d\n", dp[s]);
    }
    return 0;
}




Measured memory_bytes: 5136
#include <vector>
using namespace std;

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

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

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

#include <iostream>
#include <set>
#include <utility>

int main()
{
    int N;
    cin>>N;
    vector<int> x(N), y(N);
    for (int i=0; i<N; i++)
    {
        cin>>x[i]>>y[i];
        x[i]--;
        y[i]--;
    }

    vector<int> I(N);
    for (int i=0; i<N; i++)
        I[x[i]] = i;

    UnionFind UF(N);
    set<pair<int, int>> S;
    for (int i=N-1; i>=0; i--)
    {
        pair<int, int> m = make_pair(y[I[i]], I[i]);
        for (auto it=S.lower_bound(m); it!=S.end();)
        {
            m = *it;
            UF.unite(I[i], it->second);
            it = S.erase(it);
        }
        S.insert(m);
    }

    for (int i=0; i<N; i++)
        cout<<UF.size(i)<<endl;
}


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

void egcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return;
    }
    egcd(b, a%b, y, x);
    y -= a / b * x;
}

int main() {
    int a, b, x, y;
    cin >> a >> b;
    egcd(a, b, x, y);
    cout << x << " " << y << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{ 
    ll n,i,j;
    cin >> n;
    ll a[n][3],c[n][3];
    for(i=0;i<n;i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
    c[0][0]=a[0][0]; c[0][1]=a[0][1]; c[0][2]=a[0][2];
    for(i=1;i<n;i++) c[i][0]=c[i][1]=c[i][2]=0;
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(!j) c[i][j]=max(c[i][j],a[i][j]+max(c[i-1][j+1],c[i-1][j+2]));
            else if(j==2) c[i][j]=max(c[i][j],a[i][j]+max(c[i-1][j-1],c[i-1][j-2]));
            else c[i][j]=max(c[i][j],a[i][j]+max(c[i-1][j-1],c[i-1][j+1]));
        }
    }
    cout << max(c[n-1][0],max(c[n-1][1],c[n-1][2])) << "\n";
}

 
int main()
{
    opt;
    solve();
    return 0;
}       

Measured memory_bytes: 4992
package main

import "fmt"

type Dice struct {
	T, S, E, W, N, B int
}

func (p *Dice) roll(direction rune) {

	if direction == 'S' {
		p.S, p.B, p.N, p.T = p.T, p.S, p.B, p.N
	} else if direction == 'N' {
		p.N, p.B, p.S, p.T = p.T, p.N, p.B, p.S
	} else if direction == 'W' {
		p.W, p.B, p.E, p.T = p.T, p.W, p.B, p.E
	} else if direction == 'E' {
		p.E, p.B, p.W, p.T = p.T, p.E, p.B, p.W
	}

}

func main() {

	var t, s, e, w, n, b int
	fmt.Scanln(&t, &s, &e, &w, &n, &b)

	dice1 := Dice{t, s, e, w, n, b}

	var directions string
	fmt.Scanln(&directions)
	for _, direction := range directions {
		dice1.roll(direction)
	}

	fmt.Printf("%d\n", dice1.T)

}



Measured memory_bytes: 1152
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int n;
	boolean[] color;
	int INF = 1 << 24;
	List<List<Edge>> adj = new ArrayList<List<Edge>>();

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			adj.add(new ArrayList<Edge>());
		}
		for (int i = 0; i < n; i++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			for (int j = 0; j < k; j++) {
				int v = scanner.nextInt();
				int c = scanner.nextInt();
				adj.get(u).add(new Edge(v,c));
			}
		}
		dijkstra();
	}

	private void dijkstra() {
		PriorityQueue<Edge> pq = new PriorityQueue<Main.Edge>();
		color = new boolean[n];
		int[] d = new int[n];
		Arrays.fill(d, INF);
		d[0] = 0;
		pq.add(new Edge(0, 0));
		while (!pq.isEmpty()) {
			Edge f = pq.poll();
			int u = f.second;
			color[u] = true;
			if (d[u] < f.first)
				continue;
			for (int j = 0; j < adj.get(u).size(); j++) {
				int v = adj.get(u).get(j).first;
				if (color[v])
					continue;
				if (d[v] > d[u] + adj.get(u).get(j).second) {
					d[v] = d[u] + adj.get(u).get(j).second;
					pq.add(new Edge(d[v], v));
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.printf("%d %d\n", i, d[i] == INF ? -1 : d[i]);
		}

	}
	class Edge implements Comparable<Edge> {
		int first;
		int second;

		public Edge(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

		@Override
		public int compareTo(Edge o) {
			return this.first - o.first;
		}

	}
}

Measured memory_bytes: 307436
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

namespace solver {

string s;
typedef string::const_iterator Iter;
Iter it, end;

typedef pair<set<int>, char> pic;

void consume(char e) {
  assert(e == *it);
  it ++;
}

bool isconsume(char e) {
  if(e == *it) {
    consume(e);
    return true;
  }
  return false;
}

int number() {
  int ret = 0;
  if(!isdigit(*it)) return -1;
  while(isdigit(*it)) {
    ret *= 10;
    ret += *it - '0';
    it ++;
  }
  return ret;
}

set<int> calc(set<int> const& n1, set<int> const& n2, char o) {
  set<int> ret;
  for(auto&& e: n1) for(auto&& u: n2) {
    if(o == '+') ret.insert(e + u);
    if(o == '-') ret.insert(e - u);
    if(o == '*') ret.insert(e * u);
    if(o == '/' && u != 0) ret.insert(e / u);
  }
  return ret;
}

void push_trans(queue<vector<pic>>& q, set<vector<pic>>& used, vector<pic> const& p, int i, set<int> const& n1, set<int> const& n2, char o, char nexto) {
  set<int> r = calc(n1, n2, o);
  auto nextp = p;
  nextp.erase(nextp.begin() + i);
  nextp.erase(nextp.begin() + i);
  nextp.insert(nextp.begin() + i, {r, nexto});
  if(used.count(nextp)) return;
  used.insert(nextp);
  q.push(nextp);
}

set<int> expr() {
  vector<pic> v;
  while(1) {
    int num = number();
    set<int> nums;
    if(num == -1 && isconsume('(')) {
      nums = expr();
      consume(')');
    }
    else if(num == -1) {
      assert(0);
    }
    else {
      nums.insert(num);
    }

    if(isconsume('+')) v.push_back({nums, '+'});
    else if(isconsume('-')) v.push_back({nums, '-'});
    else if(isconsume('*')) v.push_back({nums, '*'});
    else if(isconsume('/')) v.push_back({nums, '/'});
    else {
      v.push_back({nums, '0'});
      break;
    }
  }

  queue<vector<pic>> q; q.push(v);
  set<vector<pic>> used;

  set<int> ret;

  for(;!q.empty(); q.pop()) {
    auto const& p = q.front();
    if(p.size() == 1) {
      for(auto&& e: p[0].first)
        ret.insert(e);
      continue;
    }
    assert(p.size());
    rep(i, p.size() - 1)
      push_trans(q, used, p, i, p[i].first, p[i+1].first, p[i].second, p[i+1].second);
  }

  return ret;
}

int solve() {
  it = s.begin(), end = s.end();
  return expr().size();
}

}

int main() {

  while(cin >> solver::s) {
    if(solver::s == "#") break;
    cout << solver::solve() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int a[200], b[200];
signed main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h) * (W-w) << endl;
  return 0;
}





Measured memory_bytes: 256
N,M = map(int,input().split())
WA = [0] * (N + 1)
AC = [0] * (N + 1)
sum_WA = 0
for _ in range(M):
  i,s = input().split()
  i = int(i)
  if AC[i] == 0:
    if s == 'WA':
      WA[i] += 1
    elif s == 'AC':
      AC[i] = 1
      sum_WA += WA[i]

print(sum(AC),sum_WA)

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

int main()
{
  int n;cin>>n;
  vector<int> l(n);
  int i,j;
  for(i=0;i<n;i++)cin>>l.at(i);
  sort(l.begin(),l.end());
  long long ans=0;
  for(i=0;i<n-2;i++)
  {
    for(j=i+1;j<n-1;j++)
    {
      int sumab=l.at(i)+l.at(j);
      decltype(l)::iterator it=upper_bound(l.begin(), l.end(), sumab-1);
      int index=it-l.begin()-1;
      if(index>j)ans+=(index-j);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
ans = ""
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(S)):
    if a.index(S[i]) + N > 25:
        ans += a[a.index(S[i]) + N - 26]
    else:
        ans += a[a.index(S[i]) + N]

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1e9+7;
template<class T> bool chmin(T&a,T b){if(a>=b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
ll N=1;
vi segsum,lazy;
void init(vi v){
    while(N<v.size())N*=2;
    segsum=vi(N*2-1);
    lazy=vi(N*2-1);
    rep(i,N){
        if(i<v.size())segsum[i+N-1]=v[i];
        else segsum[i+N-1]=0;
    }
    for(int i=N-2;i>=0;i--)segsum[i]=segsum[i*2+1]+segsum[i*2+2];
}
void eval(int k,int l,int r){
    segsum[k]+=lazy[k];
    if(r-l>1){
        lazy[k*2+1]+=lazy[k]/2;
        lazy[k*2+2]+=lazy[k]/2;
    }
    lazy[k]=0;
}
void update(int a,int b,int k,int l,int r,ll x){
    eval(k,l,r);
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b){
        lazy[k]+=x*(r-l);
        eval(k,l,r);
    }
    else{
        update(a,b,k*2+1,l,(l+r)/2,x);
        update(a,b,k*2+2,(l+r)/2,r,x);
        segsum[k]=segsum[k*2+1]+segsum[k*2+2];
    }
}
ll getsum(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(a<=l&&r<=b)return segsum[k];
    if(r<=a||b<=l)return 0;
    ll c1=getsum(a,b,k*2+1,l,(l+r)/2);
    ll c2=getsum(a,b,k*2+2,(l+r)/2,r);
    return c1+c2;
}
int main(){
    int n,q;cin>>n>>q;
    vi v(n);
    init(v);
    rep(i,q){
        int c;cin>>c;
        if(!c){
            ll s,t,x;cin>>s>>t>>x;
            update(s-1,t,0,0,N,x);
        }
        else{
            ll s,t;cin>>s>>t;
            out(getsum(s-1,t,0,0,N));
        }
    }
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, M;
	cin >> N >> M;
	cout << (1900 * M + 100 * (N - M))*pow(2, M);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int n = in();
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  int cost1    = 0;
  int cost2    = 0;
  int temp_sum = 0;
  rep(i, n) {
    temp_sum += a[i];
    if (i % 2 == 0) {
      if (temp_sum <= 0) {
        cost1 -= temp_sum - 1;
        temp_sum = 1;
      }
    } else {
      if (temp_sum >= 0) {
        cost1 += temp_sum + 1;
        temp_sum = -1;
      }
    }
  }
  temp_sum = 0;
  rep(i, n) {
    temp_sum += a[i];
    if (i % 2 == 1) {
      if (temp_sum <= 0) {
        cost2 -= temp_sum - 1;
        temp_sum = 1;
      }
    } else {
      if (temp_sum >= 0) {
        cost2 += temp_sum + 1;
        temp_sum = -1;
      }
    }
  }
  cout << min(cost1, cost2) << endl;
}


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

int main()
{
    int k;
    cin >> k;
    vector<int> a(32);
    a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める
ll f(ll n, ll x){
    if(n != -1) return n/x+1;
    else return 0;
}
int main()
{
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans;
    ans = f(b,x) - f(a-1,x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>

void main(void){
    int N, X;
    int D = 0;
    int j = 1;
    scanf("%d",&N);
    scanf("%d",&X);

    int length[N];

    for(int i=0; i<N; i++){
        scanf("%d",&length[i]);
        D += length[i];
        if(D <= X){
            j++;
        }

    }
    
    printf("%d ",j);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n,p;
  cin>>n>>p;
  vector<int> w(n), b(n);
  rep(i,n) cin>>w[i]>>b[i];
  long B = accumulate(all(b), 0L);

  vector<long> v(n);
  rep(i,n) v[i] = (long)(100-p)*w[i] + (long)p*b[i];

  sort(all(v));
  reverse(all(v));

  long acc = 0;
  int idx = 0;
  while(acc < p*B) acc += v[idx++];

  cout << idx << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
        int W;
		int H;
		int x;
		int y;
		int r;
    cin>>W>>H >> x >> y>>r;
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
	{cout<<"Yes"<<endl;}
	else{cout <<"No"<<endl;}
	return 0;
	}


Measured memory_bytes: 1156
use proconio::input;

fn main() {
	input!(a: isize);
	input!(v: isize);
	input!(b: isize);
	input!(w: isize);
	input!(t: isize);

	if v <= w {
		println!("NO");
		return;
	}
	let diff;
	if b > a {
		diff = b - a;
	}
	else {
		diff = a - b;
	}
	if (v-w)*t >= diff {
		println!("YES");
	}
	else {
		println!("NO");
	}
}


Measured memory_bytes: 2172
import java.util.Arrays;
import java.util.Scanner;


class Main{
	int[] d;
	
	int solve(){
		for(int i=10; 1<i; --i){
			int[] d_ = new int[i -1];
			for(int j=0; j<i -1; ++j){
				d_[j] = (d[j] + d[j+1])%10;
				
			}
			d = d_;
		}
		
		return d[0];
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String str = sc.next();
			d = new int[10];
			
			for(int i=0; i<10; ++i){
				d[i] = Integer.parseInt(new String(new char[]{str.charAt(i)}));
			}
			
			System.out.println(solve());
		}
	}
	
	public static void main(String[] args){
		new Main().io();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
static const int MAX_V = 100000;

//Graph
struct E {
	E(int t, int f) {
		to = t;
		from = f;
	}
	int to;
	int from;
	int cost;
	bool visited;
	bool use;
};

struct V {
};

vector<E> G[MAX_V];
bool v[MAX_V];

int VS, ES;
//dfs
int ans = 0;
void dfs(int n) {
	rep(i, 0, G[n].size()) {
		if (G[n][i].use && !v[G[n][i].to]) {
			v[G[n][i].to] = true;
			dfs(G[n][i].to);
		}
	}
}

int main() {
	cin >> VS >> ES;

	rep(i, 0, ES)
	{
		int s, t; cin >> s >> t;
		G[s].push_back(*new E(t, s));
		G[t].push_back(*new E(s, t));
	}

	///////////////////////////////////////////////////////////

	//Edge all false
	repe(i, 1, VS) rep(j, 0, G[i].size()) {
		//Edge all visited false;
		repe(k, 1, VS) rep(l, 0, G[k].size()) G[k][l].use = true;
		repe(k, 1, VS) v[k] = false;

		G[i][j].use = false;

		//DFS
		v[1] = true;
		dfs(1);

		bool ok = true;
		repe(k, 1, VS)  ok &= v[k];
		if (!ok)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n;
	cin >> n;
	vector<string> s(n);
	map<string, ll> mp;

	rep(i, n) {
		cin >> s[i];
		sort(all(s[i]));
		mp[s[i]]++;
	}

	ll sum = 0;
	for (auto m : mp) {
		sum += (m.second * (m.second - 1)) / 2;
	}

	out(sum);

	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    if(s <= "2019/04/30") {
        output("Heisei");
    }
    else {
        output("TBD");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
ll x,y;
int main(void){
   cin>>x>>y;
   if(x%y==0)cout<<-1<<endl;
   else cout<<x*(y-1)<<endl;
    
}


Measured memory_bytes: 384
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

typedef pair<int,string> P;
typedef long long ll;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int dta[100000];
int pen[100000];
int main() { 
  int n,m;cin>>n>>m;
  vector<P> a(m);
  for(int i = 0; m > i; i++){
    int a;
    string b;
    cin>>a>>b;a--;
    if(b == "AC"){
      dta[a]=1;
    }else{
      if(dta[a]==0){
        pen[a]++;
      }
    }
  }
  int A=0;
  int B=0;
  for(int i = 0; n > i; i++){
    if(dta[i]){
      A++;
      B += pen[i];
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 












int main(){
     ll n,m;
     cin>>n>>m;
     vector<ll> a(n);rep(i,n)cin>>a[i];
     ll pre[n+1];
     pre[0]=0;
     map<ll,int> mp;
     int ct0=0;
     for(int i=0;i<n;i++){
          pre[i+1]=(pre[i]+a[i])%m;
          if(pre[i+1]==0)ct0++;
          mp[pre[i+1]]++;
     }
     ll res=0LL;
     for(auto it:mp){
          res+=1LL*it.se*(it.se-1)/2;
     }
     res+=ct0;
     cout<<res;

     
}


























Measured memory_bytes: 8592