akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

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

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

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

ll x,y;
cin>>x>>y;

for(ll i=0;i<=x;i++){
	ll hon=2*i+4*(x-i);
	if(hon==y){
		cout<<"Yes"<<endl;
		return 0;
	}
}

cout<<"No"<<endl;


return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;


int main(){
    CIN(N);
    vi v(N);
    rep(i,N)cin>>v[i];
    sort(all(v));

    int ans= v[N-1]-v[0];
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    m, n = max(a,b), min(a,b)
    while n != 0:
        m, n = n, m%n
    return m

n, x0 = map(int, input().split())
x = list(map(int, input().split())) + [x0]

x = list(set(x))
x.sort()
if len(x) >= 3:
    diff_x = [x[i+1] - x[i] for i in range(n)]
    ans = diff_x[0]
    for dx in diff_x[1:]:
        ans = int(gcd(ans, dx))
elif len(x) == 2:
    ans = x[1] - x[0]


print(ans)

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

int main() {
  int n, m;
 cin >> n >> m;
  vector<int> vec(n+1);

for(int i=0;i<m;i++){
  int a,b;
  cin>>a>>b;
  vec.at(a)++;
  vec.at(b)++;;
}
for(int i=1;i<=n;i++) cout<<vec.at(i)<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int check1000(int x)
{
	return x % 10000;
}

int check100(int x)
{
	return x % 1000;
}

int check10(int x)
{
	return x % 100;
}

int check1(int x)
{
	return x % 10;
}

int main(void)
{
	int i;
	int N, A, B;
	int sum, tenthou, thou, hun, ten, one;
	int wa;

	sum = 0;

	scanf("%d %d %d", &N, &A, &B);

	for (i = 1; i <= N; i++) {
		tenthou = i / 10000;
		thou = check1000(i) / 1000;
		hun = check100(check1000(i)) / 100;
		ten = check10(check100(check1000(i))) / 10;
		one = check1(check10(check100(check1000(i))));
		wa = tenthou + thou + hun + ten + one;
		if (wa >= A&&wa <= B)
			sum += i;
	}

	printf("%d", sum);

	return 0;
}

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

int main()
{
    int n,k;
    cin >> n >>k;
    int h[n];
    vector <int>dp(n,INT_MAX);
    for(int i=0;i<n;i++)
     cin >> h[i];
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j>=n)
            break;
            dp[i+j]=min(dp[i+j],abs(h[i+j]-h[i])+dp[i]);
        }

    }
    cout << dp[n-1];
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n;
  cin >> n;
  vector<ll> ret;

  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
    }
  }
  sort(begin(ret), end(ret));
  ll ret2 = n / ret.back();

  ll ans = ret.back() + ret2 - 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl
use Data::Dumper;
my ($n,$m,$x) = map { $_ - 0 } split(/\s+/,<STDIN>);

my @c;
my @aa = ();

for(my $i=0;$i<$n;$i++){
  
  my @a1 = map { $_ - 0 } split(/\s+/,<STDIN>);
  my $cc = shift @a1;
  push(@c,$cc);
  push(@aa,\@a1);
}

#print Dumper(\@c,\@aa);

my $v1 = ( 2 ** $n - 1 );

my $mn = 10**10;

for(my $i = 1 ; $i <= $v1; $i ++ ){
  #print "i=$i\n";
  my @xx = (); $#xx = $m - 1;
  my $cost = 0;
  
  my $msk = 1;
  for(my $j=0;$j<$n;$j++){
    if( ( $msk & $i ) != 0 ){
      $cost += $c[$j];
      for(my $k = 0;$k<$m;$k++){
        $xx[$k] += $aa[$j]->[$k];
      }
    }
    $msk += $msk;
  }
  my $ng = undef;
  for(my $j=0;$j<$m;$j++){
    if( $xx[$j] < $x ){ $ng = 1;}
  }
  if( !$ng ){
    $mn = $cost if( $cost < $mn );
  }
}

$mn = -1 if $mn == 10**10;

print "$mn\n";



Measured memory_bytes: 6400
S = input()
c = 0


op_cnt = len(S) - 1  # すき間の個数

for i in range(2 ** op_cnt):
  T = ""
  for j in range(op_cnt):
    T += S[j]
    if ((i >> j) & 1):
      T += "+"
  T += S[op_cnt]
  c += eval(T)
print(c)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i,h) cin >> s[i];
	
	const int INF=1e9;
	vector<vector<int>> dp(h,vector<int>(w,INF));
	if(s[0][0]=='.') dp[0][0] = 0;
	else dp[0][0] = 1;
	REP(i,h){
		REP(j,w){
			int cost=0;
			if(i!=h-1){
				if(s[i][j]=='.'&&s[i+1][j]=='#') cost=1;
				chmin(dp[i+1][j], dp[i][j]+cost);
			}
			cost = 0;
			if(j!=w-1){
				if(s[i][j]=='.'&&s[i][j+1]=='#') cost=1;
				chmin(dp[i][j+1], dp[i][j]+cost);
			}
		}
	}
	
	cout << dp[h-1][w-1] << endl;
	
	
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
int main(void){
	int N;
	int i,j;
	scanf("%d",&N);
	double ans = 0;
	char s[4];
	double temp;
	for(i=0;i<N;i++){
		scanf("%lf",&temp);
		scanf("%s",s);
		if(strcmp(s,"JPY")==0){
			ans +=temp;
		}else{
			ans +=temp * 380000;
		}
	}
	printf("%lf",ans);
	return 0;
}

Measured memory_bytes: 128
X=int(input())
n_max=0
for i in range(int(X**0.5)+1):
  if(X==1):
    n_max=1
    break
  else:
    for j in range(X):
      if((i+1)**(j+1)>X):
        #print('i='+str(i+1)+' j='+str(j))
        #print((i+1)**j)
        n_max=max(n_max,(i+1)**j)
        break
print(n_max)

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

int main() {
	int N;
	cin >> N;
	map<string, int> Nums;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		Nums[s]++;
	}
	cout << "AC x " << Nums["AC"] << endl;
	cout << "WA x " << Nums["WA"] << endl;
	cout << "TLE x " << Nums["TLE"] << endl;
	cout << "RE x " << Nums["RE"] << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int m = (n+1)/2;
    cout<<setprecision(10)<<1.0*m/n<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] l = IntStream.range(0, 2 * n).map(i -> scanner.nextInt()).sorted().toArray();
        System.out.println(IntStream.range(0, n).map(i -> l[i * 2]).sum());
    }
}

Measured memory_bytes: 27856
from collections import Counter
N = int(input())

ct = Counter()

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            t = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ct[t] += 1

for i in range(1, N+1):
    print(ct[i])


Measured memory_bytes: 11636
import std.stdio;

void main() {
    int a, b, c, x;
    readf("%d\n%d\n%d\n%d\n", &a, &b, &c, &x);
    int ans = 0;
    foreach  (i; 0 .. a+1) {
        foreach (j; 0 .. b+1) {
            foreach (k; 0 .. c+1) {
                if (x - (500 * i + 100 * j + 50 * k) == 0) {
                    ++ans;
                }
            }
        }
    }
    writeln(ans);
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ch=[0 for i in range(n)]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        ch[a[j]-1]+=1

ans=0
for i in range(n):
    if ch[i]==0:
        ans+=1

print(ans)

Measured memory_bytes: 9196
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 3e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    cout << (1000 - (n%1000))%1000 << '\n';

    return 0;
}

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

using namespace std;

int a = 0, b = 0;

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

    cin >> a >> b;

    if(a <= 5)
    {
        cout << 0;
    }
    else if(a >= 6 && a <= 12)
    {
        cout << b / 2;
    }
    else
    {
        cout << b;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint M;
	cin >> M;

	ull N = 0;
	ull S = 0;
	for(uint i=0; i<M; i++) {
		ull c;
		uint d;
		cin >> d >> c;
		N += c;
		S += d * c;
	}

	cout << (N - 1) + (S - 1) / 9;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int h, w;
    cin >> h >> w;
    vvi a(h, vi(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    struct s {
        int y, x, yy, xx;
    };
    vector
 ret;
    for (int i = 0; i < h; ++i) {
        if (i % 2 == 0) {
            for (int j = 0; j < w - 1; ++j) {
                if (a[i][j] % 2 == 1) {
                    a[i][j + 1]++;
                    ret.push_back({i, j, i, j + 1});
                }
            }
            if (i != h - 1 && a[i][w - 1] % 2 == 1) {
                a[i + 1][w - 1]++;
                ret.push_back({i, w - 1, i + 1, w - 1});
            }
        } else {
            for (int j = w - 1; j > 0; --j) {
                if (a[i][j] % 2 == 1) {
                    a[i][j - 1]++;
                    ret.push_back({i, j, i, j - 1});
                }
            }
            if (i != h - 1 && a[i][0] % 2 == 1) {
                a[i + 1][0]++;
                ret.push_back({i, 0, i + 1, 0});
            }
        }
    }
    cout << ret.size() << endl;
    for (auto r : ret) {
        cout << r.y + 1 << " " << r.x + 1 << " " << r.yy + 1 << " " << r.xx + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
s=input()
cnt=len(s)//2
i=0
if len(s)%2:
    while cnt+i<len(s) and s[cnt-i]==s[cnt+i]==s[cnt]:
        i+=1
else:
    while cnt+i<len(s) and s[cnt-i-1]==s[cnt+i]==s[cnt]:
        i+=1
print(cnt+i)

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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template <class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template <class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }
template <class T> inline T bigmod(T p, T e, T m) { T ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % m; p = (p * p) % m; } return (T)ret; }


void solve() {
	
	int n, k;
	cin >> n >> k;

	cout << n - k + 1 << endl;
}

int main()
{

	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); cout.tie(nullptr); cin.tie(nullptr);

	int t = 1;

	while (t--) {

		solve();
	}



	return 0;
}

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

#define V vector
typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f(i,a) for(int i = 0 ; i < a ; i++)
#define ff first
#define ss second
#define all(x) (x).begin() ,(x).end()

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

#define blk 700
const int N = 5e5 + 5;

struct query {
	int l;
	int r;
	int idx;
};

query Q[N];
int fr[N] , ans[N] , col[N] , cnt = 0 , n , q;

bool cmp(query a , query b)
{
	if (a.l / blk != b.l / blk)
		return a.l / blk < b.l / blk;
	return a.r < b.r;
}

void add(int i)
{
	fr[col[i]]++;
	if (fr[col[i]] == 1)
		cnt++;
}

void remove(int i)
{
	fr[col[i]]--;
	if (fr[col[i]] == 0)
		cnt--;
}
int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> q;

	rep(i, 0, n)
	cin >> col[i];

	rep(i, 0, q)
	{
		int L , R;
		cin >> L >> R;
		L-- , R--;

		Q[i].l = L , Q[i].r = R , Q[i].idx = i;
	}

	sort(Q , Q + q , cmp);

	int ML = 0 , MR = -1;

	rep(i , 0 , q)
	{
		int L = Q[i].l , R = Q[i].r ;

		while (ML > L)
			ML-- , add(ML);
		while (MR < R)
			MR++ , add(MR);
		while (ML < L)
			remove(ML) , ML++;
		while (MR > R)
			remove(MR) , MR--;
		ans[Q[i].idx] = cnt;

	}

	rep(i , 0 , q)
	cout << ans[i] << "\n";
	cout << "\n";
	return 0;
}





Measured memory_bytes: 15440
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

    vector<int> v(n+1), b(n+1),ans;
    FOR(i,1,n+1) cin >> v[i]; 

    for(int i = n;i > 0; i--) {
        int c = 0;
        for(int j = i * 2; j <= n; j+=i) c += b[j];
        if (c % 2 != v[i]) {
            ans.push_back(i);
            b[i]++;
        }
    }

    cout << ans.size() << '\n';
    REP(i,ans.size()) cout << ans[i] << " ";


    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int X[511];
int C[511];
int A[250011];
pair<int, int> P[511];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	int x;
	scanf("%d", &x);
	X[i] = x;
	P[i] = make_pair(x, i);
    }

    sort(P, P+N);

    bool yes = true;
    int pos = 0;
    memset(A, -1, sizeof A);
    VI st;

    REP (i_, N) {
	int x = P[i_].first;
	int i = P[i_].second;
	
	if (x - pos < i + 1) {
	    yes = false;
	    break;
	}
	A[x-1] = i;
	REP (t, i) {
	    while (A[pos] > -1) pos++;
	    A[pos++] = i;
	}
	REP (t, N-1-i) st.push_back(i);
    }

    if (yes) {
	EACH (e, st) {
	    while (A[pos] > -1) pos++;
	    A[pos++] = *e;
	}

	REP (i, N*N) {
	    if (C[A[i]] == A[i]) {
		if (i != X[A[i]]-1) {
		    yes = false;
		}
	    }
	    C[A[i]]++;
	}
    }

    if (yes) {
	puts("Yes");
	REP (i, N*N) A[i]++;
	rprintf("%d", A, A+N*N);
    } else {
	puts("No");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int sum = 0, ans = 0;
  for (int i = 0; i <= A; i++) {
    for (int k = 0; k <= B; k++) {
      for (int l = 0; l <= C; l++) {
        sum = 500 * i + 100 * k + 50 * l;
        if (sum == X){ 
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    int nn = (n*(n-1))/2;
    int mn = (m*(m-1))/2;
    
    System.out.println(nn+mn);
  }
}

Measured memory_bytes: 23764
def main():
    n, m = map(int, input().split())
    sc = [list(map(int, input().split())) for _ in [0]*m]
    x = [None]*n

    for s, c in sc:
        s -= 1
        if x[s] == None:
            x[s] = c
        elif x[s] == c:
            pass
        else:
            print(-1)
            return
    if n != 1 and x[0] == 0:
        print(-1)
        return
    for i in range(n):
        if x[i] == None:
            x[i] = 0
    if n != 1 and x[0] == 0:
        x[0] = 1
    x = [str(i) for i in x]
    print("".join(x))


main()


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

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

typedef long long ll;

const int INF = 1e8;

int n;

bool total(int x){
  if(x == n) return true;
  
  if(x > n) return false;
  
  if(total(x+4)) return true;;
  
  if(total(x+7)) return true;
  
  return false; 
}

int main() {
  cin >> n;
    
  cout << (total(0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import math
a,b,c,x,y = map(int,input().split())
res = a*x + b*y
for i in range(1,max(x,y)+1):
    ab = i*2
    cand = ab*c + a*max(0,x-i) + b*max(0,y-i)
    
    res = min(res, cand)
print(res)

Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(180 * (N-2));
		sc.close();
	}

}


Measured memory_bytes: 20948
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);


void init() {
     
}

void solve() {
    int n;
    scanf(I,&n);
    rep (i,50000) {
        int ex = (i*1.08);
        if (ex == n) { printf(IN,i); return; }
    }
    puts(":(");
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string ss;cin>>ss;
  int k;cin>>k;
  std::vector<string> vec;
  rep(i,ss.size()){
      for(int j=1;j<=k;j++){
          string tmp=ss.substr(i,j);
          vec.push_back(tmp);
      }
  }
  sort(all(vec));
  vec.erase(unique(all(vec)),vec.end());
  cout<<vec[k-1]<<endl;
  return 0;
  }


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    unordered_map<ll,int> m;
    int n;
    cin>>n;
    ll sum=0;
    ll ans=0;
    m[0]=1;
    REP(i,n){
        int a;
        cin>>a;
        sum+=a;
        ans+=m[sum]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {

		int n = 0;
		int[] a = null;
		int q  =0;
		int[] m = null;

		try(BufferedReader br
				= new BufferedReader( new InputStreamReader(System.in) )) {

			n = Integer.parseInt(br.readLine());
			a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

			q = Integer.parseInt(br.readLine());
			m = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();


		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		Set<Integer> canMaked = new HashSet<>();
		for (int i = 0; i < n; i++) {
			final int now = a[i];
			canMaked.addAll(canMaked.stream().map(num -> num + now).collect(Collectors.toSet()));
			canMaked.add(now);
		}

		for(Integer mm : m) {
			if(canMaked.contains(mm)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

	}
}

Measured memory_bytes: 32168
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        Set s = new HashSet<Integer>();

        int n = sc.nextInt();

        boolean out = false;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            Integer e = new Integer(a);
            if (s.contains(e)) {
                System.out.println("NO");
                out = true;
                break;
            } else {
                s.add(e);
            }
        }

        if (!out) {
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 100704
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin>>s;
  ll sum = 0;
  for(auto&&c:s) {
    sum += c - '0';
  }
  if (sum % 9 == 0) {
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'
bool compare(pair<int, int> a, pair<int, int> b){
    return a.second<b.second;
}
int main() {

    fast
    int n;cin>>n;
    vector<pair<int ,int> > v(n);
    for(int i=0; i<n; ++i){
        cin>>v[i].first>>v[i].second;
        //swap(x);

    }
    sort(v.begin(), v.end(), compare);
    // for(int i=0; i<n; ++i){
    //     cout<<v[i].first<<" "<<v[i].second<<endl;
    // }
    // cout<<v[0].first<<" "<<v[0].second;
    if(v[0].first > v[0].second){
        cout<<"No";return 0;
    }
    for(int i=1; i<n; ++i){
        v[i].first+=v[i-1].first;
        // cout<<"i:"<<i<<" ";
        // cout<<v[i].first<<endl;
        if(v[i].first>v[i].second){
            cout<<"No";return 0;
        }
    }

    cout<<"Yes";

    

#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=[0]*(max(a)+3)
ans=0
for i in range(n):
  b[a[i]]+=1
for i in range(len(b)-2):
  ans=max(ans,b[i]+b[i+1]+b[i+2])
print(ans)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll b(n);
  for (ll i = 0; i < n; i++) cin >> b[i];

  vll ans(0);
  while (b.size()) {
    for (ll i = b.size() - 1; i >= 0; i--) {
      if (b[i] == i + 1) {
        b.erase(b.begin() + i);
        ans.push_back(i + 1);
        break;
      }
      if (i == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (ll i = 0; i < n; i++) cout << ans[n - 1 - i] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;
ll pt(ll a){
    return (ll)pow(2,ceil(log2(a+1)));
}

int main() {
    cin >> n;
    map<ll, int> mp;
    vector<ll> a(n);
    Rep(i,n){
        cin >> a[i];
    }
    Rep(i,n){
        auto itr = mp.find(a[i]);
        if(itr!=mp.end()){
            mp[a[i]]++;
        }else{
            mp[a[i]]=1;
        }
    }
    sort(all(a),greater<ll>());
    ll res = 0;
    Rep(i,n){
        ll b = pt(a[i])-a[i];
        if(b==a[i]){
            auto itr = mp.find(b);
            if(itr!=mp.end()){
                if(itr->second>1){
                    res++;
                    itr->second-=2;
                }
            }
        }else{
            auto itr = mp.find(b);
            if(itr!=mp.end()){
                if(itr->second>0&&mp[a[i]]>0){
                    res++;
                    itr->second--;
                    mp[a[i]]--;
                }
            }
        }
    }
    put(res);
    return 0;
}



Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  double T, A;
  cin >> T >> A;
  vector<double> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
    h[i] = abs( (T - 0.006*h[i])-A );
  }
  auto min = min_element(h.begin(), h.end());
  cout << int(min-h.begin())+1 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    using P = pair<int, int>;
    vector<P> v((u32)(h * w + 1), P{0, 0});
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            scanf("%d", &x);
            v[x] = {i, j};
        }
    }
    vector<int> dp((u32)(h*w+1), 0);
    for (int i = 1; i <= h*w; ++i) {
        if(i-d>0) dp[i] = dp[i-d] + abs(v[i].first-v[i-d].first)+abs(v[i].second-v[i-d].second);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        cout << dp[r]-dp[l] << "\n";
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t(ll h, ll w) {
	//横割→縦
	ll ideal = h * w / 3.0;
	//少ないほう
	ll ans = 1000000;
	ll less_up = (ideal / w) * w;
	ll less_left = (h - (ideal / w)) * (w / 2);
	ll less_right = (h - (ideal / w)) * (w - (w / 2));
	ll res = max(less_up, max(less_left, less_right)) - min(less_up, min(less_left, less_right));
	ans = min(ans, res);
	ll more_up = (1 + (ideal / w)) * w;
	ll more_left = (h - (1 + ideal / w)) * (w / 2);
	ll more_right = (h - (1 + ideal / w)) * (w - (w / 2));
	res = max(more_up, max(more_left, more_right)) - min(more_up, min(more_left, more_right));
	ans = min(ans, res);
	return ans;
}

int main() {
	ll h, w;
	cin >> h >> w;

	ll ans = 1e11;
	//横割り
	if (h % 3 == 0) { ans = 0; cout << ans << endl; return 0; }
	else ans = w;
	//縦割り
	if (w % 3 == 0) { ans = 0; cout << ans << endl; return 0; }
	else ans = min(ans, h);
	//横割り→縦
	ans = min(ans, t(h, w));
	ans = min(ans, t(w, h));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
using V = vector<int>;
constexpr array<int, 4> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
constexpr int INF = 1234567890, MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
// constexpr int INF2 = 1000000000000000000LL+7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int ceil(int a, int b) { return (a + b - 1) / b; }
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}

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

    int n, W;
    cin >> n >> W;

    vector<P> vw(n);
    for (int i = 0; i < n; i++)
    {
        int v, w;
        cin >> v >> w;
        vw[i] = {v, w};
    }

    // dp[w]: 容量wのナップサックの最大の価値
    // 商品iまでのdpから商品i+1のdpを求める
    // dp[W]が答え

    // 同じ商品は1つしかナップサックに入れられない
    // 遷移元のDP表には今の商品の情報は入ってほしくない
    // なので1ステップ前のDP表から遷移させる
    // 同じ商品を複数ナップサックに入れられるときは，今ステップのDP表から遷移させる

    vector<int> dp(W + 1, 0);
    vector<int> new_dp(W + 1, 0);
    for (auto &&vwi : vw)
    {
        const int v = vwi.first, w = vwi.second;

        // dp値更新
        for (int i = 1; i < W + 1; i++)
        {
            if (i - w >= 0)
                new_dp[i] = max(dp[i - w] + v, dp[i]);
        }
        dp = new_dp;
    }
    cout << dp[W] << endl;
}



Measured memory_bytes: 3348
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> ans = new ArrayList<Integer>();
		String line;
		
		while((line = in.readLine()) != null){
			int num = Integer.parseInt(line);
			if(num == -1) break;
			
			int m = num;
			while(m != 0){
				ans.add(m%4);
				m >>= 2;
			}
			
			if(ans.size() != 0){
				for(int i=ans.size()-1; i>=0; i--){
					System.out.print(ans.get(i));
				}
				System.out.println();
			}else{
				System.out.println("0");
			}	
			ans.clear();
		}
	}
}

Measured memory_bytes: 9928
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            var ls = new List<int>();
            if(n == 2) { WriteLine(s[0] * 2);return; }

            ls.Add(s[0]);
            for (int i = 0; i < n-2; i++)
            {
                ls.Add(Min(s[i] , s[i+1]));
            }
            ls.Add(s[n-2]);

            WriteLine(ls.Sum());
        }

    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, l;
  cin >> n >> l;
  vector<int> a(n);
  rep(i, n) a.at(i) = l + i;
  sort(ALL(a), [](const auto &l1, const auto &l2){
    return abs(l1) < abs(l2);
  });
  int ans = 0;
  rep2(i, 1, n) ans += a.at(i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
// include all standard library.
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
  int x;
  for(int i = 0; i< 5; i++) {
      cin >> x;
      if(x == 0) {
          cout << i+1 << endl;
          return 0;
      }
  }
  return 0;
}

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

typedef long long ll;

ll inf = 1e9+7;
ll fact[210] = {0};
ll inv[210] = {0};

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			fact[i] = 1;
			inv[i] = 1;
		}
		else{
			fact[i] = (i*fact[i-1])%inf;
			inv[i] = mult(fact[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	else return (((fact[n]*inv[k])%inf)*inv[n-k])%inf;
}

ll N,X;
ll dp[210][100010] = {};
ll S[210];
int main(){
    cin >> N >> X;
    factorial(N);
    ll ma = X;
    for(int i=1;i<=N;i++){
        cin >> S[i];
        ma = max(S[i],ma);
    }
    sort(S+1,S+N+1);
    ll ans = 0;
    for(int j=0;j<=ma;j++) dp[0][j] = j%S[1];
    for(ll i=1;i<=N;i++){//iまででjをもらったときの総和
        for(int j=0;j<=ma;j++){
            if(i!=1) dp[i][j] = (dp[i-1][j%S[i]]%inf+(dp[i-1][j]*(i-1)%inf))%inf;
            else dp[i][j] = j%S[i];
        }
        ll c = comb(N-1,N-i)*fact[N-i]%inf;
        (ans += dp[i-1][X%S[i]]*c)%=inf;
    }
    cout << ans << endl;
}

Measured memory_bytes: 157952
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
l = []
for i in range(n):
    tmp = isl()
    tmp.append(i+1)
    l.append(tmp)
#print(l)
l = sorted(l,key=lambda x:int(x[1]),reverse=True)
#print(l)
l = sorted(l,key=lambda x:x[0])
for j in l:
    print(j[2])

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

#define ll long long
#define ld long double
using namespace std;

const ll mod = (ll)1000000007;

int main() {
    ll n;
    cin >> n;
    ll answ = 1;
    for (ll i = 1; i <= n; i++)
    {
        answ = answ * i;
        answ = answ % mod;
    }
    cout << answ << 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 n = sc.nextInt();
    int l = sc.nextInt();

    int appleToRemove = Math.max(1, Math.min(n, -l + 1));

    System.out.println((2 * l + n - 1) * n / 2 - (l + appleToRemove - 1));
  }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))

f = True

for i in range(n):
	if a[i] % 2 == 0:
		if a[i] % 3 != 0 and a[i] % 5 != 0:
			f = False

print("APPROVED" if f else "DENIED")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    ll N;
    cin >> N;
    vector<ll> A(N+1);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    A[N] = -1;
    ll cnt = 0;
    for(ll i = 1; i <= N; i++){
        if(A[i] <= A[i-1])cnt++;
    }
    cout << cnt << endl << N << endl;

    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
#define GO(x, p, e, i, v) for (register int i = p[x].head, v; i; i = e[i].link)
typedef long long i64;
#define Templ(T) template <typename T>
inline int read() {
    reg int ans = 0, f = 1;
    reg char c = getchar();
    while (!isdigit(c)) f ^= (c == '-'), c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return f ? ans : -ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
} // namespace my_std
using namespace my_std;

#define N 500010
int n, m;
int f[3];
int comp;
struct Edge{
    int link, to;
}e[N << 1];
struct Vertice{
    int head, col;
}p[N];
int ecnt(0);
#define col(x) p[x].col
#define head(x) p[x].head
inline void A_E(int u, int v){
    e[++ecnt] = (Edge){head(u), v};
    head(u) = ecnt;
}
inline int qm3(reg const int &x){
    return x > 2 ? x - 3 : x;
}
inline i64 sqr(reg const int &x){
    return (i64)x * x;
}

inline void dfs(int u){
    Rint t;
    ++f[col(u)];
    GO(u, p, e, i, v){
        v = e[i].to;
        if(i & 1) ++ecnt;
        t = qm3(col(u) + 1 + (!(i & 1)));
        if(col(v) == -1){
            col(v) = t, dfs(v);
        }
        else{
            if(col(v) != t) comp = 1;
        }
    }
}

int main() {
    n = read(), m = read();
    Rint u, v;
    FOR(i, 1, m){
        u = read(), v = read();
        A_E(u, v), A_E(v, u);
    }
    FOR(i, 1, n) col(i) = -1;
    reg i64 ans(0);
    FOR(i, 1, n) if(col(i) == -1){
        col(i) = 0, f[0] = f[1] = f[2] = 0;
        ecnt = 0, comp = 0;
        dfs(i);
        if(comp){
            ans += sqr(f[0] + f[1] + f[2]);
            continue;
        }
        if(!f[0] || !f[1] || !f[2]){
            ans += ecnt;
            continue;
        }
        ans += (i64)f[0] * f[1] + (i64)f[1] * f[2] + (i64)f[2] * f[0];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 10800
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 x[100];
s64 y[100];
s64 h[100];

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

    int N;
    cin >> N;

    rep (i, N)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    if (N == 1)
    {
        cout << x[0] << " " << y[0] << " " << h[0] << "\n";
        return 0;
    }

    s64 cx, cy, H;
    bool detected;
    for (cx = 0; cx <= 100; ++cx)
    {
        for (cy = 0; cy <= 100; ++cy)
        {
            detected = true;
            int temp = 0;
            while (h[temp] == 0) ++temp;
            H = abs(x[temp] - cx) + abs(y[temp] - cy) + h[temp];
            for (int i = 0; i < N && detected; ++i)
            {
                s64 height = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                if ((h[i] != 0 && H < height) || (H > height))
                {
                    detected = false;
                }
            }
            if (detected) break;
        }
        if (detected) break;
    }

    cout << cx << " " << cy << " " << H << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; ++i) // マクロ
using namespace std; // stdの省略
using pii = pair<int, int>; // pairの略記
using ll = long long; // long longの略記


int main(void) {
   
   int n, m;
   cin >> n >> m;
   
   vector<int> a(m);
   int sum = 0;
   rep(i,m) {
       cin >> a[i];
       sum += a[i];
   }
   
   int ans = -1;
   if (n>=sum) ans = n - sum;
   cout << ans << endl;
   
   return 0;
}

Measured memory_bytes: 3628
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    p = math.ceil(n/2)
    for i in range(n):
        num = (p*(p+1))/2
        if num <= n:
            break
        else:
            p -= 1
    if num == n:
        for i in range(p):
            print(i+1)
        exit()
    else:
        p += 1
        num = (p*(p+1))/2
        dif = num-n
        for i in range(p):
            if i+1 == dif:
                pass
            else:
                print(i +1)








if __name__ == '__main__':
    solve()


Measured memory_bytes: 9188