akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 5000000
using namespace std;
struct node
{
	int l,r,id;
}q[N+5];
int n,a[N+5],m,c[N+5],f[N+5],ans[N+5];
int lowbit(int x)
{
	return x&(-x);
}
int cmp(node x,node y)
{
	return x.r<y.r;
}
void add(int x,int k)
{
	for (;x<=n;x+=lowbit(x))c[x]+=k;
}
int query(int x)
{
	int ans=0;
	for (;x;x-=lowbit(x))ans+=c[x];
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=m;i++)
		scanf("%d%d",&q[i].l,&q[i].r),q[i].id=i;
	sort(q+1,q+m+1,cmp);
	for (int i=1;i<=m;i++)
	{
		for (int j=q[i-1].r+1;j<=q[i].r;j++)
		{
			if (f[a[j]])add(f[a[j]],-1);
			f[a[j]]=j;
			add(j,1);
		}
		ans[q[i].id]=query(q[i].r)-query(q[i].l-1);
	}
	for (int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 17440
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	ll n,k;cin>>n>>k;
	
	ll ans=0;
	
	if(k==0){
		cout<<n*n<<endl;return 0;
	}
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j+=i){
			int k1=(n-j);
			k1=min(k1,i-1);
			if(k1>=k){
				ans+=(k1-k+1);
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

dic= {}
for i in A:
    if i in dic:
        dic[i]+= 1
    else:
        dic[i] = 1

flag = 1

if N%2 == 1:
    for m, n in dic.items():
        if m == 0:
            if n != 1:
                flag = 0
                break
        elif m%2 == 1 or n != 2:
            flag = 0
            break
else:
    for m, n in dic.items():
        if m%2==0 or n != 2:
            flag = 0
            break
if flag:
    if N%2 == 0:
        print(2**(N//2)%1000000007)
    else:
        print(2**((N-1)//2)%1000000007)
else:
    print(0)

Measured memory_bytes: 14436
N = int(input())

# lst = input().split() # ←だとWAになる int として処理する必要がある
lst = list(map(int,input().split()))

cnt = 0

for i in range(N):
    if lst[i] != i+1:
        cnt += 1

if cnt <= 2:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 3064
#include <iostream>
 
using namespace std;
 
int main(){
	long long h, n;
  	cin>>h>>n;
  	long long a[n];
	for(long long i = 0; i < n; i++){
    	cin>>a[i];
    }
  
  	long long sum = 0;
  	for(int i = 0; i < n; i++){
    	sum += a[i];
    }
  
  	if(sum >= h) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  
  	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;

const int MAXN = 100010;
struct Input {
	int pid, year;
	int outputorder;
	bool operator<(const Input &rhs) const {
		return year<rhs.year;
	}
}build[MAXN];
int pref[MAXN];
int main() {
	memset(pref, 0, sizeof(pref));
	int n, m;
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		cin>>build[i].pid>>build[i].year;
		build[i].outputorder=i;
	}
	sort(build, build+m);
	char ans[MAXN][15];
	for (int i=0; i<m; i++)
		sprintf(ans[build[i].outputorder], "%06d%06d",build[i].pid, ++pref[build[i].pid]);
	for (int i=0; i<m; i++)
		cout<<ans[i]<<endl;
	return 0;
}


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

using namespace std; 

int main() 
{ 
	int n1,n2;
	
	cin>>n1>>n2;
	
	int a[n1],b[n2];
	
	for(int i = 0 ; i < n1 ; i++) cin>>a[i];
	for(int i = 0 ; i < n2 ; i++) cin>>b[i];
	
	long long int cnt[n1+1][n2+1];
	memset(cnt,0,sizeof(cnt));

    for(int i = 0 ; i < n1 ; i++){
        for(int j = 0 ; j < n2 ; j++){
            if(a[i]==b[j]) {cnt[i+1][j+1] = (cnt[i][j+1]+cnt[i+1][j]+1)%1000000007;}
            else {cnt[i+1][j+1] = (cnt[i][j+1]+cnt[i+1][j]-cnt[i][j])%1000000007;}
        }
    }
	cout <<(cnt[n1][n2]+1+1000000007)%1000000007<<endl; 
	return 0; 
} 


Measured memory_bytes: 34924
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    vl v(n+1),c(n+1,0),a;
    fo(i,n)cin>>v[i+1];
    for(int i=n;i>0;i--){
        h=0;
        for(int j=i;j<=n;j+=i)h^=c[j];
        c[i]=h^v[i];
    }
    fo(i,n+1)if(c[i])a.pb(i);
    cout<<sz(a)<<el;
    if(sz(a)>0)pt(a);
    return 0;
}


Measured memory_bytes: 5108
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<vector<int>> geko;
	vector<int> nya;
	nya.push_back(1);
	geko.push_back(nya);
	geko.push_back(nya);
	while (geko[geko.size() - 1][geko[geko.size() - 1].size() - 1] < n) {
		long long now = geko[geko.size() - 1][geko[geko.size() - 1].size() - 1];
		long long maximum = now + geko.size();
		for (int i = 0; i < geko.size(); ++i) {
			geko[i].push_back(now + i + 1);
		}
		vector<int> bobo;
		REP(i, geko.size()) {
			bobo.push_back(now + i + 1);
		}
		geko.push_back(bobo);
	}
	if (geko[geko.size() - 1][geko[geko.size() - 1].size() - 1] != n) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		cout << geko.size() << endl;
		REP(i, geko.size()) {
			cout << geko[i].size();
			REP(q, geko[i].size()) {
				cout << " " << geko[i][q];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] dice1 = new int[6];
        int[] dice2 = new int[6];
        for(int i = 0; i < 6; i++){
            dice1[i] = sc.nextInt();
        }
        for(int i = 0; i < 6; i++){
            dice2[i] = sc.nextInt();
        }
        String order = "RRRRNRRRRNRRRRNRRRRWRRRWWRRR";
        for(int i = 0; i < order.length(); i++){
            char c = order.charAt(i);
            int[] temp = new int[6];
            if(c == 'R'){
                temp[0] = dice2[0];
                temp[1] = dice2[3];
                temp[2] = dice2[1];
                temp[3] = dice2[4];
                temp[4] = dice2[2];
                temp[5] = dice2[5];
            }else if(c == 'W'){
                temp[0] = dice2[2];
                temp[1] = dice2[1];
                temp[2] = dice2[5];
                temp[3] = dice2[0];
                temp[4] = dice2[4];
                temp[5] = dice2[3];
            }else if(c == 'N'){
                temp[0] = dice2[1];
                temp[1] = dice2[5];
                temp[2] = dice2[2];
                temp[3] = dice2[3];
                temp[4] = dice2[0];
                temp[5] = dice2[4];
            }
            dice2 = temp;
            if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 26416
import java.util.Scanner;

public class Main {

    public static void main(String[] args)throws Exception {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        while (!(line.equals("-"))) {
            
            String num = sc.nextLine();
            int n = Integer.parseInt(num);

            for (int i = 0; i < n; i++) {
                int count = Integer.parseInt(sc.nextLine());

                line = line.substring(count) + line.substring(0, count);
            }
            System.out.println(line);
            line = sc.nextLine();
        }
        sc.close();

    }

}

Measured memory_bytes: 17452
#!/usr/bin/perl
use POSIX qw(floor);

my ($N,$K) = map { $_ - 0 } split(/\s+/,<STDIN>);

my @p = map { $_ - 0 } split(/\s+/,<STDIN>);

my @sp = sort { $a <=> $b } @p;

my $t=0;
for(my $i=0;$i<$K;$i++){
  $t += $sp[$i];
}
print "$t\n";


Measured memory_bytes: 6712
// Vivek Rai
// Blazer_007

#include<bits/stdc++.h>
using namespace std;

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

signed main() {

    fastio

    ll a , b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3640
<?php
$n = trim(fgets(STDIN));
$arr= explode(" ", trim(fgets(STDIN)));

rsort($arr);
$ave = ($arr[$n-1] + $arr[$n-2]) / 2;

if($n > 2) {
    for ($i = $n-3; $i >= 0; $i--) {
        $ave = ($ave + $arr[$i]) / 2;
    }
}

echo $ave;


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=505;
int d[N][N],v[N][N];
int p[N*N],n;
queue<pii> q;
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
inline void update(){
	while(q.size()){
		int x=q.front().fi,y=q.front().se;q.pop();
		for(int t=0;t<4;t++){
			int px=x+dx[t],py=y+dy[t];
			if(px<1||px>n||py<1||py>n)continue;
			if(d[px][py]>d[x][y]+v[px][py]){
				d[px][py]=d[x][y]+v[px][py];
				q.push(pii(px,py));
			}
		}
	}
}
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read();int res=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)d[i][j]=min(i,min(n-i+1,min(j,n-j+1))),v[i][j]=1;
	for(int tt=1;tt<=n*n;tt++){
		int id=read(),x=(id-1)/n+1,y=id-(x-1)*n;
		res+=d[x][y]-1;v[x][y]=0;
	//	cout<<x<<" "<<y<<" "<<res<<'\n';
		d[x][y]--;q.push(pii(x,y));
		update();
	}cout<<res<<'\n';
}

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

#define ll long long
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    ll n,f=0;
	cin >> n;
	for(int i=1;i<=n;i++){
	   for(int j=1;j<=n;j++){
	       ll y=gcd(i,j);
	       for(int k=1;k<=n;k++){
	       ll z=gcd(y,k);
	       f+=z;
	       }
	   }
	}
	cout<<f;
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    sort(begin(A), end(A));
    
    if(N % 2 == 0) {
        long long res = 0;
        int n = (N - 2) / 2;
        for(int i=0; i<n; ++i) {
            res += 2LL * A[N - 1 - i];
            res -= 2LL * A[i];
        }
        res += A[n + 1] - A[n];
        cout << res << endl;
    } else {
        long long res1 = 0, res2 = 0;
        int n1 = (N - 3) / 2;
        int n2 = (N - 1) / 2;
        for(int i=0; i<n1; ++i) {
            res1 += 2LL * A[N - 1 - i];
            res2 -= 2LL * A[i];
        }
        for(int i=0; i<n2; ++i) {
            res1 -= 2LL * A[i];
            res2 += 2LL * A[N - 1 - i];
        }
        res1 += A[n2] + A[n2 + 1];
        res2 -= A[n1] + A[n1 + 1];
        cout << max(res1, res2) << endl; 
    }
}


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


#define rep(i,n) for (int i=0; i<(n); i++)
const ll INF =2*1e9+2;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    int n;
    cin >> n;
    n %= 1000;
    if(n==0) cout << "0" << endl;
    else cout << 1000-n << endl;
    return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int vec,ans = 0;
  for(int i = 0;i < n;i++){
    cin >> vec;
    if(vec >= k) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

int main(void){
   int N;
   cin>>N;
   vector<int> T(N);
   for(int i=0;i<N;i++){
      cin>>T[i];
   }
   int M;
   cin>>M;
   vector<int> P(M),X(M);
   for(int i=0;i<M;i++){
      cin>>P[i]>>X[i];
   }
   for(int i=0;i<M;i++){
      int sum=0;
      for(int j=0;j<N;j++){
         if(j==P[i]-1) sum+=X[i];
         else sum+=T[j];
      }
      cout<<sum<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()

if N%2 == 0:
  S = A[:N//2]
  L = A[N//2:]
  ans = 2*sum(L)-L[0]-2*sum(S)+S[-1]
else:
  S1 = A[:N//2]
  L1 = A[N//2:]
  S2 = A[:N//2+1]
  L2 = A[N//2+1:]
  ans1 = 2*sum(L1)-L1[0]-L1[1]-2*sum(S1)
  ans2 = 2*sum(L2)-2*sum(S2)+S2[-1]+S2[-2]
  ans = max(ans1,ans2)
print(ans)

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

int main() {
int n,m,x,y;
cin>>n>>m>>x>>y;
int x_max=-1e+9;
for(int i=0;i<n;i++){
  int xi;
  cin>>xi;
  x_max=max(x_max,xi);
}
int y_min=1e+9;
for(int i=0;i<n;i++){
  int yi;
  cin>>yi;
  y_min=min(y_min,yi);
}
int z=y_min;
if(x<z&&z<=y&&x_max<z) cout<<"No War"<<endl;
else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    boost::multi_array<int64_t, 2> a(boost::extents[H][W]);
    for (auto p = a.data(); p < (a.origin() + a.num_elements()); ++p) {
        std::cin >> *p;
    }

    int64_t movecount = 0;

    std::stringstream ss;

    int64_t moving = 0;
    for (int64_t h = 1; h <= H; ++h) {
        if (h % 2 == 1) {
            // ----->
            for (int64_t w = 1; w <= W; ++w) {
                a[h-1][w-1] += moving;
                moving = 0;
                if (!(h == H && w == W) && (a[h-1][w-1] % 2) != 0) {
                    movecount++;
                    a[h-1][w-1]--;
                    moving = 1;
                    ss << h << " " << w << " ";
                    if (w == W) {
                        ss << h+1 << " " << w << std::endl;
                    }
                    else {
                        ss << h << " " << w+1 << std::endl;
                    }
                }
            }
        }
        else {
            // <------
            for (int64_t w = W; w > 0; --w) {
                a[h-1][w-1] += moving;
                moving = 0;
                if (!(h == H && w == 1) && (a[h-1][w-1] % 2) != 0) {
                    movecount++;
                    a[h-1][w-1]--;
                    moving = 1;
                    ss << h << " " << w << " ";
                    if (w == 1) {
                        ss << h+1 << " " << w << std::endl;
                    }
                    else {
                        ss << h << " " << w-1 << std::endl;
                   }
                }
            }
        }
    }

    std::cout << movecount << std::endl;
    std::cout << ss.str();


    return 0;
}


Measured memory_bytes: 7940
#include <stdio.h>

int main(void){

    int r = 0;
    int d = 0;
    int x = 0;

    scanf("%d %d %d", &r, &d, &x);

    for (int i = 1; i <= 10; i++){
        x = r * x - d;
        printf("%d\n", x);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  int ans=N/11*2;
  N%=11;
  if(N>=6)ans++,N-=6;
  if(N)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = input()
    
    for i,vol in enumerate(s):
        if i == 0:
            continue
        if vol == s[i-1]:
            print("{} {}".format(i, i+1))
            sys.exit()
            
    for i,vol in enumerate(s):
        if i + 2 >= len(s):
            break
        if vol == s[i+2]:
            print("{} {}".format(i+1, i+3))
            sys.exit()
            
    print("-1 -1")
    
if __name__ == "__main__":
	main()


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int keta(ll A)
{
    int cnt = 0;
    while (A)
    {
        cnt++;
        A /= 10;
    }
    return cnt;
}

int main()
{
    int N, M;
    int A[] = {1, 2};
    cin >> N >> M;
    vector<vector<int>> vec(M);
    vector<int> p(M);

    rep(i, M)
    {
        int k;
        cin >> k;
        vec[i].resize(k);
        rep(j, k)
        {
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }
    rep(i, M) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        bool ok = true;
        rep(i, M)
        {
            int cnt = 0;
            rep(j, vec[i].size())
            {
                if (bit & (1 << vec[i][j]))
                {
                    cnt++;
                }
            }
            if (cnt % 2 != p[i])
                ok = false;
        }
        if (ok)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
int main(){
    ll n,k;
    cin>>n>>k;
    ll h[100000];
    ll count =0;
    for(ll i=0;i<n;i++)
    {
        ll t;
        cin>>t;
        if(t>=k)count++;
    }
    cout<<count;   
}

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

int main(){
	int n,m;
	long long int p=1e9+7;
	cin>>n>>m;
	int a;
	vector<long long int> dp(n+1,-1);
	for (int i = 0; i < m; i++) {
		cin>>a;
		dp[a]=0;
	}
	dp[0]=1;
	if (dp[1]==-1) {
		dp[1]=1;
	}
	for (int i = 0; i < n-1; i++) {
		if (dp[i+2]==-1) {
			dp[i+2]=dp[i]+dp[i+1];
			dp[i+2]%=p;
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#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 x1,y1,x2,y2;
  cin >>x1 >>y1 >>x2 >>y2;
  int X = x1-x2;
  int Y = y1-y2;
  cout << x2+Y << " " << y2-X << " " << x1+Y << " " << y1-X << endl;
  return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, S;
    cin >> N >> K >> S;
    for (int i = 1; i <= K; i++)
        cout << S << " ";
    if (S <= 500000000) {
        for (int i = K + 1; i <= N; i++)
            cout << 2 * S << " ";
    } else {
        for (int i = K + 1; i <= N; i++) {
            cout << 1 << " ";
        }
    }
    cout << endl;
}

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

int main(){
  int n;
  cin>>n;
  int f[10001]={};
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        int a=i*i+j*j+k*k+i*j+j*k+k*i;
        if(a<=10000) f[a]++;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<f[i]<<endl;
  }
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    Rep(i, n) data[i] ^= data[i-1];

    vi dp0(1 << 20, 1), dp1(1 << 20, 0), zeros(1 << 20, 0);
    // 始点に 0 があると考えるので全ての x について初期0数1個
    int zero = 0; 
    rep(i, n) {
        if (!data[i]) {
            zero++;
        } else {
            (dp0[data[i]] += dp1[data[i]] * (zero - zeros[data[i]])) %= MOD; // 0 の累積を求める
            (dp1[data[i]] += dp0[data[i]]) %= MOD; // i 番目の解が求められ、区間の値 k = data[i] の時の解の累積が増える
            zeros[data[i]] = zero;
            //std::cout << dp0[data[i]] << " , " << dp1[data[i]] << std::endl;
        }
    }

    if (data.back()) {
        std::cout << dp0[data.back()] << std::endl;
    } else {
        int ans = 1;
        rep(i, zero-1) ans = (ans * 2) % MOD;
        rep(i, dp1.size()) ans += dp1[i];
        std::cout << ans % MOD << std::endl;
    }

    return 0;
}


Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    int k, t;
    cin >> k >> t;
    priority_queue<int> pq;
    rep(i,t){
        int a;
        cin >> a;
        pq.push(a);
    }

    ll ans;
    if (t == 1){
        ans = pq.top() - 1;
    }else{
        while(true){
            int a1 = pq.top(); pq.pop();
            int a2 = pq.top(); pq.pop();
            if (a2 == 0){
                ans = max(a1-1, 0);
                break;
            }else{
                a1--; a2--;
                pq.push(a1);
                pq.push(a2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>

//#include <map>

using namespace std;

int main(void)
{
	string str;
	//str = "10000 1000 100";
	getline(cin, str);

	vector<string> vStr;

	while (str.find(' ') != -1)
	{
		vStr.push_back(str.substr(0, str.find(' ')));
		str.erase(0, str.find(' ') + 1);
	}
	vStr.push_back(str);

	vector<int> vInt;
	for (int i = 0; i < vStr.size(); i++)
	{
		vInt.push_back(stoi(vStr.at(i)));
	}

	sort(vInt.begin(), vInt.end());
	
	string ans;

	char t[20];
	sprintf(t,"%d %d %d", vInt.at(0),vInt.at(1),vInt.at(2));

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,x,a[200010];
int main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<endl;
    return 0;
}


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

using namespace std;

template <typename T>
ostream &operator<<(ostream &os, const std::vector<T> &vec) {
  for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  vector<int> B(N + 1, 0), W(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == '#') B[i + 1]++;
    B[i + 1] += B[i];
  }
  for (int i = N - 1; i > -1; i--) {
    if (S[i] == '.') W[i + 1]++;
    W[i] += W[i + 1];
  }
  int res = 1 << 29;
  for (int i = 0; i < N; i++) {
    res = min(res, B[i + 1] + W[i + 1]);
  }
  cout << res - 1 << '\n';
  return 0;
}


Measured memory_bytes: 2196
{-# LANGUAGE TypeFamilies, BangPatterns, FlexibleContexts #-}
import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.Unsafe
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as U
import Data.Int
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as B
import Data.ByteString(ByteString)
import Data.Char

type Scanner a = StateT ByteString IO a
type family Freeze a where
  Freeze (IOUArray i v) = UArray i v
  Freeze (IOArray i v) = Array i v

foldM :: Monad m => (b -> a -> m b) -> b -> [a] -> m b
foldM f z0 xs = foldr c return xs z0
    where c x k = \z -> f z x >>= k
          {-# INLINE c #-}

scan :: Read a => Scanner a
scan = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s 
        !v = read (B.unpack s1)
    in (v, B.dropWhile isSpace s2)

scanInt :: Scanner Int
scanInt = scan

scanString :: Scanner B.ByteString
scanString = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s in
    (s1, B.dropWhile isSpace s2)

scanReal :: Scanner Double
scanReal = scan

main :: IO ()
main = B.getContents >>= \content -> flip evalStateT content $ do
    vN <- scanInt
    vs <- scanString
    liftIO $ solve vN vs
solve :: Int -> B.ByteString -> IO ()
solve vN vs = putStrLn $ if flag then "Yes" else "No"
  where
  flag = B.count 'R' vs > B.count 'B' vs
  


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N,A;
int dp[55][55][2555];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>A;
    dp[0][0][0]=1;
    rep(i,N){
        int x; cin>>x;
        rep(j,N){
            rep(k,2501){
                dp[i+1][j][k]+=dp[i][j][k];
                dp[i+1][j+1][k+x]+=dp[i][j][k];
            }
        }
    }
    int ans=0;
    rep(i,N){
        ans+=dp[N][i+1][(i+1)*A];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 56448
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 


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

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

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

    ll n;
    cin>>n;
    ll a[200010];
    rep(i,n){
        cin>>a[i];
    }
    ll now=1;
    rep(i,n){
        if(a[i]==now){
            now++;
        }
    }
    if(now!=1) cout<<n-now+1<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	if ((a < b) && (b < c)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
char S[maxn],T[maxn];
bool maz[30][30],fan[30][30];
int m[30],f[30];
bool work(){
    memset(maz,false,sizeof(maz));
    memset(fan,false,sizeof(fan));
    int n = strlen(S);

    for (int i=0;i<n;i++) maz[S[i]-'a'][T[i]-'a'] = true,fan[T[i]-'a'][S[i]-'a'] = true;

    for (int i=0;i<26;i++){
        m[i] = 0;
        for (int j=0;j<26;j++) if (maz[i][j]) m[i]++;
        f[i] = 0;
        for (int j=0;j<26;j++) if (fan[i][j]) f[i]++;
//        cout<<m[i]<<" "<<f[i]<<endl;
        if (m[i] > 1 || f[i] > 1) return false;
    }
    return true;
}
int main(){
    while (~scanf("%s%s",S,T)) if (work()) puts("Yes");else puts("No");
    return 0;
}



Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
print(a*b//fractions.gcd(a,b))


Measured memory_bytes: 66156
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

string s;

int main(void) {

	cin >> s;
	int N = s.size();

	int ans = 9999999;

	int C[120];

	for (int i = 0; i < 26; i++) {
		for (int k = 0; k < N; k++) { C[k] = 9999999; }

		for (int k = 0; k < (int)s.size(); k++){
			for (int y = k; y < (int)s.size(); y++) {
				if ((s[y] == (i + 'a'))) { C[k] = min(C[k], y - k); }
			}
			C[k] = min(C[k], N - k);
        }

	/*	for (int k = 0; k <(int)s.size(); k++) {
			cout << "C[" << k << "]= " << C[k] << endl;
		}*/
		int val = 0;
		for (int j = 0; j < N; j++) { val = max(val, C[j]); }
		ans = min(ans, val);
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    ll x,y;cin >> x >> y;
    int ans=1;

    while(1){
        if(x <= y/2) x *= 2;
        else break;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    println!("{}", if a + b >= c { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
var arr=v.split(" ").map(Number);
var A=arr[0]*arr[4]-arr[3]*arr[1];
var B=arr[2]*arr[4]-arr[5]*arr[1];
var C=arr[0]*arr[5]-arr[3]*arr[2];
var x=(B/A).toFixed(3);
var y=(C/A).toFixed(3);
console.log(x+" "+y);
});

Measured memory_bytes: 7644
s = input()
K = int(input())

dp = [[[0 for i in range(2)] for j in range(4)] for k in range(105)]

n = len(s)

dp[0][0][0] = 1
# print(dp)
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])  # 今の桁の数
            for d in range(10):
                ni = i + 1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
# print(dp)
ans = dp[n][K][0] + dp[n][K][1]
print(ans)



Measured memory_bytes: 3064
def l():
    return [int(x) for x in input().split()]
def main():
    H,W=l()
    ch,cw=l()
    dh,dw=l()
    ch-=1
    cw-=1
    dw-=1
    dh-=1
    s=[[-2 if x=='#' else -1 for x in list(input())] for _ in range(H)]
    pad1=[-2,-2]
    pad2=[[-2]*(W+4)]*2
    s=pad2+[pad1+x+pad1 for x in s]+pad2
    move1=[(-1,0),(1,0),(0,-1),(0,1)]
    move2=list(set([(i,j) for i in range(-2,3) for j in range(-2,3)])-set(move1)-set([(0,0)]))
    q1=[(0,ch+2,cw+2)]
    q2=[]
    s[ch+2][cw+2]=0
    def mark(c,h,w):
        if -2<=h<H+2 and -2<=w<W+2 and s[h][w]==-1:
        #if s[h][w]==-1:
            s[h][w]=c
            q1.append((c,h,w))
    while q1:
        #print(q1)
        c,h,w=q1.pop()
        for i,j in move1:
            mark(c,h+i,w+j)
        q2.append((c+1,h,w))
        if not q1:
            for c,h,w in q2:
                for i,j in move2:
                    mark(c,h+i,w+j)
            q2=[]
    ans=s[dh+2][dw+2]
    if ans>=0:
        print(ans)
    else:
        print(-1)
main()


Measured memory_bytes: 114332
#include<iostream>
#include<string>
using namespace std;
char upper(char C){
  if(C>='A'&&C<='Z')
    C=C+'a'-'A';
  return C;
}
int main(){
  int num[26]={0};
  char alfa[26]={0};
  for(int i=0;i<26;i++)
    alfa[i]='a'+i;
  string str;
  while(cin>>str){
    for(int i=0;i<str.size();i++){
      str[i]=upper(str[i]);
      if(str[i]<='z'&&str[i]>='a')
	num[str[i]-'a']++;
    }
  }
  for(int i=0;i<26;i++){
    cout<<alfa[i]<<" "<<':'<<" "<<num[i];
    if(i!=26)
      cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
import java.util.*;
import java.math.BigDecimal;
import java.text.NumberFormat;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        float[] a = new float[6];
        float x,y = 0;
        NumberFormat nf = NumberFormat.getInstance();
        while(s.hasNext()){
            for(int i=0; i < 6; i++)
                a[i] = s.nextFloat();
            if(a[0]==0){
                y = a[2]/a[1];
                x = (a[5] - a[4]*y)/a[3];
            }else{
                float c = a[3]/a[0];
                y = (a[5]-c*a[2])/(a[4] - c*a[1]);
                x = (a[2] - a[1] * y)/a[0];
            }
            nf.setMinimumFractionDigits(3);
            BigDecimal x0 = new BigDecimal(x);
            BigDecimal x1 = x0.setScale(3, BigDecimal.ROUND_HALF_UP);
            BigDecimal y0 = new BigDecimal(y);
            BigDecimal y1 = y0.setScale(3, BigDecimal.ROUND_HALF_UP);
            System.out.println(nf.format(x1) + " " + nf.format(y1));
        }
    }
}

Measured memory_bytes: 12000
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N = ni()
MOD = 10 ** 9 + 7


def solve():
    fs = collections.Counter()
    for n in range(2, N + 1):
        i = 2
        while i * i <= n:
            while n % i == 0:
                n //= i
                fs[i] += 1
            i += 1
        if n > 1:
            fs[n] += 1

    ans = 1
    for c in fs.values():
        ans *= c + 1
        ans %= MOD

    return ans


print(solve())


Measured memory_bytes: 39536
# coding: utf-8
# Your code here!
N, Y = map(int,input().split())

for i in range(N+1):
    for j in range(N-i+1):
        y = 10000*i+5000*j+1000*(N-i-j)
        if y == Y:
            print(i,j,N-i-j)
            break
    else:
        continue
    break
if y != Y:
    print(-1,-1,-1)
    

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;
ll gcd(ll a, ll b) {
	ll c;
	while (b != 0) {
		c = a%b;
		a = b;
		b = c;
	}
	return a;
}
int A[1000001];
int mi[1000001];
int mx[1000001];
int prime[1001];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	
	int N; cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 2; i <= 1000; i++) mi[i] = 1000;
	vector<int> P;
	for (int i = 2; i <= 1000; i++) {
		if (prime[i] == 0) {
			P.push_back(i);
			for (int j = 2; j*i <= 1000; j++) {
				prime[i*j] = 1;
			}
		}
	}
	int check = 0;
	for (int i = 1; i <= N; i++) {
		int idx = 0;
		int cnt = 0;
		while (A[i] > 1 && idx < P.size()) {
			if (A[i] % P[idx] == 0) {
				A[i] /= P[idx];
				cnt++;
			}
			else {
				if (mx[P[idx]] > 0 && cnt > 0) check = 1;
				mi[P[idx]] = min(mi[P[idx]], cnt);
				mx[P[idx]] = max(mx[P[idx]], cnt);
				cnt = 0;
				idx++;
			}
		}
		if (A[i] > 1) {
			if (mx[A[i]] > 0) check = 1;
			mi[A[i]]++;
			mx[A[i]] = max(mx[A[i]], 1);
		}
	}
	for (int i = 2; i <= 1000; i++) {
		if (mi[i] > 0 && mi[i] < 1000) check = 2;
	}
	for (int i = 1001; i <= 1000000; i++) {
		if (mi[i] == N) check = 2;
	}
	if (check == 0) cout << "pairwise coprime";
	else if (check == 1) cout << "setwise coprime";
	else cout << "not coprime";
}


Measured memory_bytes: 15340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define MOD 1000000007

int main()
{
    ll H, W, A, B; cin >> H >> W >> A >> B;
 
    vector<ll> fact(H+W+1);
    vector<ll> finv(fact.size());
    vector<ll> inv(fact.size());
    
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0; inv[1] = 1;
    for (int i = 2; i < fact.size(); i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

    auto C = [&](ll n, ll r) {
        return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
    };
 
    ll ans = 0;
    for (ll i = 1; i <= H - A; i++) {
        ll a, b;
        a = C(i+B-2,i-1);
        b = C(H-i+1+W-B-2, W-B-1);
        ans = (ans + a * b % MOD) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
	int floor[4][3][10]={0};/*????¬??????????????????????*/
	int n,b,f,r,v;
	int i,j,k;

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		floor[b-1][f-1][r-1] += v;/*??\?????????????????°????????????????´?*/
		}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
			printf(" %d",floor[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3)/*???????????????????????????????????*/
		printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<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){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

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

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

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  string s; cin>>s; s[3]='8'; COUT(s);
}













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

int main(){
  long long A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  if(T*V-T*W >= abs(A-B)) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3636
li = input().split()
n = int(li[0])
t = int(li[1])

maxt = 1001
cost = 1001
ans = 1001

for i in range(0, n):
    li = input().split()
    x = int(li[0])
    y = int(li[1])
    if y <= t:
        if x <= cost:
            cost = x

if cost == 1001:
    print("TLE")
else:
    print(cost)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

main(){
    int N;
    cin >> N;
    int d[N];
    //  int med_idx;
    for(int i=0;i<N;i++) cin >> d[i];
    
    sort(d,d+N,greater<int>());

    cout << d[(N/2)-1] - d[(N/2)] << endl;

}

Measured memory_bytes: 640