akhauriyash/Code-Regression huggingface dataset:
import sys, math

if(__name__ == "__main__"):
    """
    N, D = map(int, input().strip().split() )
    D_sq = D**2
    xy_list = []
    for i in range(N):
        xy = list( map(int, input().strip().split() ) )
        xy_list.append(xy)
    """
    K = int( input().strip() )

    Remainder = 7%K
    if(Remainder==0):
        print(1)
    else:
        Flag = True
        Times = 1
        for i in range(K):
            Remainder=(10*Remainder+7)%K
            Times += 1

            if(Remainder==0):
                print(Times )
                Flag = False
                break

        if(Flag==True):
            print(-1)


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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


string s;
cin >> s;

if(s == "AAA" || s == "BBB") cout << "No" << endl;
else cout << "Yes" << endl;




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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;

int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;
    if (B / A > C) {
        cout << C << endl;
    } else {
        cout << B/A << endl;
    }
    return 0;
}


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

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << ((c + b - 1) / b <= (a + d - 1) / d ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


ll searchMax(ll c[], ll sd[], ll picked[]){
    ll max = -1;
    ll maxP = -1;
    REP(i, 26){
        if(picked[i] == 1){
            if(max < sd[i] + c[i]){
                max = sd[i] + c[i];
                maxP = i;
            }
        }else{
            if(max < sd[i]){
                max = sd[i];
                maxP = i;
            }
        }
    }

    return maxP;
}

int main(){
    // input
    ll D;
    cin >> D;

    ll c[27];
    ll s[D + 1][27];
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }

    // preparation
    ll t[D + 1];
    ll picked[27];

    // main
    REP(i, D){
        t[i] = searchMax(c, s[i], picked);
        picked[t[i]] = 1;
    }

    // output
    REP(i, D){
        cout << (i + 7) % 26 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int main()
{
	vector<char>chs(2000);
	vector<vector<int>>real_edges(2000);
	{
		int N, M; cin >> N >> M;
		vector<string>sts;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			sts.push_back(st);
		}
		vector<pair<int, int>>edges;
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b;
			a--; b--;
			edges.push_back(make_pair(a, b));
		}
		int id = 0;
		vector<int>ids(N);
		for (int i = 0; i < N; ++i) {
			ids[i] = id;
			for (int j = 0; j < sts[i].size() - 1; ++j) {
				real_edges[ids[i] + j].push_back(ids[i] + j + 1);
			}
			for (int j = 0; j < sts[i].size(); ++j) {
				chs[ids[i] + j] = sts[i][j];
			}
			id += sts[i].size();
		}
		ids.push_back(id);
		for (auto e : edges) {
			real_edges[ids[e.first + 1] - 1].push_back(ids[e.second]);
		}
		const int start = id;
		const int goal = start + 1;

		for (int i = 0; i < N; ++i) {
			real_edges[start].push_back(ids[i]);
			real_edges[ids[i + 1] - 1].push_back(goal);
		}
		chs.resize(goal + 1);
		real_edges.resize(goal + 1);
	}
	const int N = real_edges.size();
	vector<vector<int>>rev_edges(N);

	for (int i = 0; i < N; ++i) {
		for (auto e : real_edges[i]) {
			rev_edges[e].push_back(i);
		}
	}

	vector<vector<int>>memo(N, vector<int>(N, -1));
	const int S = N - 2;
	const int G = S + 1;
	memo[S][G]=0;
	queue<pair<int,int>>que;
	que.push(make_pair(S,G));
	int ans=0;
	while (!que.empty()) {
		const auto atop(que.front());
		que.pop();
		const int a=atop.first;
		const int b=atop.second;

		if(memo[a][b]>8000)break;
	

		for (auto next_a : real_edges[a]) {
			for (auto next_b : rev_edges[b]) {
				if (chs[next_a] == chs[next_b]) {
					if (a == next_b&&b == next_a) {
						ans=max(ans,memo[a][b]);
						if (ans > 2010) {
							ans=-1;
							break;
						}
					}
					if (next_b == next_a) {
						ans=max(ans,memo[a][b]+1);
						if (ans > 2010) {
							ans = -1;
							break;
						}
					}
					if (memo[next_a][next_b] < memo[a][b]+2) {
						memo[next_a][next_b]=memo[a][b]+2;
						que.push(make_pair(next_a,next_b));
					}
				}
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 19844
#if 0
cat <<EOF >mistaken-paste
#endif
// thanks for @rsk0315_h4x

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define BIG 2000000007
#define VERYBIG 2000000000000007LL

#define MOD 1000000007
#define FOD  998244353
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 1000000

typedef struct {
	sll a;
	sll b;
	sll c;
} hwllc;

ull n;

ull umin (ull x, ull y) {
	return (x < y) ? x : y;
}

ull umax (ull x, ull y) {
	return (x > y) ? x : y;
}

sll smin (sll x, sll y) {
	return (x < y) ? x : y;
}

sll smax (sll x, sll y) {
	return (x > y) ? x : y;
}

sll sdiff (sll a, sll b) {
	if (a >= b) {
		return a - b;
	} else {
		return b - a;
	}
}

int32_t ptriplecomp (const void *left, const void *right) {
	hwllc l = *(hwllc*)left;
	hwllc r = *(hwllc*)right;

	if (l.a < r.a) {
		return -1;
	}
	if (l.a > r.a) {
		return +1;
	}
	if (l.b < r.b) {
		return -1;
	}
	if (l.b > r.b) {
		return +1;
	}
	if (l.c < r.c) {
		return -1;
	}
	if (l.c > r.c) {
		return +1;
	}
	return 0;
}

char s[N_MAX + 1];
char t[N_MAX + 1];

hwllc roll[N_MAX];
bool must[N_MAX];

sll f (sll l, sll r, sll f) {
	return l + r + smin(r + sdiff(l, f) % n, l + sdiff(n - r, f) % n);
}

ull solve () {
	sll i, j, ki, li;
	// ull result = 0;
	sll result = 0;
	sll sum = 0;

	n = strlen(s);

	sll v = -1;
	for (i = 0; i < n; i++) {
		if (t[i] == '1') {
			v = i;
			break;
		}
	}
	if (v < 0) {
		for (i = 0; i < n; i++) {
			if (s[i] == '1') break;
		}
		if (i == n) {
			puts("0");
		} else {
			puts("-1");
		}
		return 0;
	}

	for (i = 0; i < n; i++) {
		ull curr = (v + i) % n;
		if (t[curr] == '1') {
			sum = 0;
		} else {
			sum++;
		}
		roll[curr].a = sum;
		roll[curr].c = curr;
	}
	for (i = 0; i < n; i++) {
		ull curr = (n + v - i) % n;
		if (t[curr] == '1') {
			sum = 0;
		} else {
			sum++;
		}
		roll[curr].b = sum;
	}
	qsort(roll, n, sizeof(hwllc), ptriplecomp);

	result = VERYBIG;
	for (i = 0; i < n; i++) {
		ull flips = 0;
		for (j = 0; j < n; j++) {
			if (must[j] = (t[(n + j - i) % n] != s[j])) flips++;
		}

		ull shifts = VERYBIG;
		sll l = n, r = 0;

		j = n - 1;
		while (l >= 0) {
			shifts = umin(shifts, f(l, r, i));

			while (j >= 0) {
				if (!must[roll[j].c]) {
					j--;
					continue;
				}
				if (roll[j].a < l) break;
				r = smax(r, roll[j].b);
				j--;
			}

			l--;
		}

		result = umin(result, flips + shifts);
	}

	printf("%lld\n", result);
	return 0;
}

int32_t main (void) {
	scanf("%s", s);
	scanf("%s", t);

	solve();

	return 0;
}


Measured memory_bytes: 2300
n = input()

d = [ [0] * 10 for _ in range(10) ]
for i in range( 1, int( n ) + 1 ):
  k = str(i)
  d[ int( k[ 0 ])][ int( k[ -1 ])] += 1

ans = 0
for i in range(10):
  for j in range(10):
    ans += d[i][j] * d[j][i]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  vector< vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  Int r=-1;
  for(Int i=0;i<n;i++)
    if(G[i].size()==1) r=i;
  assert(~r);

  MFP([&](auto dfs,Int v,Int p)->Int{
        Int sum=0;
        vector<Int> res;
        for(Int u:G[v]){
          if(u==p) continue;
          Int val=dfs(u,v);
          sum+=val;
          res.emplace_back(val);
        }
        if(res.empty()) return as[v];

        if(sum<as[v]) drop("NO");
        sort(res.rbegin(),res.rend());
        Int need=sum-as[v];
        if(sum-res[0]<need) drop("NO");

        if(as[v]-need<0) drop("NO");
        return as[v]-need;
      })(r,-1);

  drop("YES");
  return 0;
}


Measured memory_bytes: 16384
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=sc.nextLong();
        long d=0,e=0;
        d=a%(b+c);
        e=a/(b+c);
        if(d>=b)
        System.out.println(e*b+b);
        else
        System.out.println(e*b+d);
    }
}

Measured memory_bytes: 22996
n = int(input())
h = list(map(int, input().split()))
call = 0
for i in range(max(h)):
    c = 0
    if h[0]<=i:
        #print("case1")
        for j in range(n-1):
            if h[j]<=i and h[j+1]>i:
                c += 1
    elif h[-1]<=i:
        #print("case2")
        for j in range(n-1):
            if h[j]>i and h[j+1]<=i:
                c += 1
         
    else:
        #print("case3")
        c = 1
        for j in range(n-1):
            if h[j]<=i and h[j+1]>i:
                c += 1
    #print(c)
    call += c
print(call)

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 9e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }

int n, m ;
int a[N] ;
ll ans = linf, now ;

signed main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 0, n - 1) scanf("%d", &a[i]), a[i]-- ;
	vector <pii> e ;
	rep(i, 1, n - 1) {
		if (a[i - 1] < a[i]) e.pb(mp(a[i - 1], a[i])) ;
		else e.pb(mp(a[i - 1] - m, a[i])) ;
		now += (a[i] - a[i - 1] + m) % m ;
	}
	rep(i, 0, n - 1) e.pb(mp(e[i].fi + m,  e[i].se + m)) ;
	sort(all(e)) ;
	pq <pii> Q ;
	int id = 0 ;
	rep(x, 0, m - 1) {
		now -= siz(Q) ;
		while (id < 2 * n - 2 && e[id].fi < x) {
			Q.push(mp(-e[id].se, e[id].se - e[id].fi)) ;
			now += e[id].se - x + 1 ;
			now -= e[id].se - e[id].fi ;
			id++ ;
		}
		chmin(ans, now) ;
		while (!Q.empty() && -Q.top().fi == x) {
			now += Q.top().se - 1 ;
			Q.pop() ;
		}
	}
	printf("%lld\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/




Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
int e = 10000;
template <typename T>
struct range_update_range_sum{
	int N;
	vector<T> ST;
	vector<T> lazy;
	range_update_range_sum(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
		lazy = vector<T>(N * 2 - 1, e);
	}
	range_update_range_sum(vector<T> &A){
		int n = A.size();
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, 0);
		lazy = vector<T>(N * 2 - 1, e);
		for (int i = 0; i < n; i++){
			ST[N - 1 + i] = A[i];
		}
		for (int i = N - 2; i >= 0; i--){
			ST[i] = ST[i * 2 + 1] + ST[i * 2 + 2];
		}
	}
	void eval(int i, int l, int r){
		if (lazy[i] != e){
			if (i < N - 1){
				lazy[i * 2 + 1] = lazy[i];
				lazy[i * 2 + 2] = lazy[i];
			}
			ST[i] = lazy[i] * (r - l);
			lazy[i] = e;
		}
	}
	void range_update(int L, int R, T x, int i, int l, int r){
		eval(i, l, r);
		if (R <= l || r <= L){
			return;
		} else if (L <= l && r <= R){
			lazy[i] = x;
			eval(i, l, r);
		} else {
			int m = (l + r) / 2;
			range_update(L, R, x, i * 2 + 1, l, m);
			range_update(L, R, x, i * 2 + 2, m, r);
			ST[i] = ST[i * 2 + 1] + ST[i * 2 + 2];
		}
	}
	void range_update(int L, int R, T x){
		range_update(L, R, x, 0, 0, N);
	}
	T range_sum(int L, int R, int i, int l, int r){
		eval(i, l, r);
		if (R <= l || r <= L){
			return 0;
		} else if (L <= l && r <= R){
			return ST[i];
		} else {
			int m = (l + r) / 2;
			return range_sum(L, R, i * 2 + 1, l, m) + range_sum(L, R, i * 2 + 2, m, r);
		}
	}
	T range_sum(int L, int R){
		return range_sum(L, R, 0, 0, N);
	}
};
int main(){
  int n, q;
  cin >> n >> q;
  range_update_range_sum<long long> a(n);
  for (int i = 0; i < q; i++){
    int T;
    cin >> T;
    if (T == 0){
      int s, t, x;
      cin >> s >> t >> x;
      a.range_update(s, t + 1, x);
    }
    if (T == 1){
      int s, t;
      cin >> s >> t;
      cout << a.range_sum(s, t + 1) << endl;
    }
  }
}


Measured memory_bytes: 7068
n = int(input())
b = list(map(int,input().split()))

answer = [None] * n
answer[0] = b[0]
for i in range(1,n - 1):
    answer[i] = min(b[i],b[i - 1])
answer[n - 1] = b[n - 2]
print(sum(answer))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int moves=0;
  if(s[0]==s[n-1]){
    bool bip=true;
    for(int i=0;i<n;i++){
      if(s[i]!=s[i%2])bip=false;
    }
    if(!bip)moves=n-3;
  }
  else{
    moves=n-2;
  }
  if(moves%2==0)puts("Second");
  else puts("First");
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define LLINF 1234567890987654321
#define INF 1234567890
#define ph push
#define ins insert
#define db 0
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
ll n, ans;
int main()
{
	cin >> n;
	/*
	 * 
	 105
135
165
189
195
* */
	if(n < 105)
	{
		cout << 0;
		return 0;
	}

		int c = 0, d = 0;
		for(int i=105; i<=n; i+=2)
		{
			c=0;
			for(int j=1; j<=i; j++)
			{
				if( i%j == 0)
				{
					c++;
				}
			}
			if(c == 8)
			ans ++;
		}
		cout << ans << '\n';
}


Measured memory_bytes: 384
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

int N;

mint<MOD> sum(int);

bool vis[1000001] ={};
mint<MOD> dp[1000001];
mint<MOD> solve(int n){
    if(n >= N) return 0;
    if(vis[n]) return dp[n];
    vis[n] = true;
    mint<MOD> ret = solve(n+1); // 1
    ret += N-1; // aaa... (a != 1)
    if(n != N-1){
        ret += N-1; // a11... (a != 1)
        ret += mint<MOD>(N-1)*(N-2); // abb...
    }
    ret += sum(n+3) - sum(n+N+2); // a11...11
    return dp[n] = ret;
}

bool visS[1000001] ={};
mint<MOD> dpS[1000001];
mint<MOD> sum(int n){
    if(n == -1 || n >= N) return 0;
    if(visS[n]) return dpS[n];
    visS[n] = true;
    return dpS[n] = solve(n) + sum(n+1);
}

/*int a[100];
int dfs(int n){
    if(n == N){
        rep(i, N){
            for(int j=0; j<a[i]-1; j++){
                if(i+2+j >= N) break;
                if(a[i+1+j] != a[i+2+j]) return 0;
            }
        }
        rep(i, N) cout << a[i] << " ";
        cout << endl;
        return 1;
    }
    int ret = 0;
    for(int i=1; i<=N; i++){
        a[n] = i;
        ret += dfs(n+1);
    }
    return ret;
}*/

signed main(){
    cin >> N;
    cout << solve(0)+mint<MOD>(1) << endl;
}

Measured memory_bytes: 83588
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007 
int p[100001];
int32_t main()
{
    fast;
    int n,m;
    cin>>n>>m;
    if(n==m)
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    int N; cin>>N;
    vii dp(N+1,vi(N,INF));
    vi A(N);
    rep(i,0,N) cin>>A[i];
    vi cp(N+1);
    rep(i,0,N) cp[i+1]=cp[i]+A[i];
    rep(i,0,N) dp[1][i]=0;
    REP(i,2,N){
        REP(j,0,N-i){
            rep(k,1,i){
                dp[i][j]=min(dp[i][j],dp[k][j]+dp[i-k][j+k]+cp[j+i]-cp[j]);
            }
        }
    }
    cout<<dp[N][0]<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

struct fl{
	int x;
	int y;
	int d;
};

int main() {
	int n; cin >> n;
	vector<VVI> dr(4,VVI(410000,VI(0))), dl(4,VVI(410000,VI(0)));
	VVI xr(210000,VI(0)), xl(210000,VI(0)), yu(210000,VI(0)), yd(210000,VI(0));
	vector<fl> f(n);
	int x, y; char u;
	REP(i,n){
		cin >> x >> y >> u;
		int d;
		if(u=='L'){
			d=0;
			xl[y].insert(lower_bound(ALL(xl[y]),x),x);
		}
		else if(u=='R'){
			d=1;
			xr[y].insert(lower_bound(ALL(xr[y]),x),x);
		}
		else if(u=='U'){
			d=2;
			yu[x].insert(lower_bound(ALL(yu[x]),y),y);
		}
		else{
			d=3;
			yd[x].insert(lower_bound(ALL(yd[x]),y),y);
		}
		f[i]={x,y,d};
		dr[d][x-y+200000].insert(lower_bound(ALL(dr[d][x-y+200000]),x),x);
		dl[d][x+y].insert(lower_bound(ALL(dl[d][x+y]),x),x);
	}
	ll ans=INF;
	REP(i,n){
		fl now=f[i];
		int p;
		if(now.d==0){
			p=lower_bound(ALL(xr[now.y]),now.x)-xr[now.y].begin();
			if(p!=0)
				ans=min(ans,(now.x-xr[now.y][p-1])*5);
			p=lower_bound(ALL(dr[2][now.x-now.y+200000]),now.x)-dr[2][now.x-now.y+200000].begin();
			if(p!=0)
				ans=min(ans,(now.x-dr[2][now.x-now.y+200000][p-1])*10);
			p=lower_bound(ALL(dl[3][now.x+now.y]),now.x)-dl[3][now.x+now.y].begin();
			if(p!=0)
				ans=min(ans,(now.x-dl[3][now.x+now.y][p-1])*10);
		}
		else if(now.d==1){
			p=upper_bound(ALL(xl[now.y]),now.x)-xl[now.y].begin();
			if(p!=xl[now.y].size())
				ans=min(ans,(xl[now.y][p]-now.x)*5);
			p=upper_bound(ALL(dr[3][now.x-now.y+200000]),now.x)-dr[3][now.x-now.y+200000].begin();
			if(p!=dr[3][now.x-now.y+200000].size())
				ans=min(ans,(dr[3][now.x-now.y+200000][p]-now.x)*10);
			p=upper_bound(ALL(dl[2][now.x+now.y]),now.x)-dl[2][now.x+now.y].begin();
			if(p!=dl[2][now.x+now.y].size())
				ans=min(ans,(dl[2][now.x+now.y][p]-now.x)*10);
		}
		else if(now.d==2){
			p=upper_bound(ALL(yd[now.x]),now.y)-yd[now.x].begin();
			if(p!=yd[now.x].size())
				ans=min(ans,(yd[now.x][p]-now.y)*5);
			p=upper_bound(ALL(dr[0][now.x-now.y+200000]),now.x)-dr[0][now.x-now.y+200000].begin();
			if(p!=dr[0][now.x-now.y+200000].size())
				ans=min(ans,(dr[0][now.x-now.y+200000][p]-now.x)*10);
			p=lower_bound(ALL(dl[1][now.x+now.y]),now.x)-dl[1][now.x+now.y].begin();
			if(p!=0)
				ans=min(ans,(now.x-dl[1][now.x+now.y][p-1])*10);
		}
		else{
			p=lower_bound(ALL(yu[now.x]),now.y)-yu[now.x].begin();
			if(p!=0)
				ans=min(ans,(now.y-yu[now.x][p-1])*5);
			p=lower_bound(ALL(dr[1][now.x-now.y+200000]),now.x)-dr[1][now.x-now.y+200000].begin();
			if(p!=0)
				ans=min(ans,(now.x-dr[1][now.x-now.y+200000][p-1])*10);
			p=upper_bound(ALL(dl[0][now.x+now.y]),now.x)-dl[0][now.x+now.y].begin();
			if(p!=dl[0][now.x+now.y].size())
				ans=min(ans,(dl[0][now.x+now.y][p]-now.x)*10);
		}
	}
	if(ans!=INF)
		cout << ans << endl;
	else
		cout << "SAFE" << endl;
	return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << C << " "<< A  << " "<< B << endl;
}



Measured memory_bytes: 256
import 'dart:io';
import 'dart:collection';

void main(){
	Queue q = new Queue();
	int n = int.parse(stdin.readLineSync()), a, i;
	for(i = 1; i<= 9; i++){
		q.add(i);
	}
	for(a = 1; a<= n; a++){
		i = q.removeFirst();
		if(i % 10 != 0) q.add(10 * i + (i % 10 - 1));
		q.add(10 * i + i % 10);
		if(i % 10 != 9) q.add(10 * i + (i % 10 + 1));
	}
	print(i);
}

Measured memory_bytes: 16348
#include <iostream>

using namespace std;

// k, k+1番目を見たとする
// H(k) + H(k+1) : k所与で求まる
// 雪の高さ = H(k) - a = H(k+1) - b が成立する.
// b - a = H(k+1) - H(k) = k+1
// i.e. k = b - a - 1
// よって,雪の高さ
// H(k) - a = H(b-a-1) - a 
//
int getHeight(int k){
	return k*(k+1) / 2;
}	

int main(){
	int a, b;
	cin >> a >> b;
	int height = getHeight(b-a-1) - a;
	cout << height << endl;
	return 0;
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e9;
const int mod = 1e9 + 7,
N = 1e6 + 11;

int n, k;
ll res, fact[N], invf[N];
ll pw(ll a, ll b) {
    if (b == 0)
        return 1;
    ll t = pw(a, b / 2);
    t = t * t  % mod;
    if (b % 2)
        return t * a % mod;
    return t;
}
ll C(ll k, ll n) {
    return fact[n] * invf[k] % mod * invf[n - k] % mod;
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    cin >> n >> k;
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = fact[i - 1] * i % mod;
    invf[n] = pw(fact[n], mod - 2);
    for (int i = n; i > 0; i--)
        invf[i - 1] = invf[i] * i % mod;
    for (int i = 1; i <= n; i++)
        if (k >= n - i)
            res = (res + C(i, n) * C(i - 1, n - 1) % mod) % mod;
    cout << res;
}


Measured memory_bytes: 5888
#include<stdio.h>
 
int main() {
    int N;
    int i;
    int a, b, c;
 
    scanf("%d\n", &N);
 
    for(i = 0; i < N; i++) {
        scanf("%d %d %d", &a, &b, &c);
        if (a > b && a > c)
            if (a*a == b*b + c*c)
                printf("YES\n");
            else
                printf("NO\n");
        else if(b > a && b > c)
            if(b*b == a*a + c*c)
                printf("YES\n");
            else
                printf("NO\n");
        else
            if(c*c == a*a + b*b)
                printf("YES\n");
            else
                printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 2580
n=int(input())
a=list(map(int,input().split()))
b=0
for _ in a:
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1
print(*a)
print(b)


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll mn = 100000 * 5000 * 2 + 1;
    for (int i = 0; i <= 100000; i++) {
        mn = min(mn, c * i * 2 + a * max(0ll, x - i) + b * max(0ll, y - i));
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)1e18
using namespace std;
int n;
double p[3000], dp[3001][3001];
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lf", &p[i]);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= i; j++){
            dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            if (j > 0)
                dp[i][j] += dp[i - 1][j - 1] * p[i];
            //printf("%d %d %.15lf\n",i , j, dp[i][j]);
        }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans+= dp[n][i];
    printf("%.15lf\n", ans);
    return 0;
}

Measured memory_bytes: 68992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
char ch;
int main()
{
	cin>>ch;
	if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')cout<<"vowel";
	else cout<<"consonant";
return 0;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
lst_x = list(map(int, input().split()))
lst_y = list(map(int, input().split()))

if min(lst_y)<=max(lst_x):
    print('War')
else:
    if Y<=max(lst_x) or min(lst_y)<X+1:
        print('War')
    else:
        print('No War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
 
using namespace std;

signed main()
{
    fast;
    int a,b,m;
    cin>>a>>b>>m;

    vector<int> l(a);
    vector<int> n(b);

    for ( int i = 0 ; i < l.size() ; i++ )
    {
        cin>>l[i];
    }

    for ( int i = 0 ; i < n.size() ; i++ )
    {
        cin>>n[i];
    }
    int ans = mod;

    int m1 = mod;
    int m2 = mod;

    for ( int i = 0 ; i < l.size() ; i++ )
    {
        m1 = min(m1,l[i]);
    }
    for ( int i = 0 ; i < n.size() ; i++ )
    {
        m2 = min(m2,n[i]);
    }

    ans = min(m1+m2,ans);
    for ( int i = 0 ; i < m ; i++ )
    {
        int x,y,c;
        cin>>x>>y>>c;

        ans = min(ans,l[x-1]+n[y-1]-c);
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		String S = a.next();
		String T = a.next();
		String str = S + "[a-z]";
		
		if(T.matches(S + "[a-z]")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 38572
import math

a,b,x=map(int,input().strip().split())

if x<=a**2*b/2:
    h=x/a/b*2
    theta=math.atan(b/h)*180/math.pi
else:
    h=2/(a**2)*(a**2*b-x)
    theta=math.atan(h/a)*180/math.pi

print(theta)

Measured memory_bytes: 3060
import numpy as np
N = int(input())
Alist = np.array(list(map(int, input().split())))
Blist = list(map(abs, Alist))
nom = sum(Alist<0)
if nom%2 == 0 :
    ans = sum(Blist)
else :
    ans = sum(Blist) - 2*min(Blist)
print(ans)

Measured memory_bytes: 23292
from collections import deque
import sys
sys.setrecursionlimit(200000)
import math


def divisor(n):
    divs = list()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.append(i)
            if i * i != n:
                divs.append(n // i)
        i += 1
    return list(sorted(divs))


def read():
    N = int(input())
    return N,


def solve(N):
    ptn = deque()
    factors_n1 = divisor(N-1)[1:]
    factors_n = divisor(N)[1:]
    count = len(factors_n1)
    for k in factors_n:
        n = N
        while n >= k:
            if n % k == 0:
                n = n // k
            else:
                n = n % k
        if n == 1:
            count += 1
    return count
    

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v(n);
	for(int i=0; i<v.size(); i++) {
		cin >> v[i].first;
		v[i].second = i+1;
	}
	sort(v.begin(), v.end());

	for(int i=0; i<n-1; i++) {
		cout << v[i].second << " ";
	}
	cout << v[n-1].second << endl;

}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b<=c)
	{
		cout<<b<<' ';
	}
	else
	{
		cout<<c<<' ';
	}
	if((b+c)<=a)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<(b+c)-a<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 998244353L;
template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline T MinE(vector<T>& v){T m=v[0];for(T e:v)chmin(m,e);return m;}
template<class T> inline T MaxE(vector<T>& v){T m=v[0];for(T e:v)chmax(m,e);return m;}


void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}


int main()
{
	ll N;
	cin >> N;
	std::vector<lls> kofukudo(3, lls(N));
	for (ll i = 0; i < N; i++) {
		ll aa, bb, cc;
		cin >> aa >> bb >> cc;
		kofukudo[0][i] = aa;
		kofukudo[1][i] = bb;
		kofukudo[2][i] = cc;
	}

	//テーブル初期化
	std::vector<lls> tblAll(N, lls(3, -INF));
	tblAll[0][0] = kofukudo[0][0];
	tblAll[0][1] = kofukudo[1][0];
	tblAll[0][2] = kofukudo[2][0];

	//配るDPで計算
	for (ll i = 0; i < N - 1; i++) {
		for (ll j = 0; j < 3; j++) { //i日目
			for (ll k = 0; k < 3; k++) {//i+1日目
				if (j == k) continue;
				chmax(tblAll[i + 1][k], tblAll[i][j] + kofukudo[k][i + 1]);
			}
		}
	}

	cout << MaxE(tblAll[N - 1]) << '\n';

	return 0;
}


Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  ll ans = 0;
  rep(i, n-1) {
    if (a[i] > a[i+1]) {
      ans += a[i] - a[i+1];
      a[i+1] = a[i];
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
    }
    else{
        cout<<min(min((long long)b*c,(long long)a*c),(long long)a*b)<<endl;
    }
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> from;
  vector<bool> check(200010, false);
  bool f = false;
  rep(i, m){
    int a, b;
    cin >> a>> b;
    if(a==1)from.push_back(b);
    if(b==n) check.at(a)=true;
  }
  int na = from.size();
  
  rep(i, na){
    int now = from.at(i);
    if(check.at(now)){
      f = true;
      break;
    }
}
  if(f) cout <<"POSSIBLE";
  else cout << "IMPOSSIBLE";
  }


Measured memory_bytes: 3868
N = int(input())
S = input()

bad_list = ['RGB', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR']
RGB = {'R': 0, 'G': 0, 'B': 0}
other_map = {'R': 'GB', 'G': 'RB', 'B': 'RG'}
res = 0
for (i, s) in enumerate(S):
  other = other_map[s]
  res += RGB[other[0]] * RGB[other[1]]
  
  for j in range(((i+1)//2)+1)[1:]:
    if S[i::-j][:3] in bad_list:
      res -= 1

  RGB[s] += 1


print(res)

Measured memory_bytes: 73816
#include<stdio.h>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[n-1-i]=a[i];
    }
    for(int i=0;i<n;i++){
        if(i<n-1){
            printf("%d ",b[i]);
        }else{
            printf("%d\n",b[i]);
        }
    }
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
    ll n;cin>>n;
    if(n%2==0)cout<<(n/2-1)<<endl;
    else cout<<(n-1)/2<<endl;
}


Measured memory_bytes: 256
def main():
    N = input_ints()

    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - (N % 1000))


def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sougaku = 0;
  int limit = 0;
  
  cin >> sougaku;
  cin >> limit;
  
  sougaku = sougaku * 500 ;
  
  if ( limit <= sougaku ) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
b=Counter(a)
ans=0
if n%2==1:
    for i in b:
        if i==0:
            if b[i]!=1:ans=1
        elif b[i]!=2 or i%2==1 or i>n:ans=1
else:
    for i in b:
        if b[i]!=2 or i%2==0 or i>n:ans=1
if ans==1:print(0)
else: print((2**(len(a)//2))%(10**9+7))

Measured memory_bytes: 14820
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	int N,T,H,L;
	static int t[101], h[101];
	int M = 0,k;//金額
	scanf("%d%d%d%d",&N,&T,&H,&L);
	rrep(i,N)scanf("%d%d",&t[i],&h[i]);
	while(true){
		rrep(i,N){
			k=i;
			if(t[i]>0){
				t[i]--;
				M+=10;
				T++;
				if(T>L){goto ok;}
				if(M==90){
					M=0;
					//T-=9;
				}if(T<0){goto ok;}
			}else if(h[i]>0){
				h[i]--;
				M+=100;
				if(M>=90){
					t[i]+=(M-90)/10;
					T-=(M-90)/10;
					M=0;
					if(T<0){goto ok;}
				}
			}else{
				goto ok;
			}
		
		}
	}
	ok:;
	//printf("a");
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 1028
N=int(input())
H=[int(s) for s in input().split()]

count_max=0
count=0
for i in range(N-1):
    if H[i]-H[i+1] >= 0:
        count+=1
        if count > count_max:
            count_max=count
    else:
        count=0

print(count_max)
            

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

using namespace std;
typedef long long int ll;

const int MAXN = 2 * 1000 + 10;
vector <int> adj[MAXN];
int h[MAXN];
bool visit[MAXN];
int adj1[MAXN];
int adj2[MAXN];
int ans[MAXN];
int n, k;

void dfs(int v)
{
	visit[v] = true;
	for(int i = 0; i < adj[v].size(); i++)
	{
		int u = adj[v][i];
		if(!visit[u])
		{
			h[u] = (h[v] + 1);
			dfs(u);
		}
	}
	return;
}

void strt()
{
	for(int i = 0; i < n; i++)
	{
		visit[i] = false;
		h[i] = 0;
	}
	return;
}

void dfsall()
{
	if(k % 2 == 0)
	{
		for(int i = 0; i < n; i++)
		{
			strt();
			dfs(i);
			int cnt = 0;
			for(int j = 0; j < n; j++)
			{
				if(h[j] > (k / 2))
					cnt++;
			}
			ans[i] = cnt;		
		}
	}
	else
	{
		for(int i = 0; i < n - 1; i++)
		{
			strt();
			int v = adj1[i], u = adj2[i];
			visit[u] = true;
			dfs(v);
			dfs(u);
			int cnt = 0;
			for(int j = 0; j < n; j++)
			{
				if(h[j] > (k / 2))
					cnt++;
			}
			ans[i] = cnt;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
		adj1[i] = a;
		adj2[i] = b;
		ans[i] = 0;
	}
	ans[n - 1] = 0;
	dfsall();
	int mn = INT_MAX;
	for(int i = 0; i < n - 1; i++)
		mn = min(mn, ans[i]);
	if(k % 2 == 0)
		mn = min(mn, ans[n - 1]);
	cout << mn << endl;
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    long long unsigned int x,y;
    scanf("%lld %lld",&x,&y);
    int i =0;
    while(y>=x){
        x = 2*x;
        i++;
    }
    printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, k: u64
    }

    println!("{}", if n % k == 0 {0} else {1});
}

Measured memory_bytes: 4352