akhauriyash/Code-Regression huggingface dataset:
// Problem : E - Both Sides Merger
// Contest : AtCoder Regular Contest 092
// URL : https://atcoder.jp/contests/arc092/tasks/arc092_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1001, inf = 1e9 + 7;

vector<int> ans;
int n, neg = 0, a[N];
ll odd = 0, even = 0;

int main() { cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        neg += a[i] < 0;
        odd += (i & 1) * (a[i] > 0) * a[i];
        even += !(i & 1) * (a[i] > 0) * a[i];
    }
    if (neg == n) {
        int mx = -inf, pos;
        for (int i = 1; i <= n; i++) {
            if (mx < a[i]) {
                mx = a[i];
                pos = i;
            }
        }
        cout << mx << '\n' << n - 1 << '\n';
        for (int i = n; i >= pos + 1; i--) {
            cout << i << '\n';
        }
        for (int i = 1; i < pos; i++) {
            cout << 1 << '\n';
        }
        return 0;
    }
    if (odd > even) {
        cout << odd << '\n';
        if (n % 2 == 0) {
            ans.push_back(n);
            n--;
        }
        ll r = a[n];
        for (int i = n; i >= 3; i -= 2) {
            if (r < 0) {
                ans.push_back(i);
                ans.push_back(i - 1);
                r = a[i - 2];
            } else if (a[i - 2] >= 0) {
                ans.push_back(i - 1);
                r += a[i - 2];
            } else {
                ans.push_back(i - 2);
                if (i - 2 == 1) {
                	ans.push_back(1);
                }
            }
        }
    } else {
        cout << even << '\n';
        if (n & 1) {
            ans.push_back(n);
            n--;
        }
        ll r = a[n];
        for (int i = n; i >= 4; i -= 2) {
            if (r < 0) {
                ans.push_back(i);
                ans.push_back(i - 1);
                r = a[i - 2];
            } else if (a[i - 2] >= 0) {
                ans.push_back(i - 1);
                r += a[i - 2];
            } else {
                ans.push_back(i - 2);
            }
        }
        ans.push_back(1);
    }
    cout << size(ans) << '\n';
    for (auto x : ans) {
        cout << x << '\n';
    }
}

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

int main() {
  int N, A, B; cin >> N >> A >> B;
  while (A != -1 && B != -1) {
    if (A + 1 != B) A++;
    else if (A - 1 >= 1) A--;
    else A = -1;
    if (B - 1 != A) B--;
    else if (B + 1 <= N) B++;
    else B = -1;
  }
  if (A == -1) cout << "Borys" << endl;
  else cout << "Alice" << endl;
  return 0;
}

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

int main() {
	int a, b, n;

	while (cin >> a) {
		cin >> b >> n;

		int sum = 0;
		for (; n-- > 0;) {
			a = a % b * 10;
			sum += a / b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n = 0, a,b,m = 0,counter = 0;
	string in,in2;
	vector<ll>vec;
	cin >> in>>in2;
	if (in[0] == in2[2] && in[1] == in2[1] && in[2] == in2[0])cout << "YES" << endl;
	else cout << "NO" << endl;
	
}




Measured memory_bytes: 256
import sys

if __name__ == '__main__':
    a = input()
    a = a.split('/')
    year = int(a[0])
    month = int(a[1])
    date = int(a[2])
    if year > 2019:
        print('TBD')
    elif year < 2019:
        print('Heisei')
    elif month < 4:
        print('Heisei')
    elif month > 4:
        print('TBD')
    elif date <= 30:
        print('Heisei')
    else:
        print('TBD')

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int a[maxn];
int main(){
	int n;cin >> n;
	ll sum = 0;
	map<int , int>mp;
	fo(i,1,n){
		cin >> a[i];
		sum += mp[i-a[i]];
		mp[a[i] + i]++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 21208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define maxn 0x3f3f3f
#define ll long long


int main()
{
    char s[10];
    int ans=0;
    for(int i=1; i<=3; i++)
        scanf("%c",&s[i]);
    if(s[2]=='R')
    {
        for(int i=1; i<=3; i++)
            if(s[i]=='R')
                ans++;
    }
    else if(s[1]=='R'||s[3]=='R')
        ans++;
    printf("%d\n",ans);
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<=r;i++)
#define debug(x) cout<<#x<<'='<<(x)<<endl
using namespace std;
template<class T> bool maxs(T& a,T& b)
{
    if(a<b)
    {
        T t;
        t=a;
        a=b;
        b=t;
        return true;
    }
    return false;
}
template<class T> bool maxi(T& a,T b)
{
    if(a<b)
    {
        a=b;
        return true;
    }
    return false;
}
template<class T> bool mini(T& a,T b)
{
    if(a>b)
    {
        a=b;
        return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll dp[s.size()+1][t.size()+1];
    f(i,0,s.size())     f(j,0,t.size())     dp[i][j]=0;

    f(i,1,s.size())
    {
        f(j,1,t.size())
        {
            if(s[i-1]==t[j-1])  
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            
        }
    }
    string ans="";
    int l=s.size(),r=t.size();
    while(l>0&&r>0)
    {
        if(s[l-1]==t[r-1])
        {
            ans+=s[l-1];
            l--;
            r--;
        }
        else if(dp[l-1][r]==dp[l][r])
            l--;
        else
        {
            r--;
        }
    }
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i];
    
    return 0;
}

Measured memory_bytes: 70656
N,Y = map(int,input().split())
a = 0

for i in range(N+1):
    if Y/1000 - 10*i < 0:
        a = 2
    else:
        for j in range(N-i+1):
            z = Y/1000 - 10 * i - 5 * j
            if z + i + j == N:
                print(i,j,int(z))
                a = 1
    
    if a == 1 or a == 2:
        break
    else:
        continue

if a == 0 or a == 2:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#!/usr/bin/env python3

K, S = map(int, input().split())
AB = []
ret = 0
for i in range(K+1):
    for j in range(K+1):
        AB.append(i+j)

for i in range(len(AB)):
    if 0 <= S - AB[i] <= K:
        ret += 1

print(ret)


Measured memory_bytes: 255368
#include <iostream>

using namespace std;

int main(){
	int n; cin >> n;
	while(n--){
		int Y, M, D; cin >> Y >> M >> D;
		int res = 0;
		if(Y%3 != 0 && M%2 == 0) res += 20-D;
		else                     res += 21-D;
		for(int m=M+1;m<=10;m++){
			if(Y%3 != 0 && m%2 == 0) res += 19;
			else                     res += 20;
		}
		for(int y=Y+1;y<=999;y++){
			if(y%3 == 0) res += 200;
			else         res += 195;
		}
		cout << res << endl;
	}
}

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


int arr[100005];
int res[100005];

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

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

	fill(res, res+n, INT_MAX);
	res[0] = 0;

	for(int i = 1; i < n; i++){
		for(int j = max(0, i-k); j < i; j++){
			res[i] = min(res[i], res[j] + abs(arr[j]-arr[i]));
		}
	}

	cout << res[n-1] << endl;

	return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n, a[210000];
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  int ans = a[n-1];bool b = true;
  for(int i = n-2;i >= 0;i--){
    if(a[i+1] > a[i]){
      if(a[i+1]-a[i] != 1){
        b = false;
        break;
      }
    }else{
      ans += a[i];
    }
  }
  if(b && a[0] == 0)cout << ans << endl;
  else cout << -1 << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for (int i = 0;i < m;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    vector<int> ans(n,0);
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int t = que.front();que.pop();
        for (int j : edges[t]) if (ans[j] == 0) {
            ans[j] = t+1;
            que.push(j);
        }
    }
    cout << "Yes" << newl;
    for (int i = 1;i < n;++i) cout << ans[i] << newl;
}

Measured memory_bytes: 10240
def main():
    N = int(input())
    dp = [0] * N
    rt = int(pow(N, 0.5)) + 1
    for i in range(1, rt):
        ii = i * i
        for j in range(1, i + 1):
            iji = ii + j * j + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, j + 1):
                c = iji + k * k + (i + j) * k
                if c <= N:
                    if i == j or j == k:
                        l = 3
                        if i == k:
                            l = 1
                    else:
                        l = 6
                    dp[c - 1] += l
                else:
                    break
    print(*dp, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9468
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

map<string,int> a;

int main(void){
  int n, l;
  string s, t, r;
  string rt, rr;

  cin >> n;
  rep(i,n){
      a.clear();
      cin >> s;
      l = s.size();
      a[s] = 1;
      rep(j,l+1){
          t = s.substr(0,j);
          rt = s.substr(0,j);
          r = s.substr(j, l-j);
          rr = s.substr(j, l-j);
          reverse(rt.begin(), rt.end());
          reverse(rr.begin(), rr.end());
          //a.insert(t)
          a[t+r] = 1;
          a[t+rr] = 1;
          a[rt+r] = 1;
          a[rt+rr] = 1;

          a[r+t] = 1;
          a[rr+t] = 1;
          a[r+rt] = 1;
          a[rr+rt] = 1;
      }
      cout << a.size() << endl;  
  }

  return 0;
}

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

int main(){
  int a[5];
  for(int i = 0; i < 3; ++i){
    cin >> a[i];
  }
  int k;
  cin >> k;
  sort(a, a+3, greater<int>());
  int sum;
  sum = a[0]*pow(2,k) + a[1] + a[2];
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		s = s.substring(0,k-1)+s.substring(k-1,k).toLowerCase()+s.substring(k);		
		System.out.println(s);
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		double[] p=Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
		double[,] dp=new double[n,n+1];
		double ans=0;
		dp[0,0]=1-p[0];
		dp[0,1]=p[0];
		for(int i=1;i<n;i++){
			dp[i,0]=dp[i-1,0]*(1-p[i]);
			for(int j=1;j<=i+1;j++){
				dp[i,j]=dp[i-1,j-1]*p[i]+dp[i-1,j]*(1-p[i]);
			}
		}
		for(int i=n;i>n/2;i--){ans+=dp[n-1,i];}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 80992
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

// i hope i get better

// Task name:
#define Task ""
using namespace std;

// Include
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

// Define
#define reset(x, value) memset((x), (value) ,sizeof((x)))
#define fr(i,a,b) for(int i = (a); i <= (b); i++)
#define FR(i,a,b) for(int i = (a); i < (b); i++)
#define frr(i,a,b) for(int i = (a); i >= (b); i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl "\n"
#define bit(x,i) (x >> i) & 1
#define all(x) (x).begin(), (x).end()
#define optimize(x) (x).resize(unique(all(x)) - (x).begin())
#define Inpf freopen(Task".inp","r",stdin)
#define Outf freopen(Task".out","w",stdout)
#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// typedef
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const int base = 131;
const int MOD = 1e9 + 7;
const ll MM = 1ll * MOD * MOD;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void AddMOD(int &x, int y)
{
    x += y;
    if (x >= MOD)
        x -= MOD;
}
int Gcd(int x, int y)
{
    if (y == 0)
        return x;
    return Gcd(y, x % y);
}
template <class T> inline void Gmax(T &x,T y)
{
    x = max((x), (y));
}
template <class T> inline void Gmin(T &x,T y)
{
    x = min((x), (y));
}

void exit_with_runtime()
{
    db x = 1.0 * clock() / CLOCKS_PER_SEC;
    cerr << "\n\n---------------------\nTime elapsed: " << x << " s.\n\n";
    if (x > 1)
        cerr << "TIME LIMIT EXCEEDED!\n\n";
    exit(0);
}

// --------------------------------------------------------------------
const int maxn = 150005;
// --------------------------------------------------------------------

void Solve()
{
    string s;
    cin >> s;
    if (s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';
    cout << s;
}

int main()
{
#ifndef ONLINE_JUDGE
    Inpf;
    Outf;
#endif // ONLINE_JUDGE
    fasterIO;
    int test = 1;
//    cin >> test;
    while (test --)
        Solve();

    // Did you check with the special test case n = 0, n = 1??
    exit_with_runtime();
}

// Goodbye, see u again


Measured memory_bytes: 3768
n, m = map(int, input().split())
ls = sorted([[int(i) for i in input().split()] for _ in range(n)], key=lambda x: x[0])
ans = 0

for i in range(n):
    if m > ls[i][1]:
        m -= ls[i][1]
        ans += ls[i][0] * ls[i][1]
    elif m == 0:
        break
    else:
        ans += m * ls[i][0]
        break
print(ans)

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

int main (){
        long long int A[3];
        long long count =0;
        cin >> A[0] >> A[1] >> A[2];
        long long ans;

        sort(A,A+3);
        count = + A[2] -A[0];
        ans = count;
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main() {
	long long A, B, K;
	cin >> A >> B >> K;
	if (A >= K) {
		A -= K;
	}
	else if (A < K) {
		K -= A;
		A = 0;
		B -= K;
		if (B < 0)B = 0;
	}
	cout << A << ' ' << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main() {
	int n;
	cin >> n;
	int M = 0;
	hei(int) a(n);
	rep(i, 0, n) {
		cin >> a[i];
		M = max(M, a[i]);
	}
	hei(int) date(M + 1,0);
	rep(j, 0, n) {
		for (int i = 1; i * a[j] <= M; i++) {
			date[i * a[j]]++;
		}
	}
	int ans = 0;
	rep(i, 0, n)if (date[a[i]] == 1)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8004
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.nextLine();
        while(n-->0){
            String line = sc.nextLine();
            System.out.println(line.replaceAll("Hoshino","Hoshina"));
        }
    }
}

Measured memory_bytes: 17304
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    int l=s.length();
    if(s[l-1]=='s'){
        cout<<s<<"es";
    }else{
        cout<<s<<"s";
    }
}


Measured memory_bytes: 3624
from sys import stdin, setrecursionlimit
from collections import defaultdict


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = sum(a)
    dic = defaultdict(int)
    for ai in a:
        dic[ai] += 1
    q = int(input())
    bc = [list(map(int, input().split())) for _ in range(q)]
    for b, c in bc:
        count = dic[b]
        ans += count * (c - b)
        print(ans)
        dic[b] -= count
        dic[c] += count


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 102772
#include<bits/stdc++.h>
#define MN 100005
typedef long long ll;
int n,q,N;
ll num[MN],que[MN],mul[MN];
void calc(int x,ll nn,ll&gg)
{
	if(!nn) return;
	int pos=std::upper_bound(que+1,que+x,nn)-que-1;
	if(!pos) return(void)(num[n]+=gg*(nn/n),num[nn%n]+=gg);
	mul[pos]+=(nn/que[pos])*gg;
	calc(pos,nn%que[pos],gg);
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=q;i++)
	{
		ll x;
		scanf("%lld",&x);
		for(;N&&x<=que[N];N--);
		que[++N]=x;
	}
	mul[N]=1;que[0]=n;
	for(int i=N;i>=1;i--) {
		calc(i,que[i]%que[i-1],mul[i]);
		mul[i-1]+=mul[i]*(que[i]/que[i-1]);
	}
	num[n]+=mul[0];
	for(int i=n;i>1;i--) num[i-1]+=num[i];
	for(int i=1;i<=n;i++) printf("%lld\n",num[i]);
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= 0; i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll ans;
int main(){
	cin >> N;
	ans = inf;
	REP(i,1,1000010){
		if(N % i == 0){
			ans = min(ans, i + N / i - 2);
		}
	}
	p(ans);
	return 0;
}

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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)
#define Cor(i,l,r) for (int i = l; i >= r; --i)

const int MD = 1000000007;

int n, A[111111];
int main() {
	int ans = 1;
	cin >> n;
	For(i,1,n) scanf("%d", &A[i]);
	A[1] = 1;
	int cnt = 1;
	For(i,2,n) {
		A[i] = min(A[i], A[i - 1] + 2);
		ans = (long long)ans * (cnt + 1) % MD;
		if (A[i] > A[i - 1] + 1) ++cnt; else A[i] = A[i - 1];
	}
	cout << ans << endl;
	return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, K, A[200001] = {}, a;
	
	cin >> N >> K;
	
	for(int i=0; i<N; i++){
		cin >> a;
		A[a-1]++;
	}
	
	sort(A, A+N);
	
	int ans = 0;
	
	for(int i = 0; i < N - K; i++)
		ans += A[i];
	
	cout << ans;
	
	return 0;
}//not yet

Measured memory_bytes: 1024
N = int(input())
S = [input() for _ in range(N)]
S.sort()
h = {}
name = set(S)
for n in name:
    h[n] = 0

for s in S:
    h[s] += 1

max_h = max(h.values())
l = []
for s in set(S):
    if h[s] == max_h:
        l.append(s)

for i in sorted(l):
    print(i)

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static long[] ans = new long[]{-1,-1,-1};
	public static void main(String[] args) throws Exception {


		long N = nextLong();
		long Y = nextLong();

		long[] n = new long[3];
		long tmp = Y;


		for(long i=0;i<=Y/10000;i++){
			for(long k=0;k<=Y/5000;k++){
				long x = Math.max(0,(N-(i+k)));
				if(i+k+x==N&& i*10000+k*5000+x*1000 ==Y){
					System.out.println(i+" "+k+" "+x);
					return ;
				}
			}
		}

		System.out.println("-1 -1 -1");
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

int w[110];
ll v[110];
ll dp[110][100010];
int n, W;

ll solveR(int i, int c){
	if(i == n)
		return 0;
		
	if(dp[i][c] != -1LL)
		return dp[i][c];
		
	if( (c + w[i]) <= W)
		return dp[i][c] = max(solveR(i+1, c), solveR(i+1, c + w[i]) + v[i]);
	else
		return dp[i][c] = solveR(i+1, c);
}

ll solveI(){
	for(int j=0; j<w[0]; j++)
		dp[0][j] = 0;
	for(int j=w[0]; j<=W; j++)
		dp[0][j] = v[0];
	
	for(int i=1; i<n; i++){
		for(int j=0; j<w[i]; j++)
			dp[i][j] = dp[i-1][j];
		for(int j=w[i]; j<=W; j++)
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);		
	}
	
	return dp[n-1][W];
}

int main() {
	
	scanf("%d %d", &n, &W);
	
	for(int i=0; i<n; i++)
		scanf("%d %lld", &w[i], &v[i]);

//	memset(dp, -1, sizeof(dp));
//	printf("%lld\n", solveR(0, 0));
	printf("%lld\n", solveI());
		
	return 0;	
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define FOR(i,x) for(i=1;i<=x;i++)
using namespace std;
using ll = long long int;
typedef vector<ll> vi;
ll k,b,ar[11]={};
void IsEqual()
{
  FOR(b,3){
  	cin>>k;
  	ar[k]++;
  }
  cout<<(*max_element(ar,ar+11)==2?"Yes":"No")<<"\n";
}
int main()
{
    IsEqual();
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=1; cin>>n;
    vector<ll> a(n,0),c(n,0);
    rep(i,n){
        cin>>a[i];
        c[a[i]]++;
    }
    if(n%2){
        if(c[0]!=1) ans*=0;
        rep(i,n/2){
            if(c[2*i+2]==2) ans=(ans*2)%MOD;
            else ans*=0;
        }
    }
    else{
        rep(i,n/2){
            if(c[2*i+1]==2) ans=(ans*2)%MOD;
            else ans*=0;
        }
    }
    cout<<(MOD+ans)%MOD<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using std::cout;
using ll =long long;

const double PI=3.14159265358979323846;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double vol = a*a*b;
  if(vol <= 2*x){
    cout<<std::fixed << (double)180*atan( (double)2* (b - x/(a*a) ) /a )/PI<<endl;    
  }
  else{
    cout<<std::fixed << (double)180*atan(   a*b*b / ((double)2*x)   )/PI<<endl;
  }

}


Measured memory_bytes: 256
#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 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;

int main() { 
  string s,t;
  cin >> s;
  cin >> t;

  int n = s.size();
  int m = t.size();
  vector<string> l;
  rep(i,n-m+1){
    int isMatch = true;
    rep(j,m){
      isMatch&=(s[i+j] == t[j] || s[i+j] == '?');
    }
    if(isMatch){
      string ans = s.substr(0,i) + t + s.substr(i+m);
      rep(i,sz(ans))if(ans[i] == '?') ans[i] = 'a';
      l.push_back(ans);
    }
  }
  if(l.size() == 0){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  sort(l.begin(),l.end());
  cout<<l[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
use itertools::Itertools;
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 bytes") 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 n: usize = read();
    let it: Vec<Vec<usize>> = (1..=n).permutations(n).collect();
    let mut left = 0;
    let mut right = 0;
    let p: Vec<usize> = (0..n).map(|_| read()).collect();
    let q: Vec<usize> = (0..n).map(|_| read()).collect();
    for (i, perm) in it.iter().enumerate() {
        if *perm == p {
            left = i as i64;
        }
        if *perm == q {
            right = i as i64;
        }
    }
    println!("{}", (left - right).abs());
}


Measured memory_bytes: 5956
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
const int maxn = 3e5+100;
int n;
struct node
{
	int x,y;
};
node T[maxn];
set<pair<int,int>> S,F;
int xx[10]={1,1,1,0,0,0,-1,-1,-1};
int yy[10]={1,0,-1,1,0,-1,1,0,-1};
long long ans[15],sum,h,w;
bool judge(int x,int y)
{
	for(int i=0;i<9;i++)
	{
		int X=x+xx[i],Y=y+yy[i];
		if(X<1||X>h||Y<1||Y>w) return false;
	}
	return true;
}
int main()
{
	scanf("%lld%lld%d",&h,&w,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&T[i].x,&T[i].y);
		S.insert(make_pair(T[i].x,T[i].y));
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<9;j++)
		{
			int X=T[i].x+xx[j],Y=T[i].y+yy[j];
			if(X<1||X>h||Y<1||Y>w) continue;
			if(F.count(make_pair(X,Y))) continue;
			int cnt=0;
			if(!judge(X,Y)) continue; 
			for(int l=0;l<9;l++)
			{
				int X1=X+xx[l],Y1=Y+yy[l];
				//cout<<X1<<" "<<Y1<<endl;
				if(S.count(make_pair(X1,Y1))) cnt++;
			}
			//cout<<cnt<<"_____________________________________"<<endl;
			if(cnt) ans[cnt]++;
			F.insert(make_pair(X,Y));
		}
	}
	for(int i=1;i<=9;i++) sum+=ans[i];
	ans[0]=(h-2)*(w-2)-sum;
	if(ans[0]<0) ans[0]=0;
	for(int i=0;i<=9;i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 47872
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



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

	pii p;
	cin >> p.first >> p.second;
	string s, t;
	cin >> s >> t;


	vector<char> ct{ 'L','R' ,'U' ,'D' };
	vector<vector<int>> dt{ {0,-1},{0,1} ,{-1,0},{1,0} };
	vector<char> ca{ 'R','L' ,'D' ,'U' };
	vector<vector<int>> da{ {0,1},{0,-1} ,{1,0},{-1,0}};
	for (int i = 0; i < 4; i++) {
		int r = p.first;
		int c = p.second;


		for (int j = 0; j < n; j++) {


			if (s[j] == ct[i]) {
				r += dt[i][0];
				c += dt[i][1];
			}
			//cout << i << " " << r << " " << c << endl;
			if (r <1 || r >h|| c <1|| c >w) {
				cout << "NO" << endl;

				return 0;
			}
			if (t[j] == ca[i]) {
				r += da[i][0];
				c += da[i][1];
			}

			r = min(r, h);
			r = max(r, 1);
			c = min(c, w);
			c = max(c, 1);
			
			

				


			//cout <<i << " " <<  r << " " << c << endl;

		}

	}

	cout << "YES" << endl;
}

Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int f (int x) {
    int sum = 0;
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

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

    if (n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    bool c[26] = {false};
    for(int i = 0; i < S.length();i++){
        if(c[S[i] - 'a'] == false){
            c[S[i] - 'a'] = true;
        }else{
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int N, T;
  cin >> N >> T;
  ll dp[60001];
  memset(dp, -1, sizeof(dp));

  dp[0] = 0;
  ll ans = 0;
  vector<pair<int, int> > v(N);
  rep(_, N){
    int a, b; cin >> a >> b;
    v[_] = {a, b};
  }
  sort(ALL(v));

  rep(_, N){
    int a = v[_].first, b = v[_].second;
    for(int i=T-1; i>=0; i--){
      chmax(ans, dp[i] + b);
      if(i + a >= T) continue;
      if(dp[i] != -1){
        chmax(dp[i+a], dp[i] + b);
      }
    }
  }

  cout << ans << endl;
}  


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

#define WHITE 1
#define GREY 2
#define BLACK 3

int adj[100][1000]={{}, {}};
int color[100]={};
int parent[100]={}; 
int flag=0; // Have a closed circuit 1, otherwise 0;
int E,V;

void dfs_visit(int u);

int main(){
    int u, v;
    int i;
    
    //input
    scanf("%d %d", &V, &E);
    for(i=0;i<E;i++){
        scanf("%d %d", &u, &v);
        if(u != v){
            adj[u][v] = 1;
            color[u] = WHITE;
            color[v] = WHITE;
        }
    }

    for(u=0;u<V;u++){
        if(color[u] == WHITE) dfs_visit(u);
    }

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

    return 0;
}

// DFS check
void dfs_visit(int u){
    int v;

    color[u]=GREY;

    for(v=0;v<E;v++){
        if(adj[u][v]==1){
            if(color[v]==WHITE){
                parent[v]=u;
                dfs_visit(v);
            }
            if(color[v]==GREY){
                flag=1;
                break;
            }
        }
    }

    color[u]=BLACK;
}


Measured memory_bytes: 2200
#include<cstring>
#include<cstdio>

#define MOD 1000000007

typedef long long int lli;
char prime[1000000];

lli inv(lli x) {
    lli b = MOD-2;
    lli r = 1;
    while(b) {
        if(b&1) r *= x, r %= MOD;
        x *= x, x %= MOD;
        b >>= 1;
    }
    return r;
}

lli comb(int x, int y) {
    lli r = 1;
    for(int i=0; i<y; i++)
        r *= x-i, r %= MOD;
    for(int i=0; i<y; i++)
        r *= inv(i+1), r %= MOD;
    return r;
}

int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);

    memset(prime, 1, sizeof(prime));

    for(lli i=2; i*i<m; i++)
        for(lli j=2; i*j*i*j<m; j++)
            prime[i*j] = 0;

    lli res = 1;
    for(int i=2; i*i<=m; i++) {
        if(m % i) continue;
        
        int j;
        for(j=0; m%i == 0; m /= i, j++);
        res *= comb(n-1+j, j);
        res %= MOD;
    }
    if(m != 1) res *= n, res %= MOD;

    printf("%lld\n", res);
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int x;
    cin >> x;
    x %= 7;
    switch(x){
        case 0:
        cout << "thu" << "\n";
        break;
        case 1:
        cout << "fri" << "\n";
        break;
        case 2:
        cout << "sat" << "\n";
        break;
        case 3:
        cout << "sun" << "\n";
        break;
        case 4:
        cout << "mon" << "\n";
        break;
        case 5:
        cout << "tue" << "\n";
        break;
        case 6:
        cout << "wed" << "\n";
        break;
    }

    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int a,b,k;
  std::cin >> a >> b >> k;

  vt<int> p;
  p.push_back(1);
  int num = 2;

  do {
    if(a%num==0 && b%num==0){
      p.push_back(num);
    }
    num++;
  }while(num <= std::min(a,b));

  std::cout << p[p.size()-k] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m;
  n*=2;
  vector<int>v;
  for(int i=1;i<=n;i++)
    v.push_back(i);
  while(m--){
    vector<int>t,p,pp;
    cin>>x;
    if(!x){
      for(int i=0;i<n/2;i++)pp.push_back(v[i]);
      for(int i=n/2;i<n;i++)p.push_back(v[i]);
      for(int i=0;i<n/2;i++)
        t.push_back(pp[i]),t.push_back(p[i]);
    }else{
      for(int i=1+x;i<=n;i++)t.push_back(v[i-1]);
      for(int i=1;i<=x;i++)t.push_back(v[i-1]);
    }
    v=t;
  }
  for(int i=0;i<n;i++)
    cout<<v[i]<<endl;
}

Measured memory_bytes: 3100
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
  if a[i]<400:
    b[0]+=1
  elif a[i]<800:
    b[1]+=1
  elif a[i]<1200:
    b[2]+=1
  elif a[i]<1600:
    b[3]+=1
  elif a[i]<2000:
    b[4]+=1
  elif a[i]<2400:
    b[5]+=1
  elif a[i]<2800:
    b[6]+=1
  elif a[i]<3200:
    b[7]+=1
  else:
    b[8]+=1
    
min=8-b[:8].count(0)
max=min+b[8]

if min==0:
  min=1
print(min,max)

Measured memory_bytes: 9184
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n, ans;
main() {
  file("threesum");
  ios;
  cin >> n;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) ++cnt, n /= i;
      int mn = 1;
      while (mn <= cnt) {
        ++ans;
        cnt -= mn++;
      }
    }
  }
  if (n > 1) ++ans;
  cout<<ans;
  return 0;
}
/**

*/


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N, X, Y; cin >> N >> X >> Y;
    vector<int> ans(N - 1);
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
                int dist = min(j - i - 1, abs(i - X) + abs(j - Y));
                ans.at(dist)++;
        }
    }
    for (int i = 0; i < N - 1; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long k, s;
cin >> k >> s;
long ans = 0;
for(long i = 0; i <= k; i++){
    for(long j = 0; j <= k; j++){
        if(s - i - j >= 0 && s - i - j <= k) ans++;
    }
}



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



Measured memory_bytes: 256
#include <bits/stdc++.h>                                
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;

ll n;
                                                                                                                    
int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);                                                                                         
	cout.tie(0);
	srand(time(0)); 
	#ifdef LOCAL
         	freopen("input.txt", "r", stdin);
        	freopen("output.txt", "w", stdout);
        #endif                              
        cin >> n;       
        cout << (n * (n - 1)) / 2;
        return 0;
}                

Measured memory_bytes: 256