akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer skt=new StringTokenizer(in.readLine());
		
		int k=Integer.parseInt(skt.nextToken());
		int n=Integer.parseInt(skt.nextToken());
		
		skt=new StringTokenizer(in.readLine());
		
		int[] houses=new int[n];
		
		
		for (int i = 0; i < houses.length; i++) {
			houses[i]=Integer.parseInt(skt.nextToken());
		}
		
		int min=Math.min((houses[houses.length-1]-houses[0]), houses[0]+(k-houses[1]));
		for (int i = 1; i < houses.length-1; i++) {
			min=Math.min(Math.min(k-houses[i]+houses[i-1],houses[i]+(k-houses[i+1])), min);
			
		}
		
		System.out.println(min);
		
		

	}

}


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

#define N 8
#define F -1
#define NF 1

int str[N], bor[N], dp[2*N-1], dn[2*N-1];

bool X[N][N];

void ini(){
  int i;
  for(i=0;i<N;i++){
    str[i]=F;
    bor[i]=F;
  }
  for(i=0;i<2*N-1;i++){
    dp[i]=F;
    dn[i]=F;
  }
}

void prb(){
  int i, j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(str[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      cout << ((str[i]==j)?"Q" : ".");
    }
    cout << endl;
  }
}

void rec(int i){
  int j;
  if(i==N){
    prb();
    return;
  }

  for(j=0;j<N;j++){
    if(NF==bor[j] || NF==dp[i+j] || NF==dn[i-j+N-1]) continue;
    str[i]=j;bor[j]=dp[i+j]=dn[i-j+N-1]=NF;
    rec(i+1);
    str[i]=bor[j]=dp[i+j]=dn[i-j+N-1]=F;
  }
}

int main(){
  int i, j, k, r, c;
  ini();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++)X[i][j]=false;

  cin>>k;
  for(i=0;i<k;i++){
    cin >> r >> c;
    X[r][c]=true;
  }

  rec(0);

  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> S(N + 1, 0);
  for (int i = 0; i < N; i++){
    S[i + 1] = (S[i] + A[i]) % M;
  }
  map<int, int> cnt;
  long long ans = 0;
  for (int i = 0; i <= N; i++){
    ans += cnt[S[i]];
    cnt[S[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3968
#include<algorithm>
#include<cstdio>
int n,num[100005],k,ans,t=0;
int main()
{
	scanf("%d",&n);
	for(;t<n;t++)
	{
    	scanf("%d",&num[t]);
    }
	std::sort(num,num+n);
	for(t=0;t<n;t++)
	{
    	k++;
    	if(num[t]-num[t+1])
    	{
      		k<num[t]?ans+=k:ans+=k-num[t];
      		k=0;
    	}
  	}
	printf("%d",ans);
}

Measured memory_bytes: 512
n = int(input())
if n <= 8:
    print(n)

else:
    
    sn = str(n)
    num = len(sn)
    if sn[1:] == "9" * (num - 1):
        print(int(sn[0]) + 9 *(num - 1))
    else:
        print((int(sn[0]) - 1) + 9 * (num - 1))

Measured memory_bytes: 3060
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = input()
import collections
c = collections.Counter(s)
print(str("AC x ")+str(c["AC"]))
print(str("WA x ")+str(c["WA"]))
print(str("TLE x ")+str(c["TLE"]))
print(str("RE x ")+str(c["RE"]))

Measured memory_bytes: 16364
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin>>n>>k;
    vector<lint> h(n);
    lint wa = 0;
    REP(i,n){
        cin>>h[i];
        wa+=h[i];
    }
    lint ans;
    if(n>=k){
        sort(all(h),greater<int>());
        ans = wa;
        REP(i,k){
            ans-=h[i];
        }
    }
    else ans = 0;
    print(ans);
    return 0;
}


Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n;
    cin >> n;

    cout << n * (n - 1) / 2LL << "\n";
    return 0;
}

Measured memory_bytes: 384
N,M = [int(s) for s in input().split()]
text=input()
lst=[0 for s in range(N)]
for i in range(N+1):
  if(text[i-2:i]=='AC'):
    lst[i-1]=lst[i-2]+1
  else:
    lst[i-1]=lst[i-2]
for i in range(M):
  a,b = [int(s) for s in input().split()]
  print(max([lst[b-1]-lst[a-1],0]))

Measured memory_bytes: 6184
#include <cstdio>

class Dice{
    private:
        int t, b, n, e, s, w;
    public:
        void roll(char d);
        void showEast(){printf("%d\n", e);}
        int getT(){return t;}
        int getB(){return b;}
        int getN(){return n;}
        int getS(){return s;}
        int getE(){return e;}
        int getW(){return w;}
        bool eq(Dice hoge);
        bool eeq(Dice hoge);
        Dice(int t, int s, int e, int w, int n, int b) : t(t), s(s), e(e), w(w), n(n), b(b) {}
};

bool Dice::eeq(Dice hoge){
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    roll('E');
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    roll('W');
    roll('W');
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    roll('E');
    roll('N');
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    roll('S');
    roll('S');
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    roll('S');
    for(int i = 0; i < 4; i++){
        if(eq(hoge)){
            return true;
        }
        roll('C');
    }
    return false;
}

bool Dice::eq(Dice hoge){
    if(t != hoge.getT()){
        return false;
    }
    if(b != hoge.getB()){
        return false;
    }
    if(n != hoge.getN()){
        return false;
    }
    if(s != hoge.getS()){
        return false;
    }
    if(w != hoge.getW()){
        return false;
    }
    if(e != hoge.getE()){
        return false;
    }
    return true;
}

void Dice::roll(char d){
    int tmp = 0;
    if (d == 'S') {
        tmp = s;
        s = t;
        t = n;
        n = b;
        b = tmp;
    }else if (d == 'E') {
        tmp = e;
        e = t;
        t = w;
        w = b;
        b = tmp;
    }else if (d == 'N') {
        tmp = n;
        n = t;
        t = s;
        s = b;
        b = tmp;
    }else if (d == 'W'){
        tmp = w;
        w = t;
        t = e;
        e = b;
        b = tmp;
    }else if (d == 'C'){    // Clockwise
        tmp = n;
        n = w;
        w = s;
        s = e;
        e = tmp;
    }else if(d == 'U'){     // Unti-Clockwise
        tmp = s;
        s = w;
        w = n;
        n = e;
        e = tmp;
    }
}

int main(){
    int a, b, c, d, e, f, n;
    Dice **da = new Dice*[100];
    scanf("%d", &n);
    for(int i = 0; i< n; i++){
        scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
        da[i] = new Dice(a, b, c, d, e, f);
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j<n; j++){
            if(da[i]->eeq(*da[j])){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2692
def bubble_sort(A, N):
    flag = True
    c = 0
    i = 0
    while flag:
        flag = False
        for j in range(N-1, i, -1):
            if A[j] < A[j-1]:
                A[j],  A[j-1] = A[j-1], A[j]
                c += 1
                flag = True
        i += 1

    return c


while True:

    N = int(raw_input())

    if N == 0:
        break

    A = [int(raw_input()) for _ in xrange(N)]

    print bubble_sort(A, N)

Measured memory_bytes: 6376
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

ll GCD(ll x, ll y) {
	return x ? GCD(y % x, x) : y;
}

ll LCM(ll m, ll n)
{
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / GCD(m, n)) * n); // lcm = m * n / GCD(m,n)
}
int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll pos1 = b/c-a / c;
	if (a % c == 0) {
		pos1++;
	}
	ll pos2 = b / d - a / d;
	if (a % d == 0) {
		pos2++;
	}
	ll e = LCM(c, d);
	ll pos3 = b / e - a / e;
	if (a % e == 0) {
		pos3++;
	}
	ll ans= pos1 + pos2 - pos3;
	cout << b-a+1-ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int x = sc.nextInt();

		int y = 0;
		int r = (int)Math.sqrt(x);

		while ( y == 0 ) {
			int f = 0;
			for ( int i=2; i<=r; i++ ) {
				if ( x%i == 0 ) {
					f = i;
					break;
				}
			}
			if ( f == 0 ) {
				y = x ;
			} else {
				x++;
			}
		}
		System.out.println(y);
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



struct Mint {
  int x;

  Mint() : x(0) {}

  Mint(int y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

  Mint &operator+=(const Mint &p) {
    if((x += p.x) >= M) x -= M;
    return *this;
  }

  Mint &operator-=(const Mint &p) {
    if((x += M - p.x) >= M) x -= M;
    return *this;
  }

  Mint &operator*=(const Mint &p) {
    x = (int) (1LL * x * p.x % M);
    return *this;
  }

  Mint &operator/=(const Mint &p) {
    *this *= p.inverse();
    return *this;
  }

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

  Mint operator+(const Mint &p) const { return Mint(*this) += p; }

  Mint operator-(const Mint &p) const { return Mint(*this) -= p; }

  Mint operator*(const Mint &p) const { return Mint(*this) *= p; }

  Mint operator/(const Mint &p) const { return Mint(*this) /= p; }

  bool operator==(const Mint &p) const { return x == p.x; }

  bool operator!=(const Mint &p) const { return x != p.x; }

  Mint inverse() const {
    int a = x, b = M, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return Mint(u);
  }

  Mint power(int n) const {
    Mint ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const Mint &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, Mint &a) {
    int t;
    is >> t;
    a = Mint(t);
    return (is);
  }


};
using mint = Mint;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vector<Mint> v(n);
  rep(i,n){
    cin>>v[i];
  }

  Mint mul=1;
  FOR(i,1,n){
    mul*=i;
  }
  

  Mint ans=0;
  Mint m=mul;
  rep(i,n-1){
    Mint k=i+2;
    ans+=(v[i+1]-v[i])*mul;
    //cout<<ans<<endl;
    mul+=m/k;
  }

  cout<<ans<<endl;


}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  if(n%1000 == 0)
    cout << 0;
  else
  {
    int temp = 1000;
    int i=2;
    while(temp<n)
    {
      temp = i*1000;
      i++;
    }
    cout << temp-n;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll N;

  cin >> N;

  unordered_map<ll, ll> um;
  ll maxd = 0;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    if (i == 0 && tmp != 0) {
      cout << 0 << endl;
      return 0;
    }
    um[tmp]++;
    maxd = max(tmp, maxd);
  }
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  if(um[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  for (ll i = 1; i <= maxd; i++) {
    if(um[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  if(maxd == 1){
    cout << 1 << endl;
    return 0;
  }

  ll ans = 1;
  for (ll i = 2; i <= maxd; i++) {
    ans = mul(ans, pow(um[i-1], um[i]));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  string s;
  cin >> n >>s;
  if(n < 3200)s = "red";
  cout << s <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	ll n;
	cin>>n;
	vll a(n);
	ll p=1;
	f(x,0,n)
	{
		cin>>a[x];
		if(a[x]==0)
		{
			p=0;
		}
	}   
	if(p==0)
	{
		cout<<0;
		nl;
		return;
	}
	ll nn=(ll)1e18;
	f(x,0,n)
	{
		ll df=nn/p;
		if(a[x]>df)
		{
			cout<<-1;
			nl;
			return;
		}else
		{
			p=p*a[x];
		}
	}
	cout<<p;
	nl;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  char a;
  cin >> a;
  
  if(a<0x5b){
    cout << "A";
  }else{
    cout << "a";
  }

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int a,b;
	cin>>a>>b;
	cout<<(a*b%2?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _164C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            string[] S = new string[N];
            long types = 0;
            for (long i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }


            Console.WriteLine(S.Distinct().Count());

        }
    }
}

Measured memory_bytes: 47940
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<set>
using namespace std;


int main(){
  int N, Q;
  cin >> N >> Q;
  
  vector<pair<int, pair<int, int>>> event;
  int s, t, x;
  for(int n = 0; n < N; n++){
    cin >> s >> t >> x;
    event.push_back(make_pair(s-x, make_pair(1, x)));
    event.push_back(make_pair(t-x, make_pair(-1, x)));
  }
  sort(event.begin(), event.end());
  
  int d;
  int arg = 0;
  
  set<int> X = {}; 
  
  for(int q=0; q<Q; q++){
    cin >> d;
    
    while (arg < 2*N && event[arg].first <= d){
      if(event[arg].second.first == 1){
        X.insert(event[arg].second.second);
      }else{
        X.erase(event[arg].second.second);
      }
      arg++;
    }
    
    if(X.empty()){
      cout << -1 << endl;
    } else{
      cout << *(X.begin()) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 16620
s = list(input())
if s[0] == "A" and s[2:-1].count("C") == 1:
    s.remove("A")
    s.remove("C")
    if "".join(s).lower() == "".join(s):
        print("AC")
    else:
        print('WA')
else:
    print("WA")


Measured memory_bytes: 2940
#include<stdio.h>
int main(void) {
    char s[2],t[2], a,b,x,y;
    scanf("%c%c%c%c",&s[0],&s[1],&t[0],&t[1]);
    a = b = 0;
    //x = atoi(s[0])*10 + atoi(s[1]);
    //y = atoi(s[2])*10 + atoi(s[3]);
    x = atoi(s);
    y = atoi(t);
    if(0 < x && x <= 12) {a = 1;}
    if(0 < y && y <= 12) {b = 1;}
    if(a == 1 && b == 1) {
        printf("AMBIGUOUS\n");
    } else if(a == 1 && b == 0) {
        printf("MMYY\n");
    } else if(a == 0 && b == 1) {
        printf("YYMM\n");
    } else {
        printf("NA\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll 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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  vector<ll> c(n - k + 1);
  ll res = 1;
  rep(i, n - k + 1) {
    c[i] = res;
    res = (res * (k + i)) % mod;
    res = (res * modpow(i + 1, mod - 2)) % mod;
  }

  ll ans = 0;
  rep(i, n - k + 1) {
    ll re = a[n - 1 - i] - a[i];
    if (re < 0) re = (mod * mod + re) % mod;
    re = (re * c[n - k - i]) % mod;
    ans = (ans + re) % mod;
  }
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <bits/stdc++.h>
using namespace std;

#define MOD 1e9+7
#define ll long long int

#include <bits/stdc++.h>
int main(void){
	long x,y;
	cin>>x>>y;
	int ans = (int)log2l(y/x) + 1;
	cout<<ans<<endl;
	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);
        int sum = 0;
        for (int i=0; i<3; i++) {
            sum += sc.nextInt();
        }
        if (sum > 21) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 23252
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<Long> list = new ArrayList<>();
	list.add(Long.parseLong(sc.next()));
	list.add(Long.parseLong(sc.next()));
	list.add(Long.parseLong(sc.next()));
	int K = Integer.parseInt(sc.next());
    sc.close();
    int s = list.size();
    long c;
    int p;
    
    Collections.sort(list);
    for(int i = 0; i< K; i++){
      c = list.get(s-1);
      list.set(s-1 , c*2);
    }
    c = 0;
    for(int i = 0; i< s; i++){
      c += list.get(i);
    }
    
    System.out.println(c);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int N;
    int *A, *B;

    scanf("%d", &N);
    A = (int *)calloc(N+1, sizeof(int));
    B = (int *)calloc(N, sizeof(int));
    for(int i=0; i<N+1; i++)
        scanf("%d", &A[i]);
    for(int i=0; i<N; i++)
        scanf("%d", &B[i]);
    long count=0;
    int k;
    for(int i=0; i<N;i++){
        if(A[i]>=B[i])
            count+=B[i];
        else
        {   count+=A[i];
            k = B[i]-A[i];
            if(k<=A[i+1]){
                count+=k;
                A[i+1]-=k;
            }
            else {
                count+=A[i+1];
                A[i+1]=0;
            }
        }
    }

    printf("%ld\n", count);
    return 0;
}

Measured memory_bytes: 896
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a_reverse = a[::-1]
mod = 10**9+7
 
factorial = [1]
inverse = [1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))
 
def comb(n, r, mod):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

plus = 0
minus = 0
cnt = 0
ind = 0
for i in range(n-k+1):
    kaisu = comb(n-i-1, k-1, mod)
    plus = (plus + (kaisu * a_reverse[ind]) % mod) % mod
    minus = (minus + (kaisu * a[ind]) % mod) % mod
    ind += 1

print((plus-minus) % mod)

Measured memory_bytes: 16408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for (ll r = 0; r <= N; r++) {
        for (ll g = 0; g <= N; g++) {
            if (N - r * R - g * G >= 0 && (N - r * R - g * G) % B == 0) ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

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

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

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

  vector< int64 > cnt(N + 1);
  for(int i = 0; i < N; i++) cnt[A[i]]++;
  int64 all = 0;
  for(int i = 0; i <= N; i++) all += cnt[i] * (cnt[i] - 1);

  for(int i = 0; i < N; i++) {
    all -= cnt[A[i]] * (cnt[A[i]] - 1);
    cnt[A[i]]--;
    cout << (all + cnt[A[i]] * (cnt[A[i]] - 1)) / 2 << "\n";
    cnt[A[i]]++;
    all += cnt[A[i]] * (cnt[A[i]] - 1);
  }
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A <= C && C <= B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}



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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

string s;
int w;

void solve() {
	string ans;
	for (int i = 0; i < sz(s); i += w) {	
		ans += s[i];
	}
	cout << ans << endl;
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  cin >> s;
  cin >> w;
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL n, p;
  cin>>n>>p;

    if(n==1){
      cout<<p<<endl;
      return 0;
    }
    LL ans=1;
    int count;
  LL q = p;
  FOR(i,2, sqrt(p)){
    count=0;
    while(q%i==0){
      q/=i;
      ++count;
    }

    while(count>=n){
      ans *= i;
      count -=n;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int m, n;
int p[10001];
LL c[501], e[501];
LL dp[10001];



int main() {
	cin >> m >> n;
	REP(i, m)cin >> p[i];
	sort(p, p + m);
	reverse(p, p + m);
	REP(i, n)cin >> c[i] >> e[i];
	REP(i, 10001) {
		dp[i] = INF;
	}
	dp[0] = 0;

	REP(i, n) {
		for (int j = 10000; j >= 0; j--) {
			if (j + c[i] <= 10000)dp[j + c[i]] = min(dp[j + c[i]], dp[j] + e[i]);
		}
		for (int j = 10000; j > 0; j--) {
			dp[j - 1] = min(dp[j - 1], dp[j]);
		}
	}

	LL ans = 0, sum = 0;

	REP(i, m) {
		sum += p[i];
		ans = max(ans, sum - dp[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3248
def main():

    N = int(input())
    cnt = 0
    for _ in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3: return 'Yes'
    return 'No'

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 62336
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Long a[] = new Long[3 * n];
        for (int i = 0; i < 3 * n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a, Collections.reverseOrder());

        long sum = 0;
        int count = 0;
        for (int i = 1; i < 3 * n; i += 2) {
            if (count == n) {
                break;
            }
            sum += a[i];
            count++;
        }
        System.out.println(sum);
    }
}

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


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

int main()
{
  string s;
  long long int K;

  cin >> s >> K;
  long long int num = K;
  rep(i, s.length())
    {
      if(s[i] == 'a')
	{
	  continue;
	}
      long long int tmp = s[i];
      //      if((long long int)s[i] + num > 'z')
      if(tmp + num > 122)
	{
	  //	  num -= 'z' - tmp + 1;
	  num -= 122 - tmp + 1;
	  s[i] = 'a';
	}
    }
  num %= 26;
  char tmp = num;
  //  s[s.length()-1] += num;
  s[s.length()-1] += tmp;
  if(s[s.length()-1] > 'z')
    {
      s[s.length()-1] = 'a' + (s[s.length()-1] - 'z') - 1;
    }
  rep(i, s.length())
    {
      cout << s[i];
    }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 512
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let s: i64 = s.next().unwrap().parse().unwrap();
	let ans = [vec![s; k], vec![s % 1000000000 + 1; n - k]].concat().into_iter().map(|a| a.to_string()).collect::<Vec<_>>().join(" ");
	println!("{}", ans);
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
//#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int gcm(int a, int b) {
  int tmp, r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(b==0) b = a;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  int n;
  vector<int> a;
  int tmp;
  cin >> n;
  
  for (int i=0; i<n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }

  
  vector<int> left; // left[i] 左からi番目までのgcm
  vector<int> right; // 右から
  
  left.push_back(a[0]);
  right.push_back(a[n-1]);
  
  for (int i=1; i<n; i++) {
    left.push_back(gcm(a[i], left[i-1]));
    right.push_back(gcm(a[n-i-1],right[i-1]));
  }
  
  int ans=right[n-2];
  for (int i=0; i<n-1; i++) {
    tmp = gcm(left[i], right[n-3-i]);
    if (ans<tmp) {
      ans = tmp;
    }
  }
  if (ans < left[n-2]) {
    ans = left[n-2];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1912
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

float myabs(float a){
  return a>0 ? a : -a;    
}

int main(){
  int n;
  double a,b,bb,c,ccc,d,tmp;
  double x[1000],y[1000];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i<n;i++){
    cin >> y[i];
    tmp = abs(x[i]-y[i]);
    a += tmp;
    bb += tmp*tmp;
    ccc += tmp*tmp*tmp;
    d = abs(tmp)>d ? abs(tmp) : d;
  }
  printf("%.6lf\n",a);
  printf("%.6lf\n",sqrt(bb));
  printf("%.6lf\n",cbrt(ccc));
  printf("%.6lf\n",d);
}


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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  string S;
  cin >> S;

  int l = 0, r = S.size() - 1;
  int res = 0;
  while (l < r) {
    while (l < r && S[l] == 'R') ++l;
    while (l < r && S[r] == 'W') --r;
    if (r <= l) break;
    swap(S[l], S[r]);
    ++res;
  }

  cout << res << endl;

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    
    size_t i;
    while ((i = s.find('B')) != string::npos) {
        s.erase(s.begin() + i);
        if (i != 0) {
            s.erase(s.begin() + i - 1);
        }
    }
    
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
	cin >> n;	
	for(int i = n; i; --i) {
		for(int j = 1; j < i; ++j) {
			cout << __builtin_ctz(j) + 1 << ' ';
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 512
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>
#define MOD (ll)(1e9 + 7)
#define mod(a) (((a % MOD) + MOD) % MOD)

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

    ll n, k;
    cin >> n >> k;

    vi arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    ll dp[n][k + 1];
    for (int i = 0; i < n; i++) {
        dp[i][0] = 1;
    }

    for (int i = 1; i <= arr[0]; i++) {
        dp[0][i] = 1 + dp[0][i - 1];
    }
    for (int i = arr[0] + 1; i <= k; i++) {
        dp[0][i] = dp[0][i - 1];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (j > arr[i]) {
                dp[i][j] = mod(mod(dp[i - 1][j] - dp[i - 1][j - arr[i] - 1]) +
                               dp[i][j - 1]);
            } else {
                dp[i][j] = mod(dp[i - 1][j] + dp[i][j - 1]);
            }
        }
    }

    if (k != 0)
        cout << mod(dp[n - 1][k] - dp[n - 1][k - 1]) << "\n";
    else
        cout << dp[n - 1][0] << "\n";
}


Measured memory_bytes: 78336
# include <iostream>
# include <cstdio>
# include <map>

using namespace std ;

typedef long long LL ;

const LL INF = 1e18 ;

int a , b , c , d ;
map < LL , LL > mp ;

LL cal( LL n )
{
	if ( n == 0 ) return 0 ;
	if ( n == 1 ) return d ;
	if ( mp.count( n ) ) return mp[n] ;
	LL l1 = n / 2 * 2 , r1 = ( n + 1 ) / 2 * 2 ;
	LL l2 = n / 3 * 3 , r2 = ( n + 2 ) / 3 * 3 ;
	LL l3 = n / 5 * 5 , r3 = ( n + 4 ) / 5 * 5 ;
	LL res = INF ;
	if ( res / d > n ) res = n * d ;
	res = min( res , llabs( n - l1 ) * d + a + cal( l1 / 2 ) ) ;
	res = min( res , llabs( n - r1 ) * d + a + cal( r1 / 2 ) ) ;
	res = min( res , llabs( n - l2 ) * d + b + cal( l2 / 3 ) ) ;
	res = min( res , llabs( n - r2 ) * d + b + cal( r2 / 3 ) ) ;
	res = min( res , llabs( n - l3 ) * d + c + cal( l3 / 5 ) ) ;
	res = min( res , llabs( n - r3 ) * d + c + cal( r3 / 5 ) ) ;
	mp[n] = res ;
	return res ;
}

int main()
{
	int t ;
	scanf("%d" , &t) ;
	while ( t -- )
	{
		mp.clear() ;
		LL n ;
		scanf("%lld%d%d%d%d" , &n , &a , &b , &c , &d) ;
		printf("%lld\n" , cal( n )) ;
	}
	return 0 ;
}

Measured memory_bytes: 4552
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
    const int maxSize = 1000001;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    auto perm = [&](int n, int r){
        if(n < r || r < 0) return 0LL;
        return fact[n] * factInv[n-r] % MOD;
    };
    int N; cin >> N;
    long long res = 0;
    long long sum = 0;
    long long p1 = (N-2)%2, p2 = (N-2)/2;
    while(p2 >= 0){
        long long ch = p1+p2+1;
        long long sel = comb(p1+p2, p1) * fact[ch] % MOD * fact[N-1-ch] % MOD;
        sel = (sel + MOD - sum) % MOD;
        res = (res + sel * ch) % MOD;
        sum = (sum + sel) % MOD;
        p1 += 2;
        --p2;
    }
    cout << res << endl;
}

Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<typename Monoid, typename OperatorMonoid=Monoid>
struct LazySegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	using G=function<Monoid(Monoid, OperatorMonoid, int)>;
	using H=function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
	int sz;
	vector<Monoid> data;
	vector<OperatorMonoid> lazy;
	const F f;
	const G g;
	const H h;
	const Monoid e1;
	const OperatorMonoid e0;

	LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){
		sz=1;
		while(sz<n) sz<<=1;
		data.resize(2*sz-1, e1);
		lazy.resize(2*sz-1, e0);
	}

	void build(vector<Monoid> v){
		for(int i=0; i<v.size(); i++) data[i+sz-1]=v[i];
		for(int i=sz-2; i>=0; i--) data[i]=f(data[2*i+1], data[2*i+2]);
	}

	void eval(int k, int l, int r){
		if(lazy[k]!=e0){
			data[k]=g(data[k], lazy[k], r-l);
			if(k<sz-1){
				lazy[2*k+1]=h(lazy[2*k+1], lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2], lazy[k]);
			}
		}
		lazy[k]=e0;
	}

	void update(int a, int b, const OperatorMonoid &x, int k, int l, int r){
		eval(k, l, r);
		if(r<=a || b<=l) return;
		if(a<=l && r<=b){
			lazy[k]=h(lazy[k], x);
			eval(k, l, r);
		}else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			data[k]=f(data[2*k+1], data[2*k+2]);
		}
	}
	void update(int a, int b, const OperatorMonoid &x){
		return update(a, b, x, 0, 0, sz);
	}

	Monoid find(int a, int b, int k, int l, int r){
		eval(k, l, r);
		if(b<=l || r<=a) return e1;
		if(a<=l && r<=b) return data[k];
		else return f(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
	}
	Monoid find(int a, int b){
		return find(a, b, 0, 0, sz);
	}
	Monoid operator[](const int &k){
		return find(k, k+1);
	}
};
int main()
{
	int n;
	ll d, a;
	cin>>n>>d>>a;
	vector<P> v(n);
	for(int i=0; i<n; i++){
		cin>>v[i].first>>v[i].second;
		v[i].second=(v[i].second+a-1)/a;
	}
	sort(v.begin(), v.end());
	vector<ll> vc(n);
	for(int i=0; i<n; i++) vc[i]=v[i].second;
	auto f=[](ll a, ll b){ return a+b;};
	auto g=[](ll a, ll x, int len){ return a+x*len;};
	auto h=[](ll x, ll y){ return x+y;};
	LazySegmentTree<ll> seg(n, f, g, h, 0, 0);
	seg.build(vc);
	ll ans=0;
	for(int i=0; i<n; i++){
		ll c=seg[i];
		if(c<=0) continue;
		ans+=c;
		int r=lower_bound(v.begin(), v.end(), P(v[i].first+2*d+1, -1))-v.begin();
		seg.update(i, r, -c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 14720
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	set<char> cnt ;
	for(int i=0;i<s.size();i++) cnt.insert(s.at(i)) ;
	if(cnt.size()==2) cout << "Second" << endl ;
	else{
		ll t = s.size()-3 ;
		if((t&1)^(s.at(0)==s.at(s.size()-1))) cout << "Second" << endl ;
		else cout << "First" << endl ;
	}
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int V[] = new int[N];
        int C[] = new int[N];
        for(int i=0; i<N; i++) {
            V[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++) {
            C[i] = sc.nextInt();
        }
        int r = 0;
        for(int i=0; i<N; i++) {
            r+=Math.max(0, V[i]-C[i]);
        }
        System.out.println(r);
   }
}

Measured memory_bytes: 22096
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        k: i32,
        s: [proconio::marker::Bytes;h],
    }
    let mut m=h*w;
    'outer: for b in 0..1u32<<h-1 {
        let mut a=b.count_ones()as usize;
        let mut c=b<<1|1<<h|1;
        let n=a+1;
        let mut p=Vec::with_capacity(n+1);
        while c>0 {
            p.push(c.trailing_zeros()as usize);
            c&=c-1;
        }
        let mut d=vec![0;n];
        for i in 0..w {
            let mut e=vec![0;n];
            for j in 0..n {
                for l in p[j]..p[j+1] {
                    e[j]+=(s[l][i]-b'0')as i32;
                }
            }
            let mut g=true;
            for j in 0..n {
                if e[j]>k {
                    continue 'outer;
                }
                if e[j]+d[j]>k {
                    a+=1;
                    g=false;
                    break;
                }
            }
            for j in 0..n {
                if g {
                    d[j]+=e[j];
                }
                else {
                    d[j]=e[j];
                }
            }
        }
        m=std::cmp::min(m,a);
    }
    println!("{}",m);
}

Measured memory_bytes: 2164
N, M = list(map(int, input().split()))
ab = []
c = []
for i in range(M):
  ab.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))

A = [10 ** 10] * (1 << N)
C = []
for i in range(M):
  t = 0
  cc = c[i]
  a, b = ab[i]
  for j in cc:
    t |= 1 << (j - 1)
  C.append([t, a])
  A[t] = min(A[t], a)

for i in range(1, N + 1):
  n = (1 << i) - 1
  while n < (1 << N):
    for j in range(M):
      k, a = n | C[j][0], C[j][1]
      A[k] = min(A[k], A[n] + a)
    x = n & -n
    y = n + x
    n = ((n & ~y) // x >> 1) | y

if A[-1] == 10 ** 10:
  print(-1)
else:
  print(A[-1])



Measured memory_bytes: 45928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char** argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  
  auto solve = [&]() {
    ll n, m, ps = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
      ll k;
      cin >> k;
      ps += k;
    }
    if (n < ps)
      cout << "-1\n";
    else
      cout << (n - ps) << '\n';
  };
  
  int t;
  t = 1;
  while (t--)
    solve();
  
  return 0;
}

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

const int maxn=1000+9;
const int maxval=2e4+9;

int n,h,a[maxn],b[maxn];

void _input(){
    cin>>h>>n;
    for(int i=0;i<n;++i) cin>>a[i]>>b[i];
}

void tomin(int &a,int b){a>b?a=b:0;}

int dp[maxval];
const int INF=1e8+233;
int solve(){
    int maxdmg=h+10000;
    for(int j=1;j<=maxdmg;++j)
        dp[j]=INF;
    for(int i=0;i<n;++i){
        for(int j=a[i];j<=maxdmg;++j){
            tomin(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    int ans=INF;
    for(int j=h;j<=maxdmg;++j)
        tomin(ans,dp[j]);
    return ans;
}

void _solve(){
    cout<<solve()<<endl;
}

int main(){
    _input();
    _solve();
    return 0;
}


Measured memory_bytes: 384