akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, f, n;
int table[7][7] = {
	{ 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 3, 5, 2, 4, 0 }, { 0, 4, 0, 1, 6, 0, 3 },
	{ 0, 2, 6, 0, 0, 1, 5 }, { 0, 5, 1, 0, 0, 6, 2 }, { 0, 3, 0, 6, 1, 0, 4 },
	{ 0, 0, 4, 2, 5, 3, 0 } };

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
P field[200][200];//fi:rank,se:value

struct Dice{
	int d[6];
	Dice(int t, int f){
		d[0] = t, d[1] = f, d[2] = table[t][f];
		d[3] = 7 - d[1], d[4] = 7 - d[2], d[5] = 7 - d[0];
	}
	void printD(){
		REP(i, 6)cout << d[i];
		cout << endl;
	}
};

void roll(int muki,Dice *sai){
	int num;
	if (muki == 0){
		num = sai->d[1];
		sai->d[1] = sai->d[0];
		sai->d[0] = sai->d[3];
		sai->d[3] = sai->d[5];
		sai->d[5] = num;
	}
	else if (muki == 1){
		num = sai->d[2];
		sai->d[2] = sai->d[0];
		sai->d[0] = sai->d[4];
		sai->d[4] = sai->d[5];
		sai->d[5] = num;
	}
	else if (muki == 2){
		num = sai->d[3];
		sai->d[3] = sai->d[0];
		sai->d[0] = sai->d[1];
		sai->d[1] = sai->d[5];
		sai->d[5] = num;
	}
	else if (muki == 3){
		num = sai->d[4];
		sai->d[4] = sai->d[0];
		sai->d[0] = sai->d[2];
		sai->d[2] = sai->d[5];
		sai->d[5] = num;
	}
}

int main(){
	while (cin >> n&&n){
		int posy = 100, posx = 100;
		REP(i, 200)REP(j, 200)field[i][j] = P(0, -1);
		REP(i, n){
			cin >> t >> f;
			Dice sai(t, f);
			while (1){
				int muki = 0, me = -1;
				for (int j = 0; j < 4; j++){
					int ny = posy + dy[j], nx = posx + dx[j];
					if (sai.d[1+j]<=6&&sai.d[1+j]>=4&&me < sai.d[1 + j] 
						&& field[ny][nx].first < field[posy][posx].first){
						me = sai.d[1 + j];
						muki = j;
					}
					//cout << muki << " " << me << endl;
				}
				if (me < 0){
					//sai.printD();
					field[posy][posx].first++;
					field[posy][posx].second = sai.d[0];
					posy = 100, posx = 100;
					break;
				}
				else{
					roll(muki, &sai);
					posy += dy[muki], posx += dx[muki];
				}
			}
		}
		int ans[10] = {};
		REP(i, 200){
			REP(j, 200){
				int num = field[i][j].second;
				if (num != -1)ans[num]++;
			}
		}
		//FOR(i, 99, 102){
		//	FOR(j, 99, 102){
		//		cout << field[i][j].second;
		//	}
		//	cout << endl;
		//}
		//FOR(i, 99, 102){
		//	FOR(j, 99, 102){
		//		cout << field[i][j].first;
		//	}
		//	cout << endl;
		//}
		FOR(i, 1, 7){
			if(i==1)cout << ans[i];
			else cout << " " << ans[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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; }

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ld b;
    ll a;
    cin >> a;
    b=a/2+a%2;
    cout << setprecision(10) << b/a << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string N;
    cin >> N;
    int fx = 0;
    for (auto c : N) fx += c - '0';
    if (stoi(N) % fx == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

K = int(input())
A, B = map(int, input().split())

for i in range(A, B+1):
    if i % K == 0:
        print('OK')
        sys.exit()

print('NG')


Measured memory_bytes: 72736
from collections import deque
k=int(input())
q=deque(range(1,10))
for i in range(k):
    x=q.popleft()
    if x%10!=0:
        q.append(10*x+x%10-1)
    q.append(10*x+x%10)
    if x%10!=9:
        q.append(10*x+x%10+1)
print(x)


Measured memory_bytes: 40816
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int len = S.size() / 2 - 1;
    int cnt = 2;
    while(1) {
        if(S.substr(0, len) == S.substr(len, len)) {
            break;
        }
        cnt += 2;
        len--;
    }
    cout << len * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	T := ReadInts(N)
	M := ReadInt()
	s := make([]int, N+1)
	for i := 0; i < N; i++ {
		s[i+1] = s[i] + T[i]
	}
	for i := 0; i < M; i++ {
		P, X := ReadInt()-1, ReadInt()
		fmt.Println(s[P] + X + s[N] - s[P+1])
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n, m;
    unordered_set<int> a;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int tmp_a;
        cin >> tmp_a;
        a.insert(tmp_a);
    }
    vector<int> data(n+1, 0);
    data[0] = 1;
    data[1] = 1;
    for(int i = 2; i <= n; ++i){
        int tmp_data;
        auto itr_1 = a.find(i-1);
        auto itr_2 = a.find(i-2);
        if(itr_1 != a.end() && itr_2 != a.end()){
            tmp_data = 0;
        }else if(itr_1 != a.end()){
            tmp_data = data[i-2];
        }else if(itr_2 != a.end()){
            tmp_data = data[i-1];
        }else{
            tmp_data = data[i-1] + data[i-2];
            if(tmp_data >= 1000000007){
                tmp_data -= 1000000007;
            }
        }
        data[i] = tmp_data;
    }
    cout << data[n] << endl;
    return 0;
}

Measured memory_bytes: 4772
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  int P[M], Y[M];
  for (int i = 0; i < M; i++)
  {
    cin >> P[i] >> Y[i];
  }
  vector<int> vec[100001];
  for (int i = 0; i < M; i++)
  {
    vec[P[i]].push_back(Y[i]);
  }
  for (int i = 1; i <= N; i++)
  {
    sort(vec[i].begin(), vec[i].end());
  }
  for (int i = 0; i < M; i++)
  {
    printf("%06d%06d\n", P[i], lower_bound(vec[P[i]].begin(), vec[P[i]].end(), Y[i]) - vec[P[i]].begin() + 1);
  }
  return 0;
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int fib(int n,int num1,int num2);
int main(void)
{
	int n;
	cin >> n;
	cout << fib(n,1,0) << endl;
	return 0;
}
int fib(int n,int num1,int num2)
{
	if(n<2) return num1+num2;
	return fib(n-1,num1+num2,num1);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int S, T, N, M;
vector<vector<int>> G;

ll solve() {
    queue<P> que;
    vector<vector<ll>> d(N, vector<ll>(3, -1));
    que.push(P(S - 1, 0));
    d[S - 1][0] = 0;
    while (!que.empty()) {
        P p = que.front(); que.pop();
        int v = p.first, n = p.second;
        rep(i, G[v].size()) {
            int to = G[v][i];
            if (d[to][(n + 1) % 3] == -1) {
                d[to][(n + 1) % 3] = d[v][n] + 1;
                que.push(P(to, (n + 1) % 3));
            }
        }
    }

    if (d[T - 1][0] == -1) return -1;
    else return d[T - 1][0] / 3;
}

int main()
{
    cin >> N >> M;
    G = vector<vector<int>>(N);

    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
    }
    cin >> S >> T;

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll N; cin >> N;
	cout << (N - 1) * N / 2 << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;

  int upper= max(A1, max(A2, A3));
  int lower= min(A1, min(A2, A3));
  
  cout << upper- lower << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

N = int(input())
es = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(lambda x: int(x)-1, input().split())
    es[x].append(y)
    es[y].append(x)
depth = [None] * N
def dfs(v, p, d):
    depth[v] = d
    for u in es[v]:
        if u != p:
            dfs(u, v, d+1)
dfs(0, -1, 0)
dp = [[1] * 2 for i in range(N)]
@functools.lru_cache(maxsize=None)
def rec(v):
    d = depth[v]
    for u in es[v]:
        if d < depth[u]:
            w, b = rec(u)
            dp[v][0] *= w+b
            dp[v][1] *= w
    dp[v][0] %= mod
    dp[v][1] %= mod
    return dp[v][0], dp[v][1]
w, b = rec(0)
print((w+b)%mod)


Measured memory_bytes: 268036
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    ans = N
    for i in range(N+1):# 6^pで何円引き出すか
        count = 0
        tmp = i
        while tmp > 0:
            count += tmp % 6
            tmp //= 6
        tmp = N - i
        while tmp > 0:
            count += tmp % 9
            tmp //= 9
        ans = min(ans, count)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

signed main(){
	int s, w;
	cin >> s >> w;
	if(w >= s)cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
ll sum[maxn];
int n,m,v,p;
bool check(int x){
	if(x<=p)return 1;
	ll tmp = a[x]+m;
	if(tmp<a[p])return 0;
	ll sum = 0;
	for(int i=1;i<=n;i++){
		if(i<p)sum += m;
		else sum += min((ll)m,tmp-a[i]);
	} 
	if(sum>=1LL*m*v)return 1;
	return 0;
}
int main()
{
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n,greater<int>());
	for(int i=1;i<=n;i++)sum[i] = sum[i-1] + a[i];
	int l = 1,r = n;
	while(l!=r){
		int mid = (l+r)>>1;mid++;
		if(check(mid)) l = mid;
		else r = mid-1;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  if(m1!=m2){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }



  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int start = 0;
	int end = 0;
	bool found_start = false;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'A' && !found_start){
			start = i;
			found_start = true;
		}
		if(s[i] == 'Z') end = i;
	}
	cout << end - start + 1 << endl;;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e, f, g, h, ans, i, j, k, kazu;
	while (1) {
		cin >> kazu;
		if (kazu == 0) {
			goto a;
		}
		for (int z = 1; z <= kazu; z++) {
			ans = 0;
			i = 0;
			j = 0;
			k = 0;
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			ans = a * e - b * f - c * g - d * h;
			i = a * f + b * e + c * h - d * g;
			j = a * g - b * h + c * e + d * f;
			k = a * h + b * g - c * f + d * e;
			cout << ans << " " << i << " " << j << " " << k <<  endl;



		}
	}
a:;
}


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

// v = 9.8t
// y = 4.9t^2
// sp <= vになればok,  sp <= 9.8t  →   sp/9.8 <= tになればok?
//

int main(void){
	
	double t;
	double y;
	double n;
	double sp;
	
	
	while(scanf("%lf", &sp) != EOF){
		
		t = sp/9.8;
		y = 4.9*t*t;
		n = ceil((y+5)/5);
		
		printf("%d\n", (int)n);
		
	}
	
	return 0;
	
}

Measured memory_bytes: 632
from sys import stdin
from itertools import accumulate

li = [1,3,5,7,8,10,12]
li2 = [4,6,9,11]
li3 = [2]

x,y = [int(x) for x in stdin.readline().rstrip().split()]

if x in li  and y in li:
    print("Yes")
elif x in li2 and y in li2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long 
#define ld long double
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;



int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));

	int n;
	cin >> n;

	double arr[n];
	map<pair<int, int>, ll> mp;

	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		arr[i] *= 1e9;
		ll tmp = llround(arr[i]);
		int a = 0, b = 0;
		while(tmp % 2ll == 0ll)		tmp /= 2ll, a++;
		while(tmp % 5ll == 0ll)		tmp /= 5ll, b++;
		mp[make_pair(a, b)]++;
	}

	ll ans = 0;
	for(auto x : mp) {
		for(auto y : mp) {
			if(x.first.first + y.first.first >= 18 and x.first.second + y.first.second >= 18) {
				if(x < y)	ans += x.second * y.second;
				else if(x == y)		ans += ((x.second) * (x.second - 1) ) / 2ll;
			}
		}
	}

	cout << ans;
}



Measured memory_bytes: 5324
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main() {

    bool using_list[26];
    string S,new_S;
    cin >> S;
    new_S = S;

    for (bool &ui : using_list) ui = true;
    for (auto c : S) using_list[c-'a'] = false;

    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << "-1" << endl;
        return 0;
    }

    if(S.size() != 26){
        char add_c = '#';
        for(int ui = 0 ; ui < 26 ; ui++){
            if(using_list[ui]){
                add_c = char('a' + ui);
                break;
            }
        }
        if(add_c != '#'){
            S += add_c;
            cout << S << endl;
            return 0;
        }
    }
    else{
        while(true){
            char cb = new_S.back();
            new_S.pop_back();
            using_list[cb-'a'] = true;

            size_t point = new_S.size();
            for(int ui = 0 ; ui < 26 ; ui++){
                if(using_list[ui]) {
                    auto add_c = char('a' + ui);
                    if (S[point] < add_c) {
                        cout << new_S + add_c << endl;
                        return 0;
                    }
                }
            }
        }
    }
}

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

int main() {
  int h;
  int w;
  cin >> h >> w;
  string head="";
  for (int i=0;i<w+2;++i) head+="#";
  cout << head << endl;
  string str;
  for (int i=0;i<h;++i){
    cin >> str;
    str="#"+str+"#";
    cout << str << endl;
  }
  cout << head << endl;

}


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

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

    int x = n;
    int fx = 0;
    while (x != 0) {
        fx += x % 10;
        x /= 10;
    }

    if (n % fx == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int block; 
struct Query 
{ 
	int L, R; 
}; 
map<pair<int,int>,int> mp;
bool compare(Query x, Query y) 
{  
	if (x.L/block != y.L/block) 
		return x.L/block < y.L/block; 
	return x.R < y.R; 
} 
void queryResults(int a[], int n, Query q[], int m) 
{ 
	block = (int)sqrt(n); 
	sort(q, q + m, compare); 
	int x=0;
	int arr[600000];
	for(int i=0;i<600000;i++) arr[i]=0;
	for(int i=0;i<n;i++)
	{
	   if(arr[a[i]]==0) x++;	
	   arr[a[i]]++;	
	}
	int currL=0;
	int currR=n-1;
	//mp[make_pair(q[0].L,q[0].R)]=x;
	for (int i=0; i<m; i++) 
	{ 
		int L = q[i].L, R = q[i].R; 
		while (currL < L) 
		{ 
			if(arr[a[currL]]==1)
			 x--;
			arr[a[currL]]--; 
			currL++; 
		} 
		while (currL > L) 
		{ 
			if(arr[a[currL-1]]==0)
			 x++;
			arr[a[currL-1]]++; 
			currL--; 
		} 
		while (currR+1 <= R) 
		{ 
			if(arr[a[currR+1]]==0)
			 x++;
			arr[a[currR+1]]++; 
			currR++;
		} 
		while (currR > R) 
		{ 
			 if(arr[a[currR]]==1)
			  x--;
			 arr[a[currR]]--; 
			currR--; 
		} 
	  mp[make_pair(q[i].L,q[i].R)]=x;	
	} 
} 

// Driver program 
int main() 
{ 
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]--;
	}
	Query q[m];
	Query ns[m];
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		q[i].L=a;
		q[i].R=b;
		ns[i].L=a;
		ns[i].R=b;
	}
	queryResults(a, n, q, m); 
	//cout<<q[1].L<<" "<<q[1].R<<endl;
	for(int i=0;i<m;i++)
	 {
	 	cout<<mp[make_pair(ns[i].L,ns[i].R)]<<"\n";
	 }
	return 0; 
} 

Measured memory_bytes: 47188
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n;
  cin >> n;

  cout << (n+1)/2 << endl;

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


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

vector<int> possible_array(vector<int> array){
    //for(int i=0; i<array.size(); i++) cout << array.at(i) << " ";
    //cout << endl;
    if((int)array.size() == 1){
        return array;
    }else{
    int final = array.back();
    array.pop_back();
    vector<int> former_possible_array = possible_array(array);
    
    int s = former_possible_array.size();
    for(int i=0; i<s; i++){
        int r = former_possible_array.at(i) + final;
        former_possible_array.push_back(r);
    }
    former_possible_array.push_back(final);
    return former_possible_array;
    }

}

bool solve(vector<int> array, int n){
    int s = array.size();
    array.push_back(n);
    int i=0;
    while(array.at(i) != n) i++;
    return i != s;
}

int main(){
    int n,q;
    cin >> n;
    vector<int> A(n);
    for(int i=0; i<n; i++) cin >> A.at(i);
    cin >> q;
    vector<int> Q(q);
    for(int i=0; i<q; i++) cin >> Q.at(i);
    vector<int> p_array = possible_array(A);
    for(int i=0; i<q; i++){
        if(solve(p_array,Q.at(i))){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 15140
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊

    let (a,b) = (io.read::<i64>(),io.read::<i64>());

    if a==b {
        io.writeln("Draw");
    }
    else 
    if a == 1 || (a > b && b != 1){
        io.writeln("Alice");
    }else {
        io.writeln("Bob");}


}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k < a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else cout << a - (k - (a+b)) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 3636
import numpy as np
import sys

input = sys.stdin.readline

N,A,B = map(int,input().split())

res = 0
for x in range(1,N+1):

    _sum = 0
    for i in range(len(str(x))):
        _sum += int(str(x)[i])
    
    if _sum >= A and _sum <= B:
        res+=x

print(res)


Measured memory_bytes: 21108
#include <bits/stdc++.h>
using namespace std;
double pai = 3.14159265;

int main(){
  cout << fixed << setprecision(8);
  double a,b,C;
  cin >> a >> b >> C;
  C = C / 180 * pai;
  double S,L,h;
  S = a * b * sin(C) / 2;
  double c = sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(C));
  L = a + b + c;
  h = S * 2 / a;
  cout << S << endl << L << endl << h;
  return 0;
}



Measured memory_bytes: 3436
function Main(input) {
    var tmp = input.split("\n");
    var num = parseInt(tmp[0]);
    var ary = tmp[1].split(" ");
    
    for(var n=0; n<num; n++){
        ary[n] = BigInt(ary[n]);
    }
    
    var count = BigInt(1);
    var flg = 0;
    
    if(ary.includes(BigInt(0))){
        console.log("0");
    }else{
        for(var i=0; i<num; i++){
            count = count * ary[i];
            if(count>BigInt(Math.pow(10,18))){
                flg = 1;
                console.log("-1");
                break;
            }
        }
        if(flg===0){
            console.log(String(count));
        }
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 43784
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define X real()
#define Y imag()
#define cp(a,b)	( (conj(a)*(b)).imag() )
#define length(a) (hypot((a).imag(), (a).real()))
typedef complex<double> point;
typedef long long ll;
typedef unsigned long long ull;
double PI = 3.141592653589793;
const double EPS = 1e-9;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

int n = 3;
int t[30];

int main() {
	n = 3;
	int ans = oo;
	loop(i, 0, n - 1)
		cin >> t[i];
	do {
		int curr = 0;
		loop(i, 1, n - 1)
			curr += abs(t[i] - t[i - 1]);
		ans = min(ans, curr);
	} while (next_permutation(t, t + n));
	cout << ans;
	return 0;
}


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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

struct SegmentTree {
 private:
  int n;
  vector<ll> node;

 public:
  SegmentTree(vector<ll> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, INF);

    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
  }

  void update(int x, ll val) {
    x += (n - 1);

    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = max(node[2 * x + 1], node[2 * x + 2]);
    }
  }

  ll getmax(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];

    ll vl = getmax(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = getmax(a, b, 2 * k + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
};

int N;
std::vector<ll> h;
std::vector<ll> a;

vector<ll> dp;
SegmentTree *st;

ll getmax(ll l, ll r) { return st->getmax(l, r); }

void setvalue(ll i, ll v) {
  dp.at(i) = v;
  st->update(i, v);
}

void solve() {
  dp.resize(N + 1, 0);
  st = new SegmentTree(dp);

  rep(i, N) {
    ll tmp = getmax(0, h.at(i));
    setvalue(h.at(i), tmp + a.at(i));
  }

  cout << getmax(0, N + 1) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%lld", &N);
  h.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  a.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve();
  return 0;
}


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

int main(void) {
	int N, M; cin >> N >> M;
	vector<int> A(M);

	long long sum = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		sum += A[i];
	}

	if (N < sum) cout << -1 << endl;
	else cout << N - sum << endl;

	return 0;
}


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

int main(){
  int n,i,j,c1,c2,c3,c4,c5,c6;
  double h;

  while(cin >> n){
    c1=0;
    c2=0;
    c3=0;
    c4=0;
    c5=0;
    c6=0;

    for(i=0;i<n;i++){
      cin >> h;
      if(h<165.0)c1++;
      else if(h>=165.0 && 170.0>h)c2++;
      else if(h>=170.0 && 175.0>h)c3++;
      else if(h>=175.0 && 180.0>h)c4++;
      else if(h>=180.0 && 185.0>h)c5++;
      else if(h>=185.0)c6++;
    }

    printf("1:");
    for(i=0;i<c1;i++)printf("*");
    cout << endl;
 printf("2:");
    for(i=0;i<c2;i++)printf("*");
    cout << endl;
 printf("3:");
    for(i=0;i<c3;i++)printf("*");
    cout << endl;
 printf("4:");
    for(i=0;i<c4;i++)printf("*");
    cout << endl;
 printf("5:");
    for(i=0;i<c5;i++)printf("*");
    cout << endl;
 printf("6:");
    for(i=0;i<c6;i++)printf("*");
    cout << endl;




  }
}

Measured memory_bytes: 0
N,K = map(int,input().split())
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(1,K+1):
    if N-K+1>=i:
        print(c(N-K+1,i)*c(K-1,i-1)%1000000007)
    else:
        print(0)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char** argv) {
	int n,d;
	long b=1000000000;
	vector <int> ve;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>d;
		ve.push_back(d);
	}
    for(int i=-100;i<101;i++)
    {
    	long a=0;
    	for(int j=0;j<n;j++)
    	{
    		a+=((i-ve[j])*(i-ve[j]));
		}
		b=min(b,a);
	}
	cout<<b;
	return 0;
}

Measured memory_bytes: 3196
import collections
a = input()
N = int(a)
S = [input() for i in range(N)]

c = collections.Counter(S)

print('AC x %d' % c['AC'])
print('WA x %d' % c['WA'])
print('TLE x %d' % c['TLE'])
print('RE x %d' % c['RE'])

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

int main(){
	int A,B;
	cin >> A >> B;
	int ans=0;
	REP(i,2){
		if(A> B){
			ans += A;
			--A;
		}else{
			ans +=B;
			--B;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

bool check(vector<pll> v)
{
    int sm=0;
    for (int i = 0; i < v.size(); i++)
    {
        if(sm+v[i].first<0) return false;
        sm+=v[i].second;
    }
    return true;
}

int main()
{
    ll n,total=0;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }

    vector<pll> p, m;
    for (int i = 0; i < n; i++)
    {
        ll mi = 0, su = 0; //min,sum

        for (int j = 0; j < s[i].size(); j++)
        {
            char c = s[i][j];
            if (c == '(')
            {
                su++;
            }
            else
            {
                su--;
                mi = min(mi, su);
            }
        }
        if (su >= 0)
        {
            p.push_back(make_pair(mi, su));
        }
        else
        {
            m.push_back(make_pair(mi-su,-su));
        }
        total+=su;
    }
    sort(all(p));
    reverse(all(p));
    sort(all(m));
    reverse(all(m));


    if (check(p) && check(m) && total==0)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 65864
/*input
2 2
*/

#include <bits/stdc++.h>
#include <unistd.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}

ll fact[500001],inv[500001];

ll ncr(ll n,ll r){
    if(r>n)return 0;
    return ((fact[n]*inv[r])%M*inv[n-r])%M;
}

void solve(){
    ll i,j,k;
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    fact[0]=1,inv[0]=1;
    rep(i,1,500001){
        fact[i]=(i*fact[i-1])%M;
        inv[i]=power(fact[i],M-2,M);
    }
    rep(i,0,n+1){
        ll tmp=(((ncr(m,i)*ncr(n,i))%M*fact[i])%M*(power((ncr(m-i,n-i)*fact[n-i])%M,2,M)))%M;
        if(i%2)tmp=M-tmp;
        ans+=tmp;
        ans%=M;
    }
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}




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

using namespace std;

long long INF=1e15;

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

    while(1){
        int n;
        cin>>n;

        if(n==0)break;

        int a[30][30]={};

        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            a[x][y]=1;
        }

        int m;
        cin>>m;

        int b[30][30]={};

        int pos_x=10,pos_y=10;

        for(int i=0;i<m;i++){
            char c;
            int d;
            cin>>c>>d;
            if(c=='N'){
                for(int j=pos_y;j<=pos_y+d;j++)b[pos_x][j]=1;
                pos_y+=d;
            }
            else if(c=='S'){
                for(int j=pos_y;j>=pos_y-d;j--)b[pos_x][j]=1;
                pos_y-=d;
            }
            else if(c=='E'){
                for(int j=pos_x;j<=pos_x+d;j++)b[j][pos_y]=1;
                pos_x+=d;
            }
            else{
                for(int j=pos_x;j>=pos_x-d;j--)b[j][pos_y]=1;
                pos_x-=d;
            }
        }
        
        int ans=0;

        for(int i=0;i<=20;i++){
            for(int j=0;j<=20;j++){
                if(a[i][j]==1&&b[i][j]==1)ans++;
            }
        }

        if(ans==n)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    }
}


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

using namespace std;

const int N = 1e5 + 5;

int n;
long long a[N], b[N];

int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", a+i);
    sum += a[i];
  }
  long long con = 1LL * n * (n + 1)/2;
  if (sum % con) {
    puts("NO");
    return 0;
  }
  long long cur = sum/con;
  bool ok = 1;
  for (int i = 0; i < n; i++)
    if (a[i] < cur)
      ok = 0;
  if (!ok) {
    puts("NO");
    return 0;
  }
  a[n] = a[0];
  long long all = 0;
  for (int i = 0; i < n; i++) {
    long long diff = a[i+1] - a[i] - cur;
    diff *= -1;
    if (diff < 0) {
      puts("NO");
      return 0;
    }
    if (diff % n) {
      puts("NO");
      return 0;
    }
    all += diff/n;
  } 
  if (all != cur) {
    puts("NO");
    return 0;
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int a[10][10];
main()
{
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
			if(j!=1 && a[i][j]-a[i][j-1]!=a[1][j]-a[1][j-1])return cout<<"No",0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

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

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	char c;
	scanf("%c", &c);
	if ( c == toupper(c) )
		printf("A\n");
	else
		printf("a\n");
	return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
   char ch[1000];
   int len,i;
   scanf("%s",ch);
   len=strlen(ch);
   if(ch[len-1]=='s')
   {
        printf("%s",ch);
        printf("es");
   }

   else
   {
       printf("%s",ch);
        printf("s");
   }


    return 0;

}


Measured memory_bytes: 1736
n = int(input())
x = []
y = []
sum = 0
for i in range(n):
    a,b = map(str,input().split())
    x.append(float(a))
    y.append(b)
for i in range(n):
    if y[i] == "BTC":
        sum += x[i] * 380000
    else:
        sum += x[i]
print(sum)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		//int[] a = new int[n];
		/*
		for(int i =0 ; i<n;i++) {
			a[i] = sc.nextInt();
		}
		*/
		
		System.out.println(n*n*n);
	}
}

Measured memory_bytes: 22740
import sys

num, yen = map(int, input().split())
a = yen//10000
if a > num:
    print(-1, -1, -1)
    sys.exit()

for i in range(a+1):
    yen_rest = yen - 10000*i
    num_rest = num - i

    b = yen_rest//5000
    if b <= num_rest:
        for j in range(b+1):
            yen_rest = yen - 10000*i - 5000*j
            num_rest = num - i - j

            if yen_rest == 1000*num_rest:
                print(i, j, num_rest)
                sys.exit()

print(-1, -1, -1)


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n,z,w;
int a[maxn];
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n>>z>>w;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }

  if (n==1) out(abs(a[n-1]-w));

  int ans = max(abs(a[n-1]-w), abs(a[n-2]-a[n-1]));
  cout<<ans<<endl;  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n;
    cin>>n;
    auto b=vector<int>(n+5);
    
    auto an =vector<int>(n+5);
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for(ll i=n;i>=1;i--)
    {
        auto sum=0;
        for(ll j=i+i;j<=n;j+=i)
        {
            sum+=an[j];
        }
        if(sum%2!=b[i])
        {
            an[i]=1;
        }
    }
    cout<<count(an.begin(),an.end(),1)<<endl;
    for(ll i=1;i<=n;i++)
    {
        if(an[i])
        {
            cout<<i<<" ";
        }
    }
   
    

}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int res=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        int t = i*500+j*100+k*50;
        if(t==x)res++;
      }
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define mod 1000000007


int main(){

	int N;
	int L[200];
	cin >> N;
	for (int i = 0; i < 2 * N; i++)
		cin >> L[i];

	sort(L, L + 2 * N);
	int r = 0;
	for (int i = 0; i < N; i++)
		r += L[2 * i];

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){

  ll D,T,S;
  cin >> D >> T >> S;
  if(S*T>=D){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



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

  if(abs(b-a)%2==1)cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int N,p,q,r;
  cin >> N;
  vector<int> P(N),Q(N),R(N);
  for(int i=0;i<N;i++){
    cin >> P[i];
    R[i] = i+1;
  }
  for(int i=0;i<N;i++){
    cin >> Q[i];
  }
  do{
    if(P == R){
      p = r;
    }
    if(Q == R){
      q = r;
    }
    r++;
  }while(next_permutation(R.begin(),R.end()));
  cout << abs(p-q) << endl;
  
  return 0;
}


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

int main(){
  int a,b,i,c=0;
  cin>>a>>b;
  for(i=0;a+i<=b;i++){
    c+=((a+i)/10000==((a+i)%10)&&((a+i)%10000)/1000==((a+i)%100)/10);
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
def lcm(a, b):
    return a // gcd(a, b) * b

A, B, C, D = map(int, input().split())

L = lcm(C, D)

def f(X):
    return X - (X//C + X//D - X//L)

num = f(B) - f(A-1)

print(num)


Measured memory_bytes: 3060