akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  string s;cin>>s;
  sort(s.begin(),s.end());
  if(s[0] == s[2])cout << "No" << endl;
  else cout << "Yes" << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	while(1){
		int n,t=0;
		string str;
		cin>>n;
		if(n==0)
			break;
		int x=0;
		vector<int> a;
		for(int i=0;i<n;i++)
		a.push_back(0);
		cin>>str;
		for(int i=0;i<100;i++){
			if(str[i]=='M')
				a[t]++;
			if(str[i]=='S'){
				x++;
				x+=a[t];
				a[t]=0;
			}
			if(str[i]=='L'){
				a[t]++;
				a[t]+=x;
				x=0;
			}
			if(t==n-1)
			t=0;
			else
			t++;
		}
		sort(a.begin(),a.end());
		for(int i=0;i<n;i++)
		cout<<a[i]<<' ';
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
using namespace std;
int main(void){
    int n, a[100001];
    long long ans = 0;
    cin >> n;
    for(int i=0;i<n+1;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        if(a[i] < b){
            ans += a[i];
            b -= a[i];
            if(a[i+1] < b){
                ans += a[i+1];
                a[i+1] = 0;
            }else{
                ans += b;
                a[i+1] -= b;
            }
        }else{
            ans += b;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int n,ans=0,c;cin>>n;
  for(int i=1;i<=n;i+=2){
    c=0;
    for(int j=1;j*j<i;j++) if(!(i%j)){
      c++;
      if(j!=(i/j)) c++;
    }
    if(c==8) ans++;
  }  
  cout<<ans;
}

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

using namespace std;



int main(){
    string s;
    int n;
    long long sum=0;
    cin>>n;
    s = to_string(n);
    for(int i=0;s[i];i++){
    	sum+=s[i]-'0';
    }

    if(n%sum==0) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 3700
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]a = new int[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			a[i] = int.Parse(str2[i]);
		}
		int min = 1;
		int max = 1000000007;
		while(min<max){
			int m = (min+max)/2;
			long ans = 0;
			for(var k=0;k<N;k++){
				ans += (a[k]+m-1)/m-1;
			}
			if(ans > K){
				min = m+1;
			} else {
				max = m;
			}
		}
		Console.WriteLine(min);
	}
}

Measured memory_bytes: 38068
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int a, b;
	string A, B,u;
	cin >> A >> B;
	cin >> a >> b>>u;
	if (u == A) {
		a--;
	}
	else {
		b--;
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
int tot=0;
int main() {
	ll cnt=0,n,tmp;
	scanf("%lld",&n);
	tmp=n;
	for(register ll i=2;i*i<n;++i) {
		if((n-1)%i==0) {
			++cnt;
			if(i!=(n-1)/i) ++cnt;
		}
	}
	for(register ll i=2;i*i<=n;++i) {
		if(n%i==0) {
			tmp=n;
			while(tmp%i==0) tmp/=i;
			if(tmp%i==1) ++cnt;
			if(i*i==n) continue;
			tmp=n;
			while(tmp%(n/i)==0) tmp/=(n/i);
			if(tmp%i==1) ++cnt;
		}
	}
	if(n!=2) ++cnt;
	printf("%lld\n",cnt+1);
	return 0;
}

Measured memory_bytes: 128
from itertools import accumulate

N, C, *XV = map(int, open(0).read().split())

X = XV[::2]
V = XV[1::2]

A = [0] + list(accumulate(V))

ans = m0 = m1 = 0
for i in reversed(range(N)):
    a = A[i + 1] - X[i]
    ans = max(ans, a + m0, a - X[i] + m1)

    c = C - X[i]
    m = A[N] - A[i] - c
    m0 = max(m0, m - c)
    m1 = max(m1, m)

print(max(ans, m1))


Measured memory_bytes: 25588
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<int,int> P;
ll mod=pow(10,9)+7;
ll INF=pow(10,18);

int main(){
    string S;cin>>S;
    if(S[0]=='A' && S[1]=='A' && S[2]=='A') cout<<"No"<<endl;
    else if(S[0]=='B' && S[1]=='B' && S[2]=='B') cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
 
int main(){
  char c;
  cin >>c;
  
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
long long ps[N], w[N], ans[N];
int n, q;
vector<int> v;
stack<int> st;
int32_t main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	cin >> n >> q;
	st.push(n);
	for (int i = 0; i < q; i++) {
		long long x;
		cin >> x;
		while (!st.empty() && st.top() >= x)
			st.pop();
		st.push(x);
	}
	while (!st.empty()) {
		v.push_back(st.top());
		st.pop();
	}
	reverse(v.begin(), v.end());
	w[v.size() - 1] = 1;
	for (int i = (int) v.size() - 1; i > 0; i--) {
		int rn = v[i];
//		cout << "i = " << i << endl;
		while (rn >= v[0]) {
			int x = upper_bound(v.begin(), v.end(), rn) - v.begin() - 1;
			if (x == i)
				x--;
//			cout << "x = " << x << endl;
			w[x] += w[i] * (rn / v[x]);
			rn %= v[x];
//			cout << "rn = " << rn << endl;
		}
		ps[rn] += w[i];
	}	
	ps[v[0]] += w[0];
	for (int i = n; i > 0; i--)
		ans[i] = ans[i + 1] + ps[i];
	for (int i = 1; i <= n; i++)
		cout << ans[i] << "\n";
	return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

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



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N; cin >> N;
	
	ll res{0};
	for (ll a = 1; a <= N; ++a)
	{
		res += (N/a) - (N%a == 0);
	}

	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long sum = 0;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    if(i%3 != 0 && i%5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


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

#define endl "\n"
#define ll long long
#define pb emplace_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define ull unsigned long long
#define ld long double

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repa(i,a,b) for(ll i=(a);i<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int , null_type, less<int> , rb_tree_tag, tree_order_statistics_node_update>
/*
 Ordered set docs:
 order_of_key (k) : Number of items strictly smaller than k .
 find_by_order(k) : K-th element in a set (counting from zero).
*/
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
const int MOD = 1e9+7;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll powerLL(ll x, ll n, ll mod) 
{ 
    ll result = 1; 
    while (n) { if (n & 1) result = (result%mod * x%mod) % mod; n = n / 2; x = (x%mod * x%mod) % mod; } return result; 
} 

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

void solve()
{
    ll n, k,t;
    cin>>n>>k>>t;
    double res = ceil(1.0*n/k);
    ll val = res*t;
    cout<<val<<endl;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0; 
}

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

using namespace std;

priority_queue<int> ans;
int n;
string s;
int dispo;

int main(){
  ans.push(0);
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I')dispo++;
    else dispo--;
    ans.push(dispo);
}
cout<<ans.top()<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string  str;

    cin>>str;

    int flag =0;
    for(int i=0;i<3;i++){
        if(str[i] == str[i+1]){
            flag=1;
        }
    }

    if(flag==1){
        cout<<"Bad"<<endl;
    }
    else{
        cout<<"Good"<<endl;
    }


}



Measured memory_bytes: 256
def divide_and_conuer(ls):
    mi=ls.index(min(ls))
    res=ls[mi]
    if(ls[mi+1:len(ls)]!=list()):
        res+=divide_and_conuer(ls[mi+1:len(ls)])-ls[mi]
    if(ls[0:mi]!=list()):
        res+=divide_and_conuer(ls[0:mi])-ls[mi]
    return res

def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(divide_and_conuer(a))

if __name__ =="__main__":
    main()


Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	SPEED
    int n;
    cin >> n;
    ll ans = 0;
    ll divs[n+1] = {0};

    for(int i = 1; i <= n; i++)
    {
        for(int j = i; j < n+1; j += i)
        {
            divs[j]++;
        }
    }

    for (int i = 1; i < n+1; ++i)
    {
    	ans += i*divs[i];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 81740
n = int(input())
res = ''

while n > 0:
  if n % 26 != 0:
    res = chr(ord('a') + (n % 26) - 1) + res
    n = n // 26
  else:
    res = 'z' + res
    n = (n // 26) - 1
print(res)

Measured memory_bytes: 9056
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

char S[9999];
char T[9999];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> S>>T;
	for (int32_t i = 0; S[i]!='\0'; ++i)
	{
		out << S[i];
		if (T[i] == '\0') { break; }
		out << T[i];
	}
	out << endl;
	return 0;
}
#endif


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ac = 0;
	int wa = 0;

	for (int i = 0; i < m; i++) {
		int val; string res; cin >> val >> res;

		if (a[val] == -1) continue;

		if (res == "WA") {
			a[val]++;
		}
		else {
			wa += a[val];
			a[val] = -1;
			ac++;
		}
		
	}

	cout << ac << " " << wa << endl;


	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a+b>c+d) printf("Left\n");
else if(a+b<c+d) printf("Right\n");
else printf("Balanced\n");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll dp[n + 1][2][3];
  rep(i, n + 1) rep(j, 2) rep(k, 3) dp[i][j][k] = -INF;
  dp[0][1][0] = 0;
  rep(i, n) {
    rep(j, 2) {
      rep(k, 3) {
        if (j + k < 3) chmax(dp[i + 1][1][j + k], dp[i][j][k]);
        if (j == 1) chmax(dp[i + 1][0][k], dp[i][j][k] + a[i]);
      }
    }
  }
  cout << (n % 2 == 0 ? max(dp[n][1][0], dp[n][0][1]) : max(dp[n][1][1], dp[n][0][2])) << '\n';


  

  
  return 0;
}


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

using lli = long long int;

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c-(a-b), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d,e=0,f;
  cin >>a;
  cout <<"ABC"<<a<<'\n';
  return 0;
}


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

typedef long long ll;

const int mod = 998244353;
const int Maxn = 1000005;

int n;
int freq[Maxn];
int mult[Maxn];
int res;

int toPower(int a, int p)
{
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x) { return toPower(x, mod - 2); }

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        freq[a]++;
    }
    for (int i = Maxn - 1; i > 0; i--) {
        int sum = 0;
        for (int j = i; j < Maxn; j += i) {
            int add1 = ll(sum) * freq[j] % mod * j % mod;
            int add2 = ll(freq[j]) * (freq[j] - 1) / 2 % mod * j % mod * j % mod;
            mult[i] = (ll(mult[i]) + ll(add1) + ll(add2)) % mod;
            sum = (sum + ll(freq[j]) * j) % mod;
            if (j > i) mult[i] = (mult[i] - mult[j] + mod) % mod;
        }
        res = (res + ll(mult[i]) * Inv(i)) % mod;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define sqr(x) (x)*(x)

using namespace std;

long long L, R, ans = 999999999999;

int main() {
	cin >> L >> R;
	if (R - L + 1 <= 5000) {
		for (long long i = L; i <= R; ++i)
			for (long long j = i + 1; j <= R; ++j)
				if (i % 2019 * j % 2019 < ans) ans = i % 2019 * j % 2019;
		cout << ans << endl;
	} else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[10],i;
    for(i=0;i<10;i++)cin>>a[i];
    sort(a,a+10);
    for(i=9;i>6;i--)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

void factorize(ll n, map<ll, ll>& out){
    out.clear();
    while(n % 2 == 0){
        out[2]++;
        n /= 2;
    }
    for(ll p = 3; p * p <= n; p += 2){
        while(n % p == 0){
            out[p]++;
            n /= p;
        }
    }
    if(n > 2){
        out[n]++;
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    map<ll, ll> f;
    factorize(m, f);
    mint ans = 1;
    for(auto p : f){
        ans *= mint::comb(n - 1 + p.second, p.second);
    }
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int max = 0;
		for (int i = 0; i < S.length - 1; i++) {
			int[] lens = zalgo(S, i);
			for (int j = 1; j < lens.length; j++) {
				int v = Math.min(lens[j], j);
				if (v > max) {
					max = v;
				}
			}
		}
		System.out.println(max);
	}

	static int[] zalgo(char[] chars, int offset) {
		int n = chars.length - offset;
		int[] ret = new int[n];
		ret[0] = n;
		int i = 1, j = 0;
		while (i < n) {
			while (i + j < n && chars[j + offset] == chars[i + j + offset])
				++j;
			ret[i] = j;
			if (j == 0) {
				++i;
				continue;
			}
			int k = 1;
			while (i + k < n && k + ret[k] < j) {
				ret[i + k] = ret[k];
				++k;
			}
			i += k;
			j -= k;
		}
		return ret;
	}
}


Measured memory_bytes: 44528
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s, t;
  cin >> s >> t;
  bool ans = true;
  
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) != t.at(i)){
      ans = false;
      break;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> an(N);
    for (int i = 0; i < N; i++) 
        cin >> an[i];
    
    sort(an.begin(), an.end(), greater<int>());
    int Alice_score = 0;
    int Bob_score = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0)
            Alice_score += an[i];
        if (i % 2 == 1)
            Bob_score += an[i];
    }
    cout << Alice_score - Bob_score << endl;
}

Measured memory_bytes: 3636
"use strict";

function main(input){
  const nkxy = input.trim().split('\n').map(_=>parseInt(_, 10));
  const n = nkxy[0];
  const k = nkxy[1];
  const x = nkxy[2];
  const y = nkxy[3];
  
  if(n <= k) console.log(x*n); 
  else console.log(x*k + y*(n-k));
}

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

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	long long int n, k; std::cin >> n >> k;
	long long int min = 0, max = k + 1;
	while (min < max) {
		const auto mid = (min + max) / 2;
		auto prev = mid;
		auto rest = k;
		for (auto i = 0; i < n && prev != 0 && rest >= 0; ++i) {
			rest -= prev;
			prev = prev / 2;
		}
		if (rest >= 0) min = mid + 1;
		else max = mid;
	}
	std::cout << max - 1 << std::endl;
}


Measured memory_bytes: 3104
program main
  implicit none
  integer :: n, i, k
  integer(8), allocatable :: h(:)
  read (*, *) n, k
  allocate (h(n))
  read (*, *) h(:)
  call quicksort(h)
  if (k >= n) then
    write (*, "(i0)") 0
  else
    write (*, "(i0)") sum(h(1:n - k))
  end if

  contains

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int N;
int dp[1<<20];
main()
{
	cin>>N;
	int ans=0;
	for(int i=0;i<1<<N;i++)
	{
		cin>>dp[i];
		bool flag=false;
		for(int j=0;j<N;j++)
		{
			if(!(i>>j&1))continue;
			int I=i&~(1<<j);
			if(dp[I])flag=true;
		}
		if(flag&&!dp[i])
		{
			cout<<-1<<endl;
			return 0;
		}
		if(!flag&&dp[i])ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 7204
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int h, w, cnt=0;
char stage[52][52] = {};
int visited[52][52] = {};
queue<pair<int,int>> q;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    for (int i=1; i<=h; i++)
        for (int j=1; j<=w; j++) {
            cin >> stage[j][i];
            if (stage[j][i] == '.')
                cnt++;
        }
    for (int i=1; i<=h; i++)
        for (int j=1; j<=w; j++)
            visited[j][i] = -1;
    visited[1][1] = 1;
    q.push(make_pair(1,1));
    while(!q.empty()) {
        pair<int,int> p = q.front();
        q.pop();
        int x = p.first, y = p.second;
        for (int i=0; i<4; i++) {
            int nx = x + dx[i] , ny = y + dy[i];
            if (stage[nx][ny] == '.' && visited[nx][ny] == -1)  {
                visited[nx][ny] = visited[x][y] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    if (visited[w][h] == -1)
        cout << "-1" << endl;
    else
        cout << cnt - visited[w][h]<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n;
  int B[100];
  int i,j;
  int koukann=0;
  int s;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&B[i]);

  for(i=0;i<n;i++){
    for(j=n-1;j>i-1;j--){
      if(B[j]<B[j-1]) {
	s=B[j-1];
	B[j-1]=B[j];
	B[j]=s;
	koukann++;
      }
    }
  }
  for(i=0;i<n-1;i++) printf("%d ",B[i]);

  printf("%d\n",B[n-1]);
  

  printf("%d\n",koukann);


  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int x;
  scanf("%d",&x);
  rrep(i,MX) {
    x -= i;
    if (x <= 0) {
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}






















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;

int x;

signed main() {
	int i;
	
	cin >> x;
	
	int ssum = 0;
	for (i = 1; ; i++) {
		ssum += i;
		if (ssum >= x) {
			break;
		}
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H&&A[l] > A[i]) largest = l;
	else largest = i;
	if (r <= H&&A[r] > A[largest]) largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int extract() {
	int maxv;
	if (H < 1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i, int key) {
	if (key < A[i]) return;
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]) {
		swap(A[i], A[i / 2]);
		i = i / 2;
	}
}

void insert(int key) {
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main() {
	int key;
	char com[10];

	while (1) {
		scanf("%s", com);
		if (com[0] == 'e' && com[1] == 'n') break;
		if (com[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		}
		else {
			printf("%d\n", extract());
		}
	}

	return 0;
}


Measured memory_bytes: 6596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;

  	while(N>0){
  		if(N%10==7){
  			cout << "Yes" <<endl;
  			return 0;
  		}
  		N /=10;
  	}
  	cout << "No" <<endl;

    
  	return 0;
}



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

int h, w;
string s;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s;
		cout << s << '\n' << s << '\n';
	}
 
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String aaaa = sc.next();
		String X = "";
		String Y = "";
		HashSet<String> Xlist = new HashSet<>();
		HashSet<String> Ylist = new HashSet<>();
		;
		String[] Xarray;
		String[] Yarray;

		int ans = 0;
		int maxAns = 0;
		// aabbca →　aab  bca
		for (int i = 1; i < aaaa.length(); i++) {
			X = aaaa.substring(0, i);
			Y = aaaa.substring(i, aaaa.length());
			Xarray = X.split("");
			Yarray = Y.split("");

			for (String s : Xarray) {

				Xlist.add(s);
			}

			for (String s : Yarray) {

				Ylist.add(s);
			}

			for (String x : Xlist) {
				if (Ylist.contains(x)) {
					ans++;
				}
			}
			maxAns = Math.max(maxAns, ans);
			ans = 0;
			Xlist.clear();
			Ylist.clear();
		}

		System.out.println(maxAns);

	}

}


Measured memory_bytes: 24020
package main

import "fmt"

func main() {
    var m, f, r, sum int
    var rank string

    for {
        fmt.Scanf("%d %d %d", &m, &f, &r)
        if m == -1 && f == -1 && r == -1 {
            break
        }

        sum = m + f
        if m == -1 || f == -1 || sum < 30 {
            rank = "F"
        } else if sum >= 80 {
            rank = "A"
        } else if sum >= 65 {
            rank = "B"
        } else if sum >= 50 {
            rank = "C"
        } else if r >= 50 {
            rank = "C"
        } else {
            rank = "D"
        }
        fmt.Println(rank)
    }
}


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

int main()
{
    int n, z, w;
    cin >> n >> z >> w;
    int a[2003];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(n == 1) cout << abs(a[0] - w) << endl;
    else cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
	srand((unsigned)time(NULL));
	cin >> a >> b >> c; vector<int> v(rand() % 2000000 + 63000000);
	cout << (a <= c && c <= b ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 253696
#include <iostream>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> A;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        A[a+1]++;
        A[a-1]++;
        A[a]++;
    }

    int ans = 0;
    for(auto p : A){
        ans = max(ans, p.second);
    }

    cout << ans << endl;


    return 0;
}

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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = 0;

            for (int i = 0; i <= n; i++ )
            {
                a = a + i;
            }

            Console.WriteLine(a);
            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N, M;
    cin >> N >> M;

    vector<int> A(M);
    REP(i, M) {
        cin >> A[i];
    }

    vector<ll> dp(N + 1);
    int step = 0;
    REP(i, N + 1) {
        if (A.size() > 0 && A[step] == i) {
            step++;
            if (step >= M) step = 0;
            continue;
        }
        if (i == 0) {
            dp[i] = 1;
        } else if (i == 1) {
            dp[i] = 1;
        } else {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        dp[i] %= MOD;
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
n,p = map(int, input().split())
s = input()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)



else:
    res = 0
    cnt = [0] * p
    for i in range(n):
        res = (res + int(s[n-1-i]) * pow(10, i, p)) % p
        cnt[res] += 1

    ans = 0
    for c in cnt:
        ans += c * (c-1) // 2
    ans += cnt[0]
    print(ans)

Measured memory_bytes: 41180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long mod_inv(long long a, long long mod = MOD) {
  a %= mod;
  if (__gcd(a, mod) != 1) return -1;
  long long b = mod, x = 1, y = 0;
  while (b > 0) {
    long long tmp = a / b;
    a -= tmp * b;
    swap(a, b);
    x -= tmp * y;
    swap(x, y);
  }
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int val = MAX, long long mod = MOD) {
  fact[0] = 1;
  FOR(i, 1, val + 1) fact[i] = fact[i - 1] * i % mod;
  fact_inv[val] = mod_inv(fact[val], mod);
  for (int i = val; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

long long nCk(int n, int k, long long mod = MOD) {
  if (n < 0 || n < k || k < 0) return 0;
  return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  nCk_init();
  int n, m; cin >> n >> m;
  long long ans = 0;
  REP(i, min(n, m) + 1) {
    int gp = 3 * m - i;
    if (gp & 1) continue;
    gp /= 2;
    (ans += nCk(n, i) * nCk(gp + n - 1, n - 1) % MOD) %= MOD;
  }
  long long tmp = 0;
  REP(i, m) (tmp += nCk(i + n - 2, n - 2)) %= MOD;
  (tmp *= n) %= MOD;
  ans -= tmp;
  if (ans < 0) ans += MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 156544
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<P> vec[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vi p(m),y(m);
    vi a(m),b(m);
    rep(i,m){
        cin >> p[i] >> y[i];
        a[i] = p[i];
        vec[p[i]-1].pb(P(y[i],i));
    }
    rep(i,n){
        sort(all(vec[i]));
        rep(j,len(vec[i])){
            b[vec[i][j].se] = j;
        }
    }
    rep(i,m){
        printf("%06d%06d\n",a[i],b[i]+1);
    }
    return 0;
}

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


int main() {
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for (int i = 0; i <= 1000; i++) {
        vector<int> digits{i / 100, (i % 100) / 10, i % 10};
        int curr = 0;

        for (int j = 0; j < N; j++) {
            if (S[j] - '0' == digits[curr]) {
                curr++;
                if (curr == 3) {
                    res++;
                    break;
                }
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b;
    else if (a >= 6) cout << b / 2;
    else cout << 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define F first
#define S second
#define pb push_back
#define f(a,j,b) for(int a=j;a<b;a++)
void solve()
{
    ll n,w;
	cin>>n>>w;
	ll wei[n+1],val[n+1];
	ll dp[n+1][100001];
	f(i,0,n+1)
	{
		f(j,0,100001)
		{
			dp[i][j]=INT_MAX;
		}
	}
    f(i,1,n+1)
	{
		cin>>wei[i]>>val[i];
		dp[i][0]=0;
	}
	dp[0][0]=0;
	ll fin;
	f(i,1,n+1)
	{
		f(j,1,100001)
		{
           if(j>=val[i])
		   {
			   dp[i][j]=min(dp[i-1][j],wei[i]+dp[i-1][j-val[i]]);
		   }
		   else
		   {
			   dp[i][j]=dp[i-1][j];
		   }
		//    cout<<dp[i][j]<<" ";
		}
		// cout<<endl;
	}
	f(i,1,100001)
	{
		if(dp[n][i]<=w)
		{
			fin=i;
		}
	}
	cout<<fin<<endl;
}
int main() {
	fast;
	fast_input;
	fast_output;
	// ll t;
	// cin>>t;
	// f(i,t)
	// {
    //   cout<<"Case #"<<i+1<<":"<<" ";
	     solve();
	// }
	return 0;
}

Measured memory_bytes: 79232
package main

import (
	"fmt"
	"strconv"
	"os"
	"bufio"
	"math"
)
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int{
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil{
		panic(e)
	}
	return i
}


func main(){
	sc.Split(bufio.ScanWords)
	n := nextInt()

	max := 0
	numbers := make([]int, n)
	for i:=0; i<n; i++{
		numbers[i] = nextInt()
		if max < numbers[i]{
			max = numbers[i]
		}
	}
	
	minsum := math.MaxInt32
	for i:=0; i<=max; i++{
		sum := 0
		for _, j:= range numbers{
			sum += (j - i) * (j - i)
		}
		if sum < minsum {
			minsum = sum
		}
	}

	fmt.Println(minsum)

	return
}

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

int n;

bool solve() {
	vector<pair<int, int> > b;
	for (int i = 0; i < n; i++) {
		int v, l;
		cin >> v >> l;
		b.push_back(make_pair(l, v));
	}
	sort(b.begin(), b.end());
	
	int s = 0;
	for (int i = 0; i < n; i++) {
		s += b[i].second;
		if (s > b[i].first) {
			return false;
		}
	}
	return true;
}

int main() {
	while (cin >> n, n) {
		if (solve()) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 6484
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

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

	RFOR(i, s.size() - 1, 0) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3180
import collections
import bisect

n = 10 ** 6 + 10
fl = [1] * n
fl[0] = 0
fl[1] = 0
lprime = []
for i in range(n):
    if fl[i] == 1:
        lprime.append(i)
        ti = i * 2
        while ti < n:
            fl[ti] = 0
            ti += i


def prime_factorize(n):
    global lprime
    a = []
    for p in lprime:
        if p * p > n:
            break
        while n % p == 0:
            a.append(p)
            n //= p
    if n != 1:
        a.append(n)
    return a


N = int(input())
tres = prime_factorize(N)
ctres = collections.Counter(tres)
sl = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]
res = 0
for c in ctres.values():
    res += bisect.bisect_right(sl, c)
print(res)


Measured memory_bytes: 80668
N = int(input())
v_list = [int(x) for x in input().split()]
c_list = [int(x) for x in input().split()]
p_list = [x-y for x, y in zip(v_list, c_list)]

ans = 0
for i in p_list:
    if i > 0:
        ans += i
print(ans)

Measured memory_bytes: 3064
def resolve():
    '''
    code here
    最小値が0にはならないので1 or 計算結果にするとところが味噌
    上記を忘れていると全ての値が3200を超えていた時にバグる
    '''
    import collections

    N = int(input())
    A_list = [int(item)//400 for item in input().split()]

    cnt_dict = collections.Counter(A_list)

    res_low = 0
    res_high = 0
    for i in range(4800//400 + 1):
        if i <= 7:
            if cnt_dict[i] >= 1:
                res_low += 1
        else:
            res_high += cnt_dict[i]

    print(max(res_low, 1), res_low + res_high)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
#include <stdio.h>
int main() {
    long n, y;
    scanf("%ld %ld", &n, &y);
    for (long i=0; i<=n; i++)
        for (long j=0; j+i<=n; j++)
            if (10000*i + 5000*j + (n-i-j)*1000 == y) {
                printf("%ld %ld %ld\n", i, j, n-i-j);
                return 0;
            }
    puts("-1 -1 -1");
}

Measured memory_bytes: 128