akhauriyash/Code-Regression huggingface dataset:
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

pair<ll, ll> f(ll x, ll y)
{
    if (x == 0) return {0, 1};
    if (y == 0) return {1, 0};
    if (x < 0) x *= -1, y *= -1;
    return {x / __gcd(x, y), y / __gcd(x, y)};
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a, b;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        a.push_back(0), b.push_back(0);
        cin >> a[i] >> b[i];
        if (a[i] == 0 && b[i] == 0) ans++, n--, a.pop_back(), b.pop_back(), i--;
    }
    if (n == 0)
    {
        cout << ans;
        return 0;
    }
    ll c = 1;
    map<pair<ll, ll>, ll> mm;
    for (int i = 0; i < n; i++)
    {
        mm[f(a[i], b[i])]++;
    }
    map<pair<ll, ll>, ll> dif;
    for (auto it : mm)
    {
        pair<ll, ll> b = {it.fi.second, -it.fi.first};
        b = f(b.fi, b.se);
        if (dif[b] || dif[it.fi]) continue;
        dif[b] = 1, dif[it.fi] = 1;
        ll x = mm[it.fi];
        ll y = mm[b];
        c = c * (inq(2, x) + inq(2, y) - 1) % MOD;
    }
    cout << (ans + c + MOD - 1) % MOD;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 56224
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))


Measured memory_bytes: 26140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n){
        if(n/10==9||n%10==9) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program {
    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        int[] numbers = input
            .Select (int.Parse)
            .ToArray ();
        int N = numbers[0];
        int D = numbers[1];
        int X = 2*D+1;
        int cnt = 1;

        while(true){
            if(cnt*X / N >= 1){
                break;
            }else{
                cnt += 1;
            }
        }
        Console.WriteLine (cnt);
    }
}

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

int main() {
  int n;
  string s;
  bool flag = false;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "Y") flag = true;
  }
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}


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

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> c(n), T(n);
  for(int i=0; i<n; i++){
    cin >> c.at(i) >> T.at(i);
  }
  vector<int> filtered_c;
  for(int i=0; i<n; i++){
    if(T.at(i)<=t){
      filtered_c.push_back(c.at(i));
    }
  }
  if(filtered_c.size() == 0){
    cout << "TLE" << endl;
  }else{
    cout << *min_element(filtered_c.begin(), filtered_c.end()) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		
		
		while(true){
			 
			 int x = Integer.parseInt(s.next());
			 int y = Integer.parseInt(s.next());
			 
			 if(x==0 && y==0){
				 break;
			 }
			 if(x<y){
				 System.out.println(x+" "+y);
			 }else{
				 System.out.println(y+" "+x);
			 }	 

		}
	}

}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "AC") {
			ac++;
		} else if (s == "WA") {
			wa++;
		} else if (s == "TLE") {
			tle++;
		} else if (s == "RE") {
			re++;
		}
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 3724
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

#include <iostream>

using namespace std;

void scans(string & str) {
	char c;
	scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 * number2 / gcd(number1, number2);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	printf("%lld\n", (b - a + 1) - ((b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / lcm(c , d) - (a - 1) / lcm(c , d))));

 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;

void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}



int main(void)
{
    boost();
    ll n , w1;
    cin>>n>>w1;
    vi v(n) , w(n);
    rep(i,0,n){
        cin>>w[i];
        cin>>v[i];
    }
    ll a[n+1][w1+1];
    rep(i,0,n+1)
        a[i][0] = 0;
    rep(i,0,w1+1)
        a[0][i] = 0;
    rep(i,0,n){
        rep(j,0,w1){
            if (w[i] <= (j + 1))
                a[i+1][j+1] = max(v[i] + a[i][j+1 - w[i]] , a[i][j+1]);
            else
                a[i+1][j+1] = a[i][j+1];
        }
    }
    cout<<a[n][w1];
   
}   

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<string> v(h);
  REP (i, h) {
    cin >> v[i];
  }

  vector<int> alp(26, 0); 
  REP (i, h) {
    REP (j, w) {
      alp[v[i][j] - 'a']++;
    }
  }
  REP (i, 26) {
    if (alp[i] > 4) {
      REP (j, alp[i] / 4) alp.push_back(4);
      alp[i] %= 4;
    }
  }
  sort(alp.begin(), alp.end());

  vector<int> h_box(h / 2, 2);
  vector<int> w_box(w / 2, 2);

  if (h % 2) h_box.push_back(1);
  if (w % 2) w_box.push_back(1);

  vector<int> num_vec;
  REP (i, h_box.size()) {
    REP (j, w_box.size()) {
      num_vec.push_back(h_box[i] * w_box[j]);
    }
  }

  sort(num_vec.begin(), num_vec.end());

  int i = 0;
  int j = 0;
  bool flag = true;
  while(i < 26) {
    if (alp[i] == 0) {
      i++;
      continue;
    } else if (alp[i] < num_vec[j]) {
      flag = false;
      break;
    } else {
      alp[i] -= num_vec[j];
      j++;
    }
  }

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
l = len(s)
if l % 2:
    c = s[l//2]
    ans = l
    for i in range(1, l//2+1):
        if s[l//2 - i] != c or s[l//2 + i] != c:
            ans = i + l//2
            break
else:
    if s[l//2-1] != s[l//2]:
        ans = l//2
    else:
        ans = l
        c = s[l//2]
        for i in range(1, l//2):
            if s[l//2 - i - 1] != c or s[l//2 + i] != c:
                ans = l//2 + i
                break
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string s;
int k;
ll dp[110][2][5];

int main() {
    cin >> s >> k;
    int slen = s.length();

    dp[0][0][0] = 1;
    for(int i = 0; i < slen; ++i) {
        for(int j = 0; j <= k; ++j) {
            // i桁目まででsより小さいならi+1桁目は全部
            dp[i+1][1][j+1] += dp[i][1][j] * 9;
            // 追加しなかったとき
            dp[i+1][1][j] += dp[i][1][j];

            int check = s.at(i) - '0';
            // i桁目までは一緒だったが、i+1桁目を入れたら小さくなった
            if(check > 0) {
                dp[i+1][1][j+1] += dp[i][0][j] * (check-1);
                dp[i+1][1][j] += dp[i][0][j];
            }

            // i+1桁目もピンチケ
            if(check > 0) {
                dp[i+1][0][j+1] += dp[i][0][j];
            }else {
                dp[i+1][0][j] += dp[i][0][j];
            }
        }
    }

    cout << dp[slen][0][k] + dp[slen][1][k] << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC127C
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();
            int N = int.Parse(line[0]);
            int M = int.Parse(line[1]);

            int[] L = new int[M];
            int[] R = new int[M];

            for(var i = 0; i < M; i++)
            {
                var line1 = Console.ReadLine().Split(' ').ToArray();
                L[i] = int.Parse(line1[0]);
                R[i] = int.Parse(line1[1]);
            }

            int lmax = 0;
            int rmin = 100000;
            
            for(var i = 0; i < M; i++)
            {
                if(lmax < L[i])
                {
                    lmax = L[i];
                }

                if(rmin > R[i])
                {
                    rmin = R[i];
                }
            }

            int aida = rmin - lmax;
            if(aida < 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(aida+1);
            }
        }
    }
}


Measured memory_bytes: 17376
import java.util.Scanner;

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

		int diffHeightA = sc.nextInt();
		int diffHeightB = sc.nextInt();

		int diffHeight = diffHeightB - diffHeightA;
		int count = diffHeight - 1;
		int heightA = 0;

		for(int i = 1; i <= count; i++) {
			heightA += i;
		}

		int Ans = heightA - diffHeightA;
		System.out.println(Ans);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 500 + 50;
int x[MAXN];
int a[MAXN * MAXN];
int lst[MAXN * MAXN];
bool fine[MAXN];

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%d", &x[i]);
	for(int i = 1; i <= N * N; i++)
		lst[i] = i - 1;
	for(int p = 1; p <= N; p++) {
		a[x[p]] = p;
	}
	bool bad = false;
	queue<int> q1, q2;
	for(int i = 1; i <= N * N; i++)
		if(a[i] > 0)
			for(int j = 1; j < a[i]; j++)
				q1.push(a[i]);
	fine[1] = true;
	for(int i = 1; i <= N * N; i++) {
		if(a[i] > 0) {
			if(!fine[a[i]]) {
				bad = true;
				goto out;
			}
			for(int j = a[i] + 1; j <= N; j++)
				q2.push(a[i]);
		}
		else {
			if(q1.empty()) {
				if(q2.empty()) {
					bad = true;
					goto out;
				}
				int t = q2.front(); q2.pop();
				a[i] = t;
			}
			else {
				int t = q1.front(); q1.pop();
				a[i] = t;
				if(q1.empty() || q1.front() != t)
					fine[t] = true;
			}
		}
	}
	out:
	if(bad) puts("No");
	else {
		puts("Yes");
		for(int i = 1; i <= N * N; i++)
			printf("%d%c", a[i], " \n"[i == N * N]);
	}
	return 0;
}


Measured memory_bytes: 3968
// OURL: https://atcoder.jp/contests/abc165/tasks/abc165_e
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

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

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  int n,m;
  cin >>n >> m;
  int t = n/2;
  int tt = 0;
  auto vs = make_v<int>(n+1);

  for (int i = 0; i < m; ++i) {
    int h = 0;
    while (true) {
      if (vs[i*2+1+h]==0 && (n-(i*2+1+h)) != (i*2+1+h)) {
      // if (vs[i*2+1+h]==0) {
        cout << t - i << " " << t+i+1+h<< endl;
        vs[i*2+1+h] = vs[n-(i*2+1+h)] = 1;
        break;
      }
      h++;
    }
  }
  debug(vs);

  return 0;
}


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

bool syori() {
    int n;
    scanf("%d", &n);
    if(n==0) return true;

    std::vector<int> data;
    for(int i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        data.push_back(tmp);
    }

    std::sort(data.begin(), data.end());

    int pre = -1;
    int ret = INT_MAX;
    for(int i: data) {
        if(pre != -1) {
            ret = std::min(i-pre,  ret);
        }
        pre = i;
    }
    printf("%d\n", ret);
    return false;
}

int main() {
    bool flag = false;
    while(!flag) {
        flag = syori();
    }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;
    if(s.at(1)=='A'&&s.at(2)=='A'&&s.at(0)=='A') {
        cout << "No" << endl;
        return 0;
    }
    if(s.at(1)=='B'&&s.at(2)=='B'&&s.at(0)=='B') {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long
signed main(){
    boost;
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
   cin>>arr[i];
    int ans=0;
   sort(arr,arr+n);
   for(int i=0;i<k;i++)
   ans+=arr[i];

   cout<<ans;
}


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

int main(){
  int N,P;
  cin >> N >> P;
  int x=0;
  int y=0;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    if(A%2==0){
      x++;
    }else{
      y++;
    }
  }
  vector<int64_t> comb(y+1);
  comb.at(0)=1;
  for(int i=1;i<=y;i++){
    comb.at(i)=comb.at(i-1)*(y-i+1)/i;
  }
  if(P==0){
    int64_t a=0;
    int64_t b=0;
    a=pow(2,x);
    for(int i=0;i<=y;i+=2){
      b+=comb.at(i);
    }
    cout << a*b << endl;
  }else{
    int64_t a=0;
    int64_t b=0;
    a=pow(2,x);
    for(int i=1;i<=y;i+=2){
      b+=comb.at(i);
    }
    cout << a*b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  // 最大数
  int m = (n - 1) * (n - 2) / 2;
  if (k > m)
  {
    cout << -1 << endl;
    return 0;
  }

  cout << n - 1 + m - k << endl;
  FOR(i, 2, n + 1)
  {
    cout << 1 << " " << i << endl;
  }
  int c = 0;
  int u = 2;
  int v = 3;
  while (c < m - k)
  {
    if (v > n)
    {
      u++;
      v = u + 1;
    }
    cout << u << " " << v << endl;
    v++;
    c++;
  }
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

ll add(ll a, ll b) {
    return ((a + b) % MOD + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return ((a * b) % MOD + MOD) % MOD;
}

ll binpow(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    long long sm = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int v; cin >> v;
        sm = add(sm, binpow(v, MOD - 2));
        for (int mul = 2; mul * mul <= v; mul++) {
            if (v % mul == 0) {
                int deg = 0;
                while (v % mul == 0) {
                    v /= mul; deg++;
                }
                mp[mul] = max(mp[mul], deg);
            }
        }
        if (v != 1) mp[v] = max(mp[v], 1);
    }
    ll res = 1;
    for (auto x : mp) {
        res = mul(res, binpow(x.first, x.second));
    }
    res = mul(res, sm);
    cout << res;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 768
n,k=map(int,input().split())

bin=list(str(format(n,'b')))

mod=10**9+7
list=[0]*(k+1)
ans=0

for i in reversed(range(1,k+1)):
  p=k//i
  pn=[p]
  for x in range(len(bin)-1):
    y=pn[x]**2%mod
    pn.append(y)
  num=1
  for l in range(len(bin)):
    if bin[l]=='1':
      num=num*pn[-1-l]%mod
  j=2
  while i*j<=k:
    num=(num-list[i*j])%mod
    j=j+1
  list[i]=num
  ans=(ans+num*i)%mod
print(ans)

Measured memory_bytes: 11260
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c =sc.nextInt();
        //System.out.println(max);
        if(c-(a-b)<0){
            System.out.println("0");
        }else{
        System.out.println(c-(a-b));
        }

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main()
{int N; cin >> N;
      if( N >= 195){cout << 5;}
 else if( N >= 189){cout << 4;}
 else if( N >= 165){cout << 3;}
 else if( N >= 135){cout << 2;}
 else if( N >= 105){cout << 1;}
               else{cout << 0;}
 return 0;}
                    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair <int,string> P;
#define num first
#define col second
int  c[3][10];
P card[9];

bool check2(vector <P> N) {
  int cnt[3][10] = {};
  for(int i=0;i<N.size();i++) 
    if(N[i].col == "R") cnt[0][N[i].num]++;
    else if(N[i].col == "G") cnt[1][N[i].num]++;
    else cnt[2][N[i].num]++;

  for(int i=0;i<3;i++)
    for(int j=1;j<=9;j++)
      if(cnt[i][j] < 0) return false; 
      else if(cnt[i][j] > 0) {
	if(j >= 8) return false;
	cnt[i][j+1] -= cnt[i][j];
	cnt[i][j+2] -= cnt[i][j];
	cnt[i][j] = 0;
      }
  return true;
}

bool check(){
  vector <P> flg;
  for(int i=0;i<3;i++)
    for(int j=0;j<=9;j++) 
      if(c[i][j] >=3){
	if(i == 0)flg.push_back(P(j,"R"));
	else if(i == 1) flg.push_back(P(j,"G"));
	else flg.push_back(P(j,"B"));
      }

  for(int i=0;i<(1<<flg.size());i++) {
    vector <P> t;
    int cnt[3] = {};
    for(int j=0;j<9;j++) {
      if((i&1) != 0 &&cnt[0]<3 && card[j].num == flg[0].num && card[j].col == flg[0].col)cnt[0]++;
      else if((i&2) != 0 && cnt[1]<3 && card[j].num == flg[1].num && card[j].col == flg[1].col)cnt[1]++;
      else if((i&4) != 0 && cnt[2]<3 &&card[j].num == flg[2].num && card[j].col == flg[2].col)cnt[2]++;
      else t.push_back(card[j]);
    }
    if(check2(t) == true) return true;
  } 
  return false;
}


int main() {
  int n;
  cin >> n;
  for(int q=0;q<n;q++) {
    for(int i=0;i<9;i++) cin >> card[i].num;
    for(int i=0;i<9;i++) cin >> card[i].col;
    for(int i=0;i<3;i++)
      for(int j=0;j<=9;j++) c[i][j] = 0;

    for(int i=0;i<9;i++) 
      if(card[i].col == "R") c[0][card[i].num]++;
      else if(card[i].col == "G") c[1][card[i].num]++;
      else c[2][card[i].num]++;
    cout << check()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import java.io.*;
import java.util.*;
/**
 * Main
 */
public class Main {
        static Stack<Integer> subset = new Stack<>();
        static String input = "";
        static int stop = 0;
        static int mod  = 1000000007;
        static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        static HashMap<Integer,Integer> map = new HashMap<>();
        static ArrayList<String> list = new ArrayList<>();
    public static void main(String[] args) {
       MyScanner ms  = new MyScanner();
        int N = ms.nextInt();
       HashMap<String,Integer> map = new HashMap<>();
       int max =0;
       for(int i=0;i<N;i++){
           String line = ms.nextLine();
            if(map.containsKey(line)){
                map.replace(line, map.get(line)+1);
                max = Math.max(map.get(line),max);
            }else{
                map.put(line, 1);
                max = Math.max(map.get(line),max);
            }
       }
        ArrayList<String> list = new ArrayList<>();
        for (Map.Entry<String,Integer> entry : map.entrySet()) {
                if(entry.getValue()==max){
                    list.add(entry.getKey());
                }
        }
        Collections.sort(list);
        for(int i=0;i<list.size();i++){
            pw.println(list.get(i));
        }
        pw.flush();
        

    }


       /**
1.What is the unknown: the maxium number of nodes he can buy
2.What are the data: the size of the array and  element int he array
3.What is the condition: the longest increasing usbsequece
4.What is the restriction: the 100,000 *100 = 100,000,000 = thus made N^2 for 3 second
*/

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
    
}

Measured memory_bytes: 69932
q = int(input())
A = []

for i in range(q):
    Q, *x = (int(x) for x in input().split())
    x = x[0] if x else None
    if Q == 0:
        A.append(x)
    elif Q == 1:
        print(A[x])
    else:
        del A[-1]



Measured memory_bytes: 13372
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG


int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG
    
    int a;
    scanf("%d", &a);
    int sec, minu, hour;
    sec = a % 60;
    a = a / 60;
    minu = a % 60;
    hour = a / 60;
    printf("%d:%d:%d\n", hour, minu, sec);

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2120
def check(x,d):
    s=str(x)
    flag=True 
    for i in range(len(s)):
        if int(s[i]) not in d:
            flag=False 
    return flag
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
d=[]
for i in range(10):
    if i not in a:
        d.append(i)
l=len(str(n))
final=10**l 
flag=False
#print(d)
for i in range(n,final):
    #print("HI")
    if check(i,d):
        flag=True
        print(i)
        break 
if not flag:
    if d[0]==0:
        print(str(d[1])+"0"*(l))
    else:
        print(str(d[0])*(l+1))
    
    
    

    
    
    
    
    

Measured memory_bytes: 41324
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    string s,t;
    cin >> s >> t;
    string res = "";
    REP(i,max(s.size(),t.size())){
        res.push_back(s[i]);
        if(t.size()>i){
            res.push_back(t[i]);
        }
        
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int cur = k, ans;
	for(int i = 100; cur > 0; --i){
		if(!(a % i) && !(b % i)){
			--cur;
			ans = i;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

class union_find {
public:
	int par[200005], Rank[200005];
	union_find(int n) {
		rep(i, n) {
			par[i] = i;
			Rank[i] = 1;
		}
	}

	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}

	void unit(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y]) {
			par[x] = y;
			Rank[y] += Rank[x];
		}
		else {
			par[y] = x;
			Rank[x] += Rank[y];
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
int a[100005], b[100005];
int ans[100005];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m)cin >> a[i] >> b[i];
	static union_find uf(n);
	stack<int>ans;
	int memo = n * (n - 1) / 2;
	for (int i = m - 1; i >= 0; i--) {
		ans.push(memo);
		if (uf.same(a[i] - 1, b[i] - 1))continue;
		memo -= uf.Rank[uf.find(a[i] - 1)] * uf.Rank[uf.find(b[i] - 1)];
		uf.unit(a[i] - 1, b[i] - 1);
	}
	while (ans.size()) {
		cout << ans.top() << endl;
		ans.pop();
	}
	endre;
}


Measured memory_bytes: 5788
N, M = map(int, input().split())
ad_list = {}
for i in range(M):
  a, b = map(int, input().split())
  if a in ad_list:
    ad_list[a].add(b)
  else:
    ad_list[a] = {b}
  if b in ad_list:
    ad_list[b].add(a)
  else:
    ad_list[b] = {a}

#BFS
ans = 0
done = [True for i in range(N+1)]

import queue
q = queue.Queue()

for i in range(1, N+1):
  if done[i]:
    done[i] = False
    tmp = 1
    if i in ad_list:
      q.put(i)
      while not q.empty():
        x = q.get()
        for y in ad_list[x]:
          if done[y]:
            tmp += 1
            done[y] = False
            q.put(y)
    ans = max(ans, tmp)

print(ans)

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


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#define maxn 100010
using namespace std;

int n, u, v, c, q, k, xi, yi;
long long dis[maxn];
bool vis[maxn];
struct Edge {
	int u, v, c;
	Edge(int u, int v, int c): u(u), v(v), c(c) {}
};
vector<Edge> V[maxn];
void dfs(int x, long long d) {
	vis[x] = true;
	dis[x] = d;
	for (int i = 0; i < V[x].size(); i++) {
		int v = V[x][i].v, c = V[x][i].c;
		if (!vis[v])
			dfs(v, d + c);
	}
}
int main(void) {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d%d", &u, &v, &c);
		V[u].push_back(Edge(u, v, c));
		V[v].push_back(Edge(v, u, c));
	}
	scanf("%d%d", &q, &k);
	dfs(k, 0);
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &xi, &yi);
		printf("%lld\n", dis[xi] + dis[yi]);
	}
}

Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	a, b, k := nextInt(sc), nextInt(sc), nextInt(sc)

	for i := a; i <= b; i++ {
		if i < a+k || i > b-k {
			fmt.Fprintln(out, i)
		}
	}

	return nil
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define pai 3.14159265358979323846

int main(void) {
  int scan; // scanf result
  long double answer; // to output 
  long double a; // to input 
  long double b; // to input 
  long double h; // to input 
  long double m; // to input 

  scan = scanf("%Lf", &a);
  scan = scanf("%Lf", &b);
  scan = scanf("%Lf", &h);
  scan = scanf("%Lf", &m);

  long double k;
  long double diff;
  diff = (h + m / 60) * 30 - m * 6;
  if (diff < 0) {
    diff = (-1) * diff;
  }

  if (diff > 180) {
    k = 360 - diff;
  } else {
    k = diff;
  } 

  long double rad;
  rad = k * (pai / 180);

  answer = a * a + b * b - 2 * a * b * cos(rad);
  answer = sqrt(answer);

  printf("%.16Lf", answer);
  return (0);
}


Measured memory_bytes: 2608
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
#define MXN 3002
int dp[MXN][MXN];
char s[MXN], t[MXN];
pair<int, int> trace[MXN][MXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>s;
	cin>>t;
	int lens = strlen(s), lent = strlen(t);

	for(int i=0; i<lens; i++)
		for(int j=0; j<lent; j++)
		{
			if(s[i]==t[j])
			{
				if(!i or !j) dp[i][j] = 1, trace[i][j] = make_pair(-1, -1);
				else dp[i][j] = dp[i-1][j-1]+1, trace[i][j] = make_pair(i-1, j-1);
			}
			else if(!i and !j) dp[i][j] = 0, trace[i][j] = make_pair(-1, -1);
			else if(!i) dp[i][j] = dp[i][j-1], trace[i][j] = make_pair(i, j-1);
			else if(!j) dp[i][j] = dp[i-1][j], trace[i][j] = make_pair(i-1, j);
			else dp[i][j] = dp[i-1][j]>dp[i][j-1]? dp[i-1][j]:dp[i][j-1], trace[i][j] = dp[i-1][j]>dp[i][j-1]? make_pair(i-1, j):make_pair(i, j-1); 
		}

	int pos =  dp[lens-1][lent-1];
	char ret[MXN];
	ret[pos--] = '\0';
	int x = lens-1, y = lent-1;
	while(pos>=0 and x!=-1 and y!=-1)
	{
		if(x!=-1 and y!=-1 and s[x]==t[y]) ret[pos--] = s[x];
		pair<int, int> tmp = trace[x][y];
		x = tmp.first, y = tmp.second;
	}
	cout << ret << '\n';


	return 0;
}

Measured memory_bytes: 105856
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001];
int main() {
	int h, n;
	cin >> h >> n;
	for (int i = 0;i < n;i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int i = 0;
	while (1) {
		if (h <= 0) {
			cout << "Yes" << endl;
			break;
		}
		if (i == n ) {
			cout << "No" << endl;
			break;
		}
		h -= a[i];
		i++;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n;
int F[N];
vector<int> G[N];
bool cmp(int a,int b) {
  return F[a]>F[b];
}
void Solve(int u) {
  for(auto v: G[u]) Solve(v);
  sort(G[u].begin(),G[u].end(),cmp);
  for(int i=0;i<(int)G[u].size();++i) F[u]=max(F[u],F[G[u][i]]+i+1);
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n);
  for(int i=2;i<=n;++i) {
    int u; read(u);
    G[u].push_back(i);
  }
  Solve(1);
  printf("%d\n",F[1]);
  return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define forn(i,a,b) for (ll i =a; i <=b; ++i)
void debug()
{
    cerr << "\n";
}
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cerr << H << " ";
    debug(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] : ";debug(__VA_ARGS__);
const ll maxn = 1e6 + 1;
bool dp[maxn],dp2[maxn];
void solve()
{
    ll n;
    cin >> n;
    map<ll, bool>mp;
    if(n == 1)
    {
        cout << "0\n";
        return;
    }
    ll ans{};
    forn(i, 2, maxn - 1)
    {
        if(n % i == 0 && dp[i] == 1)
        {
            n /= i;
            ans++;
            mp[i] = 1;
        }
    }
    if(n > (ll)1e6)
        ans++;
    else if(n != 1 && mp[n] == 0 && dp[n] == 1)
        ans++;
    cout << ans;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t;
    // cin >> t;
    t = 1;
    forn(i, 2, maxn - 1)
    {
        if(dp2[i] == 0)
        {
            for(ll j=i*i;j<maxn;j+=i)
                dp2[j]=1;
        }
    }
    forn(i, 2, maxn - 1)
    {
        if(dp2[i] == 0)
        {
            for(ll j = i; j < maxn; j *= i)
            {
                dp[j] = 1;
            }
        }
    }
    rep(i, t)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5612
#include<stdio.h>

main(){

  int a=0;

  int W,H,x,y,r=0;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(x-r>=0&&x+r<=W){

    if(y-r>=0&&y+r<=H){

      a=1;

    }

  }

  else{

    a=0;

  }

  if(a==1){

    printf("Yes\n");

  }

  else if(a==0){

    printf("No\n");

  }

  return 0;

}

Measured memory_bytes: 584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

ll N,A[100000];

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

ll l[100000],r[100000];
int main(void) {
  cin >> N;
  rep (i,N) cin >> A[i];

  l[0] = A[0];
  rep (i,N-1)l[i + 1] = gcd(l[i], A[i + 1]);
  r[N-1] = A[N-1];
  rrep (i,N-1)r[i] = gcd(r[i+1], A[i]);

  ll ans = 1;

  rep (i,N) {
    ll l2 = (i > 0 ? l[i - 1] : 0);
    ll r2 = (i < N - 1 ? r[i + 1] : 0);
    ans = max(ans, gcd(l2, r2));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  int n; cin >> n;
  const ll MOD = 1'000'000'007;
  vector<ll>A(n);
  ll sum = 0;
  rep(i,n){
    cin >> A[i];
    sum += A[i];
  }
  ll ans = 0;
  rep(i,n){
    sum -= A[i];
    ll tmp = sum%MOD;
    tmp = (tmp*A[i])%MOD;
    ans = (ans+tmp)%MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 4820
def main():
    n = int(input())
    rw = input()
    r_num = 0
    for i in rw:
        if i == 'R':
            r_num += 1
    w_num = n - r_num
    ans = 0
    for i in range(r_num):
        if rw[i] == 'W':
            ans += 1
    print(ans)
    return
if __name__ == '__main__':
    main()

Measured memory_bytes: 9456
n = int(input())
a = list(map(int, input().split()))
flag = True
c = 0
j = 0
while flag:
    flag = False
    for i in range(n - 1, j, -1):
        if a[i] < a[i - 1]:
            a[i], a[i - 1] = a[i - 1], a[i]
            c += 1
            flag = True
    j += 1
print(" ".join(map(str, a)))
print(c)
    


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

int main()
{
    int n,harr[100010];
    int i,j,max=0;
    int flag=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",harr+i);
        if(max<harr[i])max=harr[i];
        if(max-1>harr[i])flag=0;
    }

    if(flag)printf("Yes");
    else printf("No");
}



Measured memory_bytes: 512
package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"sort"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	// get stg input
	s := nextLine()
	tasksInput := strings.Split(s, " ")

	// []string -> []int
	tasks := make([]int, len(tasksInput))
	for i, s := range tasksInput {
		v, err := strconv.Atoi(s)
		if err != nil {
			return
		}
		tasks[i] = v
	}

	// asc sort
	sort.Sort(sort.IntSlice(tasks))

	// calc result
	result := 0
	for i, s := range tasks {
		if i != 0 {
			result += s - tasks[i-1]
		}
	}

	// output
	fmt.Println(result)
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    n -= a;
    n %= b;
    cout << n << '\n';
}


Measured memory_bytes: 256
/* while(!cin.eof()) */

#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e18+100)
#define N 1000200 

int fre[N];

// Driver code to test above functions
int32_t main()
{
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    vector<pair<int, int>> xy(n);
    for(int i = 0; i < n; i++)
        cin >> xy[i].first >> xy[i].second;
 
    sort(xy.begin(), xy.end(), [](const pair<int, int>& l, const pair<int, int>& r) {
        return atan2l(l.second, l.first) < atan2l(r.second, r.first);
    });
    for(int i = 0; i < n; i++)
        xy.push_back(xy[i]);
 
 
    int res = 0;
    for(int i = 0; i < n; i++)
    {
        int x = 0, y = 0;
        for(int j = i; j < i + n; j++) {
            x += xy[j].first;
            y += xy[j].second;
            res = max(res, x*x + y * y);
        }
    }
 
 
    cout << fixed << setprecision(15) << sqrtl(res) << endl;


    return 0;  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll int64_t
#define inf LLONG_MAX

void solve()
{
    ll n,i;
    cin>>n;

    ll arr[100005];
    memset(arr,0,sizeof(arr));

    for(i=1;i<105;i++)    
    {
        for(ll j=1;j<105;j++)    
        {
            for(ll k=1;k<105;k++)    
            {
                ll val = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k);
                arr[val]++;
            }
            
        }
        
    }

    for(i=1;i<=n;i++)    {cout<<arr[i]<<endl;}
    
    

}


signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //ll tt;    cin>>tt;    while(tt--)
    {
        solve();
     }
    cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
        
        
return 0;
}

Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,a,b,n,c,y,d,m,prev,sum,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>a>>b>>c>>d;
      cout<<max(min(b,d)-max(a,c),0);
    }
}

Measured memory_bytes: 256
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>

using namespace std;


int main(){

    string s;
    cin>>s;

    int count1=1;
    int count2=1;
    int count3=1;
    int i,j,k;
    for(i=1;i<4;i++){
        if(s[0]==s[i]){
            count1++;
        }

    }
    for(j=0;j<4;j++){
        if(j==1){
            continue;
        }
        if(s[1]==s[j]){
            count2++;
        }
    }
    for(k=0;k<4;k++){
        if(k==2){
            continue;
        }
        if(s[2]==s[k]){
            count3++;
        }
    }
    if(count1==2&&count2==2&&count3==2){
        std::cout<<"Yes"<<endl;
    }else{
        std::cout<<"No"<<endl;
    }
        return 0;
}

Measured memory_bytes: 256