akhauriyash/Code-Regression huggingface dataset:
def F(a,b):
 A=len(a)
 r=[all([len(set([a[i+j],b[j],'?']))<3for j in range(min(A-i,len(b)))])for i in range(A)]
 return r+[1]
def Z(ix):
 i1,i2,i3=ix;ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3];A,B,C=map(len,[S[i]for i in ix]);q=A+B+C
 for l in range(A+1):
  if ab[l]!=0:
   for r in range(l,A+B+1):
    if (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in'abc']
T=range(3);M=[[F(S[i],S[j])for j in T]for i in T]
print(min([Z(i)for i in[(0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,1,0),(2,0,1)]]))

Measured memory_bytes: 56284
#include <stdio.h>
#include <iostream>

using namespace std;

void printArray(int A[], int N) {
	for(int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N-1] << endl;;
}

void insertionSort(int A[], int N) {
	for (int i = 1; i < N; i++) {
		int val = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > val) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = val;
printArray(A, N);
	}
}


int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	printArray(A, N);
	insertionSort(A, N);

	return 0;
}

Measured memory_bytes: 3080
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << 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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<ll> a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        b.push_back(temp);
    }
    //sort(ALL(a));
    //sort(ALL(b));
    ll ad=0;
    ll bd=0;
    for (int i = 0; i < n; i++)
    {
        if(a[i]>b[i]){
            bd+=a[i]-b[i];
        }
        else{
            ad+=(b[i]-a[i])/2;
        }
    }
    if(ad<bd){
        return no,0;
    }
    yes;
}



Measured memory_bytes: 512
class Dice:
    def __init__(self, pip):
        self.pip = pip
    
    def move(self, dir):
        if str(dir) == 'E':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[3], self.pip[0], self.pip[5], self.pip[2]
        elif str(dir) == 'W':
            self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \
                self.pip[2], self.pip[5], self.pip[0], self.pip[3]
        elif str(dir) == 'N':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[1], self.pip[5], self.pip[0], self.pip[4]
        elif str(dir) == 'S':
            self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \
                self.pip[4], self.pip[0], self.pip[5], self.pip[1]


n = int(input())
dices = [Dice(list(map(int, input().split()))) for _ in range(n)]
check = "Yes"

for i in range(len(dices)-1):
    for j in range(i+1, len(dices)):
        tmp = Dice(dices[j].pip)
        for x in "EEENEEENEEESEEESEEENEEEN":
            if dices[i].pip == tmp.pip:
                check = "No"
                break
            tmp.move(x)
print(check)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 300000+5
using namespace std;

ll a[MAX],b[MAX],c[MAX];
map<ll,ll> smax;
map<ll,ll> smin;
typeof(smax.begin()) it;

int main()
{
	clr(a); clr(b); clr(c);
	ll n;
	sl(n);
	rep(i,0,3*n)
	sl(a[i]);
	ll sum=0;
	rep(i,0,n)
	{
		it=smax.find(a[i]);
		sum+=a[i];
		if(it==smax.end())
			smax.insert(mp(a[i],1ll));
		else
			it->S++;
	}
	b[n-1]=sum;
	rep(i,n,2*n)
	{
		it=smax.begin();
		if(it->F > a[i])
		{
			b[i]=sum;
			continue;
		}

		sum -= it->F;
		if(it->S==1)
			smax.erase(it);
		else
			it->S--;

		it=smax.find(a[i]);
		sum+=a[i];
		if(it==smax.end())
			smax.insert(mp(a[i],1ll));
		else
			it->S++;

		b[i]=sum;
	}

	reverse(a,a+3*n);
	sum=0;

	rep(i,0,n)
	{
		it=smin.find(a[i]);
		if(it==smin.end())
			smin.insert(mp(a[i],1ll));
		else
			it->S++;
		sum+=a[i];
	}

	c[n-1]=sum;
	rep(i,n,2*n)
	{
		it=smin.end();
		it--;
		if(it->F < a[i])
		{
			c[i]=sum;
			continue;
		}


		sum -= it->F;
		if(it->S==1)
			smin.erase(it);
		else
			it->S--;


		it=smin.find(a[i]);
		sum+=a[i];
		if(it==smin.end())
			smin.insert(mp(a[i],1ll));
		else
			it->S++;

		c[i]=sum;
	}

	//return 0;

	reverse(c,c+3*n);
	ll ans=-INF;
	rep(i,n-1,2*n)
		ans=max(ans,b[i]-c[i+1]);
	
	prll(ans);

	/*rep(i,0,3*n)
	printf("%3lld",b[i]);
	printf("\n");
	rep(i,0,3*n)
	printf("%3lld",c[i]);*/
	return 0;
}

Measured memory_bytes: 19712
def main():
    year, month, day = map(int, input().strip().split('/'))

    if year < 2019:
        print('Heisei')
        return
    
    if year == 2019:
        if month < 4:
            print('Heisei')
            return
        elif month == 4 and day <= 30:
            print('Heisei')
            return

    print('TBD')
    return

if __name__ == '__main__':
    main()


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


int main()
{
    int A,B,X=0;
    cin >> A>>B>>X;
    if(A+B>=X&&A<=X)
    {
        cout << "YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #pragma comment(linker, "/STACK:2000000")
  #pragma comment(linker, "/HEAP:2000000")
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  int32_t main()
  {       
    IOS
    int n;
    cin>>n;
    int arr[n],arr2[n];
    for(int i=0;i<n;i++)
    {
      cin>>arr[i];
      arr2[i]=arr[i];
    }
    sort(arr2,arr2+n);

    int a=arr2[n-1];
    int b=arr2[n-2];

    for(int i=0;i<n;i++)
    {
      if(arr[i]==a)
      {
        cout<<b;
      }
      else
      {
        cout<<a;
      }
      cout<<endl;
    }
    return 0;      
} 

Measured memory_bytes: 4736
#!/usr/bin/env python3
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = [i for i in input()]
b = [0] * n
for i in range(n - k):
    if t[i] == t[i + k] and b[i] == 0:
        if t[i] == 's':
            b[i + k] -= r
        elif t[i] == 'p':
            b[i + k] -= s
        else:
            b[i + k] -= p
print(t.count('s') * r + t.count('p') * s + t.count('r') * p + sum(b))


Measured memory_bytes: 12068
s = input()

ans=0
s=s[::-1]
t=1
ketame=0
amari10=1
kosuu=[1]+[0]*2020
for i in s:
    ketame=(ketame+(int(i)*amari10)%2019)%2019
    amari10*=10
    amari10%=2019
    kosuu[ketame]+=1

for i in range(len(kosuu)):
    if kosuu[i]>0:
        ans+=kosuu[i]*(kosuu[i]-1)/2
    
print(int(ans))

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

int main()
{
	int r, D, x_2000;
	int x_list[11];

	cin >> r >> D >> x_2000;

	for (int i = 0; i < 10; i++) {
		if (i == 0) x_list[i] = r * x_2000 - D;
		else x_list[i] = r * x_list[i - 1] - D;
		cout << x_list[i] << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

vector<int> g[200005];


void dfs(int v, int& ans, vector<bool> seen) {
	seen[v] = true;
	
	for (int next_v : g[v]) {
		if (seen[next_v] == true) continue;
		ans++;
		dfs(next_v, ans, seen);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> fre(n + 1);
	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> dist(n + 1, -1);
	queue<int> que;
	
	int ans = 0;
	
	for (int i = 1;i <= n;i++) {
		if (dist[i] != -1) continue;
		dist[i] = 0;
		que.push(i);
		int count = 1;
		while (!que.empty()) {
			int v = que.front();
			que.pop();

			for (auto nv : g[v]) {
				if (dist[nv] != -1)continue;
				dist[nv] = dist[v] + 1;
				que.push(nv);
				count++;
			}
		}
		if (ans < count)ans = count;
	}

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


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

int main() {
    string s, t;
    string ans;
    
    cin >> s >> t;
    ans += t;
    ans += s;
    
    cout << ans;
    
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
bool used[26];
std::string S;
char ans = 'a';
int main() {
	std::cin >> S;
	for (auto u : S) {
		used[u - 'a'] = true;
	}
	if (used[25]&&S.size()==26) {
		if (S[0] == 'z') {
			for (int i = 0; i < 26; i++)used[i] = false;
			for (int i = 0; i < S.size(); i++) {
				used[S[i] - 'a'] = true;
				for (int j = S[i]-'a'; j < 26; j++) {
					if (!used[j]) {
						for (int k = 0; k < i; k++)std::cout << S[k];
						ans += j;
						std::cout <<ans << std::endl;
						return 0;
					}
				}
			}
		}
		else {
			for (int i = S.size() - 1; i >= 0; i--) {
				for (int j = S[i] - 'a'; j < 26; j++) {
					if (!used[j]) {
						for (int k = 0; k < i; k++) {
							std::cout << S[k];
						}
						ans += j;
						std::cout << ans << std::endl;
						return 0;
					}
				}
				used[S[i] - 'a'] = false;
			}
		}
		if (S.size() != 26) {
			std::cout << S;
			for (int i = 0; i < 26; i++) {
				if (!used[i]) {
					ans += i;
					std::cout << ans << std::endl;
					return 0;
				}
			}
		}
	}
	else {
		std::cout << S;
		for (int i = 0; i < 26; i++) {
			if (!used[i]) {
				ans += i;
				std::cout << ans << std::endl;
				return 0;
			}
		}
	}
	std::cout << -1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i=0; i<M; i++) {
        cin >> a[i] >> b[i];
    }
    
    bool possible=false;
    vector<int> from_start(N+1,0), to_goal(N+1,0);
    for (int i=0; i<M; i++) {
        if (a[i]==1) {
            from_start[b[i]]++;
        }
        if (b[i]==N) {
            to_goal[a[i]]++;
            //cout << a[i] << endl;
        }
    }
    
    for (int i=0; i<N+1; i++) {
        if (from_start[i]>0) {
            if (to_goal[i]>0) {
                possible=true;
            }
        }
    }
    
    //cout << from_start[2] << endl;
    //cout << to_goal[2] << endl;
    
    if (possible) {
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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 print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
ll A;
double B;
int main()
{
    cin >> A >> B;
    ll C = (ll)((B + 0.00001)* 100);
    
    //fprintf(stderr, "%d, %f, %d, %d, %f\n", A, B, C, A * C/100, A * B);
    cout << A * C/100;
    return 0;
}


Measured memory_bytes: 3720
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, c;
  cin >> a >> b >> c;
  print(c, a, b);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) {
            ++cnt;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3660
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

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

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

s = S()

al = [ chr(ord('a') + i) for i in range(26) ]
# AL = [ chr(ord('A') + i) for i in range(26) ]

if s in al:
    print("a")
else:
    print("A")


Measured memory_bytes: 72668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,sum=0; cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    if(sum%(n*(n+1)/2)!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    int cnt,cnt2;
    cnt=sum/(n*(n+1)/2);
    cnt2=cnt;
    rep(i,n){
        int tmp=a.at((i+1)%n)-a.at(i)-cnt;
        if(tmp%n!=0 or tmp>0){
            cout<<"NO"<<endl;
            return 0;
        }else{
            cnt2+=tmp/n;
        }
    }
    cout<<(cnt2==0?"YES":"NO")<<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 065_arc_a / Link: https://arc065.contest.atcoder.jp/tasks/arc065_a?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string S;
	cin >> S;
	reverse(ALL(S));
	string t[4] = { "dream","erase","eraser","dreamer" };
	FOR(i, 0, 4)reverse(ALL(t[i]));
	FOR(i, 0, SZ(S)) {
		if (S.substr(i, 5) == t[0] || S.substr(i, 5) == t[1]) {
			i += 4;
		}
		else if (S.substr(i, 6) == t[2]) {
			i += 5;
		}
		else if (S.substr(i, 7) == t[3]) {
			i += 6;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout <<"YES" << "\n";

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,l,r,r1,l1,a[100001],b[100001],f;
main(){
  string s;
  cin>>s;
  r(i,s.size()){
    if(s[i]=='N')l++;
    if(s[i]=='S')l1++;
    if(s[i]=='W')r++;
    if(s[i]=='E')r1++;
  }
  if((r1&&r||!r1&&!r)&&(l1&&l||!l1&&!l))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll sum(ll l, ll r) { return (r - l + 1) * (l + r) / 2; }

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

  vector<ll> a(n + 2, 0);
  // a[0] = 0;
  rep(i, n + 1) a[i + 1] = a[i] + i;

  ll ans = 0;
  for (int i = k; i <= n + 1; ++i) {
    ll mn = a[i], mx = a[n + 1] - a[n + 1 - i];
    // ll mn = sum(0, i - 1);
    // ll mx = sum(n - i + 1, n);
    ans += (mx - mn + 1) % mod;
    // ans %= mod;
  }
  ans %= mod;
  cout << ans << endl;

  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

int N;
int x[10], y[10];

double distance(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx * dx + dy * dy);
}

void solve() {
    cin >> N;
    FOR(i, 1, N+1) cin >> x[i] >> y[i];

    double ans;
    vector<int> vec(N);
    REP(i, N) vec[i] = i + 1;
    do {
        FOR(i, 0, N-1) ans += distance(vec[i], vec[i+1]);
    } while (next_permutation(vec.begin(), vec.end()));

    int factorial = 1;
    FOR(i, 2, N+1) factorial *= i;

    cout << ans / factorial << endl;
}

signed main() {
    solve();
    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, m, k, ans = 0;
int a[N], b[N];

int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for(int i = 1; i <= m; i++)
	{
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0;
	int idx = m;
	for(int i = 0; i <= n; i++)
	{
		if(a[i] > k)
			break;
		while(a[i] + b[idx] > k)
			idx--;
		ans = max(ans, i + idx);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[200010], b[200010];
multiset<int> ms;
set<pii> s;

int main() {
    ios_base::sync_with_stdio(0);
    int h, w; cin >> h >> w;
    for (int i=0;i<h;i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    for (int i=0;i<w;i++) {
        s.insert({i, i});
        ms.insert(0);
    }
    for (int i=0;i<h;i++) {
        auto st = s.lower_bound({a[i], -1});
        auto ed = s.lower_bound({b[i]+1, w});
        vector<pii> t;
        for (auto j=st;j!=ed;j++) {
            t.pb({j->se, j->fi});
            ms.erase(ms.find(j->fi-j->se));
        }
        s.erase(st, ed);

        if (t.size()) {
            pii p = *max_element(t.begin(), t.end());
            if (b[i]+1<w) {
                s.insert({b[i]+1, p.fi});
                ms.insert(b[i]+1-p.fi);
            }
        }
        cout << (ms.size()? *ms.begin()+i+1: -1) << endl;
    }
}


Measured memory_bytes: 23908
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,ans=0;
  string s;cin>>s;
  rep1(i,(ll)s.size()){
    if(s[i]!=s[i-1])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	count := 0
	a := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&a[i])
		count += strings.Count(a[i], "#")
	}

	if h+w-1 == count {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Set<Card> exists = new HashSet<Card>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] tmp;
		String suite;
		int rank;
		for(int i = 0;i < n;i++){
			tmp = br.readLine().split(" ");
			suite = tmp[0];
			rank = Integer.parseInt(tmp[1]);
			exists.add(new Card(suite, rank));
		}
		
		String[] suiteTable = {"S", "H", "C", "D"};
		for(int i = 0;i < suiteTable.length;i++){
			for(int j = 0;j < 13;){
				if(!exists.contains(new Card(suiteTable[i], ++j))){
					StringBuilder sb = new StringBuilder();
					sb.append(suiteTable[i]);
					sb.append(" ");
					sb.append(j);
					System.out.println(sb.toString());
					sb = null;
				}
			}
		}
	}

}

class Card {
	private String suite;
	private int rank;
	
	Card(){
		
	}
	
	Card(String suite, int rank){
		setSuite(suite);
		setRank(rank);
	}

	public String getSuite() {
		return suite;
	}

	public void setSuite(String suite) {
		this.suite = suite;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + rank;
		result = prime * result + ((suite == null) ? 0 : suite.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Card other = (Card) obj;
		if (rank != other.rank)
			return false;
		if (suite == null) {
			if (other.suite != null)
				return false;
		} else if (!suite.equals(other.suite))
			return false;
		return true;
	}

}

Measured memory_bytes: 16944
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct TCoordinate
{
	double x;
	double y;
};

struct TCircle
{
	double CenterX;
	double CenterY;
	double Radius;
};

TCircle GetCircle(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
	TCircle Circle = {x, y, r};
	return Circle;
}

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	TCircle Circle = GetCircle(P1, P2, P3);
	return {Circle.CenterX, Circle.CenterY};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	TCircle Circle = GetCircle(P1, P2, P3);
	return Circle.Radius;
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3);
		cout << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

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

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

    int n, x, t;
    cin >> n >> x >> t;

    int num = (n + x - 1) / x;
    cout << num * t << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1e18;
int main()
{
    int k, n;
    cin >> k  >> n;
    vector<long long> a(n + 1);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    a[n] = a[0] + k;

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, abs(a[i + 1] - a[i]));
    }
    ans = k - ans;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict as dd
def factorization(n):
    """
    引数の値を素因数分解したリストを返す

    Parameters
    ----------
    n : int
        素因数分解したい自然数

    Returns
    -------
    retlist : list
        2以上の整数n => [[素因数, 指数], ...]の2次元リスト
    """
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            retlist.append([i, cnt])

    if temp!=1:
        retlist.append([temp, 1])

    if retlist==[]:
        retlist.append([n, 1])

    return retlist

n=int(input())
mod=10**9+7
ans=1
d=dd(int)
for i in range(2,n+1):
    a=factorization(i)
    for j in range(len(a)):
        d[a[j][0]]+=a[j][1]

for v in d.values():
    ans*=v+1
    ans%=mod
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll h;
    cin >> h;
    ll x = 1;

    ll ans = 0;

    while(true){
        ans += x;
        h /= 2;
        x *= 2;
        if(h == 0)break;
    }

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


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

using namespace std;

int main()
{
  int n, w, v, p, q;
  double s, t, a[101], mx;

  while(cin>>n>>w && (n+w)){
    vector<double> vec;
    fill(a, a+101, 0);
    for(int i = 0; i < n; i++){
      cin >> v;
      for(int j = 0; j < 101; j++){
	if(j*w <= v && v < (j+1)*w){
	  a[j]++;
	}
      }
    }
    q = 100;
    s = 0.01;
    while(a[q] == 0 && 0 < q){
      q--;
    }

    mx = 0;
    for(int i = 0; i <= q; i++){
      mx = max(mx, a[i]);
      vec.push_back(a[i]);
    }
    for(int i = 0; i < vec.size(); i++){
      vec[i] /= mx;
    }

    p = vec.size()-1;
    if(p == 0){
      p = 1;
    }
    reverse(vec.begin(), vec.end());
    for(int i = vec.size()-1; i >= 0; i--){
      s += ((double)i*vec[i]/p);
    }

    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  if(s=="Sunny"){
  	cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
  	cout<<"Rainy"<<endl;
  }else{
  	cout<<"Sunny"<<endl;
  }
}








Measured memory_bytes: 256
N, K = map(int, input().split())
result = [0] * N

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        result[a-1] = 1
    A.clear()

ans = 0

for r in result:
    if r == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    if (abs((x[i] + y[i]) % 2) != abs((x[0] + y[0]) % 2)) {
      puts("-1");
      return 0;
    }
  }
  int m = 40;
  vector<ll> ans(m);
  for (int i = m - 1; i >= 0; i--) {
    if (i > m - 5) {
      ans[i] = 1;
    } else {
      ans[i] = ans[i + 1] * 2;
    }
  }
  if ((x[0] + y[0]) % 2) {
    m--;
  }
  cout << m << endl;
  for (int i = 0; i < m; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (abs(x[i]) <= abs(y[i])) {
        cout << (y[i] <= 0 ? 'D' : 'U');
        y[i] += ans[j] * (y[i] <= 0 ? 1 : -1);
      } else {
        cout << (x[i] <= 0 ? 'L' : 'R');
        x[i] += ans[j] * (x[i] <= 0 ? 1 : -1);
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 2005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int ncr[MAX][MAX];

void ncrTable(){
    memset(ncr , -1 , sizeof(ncr));
    ncr[0][0] = 1;
    ncr[1][0] = 1;
    ncr[1][1] = 1;
    for(int i = 2 ; i < MAX ; i++){
        ncr[i][0] = 1;
        for(int j = 1 ; j < i ; j++){
            ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1];
            if(ncr[i][j] >= MOD)
                ncr[i][j] -= MOD;
        }
        ncr[i][i] = 1;
    }
}
void solve() {
    ncrTable();
    int n , k;
    cin>>n>>k;
    for(int i = 1 ; i<= k ; i++){
        if(i > n - k + 1){
            cout<<0<<endl;
        }else {
            cout<<ncr[n - k + 1][i] * ncr[k-1][i-1] % MOD<<endl;
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using namespace std;

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

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

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

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

void solve() {
    int N; cin >> N;
    int cnt = 1, crash = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a == cnt) cnt++;
        else crash++;
    }

    if (crash == N) cout << -1 << '\n';
    else cout << crash << '\n';
}

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

    solve();

    return 0;
}

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

int check(int n, int count){
    
    for(int i = 1; i <= n; i++){
        if(n % i == 0) count++;
    }
    
    return count;
}

int main(void){
    
    int N;
    cin >> N;
    
    int ans = 0;
    for(int i = 1; i <= N; i+=2){
        if(check(i, 0) == 8) ans++;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
using System;
class clock{
    public static void Main(){
        int time = int.Parse(Console.ReadLine());
        int h=0,m=0,s=0;
        h = time/3600;
        time = time%3600;
        m = time/60;
        s = time%60;
        Console.WriteLine("{0}:{1}:{2}",h,m,s);
    }
}


Measured memory_bytes: 19964
PATTERN = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]].freeze

def judge(list)
  PATTERN.each do |p|
    if list[p[0]] == list[p[1]] && list[p[1]] == list[p[2]] and list[p[0]] != 's'
      return list[p[0]]
    end
  end
  return 'd'
end

while gets
  list = $_.chomp.chars
  puts judge(list)
end

Measured memory_bytes: 6092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	double n, x[10];
	cin >> n;
	string u[10], B = "BTC", J = "JPN";
	double ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == B) ans += 380000 * x[i];
		else ans += x[i];
	}
	
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    int n ;
    cin >> n ;
    vector<int> dis(n+1,0) ;
    vector<int> seen(n+1,0) ;
    queue<int> que ;
    vector<int> next ;
    next.push_back(1) ;
    int i6 = 6 ;
    while(i6<=n){
        next.PB(i6) ;
        i6 *= 6 ;
    }
    int i9 = 9 ;
    while(i9<=n){
        next.PB(i9) ;
        i9 *= 9 ;
    }
    
    que.push(0) ;
    seen[0] = 1 ;
    dis[0] = 0 ;

    while(!que.empty()){
        int k = que.front() ;
        que.pop() ;
        for(int i=0;i<next.size();i++){
            if(k+next[i]<=n && seen[k+next[i]]==0){
                que.push(k+next[i]) ;
                seen[k+next[i]] = 1 ;
                dis[k+next[i]] = dis[k] + 1 ;
                if(k+next[i]==n){
                    cout << dis[k+next[i]] <<endl;
                    return 0 ;
                }
            }
        }
    }

    cout << dis[n] <<endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x_1,y_1,x_2,y_2,x_3,y_3,x_4,y_4;
    cin>>x_1>>y_1>>x_2>>y_2;
    x_3=x_2+y_1-y_2;
    y_3=y_2+x_2-x_1;
    x_4=x_3+y_2-y_3;
    y_4=y_3+x_3-x_2;
    cout<<x_3<<" "<<y_3<<" "<<x_4<<" "<<y_4<<endl;
}

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

const int C = 26;
const int D = 365;

int d;
int c[C];
int s[D][C];

vector<int> t;

void read() {
  scanf("%d", &d);
  for (int i = 0; i < C; ++i) scanf("%d", &c[i]);
  for (int i = 0; i < d; ++i) {
    for (int j = 0; j < C; ++j) {
      scanf("%d", &s[i][j]);
    }
  }
}

int score[D];
int lst[D];
int eval(vector<int> t) {
  int cur = 0;
  for (int i = 0; i < D; ++i) lst[i] = -1;
  for (int i = 0; i < t.size(); ++i) {
    cur += s[i][t[i]];
    lst[t[i]] = i;
    for (int j = 0; j < C; ++j) {
      cur -= (i - lst[j]) * c[j];
    }

    score[i] = cur;
  }

  return cur;
}

void solve() {
  for (int i = 0; i < d; ++i) {
    t.push_back(0);
    for (int j = 1; j < C; ++j) {
      vector<int> nt = t;
      t.back() = j;

      if (eval(nt) > eval(t)) {
        t = nt;
      }
    }
  }

  for (int k = 0; k < 10; ++k) {
    for (int i = 0; i < d; ++i) {
      for (int j = 0; j < C; ++j) {
        vector<int> nt = t;
        nt[i] = j;
        if (eval(nt) > eval(t)) t = nt;
      }
    }
  }
}

void print() {
  for (int i = 0; i < d; ++i) printf("%d\n", t[i] + 1);
}

void printScore() {
  eval(t);
  for (int i = 0; i < d; ++i) printf("%d\n", score[i]);
}

int main() {
  read();
  solve();
  print();
  // cerr << eval(t) << endl;
  // printScore();
  return 0;
}


Measured memory_bytes: 3936
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int, input().split())
if n < 2 :
    n = 0
else :
    n = combinations_count(n, 2)

if m < 2 :
    m = 0
else :
    m = combinations_count(m, 2)

print(n+m)


Measured memory_bytes: 3060
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;

void main() {
    int N, A, B;
    readf("%d %d %d\n", &N, &A, &B);
    iota(N+1).filter!(i => i.to!string.map!(pipe!(to!string, to!int)).sum.pipe!(s => A <= s && s <= B)).sum.writeln;
}



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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

#define MOD 1000000007
 
int expmod(int a, int p) {
	if(p == 0) return 1;
	int r = expmod(a, p >> 1);
	r = 1LL * r * r % MOD;
	if(p & 1) return 1LL * r * a % MOD;
	return r;
}

map<int, int> p;
vi S;

void f(int n) {

	if(!(n & 1)) {
		
		int i = 0;
		
		while(!(n & 1)) {
			
			n >>= 1;
			++i;
		}
		
		p[2] = max(p[2], i);
	}
	
	for(int k = 0; S[k] * S[k] <= n; k++) {
		
		int j = S[k];
		
		if(n % j == 0) {
			
			int i = 0;
			
			while(n % j == 0) {
				++i;
				n /= j;
			}
			
			p[j] = max(p[j], i);
		}
	}
	
	if(n > 1) p[n] = max(p[n], 1);
}

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	bitset<1000> prime;
	
	for(int k = 3; k < 1000; k += 2) {
	
		if(!prime[k]) {
			
			S.push_back(k);
			
			for(int i = 2 * k; i < 1000; i += k)
				prime[i] = 1;
		}
	}
	
	S.push_back(1001);
	
	cin >> n;
	
	vi a(n);
	
	for(int& z : a) {
		
		cin >> z;
		f(z);
	}
	
	int m = 1;
	
	for(auto x : p)
		m = 1LL * m * expmod(x.first, x.second) % MOD;
	
	int ans = 0;
	
	for(int k = 0; k < n; ++k)
		ans = (ans + 1LL * m * expmod(a[k], MOD - 2)) % MOD;
		
	cout << ans << '\n';
		
    return 0;
}



Measured memory_bytes: 768