akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R0, C0, R1, C1;
    cin >> R0 >> C0 >> R1 >> C1;
    Combination cmb(R1 + C1 + 5);
    ll ans = 0;
    for (ll r = R0; r <= R1; ++r) {
        ans += (MOD + cmb.get(r + C1 + 1, C1) - cmb.get(r + C0, C0 - 1)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>
#include<stdlib.h>
#define N 2000001
#define Max 10000
int n;
void count(short *, short *, int);
int main()
{
  unsigned short *A,*B;
  int i,k=Max;
  
  scanf("%d",&n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0; i<n; i++){
    scanf("%hd",&A[i+1]);
  }

  count(A,B,k);

  for(i=1; i<=n; i++){
    if(i>1) printf(" ");
    printf("%hu",B[i]);
  }
  
  printf("\n");
  
  return 0;
  
}

void count(short *A,short *B,int k)
{
  int C[Max+1];
  int i,j;

  for(i=0; i<=k; i++){
    C[i] = 0;
  }

  for(j=1; j<=n; j++){
    C[A[j]]++;
  }

  for(i=1; i<=k; i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

}
  
  

Measured memory_bytes: 8460
n, m = [int(x) for x in input().split()]

ps = [[] for i in range(n)]
for i in range(m):
    p, y = [int(x) for x in input().split()]
    ps[p-1].append((y, i))

res = [None] * m
for i, ms in enumerate(ps):
    ms.sort()
    for j, x in enumerate(ms):
        res[x[1]] = str(i+1).zfill(6) + str(j+1).zfill(6)

for i in range(m):
    print(res[i])


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int a,b;cin >> a >> b;
    cout << a*b << "\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    string s;
    cin >> s;

    for (auto c : s) {
        cout << 'x';
    }

    cout << endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    char b, ans;
    cin >> b;
    if(b == 'A') ans = 'T';
    else if(b == 'T') ans = 'A';
    else if(b == 'C') ans = 'G';
    else ans = 'C';
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
i = int(input())
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(K[i-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int main() {
	int m;
	bool first = true;
	while(cin >> m, m) {
		if(!first) {
			cout << endl;
		}
		first = false;
		int coins[4], back[4];
		rep(i,4) cin >> coins[i];
		int b = coins[0]*10 + coins[1]*50 + coins[2]*100 + coins[3]*500 - m;
		const int base[4] = {10, 50, 100, 500};
		for(int i=3; i>=0; i--) {
			back[i] = b / base[i];
			b -= base[i] * back[i];
		}
		rep(i,4) {
			coins[i] = max(0, coins[i]-back[i]);
			if(coins[i]>0)
				cout << base[i] << ' ' << coins[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if(H==0&W==0){
            break;
        }
        else{
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    cout << "#" << flush;
                }
                cout << endl;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,n;
  cin>>h>>n;
  int total=0;
  for ( int i=0;i<n;i++){
int aa;
    cin>>aa;
    total+=aa;
  }
  if ( total>=h)
    cout<<"Yes\n";
  else
    cout<<"No\n";
 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,k, x, y; cin >> n >> k >> x >> y;
    int ans =0;
    if(k < n) {
        ans += k * x + (n - k) * y;
    }else {
        ans += n * x;
    }
    cout << ans << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  set<int> div;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      div.insert(i);
      div.insert(M/i);
    }
  }
  for (auto e :div) {
    if (e >= N) {
      cout << M/e << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int H, W;
vector<vector<char > > board;

vector<vector<int > > d;

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

int main(){
	cin >> H >> W;
	board.assign(H, vector<char >(W, ' '));
	d.assign(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < W; j++) {
			board[i][j] = s[j];
		}
	}


	queue<P> que;
	que.push(P(0, 0));
	d[0][0] = 0;
	// forward
	while (que.size()) {
		P p = que.front(); que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W&&board[nx][ny] == '.'&&
				d[nx][ny] == -1) {
				d[nx][ny] = d[p.first][p.second] + 1;
				que.push(P(nx, ny));
			}
		}
	}
	if (d[H - 1][W - 1] == -1) {
		cout << -1 << endl;
		return 0;
	}


	stack<P> st;
	int distance = d[H - 1][W - 1];
	d[H - 1][W - 1] = 0;
	P cur(H - 1, W - 1);
	// backward
	while (true) {
		if (distance == 1)break;
		for (int i = 0; i < 4; i++) {
			int nx = cur.first + dx[i];
			int ny = cur.second + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W&&board[nx][ny] == '.'&&
				d[nx][ny] == distance-1) {
				distance--;
				cur = P(nx, ny);
				d[nx][ny] = 0;
				break;
			}
		}
	}

	int score = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (d[i][j] == 0)continue;
			else if (d[i][j] == -1) {
				if (board[i][j] == '.')score++;
			}
			else score++;
		}
	}
	cout << score << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

# Aの重複組み合わせ結果配列のリスト
A_list = list(itertools.combinations_with_replacement(range(1, M+1), N))
ans = 0
for A in A_list:
  score = 0
  for a, b, c, d in abcd:    
    if A[b-1] - A[a-1] == c:
      score += d
  ans = max(ans, score)
print(ans)

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int h, w;
int a[80][80];
int b[80][80];

const int kMax = 80 * 80 * 2;
using bs = bitset<kMax * 2 + 1>;
bs dp[81][81];

int main() {
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  dp[0][1][kMax] = 1;
  rep(i, h) rep(j, w) {
    int d = abs(a[i][j] - b[i][j]);
    bs b = (dp[i][j + 1] | dp[i + 1][j]);
    dp[i + 1][j + 1] = (b << d) | (b >> d);
  }
  rep(i, 80 * 80 * 40 + 1) if (dp[h][w][i + kMax]) {
    wt(i);
    return 0;
  }
}


Measured memory_bytes: 23972
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n, Q;
    cin >> n >> Q;
    vector<int> v[n];
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<ll> add(n, 0);
    while(Q-- > 0){
        int p, x;
        cin >> p >> x;
        p--;
        add[p] += x;
    }
    vector<bool> visit(n, 0);
    queue<int> q;
    visit[0] = true;
    for(int j : v[0])   q.push(j), visit[j] = true, add[j] += add[0];
    while(!q.empty()){
        int now = q.front();    q.pop();
        for(int child : v[now]){
            if(!visit[child]){
                q.push(child);
                visit[child] = true;
                add[child] += add[now];
            }
        }
    }
    for(int i = 0; i < n; i++)  cout << add[i] << " \n"[i+1==n];
    return 0;
}


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

const int nCk_MAX = 510000;
ll fac[nCk_MAX], finv[nCk_MAX], inv[nCk_MAX];
bool Pre = true;
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < nCk_MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com(int n, int k) {
    if (Pre) {
        cominit();
        Pre = false;
    }
    if (n < k)return 0;
    if (n < 0 || k < 0)return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    init();

    ll n, a, b, k; cin >> n >> a >> b >> k;
    ll ans = 0;
    eFOR(i, 0, n) {
        ll rem = k - a * ll(i);
        if (rem < 0 || rem % b != 0)continue;
        (ans += com(n, i) * com(n, rem / b) % MOD) %= MOD;
    }
    cout << ans << "\n";
}

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

int main(){
  int n, k; cin >> n >> k;
  int p[n];
  rep(i, n){
    cin >> p[i];
    p[i]--;
  }
  ll c[n];
  rep(i, n){
    cin >> c[i];
  }

  ll ans = -1e18;

  rep(si, n){
    int next = p[si];
    ll sum = 0;
    vector<int> s;
    while(1){
      s.push_back(c[next]);
      sum += c[next];
      if(next == si) break;
      next = p[next];

    }
    //cout << sum << endl;
    int l = s.size();
    ll t = 0;
    rep(i, l){
      if(i + 1 > k) break;
      t += s[i];
      ll now = t;
      if(sum > 0){
        ll e = (k - (i + 1)) / l;
        now += e * sum;
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;




  return 0;
}


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

using namespace std;

const int MAXN = 1000100;

int pr[MAXN];
vector<int> prim;

void build(int n) {
	for (int i = 2; i < MAXN; ++i) {
		if (!pr[i]) {
			prim.push_back(i);
			for (int j = i + i; j < MAXN; j += i) {
				pr[j] = 1;
			}
		}	
	}
}


int main() {
	int n;
	scanf("%d", &n);
	
	build(n);
	
	int ans = *lower_bound(prim.begin(), prim.end(), n);
	printf("%d\n", ans);
	
				
		
	return 0;
}

Measured memory_bytes: 4732
n, x = map(int, input().split())
ls = list(map(int, input().split()))
res = 0
for i in range(n):
    a = ls[i]
    ls[i] = min(x, a)
    res += max(0, a - x)
for i in range(1, n):
    s = ls[i - 1] + ls[i]
    ls[i] -= max(0, s - x)
    res += max(0, s - x)
print(res)

Measured memory_bytes: 14252
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Jan  3 16:51:59 2019
//
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var Q int
	fmt.Scan(&Q)

	table := make([]bool, 1e5+1)
	for i := range table {
		table[i] = true
	}
	table[1] = false

	for i := 2; i*i <= 1e5; i++ {
		if table[i] {
			for j := i + i; j <= 1e5; j += i {
				table[j] = false
			}
		}
	}

	likes := make([]int, 1e5+1)
	for i := range likes {
		if table[i] && table[(i+1)/2] {
			likes[i]++
		}
	}

	for i := range likes {
		if i+1 < len(likes) {
			likes[i+1] += likes[i]
		}
	}

	for i := 0; i < Q; i++ {
		var l, r int
		fmt.Sscan(nextLine(), &l, &r)
		fmt.Println(likes[r] - likes[l-1])
	}
}


Measured memory_bytes: 5888
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int();
        int tmp = N/2;
        if (N % 2 == 1) {
            tmp ++;
        }

        double ret = (double)tmp/(double)N;
        Console.WriteLine(ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define ll long long
using namespace std;
static const int INF = (1 << 21);

int maxi = 0,save=0;
int N;
int s[100], f[100] = { 0 };


int main() {
	
	int N, K;
	cin >> N >> K;
	int d[9];
	for (int i = 0;i < K;i++) {
		cin >> d[i];
	}
	sort(d, d + K);

	while (1) {
		int f = 0;
		string s = to_string(N);
		for (int i = 0;i < K;i++) {
			for (int j = 0;j < s.length();j++) {
				if ((int)(s[j])-48 == d[i]) {
					f = 1;
					N++;
					break;
				}
			}
		
		}
		if (f == 0) {
			cout << N << endl;
			break;
		}
	}
	return 0;
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define vi              vector<int>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 2e6 + 10;


int n;

void Solve(){
    cin >> n;
    cout << n * n * n;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
    return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  vector<int> a(5);
  REP(i, 5) cin >> a[i];
  sort(ALL(a));
  RREP(i, 5) {
    if (i != 4) cout << " ";
    cout << a[i];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3148
N, M = map(int, input().split())
SC = [input().split() for _ in range(M)]
ans = ["0"] * N
for s, c in SC:
  # check duplicated s
  if ans[int(s) - 1] != "0" and ans[int(s) - 1] != c:
    print(-1)
    exit()
  # check impossible case
  if N > 1 and s == "1" and c == "0":
    print(-1)
    exit()
  ans[int(s) - 1] = c
# replace head
if ans[0] == "0" and N > 1:
  ans[0] = "1"
print("".join(ans))

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

int main() {
	int64_t n,tmp=0,count=0;
	cin >> n;
	vector<char>ss(n*10);
	vector<string>s(n);
	for(int i=0;i<n*10;i++) cin >> ss.at(i);
	for(int i=0;i<n;i++) {
		sort(ss.begin()+10*i,ss.begin()+10*(i+1));
		for(int j=0;j<10;j++) s.at(i)+=ss.at(10*i+j);
  }
  sort(s.begin(),s.end());
  int i=0,j=0;
  while(i<n){
    j=i+1;
	  tmp=0;
  	while(j<n){
  	 if(s.at(i)==s.at(j)){
  	 	tmp++;
  	 	j++;
  	 }
  	 else{
  	 	 break;
  	 }
  	}
		count+=((tmp+1)*tmp)/2;
	  i=j;
	}
 	cout << count <<endl;
}


Measured memory_bytes: 8320
K, N = map(int, input().split())
A_li = list(map(int, input().split()))
max_dif = K - A_li[N - 1] + A_li[0]
for i in range(N - 1) :
    diff = A_li[i + 1] - A_li[i]
    if diff > max_dif :
        max_dif = diff
print(K - max_dif)


Measured memory_bytes: 26692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    string s;cin>>s;
    if(s=="SUN")co(7);
    if(s=="MON")co(6);
    if(s=="TUE")co(5);
    if(s=="WED")co(4);
    if(s=="THU")co(3);
    if(s=="FRI")co(2);
    if(s=="SAT")co(1);

}

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

int solve(int n, int l, int r) {
    vector<int> A(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    for (int year = l; year <= r; year++) {
        bool flag = false;
        for (int i = 0; i < n; i++) {
            if (year % A[i] == 0) {
                if (i % 2 == 0)
                    ans++;
                flag = true;
                break;
            }
        }
        if (!flag && n % 2 == 0) ans++;
    }
    return ans;
}

int main(void) {
    int n, l, r;
    vector<int> ans;
    while (1) {
        cin >> n >> l >> r;
        if (!n && !l && !r) break;
        ans.push_back(solve(n, l, r));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3104
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    regex re("(dream|dreamer|erase|eraser)*");
    cout << (regex_match(s, re) ? "YES" : "NO") << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 33872
#include <iostream> 
#include <math.h>  
using namespace std; 

void findNumberOfDigits(long long n, int base) 
{ 
    int dig = (int)(floor( log(n) / log(base)) + 1);        
    cout << dig;
}   

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

    findNumberOfDigits(n, base); 
    return 0; 
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.println(a.substring(0,1) + b.substring(0,1) + c.substring(0,1));

	}
}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

//Binary exponent
ll Bin_pow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}

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

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	char t;
	
	cin>>t;
	
	if(t>=97)
	    cout<<"a"<<"\n";
	    else
	        cout<<"A"<<"\n";
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    //変数xを宣言
    int x;
    //変数Xに値を入力する
    x = sc.nextInt();
    //変数Xの3乗を値を出力する
    System.out.println(x * x * x);
    
    }
}


/*覚えよう！！

・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要

・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku

*/


/*前回の内容！！

・println・・・画面に出力するときに使用
・文字列の表示・・・"〇〇〇の間に入力"ことが約束

*/


Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,m,q;cin>>n>>m>>q;
	//imos
	vector<vector<ll>> d(n + 1,vector<ll>(n + 1,0));
	ll l,r;
	for(int i = 0; i < m; i++) {
		cin>>l>>r;
		d[l][r]++;
	}

	vector<vector<ll>> c(n+1,vector<ll>(n+1,0));
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			c[i][j] = c[i][j - 1] + d[i][j];	
		}
	}

	for(int i = 0; i < q; i++) {
		ll P,Q;cin>>P>>Q;
		ll sum = 0;
		for(int i = P; i <= Q; i++) {
			sum += c[i][Q] - c[i][P - 1];
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int q;
	cin>>q;
	for (int i = 0; i < q; ++i)
	{
		long long a[2];
		cin>>a[0]>>a[1];
		sort(a,a+2);
		if (a[0]==a[1]||a[0]+1LL==a[1])
		{
			cout<<2LL*(a[0]-1LL)<<endl;
			continue;
		}
		long long ok=0LL,ng=a[1];
		while (ng-ok>1LL)
		{
			long long mid=(ok+ng)/2LL;
			if (mid*mid<a[0]*a[1])
			{
				ok=mid;
			}
			else
			{
				ng=mid;
			}
		}
		if (ok*(ok+1LL)>=a[0]*a[1])
		{
			cout<<2LL*(ok-1LL)<<endl;
		}
		else
		{
			cout<<2LL*ok-1LL<<endl;
		}
	}
	return 0;
}


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

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;
 
int main (){
  int a,b,c;
  cin >> a >> b >> c;

  rep(i,1,101){
    if((i*a)%b == c){
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
#define _USE_MATH_DEFINES

int main() {
	int n,tmp;
	int min = 1e9;
	int max = -1e9;
	long long sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		sum += tmp;
		if (tmp < min)
			min = tmp;
		if (tmp > max)
			max = tmp;
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1164
from collections import defaultdict
d = defaultdict(int)
a = int(input())
d[a] += 1

for i in range(10**6):
    a = a//2 if (a%2 == 0) else a*3+1
    d[a] += 1
    if (d[a] > 1):
        print(i+2)
        break



Measured memory_bytes: 3316
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<998244353>;

//--------------------------- Solve ---------------------------//

mint dp[3005][3005];

void solve() {
    int A, B, C, D; cin >> A >> B >> C >> D;

    dp[0][0] = 1;
    for (int i = 1; i <= C-A; i++) dp[i][0] = dp[i-1][0] * B;
    for (int j = 1; j <= D-B; j++) dp[0][j] = dp[0][j-1] * A;

    for (int i = 1; i <= C-A; i++) {
        for (int j = 1; j <= D-B; j++) {
            dp[i][j] = dp[i-1][j] * (B+j) + dp[i][j-1] * (A+i) - dp[i-1][j-1] * (A+i-1) * (B+j-1);
            //print(i, j, dp[i][j]);
        }
    }

    mint ans = dp[C-A][D-B];

    cout << ans << '\n';

}

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

    solve();

    return 0;
}

Measured memory_bytes: 74040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][][] rooms = new int[4][3][10];
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=1; i<=n; i++){
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			
			rooms[b-1][f-1][r-1] += v;
		}
		
		for(int i=0; i<4; i++){
			for(int j=0; j<3; j++){
				for(int k=0; k<10; k++){
					System.out.print(" " + rooms[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3){
				System.out.println("####################");
			}
		}
		
	}

}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;


int32_t main(){
	boost;

    //code
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0 ; i < n-5 ; ++i){
		if(s[i] == 'e' and s[i+1] == 'r' and s[i+2] == 'a' and s[i+3] == 's' and s[i+4] == 'e' and s[i+5] == 'r'){
			s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = s[i+5] = '*';
		}
	}


	for(int i = 0 ; i < n-4 ; ++i){
		if(s[i] == 'e' and s[i+1] == 'r' and s[i+2] == 'a' and s[i+3] == 's' and s[i+4] == 'e'){
			s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = '*';
		}
	}



	for(int i = 0 ; i < n-6 ; ++i){
		if(s[i] == 'd' and s[i+1] == 'r' and s[i+2] == 'e' and s[i+3] == 'a' and s[i+4] == 'm' and s[i+5] == 'e' and s[i+6] == 'r'){
			s[i+6] = s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = s[i+5] = '*';
		}
	}

	for(int i = 0 ; i < n-4 ; ++i){
		if(s[i] == 'd' and s[i+1] == 'r' and s[i+2] == 'e' and s[i+3] == 'a' and s[i+4] == 'm'){
			s[i] = s[i+1] = s[i+2] = s[i+3] = s[i+4] = '*';
		}
	}

	for(int i = 0 ; i < n ; ++i){
		if(s[i] != '*'){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A  = [int(i) for i in input().split()]
    ans = 0
    max = A[0]
    for a in A:
        if max > a:
            ans += max-a
        else:
            max = a
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105208
#include <bits/stdc++.h>
#define MAXN 100000
using namespace std;
int H[MAXN+2];


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

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll i,j,k,l,m,n;
	cin>>n>>m;
	cout<<n*m/__gcd(n, m);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N);
  vector<ll> w(N);
  rep(i,N)cin >> v[i];
  int s;
  ll sum;
  ll mini;
  ll ans = 0;

  sort(all(v));
  s = 0;
  rep(i,N){
    w[i] = v[s];
    if(s>N/2) s = N - s;
    else s = N - s - 1;
  }
  sum = 0;
  mini = MAX_LL;
  rep(i,N){
    sum += abs(w[(i+1)%N] - w[i]);
    mini = min(mini,abs(w[(i+1)%N] - w[i]) );
  }
  ans = max(ans,sum-mini);

  reverse(all(v));
  s = 0;
  rep(i,N){
    w[i] = v[s];
    if(s>N/2) s = N - s;
    else s = N - s - 1;
  }
  sum = 0;
  mini = MAX_LL;
  rep(i,N){
    sum += abs(w[(i+1)%N] - w[i]);
    mini = min(mini,abs(w[(i+1)%N] - w[i]) );
  }
  ans = max(ans,sum-mini);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

int N, x;
long long ans;
int count[100010];
const long long MOD = 1000000007;

inline int max(int a, int b) {
	return a > b ? a : b;
}

int main() {
	scanf("%d", &N);
	ans = 1LL;
	int stocked = 0;
	int pen = 0;
	for(int i=1; i<=N; i++) {
		scanf("%d", &x);
		int want;
		want = stocked*2;
		if(x > want) {
			stocked ++;
		}
		if(x < want) {
			pen ++;
		}
		//printf("%d:%d %d\n", x, pen, i-pen);
		count[pen] ++;
		if(x == want) {
			pen ++;
		}
	}
	int curr = 0;
	for(int i=0; i<N; i++) {
		curr += count[i];
		//printf("i=%d: %d\n", i, curr-i);
		ans = ans * (curr-i) % MOD;
	}
	printf("%d\n", (int)ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 300005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;

int n;
ll a[maxn];
ll cnt[62];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        for (int j = 0; j < 62; j++)
            if (a[i] >> j & 1)
                cnt[j]++;
    }
    ll ans = 0;
    for (int i = 0; i < 62; i++)
    {
        ll times = cnt[i] * (n - cnt[i]) % mod;
        ll num = (1ll << i) % mod;
        ans = (ans + times * num) % mod;
    }
    cout << ans << endl;

    return 0;
}

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

a, b = A[0], A[0]
ct = 0
j = 0
flag = True
for i in range(N):
    while a == b and j < N:
        j += 1
        if j == N:
            break
        a += A[j]
        b ^= A[j]
    ct += j-i
    a -= A[i]
    b ^= A[i]
print(ct)


Measured memory_bytes: 99796
function main(input) {
    const args = input.split(' ');
    var a = parseInt(args[0], 10);
    var b = parseInt(args[1], 10);

    if ((a * b) % 2 == 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
package main 

import (
        "fmt"
)


func main () {
        var x, y, z, an int 
        fmt.Scan(&x,&y,&z)
        x = x - z 
        for {
                x = x - z - y
                if x > 0 {
                        an += 1
                }  else if x == 0 {
                        an += 1
                        break
                }  else if x < 0 {
                        break
                }
        }
        fmt.Println(an)
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long D;
    cin>>D;
    D=25-D;
    
    cout<<"Christmas";
    for(int i=0;i<D;i++){
        cout<<" Eve";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int M,T,P,R;
struct team
{
	int id,ac,miss;
	team(int id,int ac,int miss):id(id),ac(ac),miss(miss){}
	bool operator <(const team &T)const{
		if(ac!=T.ac)return ac >T.ac;
		if(miss!=T.miss)return miss <T.miss;
		return id >T.id;
	}
	bool operator ==(const team &T)const{
		return (ac==T.ac&&miss ==T.miss);
	}
};
int main(){
	while(cin>>M>>T>>P>>R,M||T||P||R){
		vector<team> data;
		int failed[400][20]={{0}};
		rep(i, T)data.push_back(team(i+1,0,0));
		rep(i,R){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			t--;
			if(j==0){
				data[t].ac++;
				data[t].miss+=(m+failed[t][p]);
			}else{
				failed[t][p]+=20;
			}
		}
		sort(all(data));
		rep(i, T){
			cout <<data[i].id;
			if(i==T-1){
				cout <<endl;
			}else{
				cout <<((data[i]==data[i+1])?"=": ",");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1240
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n, q = readline() |> split |> parseArray
  # e = Array{Set{Int}, 1}(undef, n)
  # e = Array{Set{Int}, 1}(n)
  # for i in 1:n
  #   e[i] = Set{Int}()
  # end
  e = [Int[] for _ in 1:n]
  for i in 1:n-1
    a, b = readline() |> split |> parseArray
    append!(e[a], b)
    append!(e[b], a)
  end

  v = zeros(Int, n)
  for i in 1:q
    p, x = readline() |> split |> parseArray
    v[p] += x
  end

  function loop(i, j)
    for k in e[i]
      k == j && continue
      v[k] += v[i]
      loop(k, i)
    end
  end
  loop(1, 0)

  # i = 1
  # j = 1
  # i′ = 0
  # j′ = 0
  # e′′ = 0
  # @label loop
  # e′ = setdiff(e[i], [j])
  # if isempty(e′)
  #   i = i′
  #   j = j′
  #   e′ = e′′
  #   @goto next
  # end
  # for k in e′
  #   v[k] += v[i]
  #   i′ = i
  #   j′ = j
  #   e′′ = e′
  #   i = k
  #   j = i
  #   @goto loop
  #   @label next
  # end

  # print(v[1])
  # for i in 2:n
  #   print(" ")
  #   print(v[i])
  # end
  # println("")
  println.(v)
end

main()


Measured memory_bytes: 312296
#include <iostream>
#include <ios>
#include <iomanip>
using namespace std;

int main(void){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;

    int square[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        square[i][j]=0;
      }
    }
    int x=n/2;
    int y=n/2+1;
    square[y][x]=1;
    for(int i=2;i<=n*n;i++){
      x=(x+1)%n;
      y=(y+1)%n;
      while(square[y][x]!=0){
        x=(x+n-1)%n;
        y=(y+1)%n;
      }
      square[y][x]=i;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        cout<<right<<setw(4)<<square[i][j];
      }
      cout<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;




typedef long long LL;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, K;
  cin >> N >> K;
  string s; cin >> s;
  s[K - 1] = tolower(s[K - 1]);
  cout << s << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    const int mod=1e9+7;
    ll n,k,a[2005],ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        int t=0;
        for(int j=i;j<=n;j++)
            if(a[i]>a[j])
                t++;
        ans+=t*k;
        t=0;
        for(int j=1;j<=n;j++)
            if(a[i]>a[j])
                t++;
        ans+=(k-1)*k/2%mod*t;
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
# 幅優先で始点をメモ
from collections import deque, defaultdict


N, M = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)

visited = [False]*N
q = deque([0])  # 始まりのノード
visited[0] = True
ans = defaultdict(int)
while len(q):
    # vは数字, 親のノードのインデックス
    v = q.popleft()
    color = 1

    for e in tree[v]:
        if visited[e]:  # 到達済みなら次のノードへ
            continue
        visited[e] = True
        ans[e] = v
        q.append(e)

if False in visited:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i]+1)


Measured memory_bytes: 105456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

vector<bool> visited;
vector<int> dist;
vector<int> sum(2005, 0);

Graph G;

void bfs(int s) {
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    rep(i, G[x].size()) {
      if (visited[G[x][i]]) continue;
      visited[G[x][i]] = true;
      dist[G[x][i]] = dist[x] + 1;
      que.push(G[x][i]);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ///////////////////////////////////////
  int n, x, y;
  cin >> n >> x >> y;
  G.resize(n);
  --x;
  --y;
  G[x].push_back(y);
  G[y].push_back(x);
  rep(i, n - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  rep(i, n) {
    visited.resize(n);
    dist.resize(n);
    rep(j, n) {
      visited[j] = false;
      dist[j] = 0;
    }
    visited[i] = true;
    bfs(i);
    rep(j, n) { sum[dist[j]]++; }
  }
  repi(i, 1, n) { cout << sum[i] / 2 << endl; }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  int a[4],i;
int main(){
  for(;i<4;i++)cin>>a[i];
  sort(a,a+4);
  if(a[0]==a[1]&&a[2]==a[3])cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 3104