akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    auto c = vec<int>(3, 3); cin >> c;
    
    int a = c[0][1] - c[0][0];
    int b = c[0][2] - c[0][1];
    int C = c[1][0] - c[0][0];
    int d = c[2][0] - c[1][0];
    FOR(y, 1, 3) {
        if (a != c[y][1] - c[y][0]) {
            cout << "No\n";
            return 0;
        }
        if (b != c[y][2] - c[y][1]) {
            cout << "No\n";
            return 0;
        }
    }
    FOR(x, 1, 3) {
        if (C != c[1][x] - c[0][x]) {
            cout << "No\n";
            return 0;
        }
        if (d != c[2][x] - c[1][x]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
 
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
	if a[i][2] == 1:
		x1 = max(x1, a[i][0])
	elif a[i][2] == 2:
		x2 = min(x2, a[i][0])
	elif a[i][2] == 3:
		y1 = max(y1,a[i][1])
	elif a[i][2] == 4:
		y2 = min(y2, a[i][1])

if (x2-x1) < 0 or (y2-y1) < 0:
	print(0)
else:
	print((x2-x1)*(y2-y1))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main() {
	lint a,b,c,k;
	std::cin>>a>>b>>c>>k;
	if(k%2==0)std::cout<<a-b<<std::endl;
	else std::cout<<b-a<<std::endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
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;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    vector<int> A(N);

    REP(i, N) { cin >> A[i]; }
    vector<int> sum(N + 1);
    sum[0] = 0;
    REP(i, N) { sum[i + 1] = (sum[i] + A[i] - 1) % K; }

    ll ans = 0;
    map<int, int> range;
    FOR(i, 0, min(K, N + 1)) {
        auto it = range.find(sum[i]);
        if (it != range.end()) {
            range[sum[i]]++;
        } else {
            range[sum[i]] = 1;
        }
    }

    FOR(i, 0, N + 1) {
        // cout << i << " " << sum[i] << " " << range[sum[i]] << endl;
        ans += range[sum[i]] - 1;
        range[sum[i]]--;
        if (i + K < N + 1) {
            auto it = range.find(sum[i + K]);
            if (it != range.end()) {
                range[sum[i + K]]++;
            } else {
                range[sum[i + K]] = 1;
            }
            // cout << " " << i + K << endl;
        }
    }

    cout << ans << endl;
}


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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	int dp[n] = {};
	for (int i = 0; i < n; i++)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{

		if (i - 1 >= 0) {
			dp[i] =  dp[i - 1] + abs(arr[i - 1] - arr[i]);
		}
		for (int j = 2; j <= k; j++) {

			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
			}
		}

	}
	cout << dp[n - 1];


}

Measured memory_bytes: 4396
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll i,a,b,c,n;
  cin >> n;
  for(i=1;i<=n;i++){
    ll ans=0;
    for(a=1;a*a<=i;a++){
      for(b=1;a*a+b*b<=i;b++){
        for(c=1;a*a+b*b+c*c+a*b+b*c+c*a<=i;c++){
          if(a*a+b*b+c*c+a*b+b*c+c*a==i){
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main(){
	int n,r,p,c;
	int a[50],buf[50];
	while(cin>>n>>r,n|r){
		for(int i=0;i<n;i++)a[i]=n-i;
		for(int i=0;i<r;i++){
			cin>>p>>c;
			p--;
			memcpy(buf,a,p*sizeof(int));
			memmove(a,a+p,c*sizeof(int));
			memcpy(a+c,buf,p*sizeof(int));
		}
		cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N,a,b;
    cin >> N;
    if (N == 1) {
        cout << "Hello World";
    }
    if (N == 2) {
        cin >> a >> b;
        cout << a+b;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j;

	for( i = 1 ; i <= 9 ; i++)
	{
		for( j = 1 ; j <= 9 ; j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B) {
  if (B % A == 0)
    cout << A + B << endl;
  else
    cout << B - A << endl;
}

int main() {
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
num = int(input())
A = [int(i) for i in input().split()]
B = []
for i in range(0,num-1):
    if(i==0):
        B.append(A[i])
        B.append(A[i])
    else :
        if(A[i]>B[i]):
            B.append(A[i])
        else:
            B[i] = A[i]
            B.append(A[i])
sum = 0
for i in range(0,num):
    sum = sum + B[i]
print(sum)

Measured memory_bytes: 3064
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split('\n');
    for (var i = 0; i <inputs.length; i ++) {
        if (inputs[i]=== '0 0') {
            break;
        }
        var input = inputs[i].split(' ')
        .map(Number).sort(function(a,b) {
            return a - b;
        })
        .join(' ');
console.log (input);

}
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

bool check(int n) {
	string s = to_string(n);
	#define sz(s) (int)(s.size())
	if (sz(s) == 1)
		return true;
	for (int i = 1; i < sz(s); ++ i)
		if (s[i] != s[i - 1])
			return false;
	return true;
}

int func(int n) {
	if (check(n))
		return n;
	while(true) {
		++n;
		if (check(n))
			return n;
	}
}

int main() {
	clog << "Ready\n";
	int n;
	cin >> n;
	cout << func(n);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll v[n];
        cnt = 0;
        rep(i, n){
            cin >> v[i];
            cnt += v[i];
        }
        a = 0;
        ans = INF;
        rep(i, n - 1){
            a += v[i];
            cnt -= v[i];
            mins(ans, abs(a - cnt));
        }
        print(ans);
    }
}


Measured memory_bytes: 1792
a, b, k=map(int, input().split()) #a<=x<=b
if(b - a < k * 2):
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(k):
        print(a + i)
    for i in range(k):
        print(b - k + 1 + i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>   //头文件
using namespace std;
int main()
{
    long long n,min,l=0;    // n为所需要输入的乘积
    cin>>n;//min是最小值 l是所要输出的位数
    min=n; //起手一个最小值等于n    
    for(int i=2;i<=sqrt(n);i++)//开始循环 从2-根号n 因为如果想要l最小 所需要的a与b就要越相近
    {//a与b最相近的极限情况就是a=b=根号n
        if(n%i==0)//这个判断n是几的倍数 
        {
            min=n/i;//最小值是等于n/i
        }
    }
    while(min!=0)//当min不得0时候
    {
        min/=10;
        l++;
    }          
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	vector<int>v;
	for (int i = 0; i < 5; ++i) {
		int n;
		cin >> n;
		v.push_back(n);
	}
	sort(v.rbegin(), v.rend());
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
	cout << endl;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[100100];
int B[100100];

signed main() {
    cin >> N;
    int as = 0, bs = 0;
    rep(i, N) {
        cin >> A[i];
        as += A[i];
    }

    int mi = 0, mic = 0;
    rep(i, N) {
        cin >> B[i];
        bs += B[i];
        A[i] -= B[i];
        if (A[i] < 0) {
            mi += A[i];
            mic++;
        }
    }
    sort(A, A + N, greater<>());
    if (as < bs) {
        cout << -1 << endl;
        return 0;
    }
    if (mi == 0) {
        cout << 0 << endl;
        return 0;
    }
    int ma = 0;
    rep(i, N) {
        ma += A[i];
        if (ma >= -mi) {
            cout << mic + i + 1 << endl;
            return 0;
        }
    }
}


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

int main(void) {
	string s;
	cin >> s;
	int b = 0;
	long long sum = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			b++;
		} else {
			sum += b;
		}

	}

	cout << sum <<  endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int a, b;
    string s;
    R a >> b >> s;
    if(s[a] != '-'){
        co("No");
        return 0;
    }
    rep(i, a+b+1){
        if(!isdigit(s[i]) && (i != a)){
            co("No");
            return 0;
        }
    }
    co("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


long long int mod = 4294967296;
ll rui(ll number1,ll number2){
    //abcのbed乗を計算する
    if(number2 == 0){return 1;}
    else{
        ll number3 = rui(number1,number2/2);
        number3 *= number3;
        number3 %= mod;
        if(number2 % 2 == 1){number3 *= number1; number3 %= mod;}
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,res,q;
ll x[500005],y[500005],z[500005];
char s[500005];

int main(){
    cin >> s;
	n = strlen(s);
	for(i=0;i<n;i++){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
			a++;
		}else{
			ans = max(ans,a);
			a = 0;
		}
	}
	ans = max(ans,a);
	p(ans);
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

m = [0 for i in range(101)]
n = [0 for i in range(101)]

i = a
while(True):
    m[i] = 1
    if(i == b):
        break
    i+=1
i = c
while(True):
    n[i] = 1
    if(i == d):
        break
    i+=1

ans = 0
for i in range(101):
    if(m[i] * n[i] == 1):
        ans+=1

if(ans!=0):
    ans-=1

print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B, K; cin >> A >> B >> K;
    int gcd = __gcd(A, B);

    vector<int> divisor;
    for (int i = 1; i*i <= gcd; i++) {
        if (gcd%i == 0) {
            divisor.push_back(i);
	    if (gcd/i != i) {
	      divisor.push_back(gcd/i);
	    }
        }
    } 
    sort(divisor.begin(), divisor.end(), greater<int>());
    cout << divisor[K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int MAX = 2e6+10;
char s[MAX];

int main(){
    scanf("%s", s);
    int len = strlen(s);
    int sum = 0;
    for (int i = 0; i < len; i++) sum += s[i] - '0';
    if (sum==0 || sum%9==0) puts("Yes");
    else puts("No");
    return 0;
}


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

const int N = 5e5 + 5;
const int mod = 1e9 + 9277;

int n;
string s;
int hs[N], pw[N];
bool prf[N], suf[N];

int get(int l,int r) {
	return (hs[r] - 1LL * hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s; n = s.size(); s = '#' + s;
	hs[0] = 0, pw[0] = 1;
	for (int i = 1; i <= n; ++i) {
		hs[i] = (1LL * hs[i - 1] * 1007 % mod + (s[i] - 'a' + 1)) % mod;
		pw[i] = 1LL * pw[i - 1] * 1007 % mod;
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = i + i; j <= n; j += i) {
			if (get(j - i + 1, j) == get(1, i)) prf[j] = true;
			else break;
		}
	}
	
	for (int i = 1; i <= n; ++i) {
		for (int j = n - i - i + 1; j >= 1; j -= i) {
			if (get(j, j + i - 1) == get(n - i + 1, n)) suf[j] = true;
			else break;
		}
	}
	
	if (!prf[n]) return cout << 1 << '\n' << 1 << '\n',0;
	int cnt = 0;
	for (int i = 1; i < n; ++i) if (!prf[i] && !suf[i + 1]) {
		cnt++;
	} 
	if (cnt) cout << 2 << '\n' << cnt << '\n';
	else cout << n << '\n' << 1 << '\n';
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0;i < n;i++)cin >> a[i];
	int num[n] = {};
	for (int i = 0;i < n;i++)if(a[i]!=0)num[a[i]-1]++;
	sort(num, num + n);
	reverse(num, num + n);
	for (int i = 0;i < k;i++)num[i] = 0;
	int ans = 0;
	for (int i = 0;i < n;i++)ans += num[i];
	cout << ans << endl;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  vector<int> 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};
  int k; cin >> k; --k;
  cout << a[k] << '\n';
  return 0;
}


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

int32_t main(){

	int h,n,x;
	cin>>h>>n;
	REP(i,n){
		cin>>x;
		h-=x;
	}
	if(h>0)cout<<"No\n";
	else cout<<"Yes\n";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    ll n = s.size();

    vl dp0(n+1);  // dp0[i+1] : a+bの先頭i文字(iは0-index)がsの先頭i文字と一致しているときの組の数
    vl dp1(n+1);  // dp1[i+1] : a+bの先頭i文字(iは0-index)がsの先頭i文字より辞書順で小さいときの組の数
    dp0[0] = 1;
    rep(i, n) {
        // (a[i], b[i]) = (0, 0) のとき
        if(s[i] == '0') {
            dp0[i+1] += dp0[i];
            dp1[i+1] += dp1[i];
        }
        else if(s[i] == '1') {
            dp1[i+1] += (dp0[i] + dp1[i]);
        }
        // (a[i], b[i]) = (0, 1), (1, 0) のとき
        if(s[i] == '0') {
            dp1[i+1] += 2*dp1[i];
        }
        else if(s[i] == '1') {
            dp0[i+1] += 2*dp0[i];
            dp1[i+1] += 2*dp1[i];
        }
        dp0[i+1] %= mod;
        dp1[i+1] %= mod;
    }

    ll ans = (dp0[n] + dp1[n])%mod;
    out(ans);
    re0;
}

Measured memory_bytes: 2048
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    numbers = list(map(int, input().split()))

    minus_count = len([n for n in numbers if n < 0])
    absolute_numbers = [abs(n) for n in numbers]

    if minus_count % 2 == 0:
        print(sum(absolute_numbers))
    else:
        min_num = min(absolute_numbers)
        print(sum(absolute_numbers)-min_num*2)


Measured memory_bytes: 14252
n = int(input())
a = list(map(int, input().split()))

print(' '.join([str(x) for x in a]))

for i in range(1, n):

    v = a[i]
    j = i - 1
    while (j >= 0) and (a[j] > v):
        a[j+1] = a[j]
        j -= 1

    a[j+1] = v

    print(' '.join([str(x) for x in a]))



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

int main(){
    int N;
    long int total = 0;
    cin >> N;
    for (int i=1; i<=N; ++i) {
        if (i%3 != 0 && i%5 != 0) {
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
	int i, n;
	int minv, maxv;
	int R[200000];

	scanf("%d",&n);
	for(i = 0;i < n; i++){
		scanf("%d",&R[i]);
	}

	maxv = R[1]-R[0];
	minv = R[0];
	for(i = 1;i < n; i++){
		if(maxv < R[i] - minv) maxv = R[i] - minv;
		if(minv > R[i]) minv = R[i];
	}

	printf("%d\n",maxv);
	return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong n, m, d;
	cin >> n >> m >> d;

	long double ans;
	if(d == 0){
		ans = (long double)(1.0/n)*(m-1);
	}else{
		ans = (long double)(2.0*(n-d)/(n*n))*(m-1);
	}

	cout << fixed << setprecision(9) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int numbers[100001];
int mods_pair[100001];
int mods_rest[100001];

int main(){
	
	for(int i = 0; i < 100001; i++){
		numbers[i] = 0;
		mods_pair[i] = 0;
		mods_rest[i] = 0;
	}
	
	int n, m;
	
	cin >> n >> m;
	
	int x;
	
	for(int i = 0; i < n; i++){
		cin >> x;
		numbers[x]++;
	}
	
	for(int i = 0; i <= 100000; i++){
		mods_pair[i % m] += numbers[i] / 2 * 2;
		mods_rest[i % m] += numbers[i] % 2;
	}
	/*
	for(int i = 0; i < m; i++){
		cout << mods_pair[i] << " " << mods_rest[i] << endl;
	}
	*/
	int ans = 0;
	
	int id1, id2;
	
	for(int i = 1; i < (double)m / 2; i++){
		if((mods_pair[i] > 0 || mods_rest[i] > 0) && (mods_pair[m - i] > 0 || mods_rest[m - i] > 0)){
			if(mods_pair[i] + mods_rest[i] >= mods_pair[m - i] + mods_rest[m - i]){
				id1 = i;
				id2 = m - i;
			}else{
				id1 = m - i;
				id2 = i;
			}
			ans += mods_pair[id2] + mods_rest[id2];
			mods_rest[id1] -= mods_pair[id2] + mods_rest[id2];
			if(mods_rest[id1] < 0){
				mods_pair[id1] += mods_rest[id1];
				mods_rest[id1] = 0;
			}
			mods_pair[id2] = 0;
			mods_rest[id2] = 0;
		}
	}
	/*
	for(int i = 0; i < m; i++){
		cout << mods_pair[i] << " " << mods_rest[i] << endl;
	}
	*/
	if(mods_rest[0] > 0){
		ans += mods_rest[0] / 2;
		mods_rest[0] = 0;
	}
	if(m % 2 == 0){
		if(mods_rest[m / 2] > 0){
			ans += mods_rest[m / 2] / 2;
			mods_rest[m / 2] = 0;
		}
	}
	
	for(int i = 0; i < m; i++){
		ans += mods_pair[i] / 2;
		mods_pair[i] = 0;
	}
	
	cout << ans << endl;
	/*
	for(int i = 0; i < m; i++){
		cout << mods_pair[i] << " " << mods_rest[i] << endl;
	}
	*/
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    set<string> S;
    rep(i,N) {
        string s; cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 19124
import sys
from collections import Counter
INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    N, K, Q = MAP()
    A = [INT() for _ in range(Q)]
    C = Counter(A)

    for i in range(N):
        if K + C[i+1] - Q > 0: print('Yes')
        else: print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 54876
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  map<int, int> cnt;
  for(int i = 2; i <= n; i++){
    int num = i;
    for(int j = 2; j <= sqrt(i); j++){
      while(num % j == 0){
        num /= j;
        cnt[j]++;
      }
    }
    if(num >= 2) cnt[num]++;
  }
  vi check(5);
  for(auto x : cnt){
    if(x.second >= 2) check[0]++;
    if(x.second >= 4) check[1]++;
    if(x.second >= 14) check[2]++;
    if(x.second >= 24) check[3]++;
    if(x.second >= 74) check[4]++;
  }
  int num = check[2] * (check[1] - 1);
  num += check[3] * (check[0] - 1);
  num += check[1] * (check[1] - 1) * (check[0] - 2) / 2;
  num += check[4];
  cout << num << endl;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v) {return accumulate(all(v), (T)0LL);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, W, ans=0;
    cin >> n >> W;
    vll v(n), w(n);
    vvll dp(n+1, vll(W+1, 0));
    REP(i,n) cin >> w[i] >> v[i];

    REP(i,n){
        FOR(j,1,W){
            chmax(dp[i+1][j], dp[i][j]);
            if(j-w[i]>=0) chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <set>
#include <string>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, m, n) for (int i = m; i <= n; ++i)
using namespace std;

set<string> sub_set;

void insert_substr(string str, int n) {
  REP(len,n) REP(i,n-len) sub_set.insert(str.substr(i, len+1));
}

int main() {
	string str; int k;
	cin >> str >> k;
	if ( str.length() >= k ) {
		REP(i,str.length()-k+1) {
			insert_substr(str.substr(i,k),k);
		}
	} else {
		insert_substr(str,str.length());
	}

	set<string>::iterator it = next(sub_set.begin(), k-1);
	cout << *it << endl;
}

Measured memory_bytes: 1664
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype="int32")
for i in range(1,n):
    start=0 if k>i else i-k
    dp[i]=np.min(dp[start:i]+np.abs(h[i]-h[start:i]))
print(dp[-1])

Measured memory_bytes: 22904
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
fn lcm(a: usize, b: usize) -> usize {
    a * gcd(a, b)
}

fn main() {
    input!(n: usize, a: [usize; n]);
    println!("{}", a.iter().map(|&a| a - 1).sum::<usize>())
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    if A[i-1] > A[i]:
        #前の人の方が大きい
        ans += A[i-1] - A[i]
        A[i] = A[i-1]
print(ans)

Measured memory_bytes: 32260
/*
Original problem: https://atcoder.jp/contests/abc136/tasks/abc136_e
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
	// helper to see if the array can be 0mod using 'cost' up and 'cost' down
	int good(VLL A, ll mod, ll k) {
		int n = A.size();
		REP(i,0,n) {
			A[i] = A[i] % mod;
		}

		sort(A.begin(), A.end());
		
		// work out down/up
		// down[i] is req to down everything up to i-1
		// up[i] is req to up everything after i

		VLL down(n + 1);
		VLL up(n + 1);

		down[0] = 0;
		REP(i,0,n) {
			down[i+1] = down[i] + A[i]; 
		}

		up[n] = 0;
		RREP(i,n - 1,0) {
			up[i] = up[i+1] + (mod - A[i]) % mod;
		}

		ll ans = k + 1; // invalid initially
		REP(i,0,n) {
			// down[i] is down needed up to, not including i
			if (down[i] == up[i]) {
				ans = down[i];
			}
		}
		return ans <= k;	
	}

    void main() {
        ll n, k;
		cin >> n >> k;
		VLL A(n);
		ll t = 0;
		REP(i,0,n) {
			cin >> A[i];
			t += A[i];
		}

		// t is maximum ~1e9
		// i can use O(sqrt(n)) to find all factors
		VLL F;
		for (ll f = 1; f * f <= t; f++) {
			if (t % f == 0) {
				F.push_back(f);
				F.push_back(t / f);
			}
		}

		// largest first: 
		// i will see if it is possible to let this be gcd
		sort(F.rbegin(), F.rend());
		for (ll f : F) {
			if (good(A,f,k)) {
				cout << f << endl;
				return;
			}
		}
		cout << 1 << endl;
		return;
    }
}


signed main() {
	int t;
	t = 1; 
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))

from collections import defaultdict

d = defaultdict(lambda:0)
for i in range(N):
    d[A[i]] += 1

ans = 0
for k in d:
    ans += d[k]*(d[k]-1)//2

for i in range(N):
    print(ans-d[A[i]]+1)

Measured memory_bytes: 88012
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll table[510][510];
int main(){
  ll n,m,Q;cin>>n>>m>>Q;

  ll l,r;
  rep(i,m){
    cin>>l>>r;
    table[1][r]++;
    table[l+1][r]--;
  }

  FOR(i,1,n+1){
    FOR(j,1,n+1){
     table[i][j]+=table[i-1][j]; 
    }
  }

  FOR(i,1,n+1){
    FOR(j,1,n+1){
     table[i][j]+=table[i][j-1]; 
    }
  }
  ll p,q;
  rep(i,Q){
    cin>>p>>q;
    cout<<table[p][q]<<endl;
  } 
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    vector<vector<int>> c(10,vector<int>(10));
    for(int i=0;i<=9;++i)for(int j=0;j<=9;++j)cin>>c[i][j];
    for(int k=0;k<=9;++k)for(int i=0;i<=9;++i)for(int j=0;j<=9;++j){
        c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
    }
    int sum = 0;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j){
        int a;cin>>a;
        if(a != 1 and a != -1){
            sum += c[a][1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int sum = 0;
  REP(i, N){
    if(S[i] == 'o'){
      sum++;
    }
  }
  if(sum + (15-N) >= 8){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    vector<ll> num(n+1);
    num[0] = 0;
    ll cnt = 0;
    rep(i, n) {
        if (s[i] == '<') {
            ++cnt;
            num[i+1] = cnt;
        }
        else {
            cnt = 0;
        }
    }
    cnt = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (i == n - 1 && s[i] == '>') {
            num[i+1] = 0;
        }
        if (s[i] == '>') {
            ++cnt;
            num[i] = max(num[i], cnt);
        }
        else {
            cnt = 0;
        }
    }
    for (auto nn: num) {
        ans += nn;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7716
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 2147483647
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> candle(N, 0);
	for (int i = 0; i < N; i++)cin >> candle[i];
	int ans = INF;
	for (int i = 0; i < N - K + 1; i++) {
		int first = candle[i], end = candle[i + K - 1];
		int tmp = min(abs(first), abs(end)) + abs(first - end);
		if (ans > tmp) ans = tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
// O(4*HW)

#include <bits/stdc++.h>
#define int long long
using namespace std;
int mod;
string s[2010];
using T=array<int,4>;
using TT=array<T,4>;
T dp[2010][2010];
T operator + (T v,T w){
		return T{(w[0]+v[0])%mod,(w[1]+v[1])%mod,(w[2]+v[2])%mod,(w[3]+v[3])%mod};
}

T mul(int d,T &v){
	if(d==0) return T{(v[0]+v[2])%mod,v[3],0,v[3]};
	if(d==10) return T{(v[0]),v[2],0,v[3]};
		return T{v[0],v[1],(10*v[2]+d*v[1])%mod,v[3]};
}

int ch(char c){
	if(c=='+') return 0;
	if(c=='*') return 10;
	return c-'0';
}
 signed main(){
int h,w;
 	cin>>h>>w>>mod;
 	for(int i=0;i<h;i++) cin>>s[i];

 	for(int i=0;i<h;i++)for(int j=0;j<w;j++){
 		T e;
 		if(i+j==0) e={0,1,0,1};
 		else if(i==0) e=dp[i][j-1];
 		else if(j==0) e=dp[i-1][j];
 		else e=dp[i-1][j]+dp[i][j-1];
 		dp[i][j]=mul(ch(s[i][j]),e);
 	}
 	
 	cout<<(dp[h-1][w-1][0]+dp[h-1][w-1][2])%mod<<endl;
 	return 0;
 
  }
 


Measured memory_bytes: 130776
#include <stdio.h>

int main(int argc, char *argv[]){
    int A;
    int i;
    char buf[128];
    scanf("%s", buf);
    for(i=0;i<4;i++){
        if(buf[i]=='+'){
            A++;
        }
        else{
            A--;
        }
    }
    printf("%d",A);
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d=0;
cin>>a>>b>>c;
if ( a==5 && b==5 && c==7)
	d=1;
else if ( a==5 && c==5 && b==7)
	d=1;
else if ( b==5 && c==5 && a==7)
	d=1;
else 
	d=0;
if(d==1)
	cout<<"YES\n";
else
	cout<<"NO\n";
}


Measured memory_bytes: 256