akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define llu long long unsigned
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define ull unsigned long long int
#define pii pair<ll,ll>
#define vll vector<ll>
#define vp vector<pii>
#define mp make_pair
#define lb "\n"
#define ins insert
#define fon(i,n) for(int i = 0;i<n;i++)
#define foa(i,a) for(auto i = a.begin();i!=a.end();i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 100000007
#define sz size
#define len length
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
ll i,j,k,m,n,q,p;
cin>>n;
j=n/500;
j*=1000;
k=n%500;
k/=5;
k*=5;
cout<<(j+k);
return 0;
}


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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) elems.push_back(item);
      item.clear();
    }
    else item += ch;
  }
  if (!item.empty()) elems.push_back(item);
  return elems;
}

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n, m;

  while (cin >> n >> m, n + m){
    int a[n];
    long long int maxsum = 0;
    long long int ans = 0;

    rep(i, n) a[i] = in();
    rep(i, m) maxsum += a[i];
    ans = maxsum;
    reps(i, m, n) {
      ans += a[i] - a[i - m];
      maxsum = max(maxsum, ans);
    }
    print(maxsum);
  }

  return (0);
}

Measured memory_bytes: 3500
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
class Main {
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int n=scan.nextInt();
        int[] arr=new int[n+1];
        for(int i=1;i<n;i++){
            arr[scan.nextInt()]++;
        }
        StringBuilder print=new StringBuilder();
        for(int i=1;i<=n;i++){
            print.append(arr[i]+" ");
        }
        System.out.println(print);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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: 57216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

string extraction(int x) {
  string res;
  rep(i, 3) {
    res.push_back(x % 10 + '0');
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < 1000; ++i) {
    int count = 0;
    string t = extraction(i);
    rep(j, n) {
      if(count == 3) break;
      if(s[j] == t[count]) count++;
    }
    if(count == 3) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  ull n;
  cin >> n;

  vector<string> s;
  vector<ull> t;
  each(i, n) {
    string tmp1;
    ull tmp2;
    cin >> tmp1 >> tmp2;
    s.push(tmp1);
    t.push(tmp2);
  }

  string x;
  cin >> x;

  bool f = false;
  ull res = 0;
  each(i, n) {
    if (f) {
      res += t[i];
    }
    if (s[i] == x) {
      f = true;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,q;
int parent[10000];
int pare(int i){
    if(parent[i]==i){
        return i;
    }
    return parent[i]=pare(parent[i]);
    
}
void unite(int a,int b){
    a=pare(a);
    b=pare(b);
    if(pare(a)!=pare(b)){
        parent[a]=b;
    }
    pare(a);
    pare(b);
}
int main(){
    cin>>n>>q;
    for(int i=0;i<n;i++){
        parent[i]=i;
    }
    int com,x,y;
    for(int i=0;i<q;i++){
        cin>>com>>x>>y;
        if(com==0){
            unite(x,y);
        }
        else{
            if(pare(x)==pare(y)){
                cout<<1<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5+3, INF = 0x3f3f3f3f;
int dp[MX][26], tmp[26];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	memset(tmp, 0x3f, sizeof tmp);
	for(int i=2*n-1; i>=0; i--) {
		if(i < n) {
			memcpy(dp[i], tmp, sizeof tmp);
		}
		tmp[s[i%n]-'a'] = i;
	}
	for(int i=0; i<n; i++) {
		for(int j=0; j<26; j++) {
			// printf("dp[%d][%c]=%d\n", i, j+'a', dp[i][j]);
		}
	}
	int cur = tmp[t[0]-'a'];
	long long ans = 1+cur;
	if(cur == INF)
		return !(cout << -1);
	for(int i=1; i<m; i++) {
		int c = t[i]-'a';
		// printf("at i=%d, cur=%d\n", i, cur);
		if(dp[cur][c] == INF) {
			// printf("impossible at i=%d, since cur=%d, c=%d\n", i, cur, c);
			return !(cout << -1);
		}
		ans += dp[cur][c]-cur;
		cur = dp[cur][c] % n;
	}
	cout << ans;
}

Measured memory_bytes: 10704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 107
	// https://atcoder.jp/contests/abc107/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		if (n == 3 || n == 5 || n == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            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: 21204
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int sum=0;
    int cnt=0;
    for(int i=1; i<=1e7; ++i){
        sum+=i;
        cnt++;
        if(sum>=n){
            break;
        }
    }
    for(int i=1; i<=cnt; ++i){
        if(i!=sum-n){
            cout<<i<<endl;
        }
    }
}

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

const int N = 1005, P = 1e9 + 7;
int n, m;
long long K;
char map[N][N];

struct Matrix {
  int mat[2][2];
  Matrix() { memset(mat, 0, sizeof(mat)); }
  inline int *operator[](int x) { return mat[x]; }
};
inline Matrix operator*(Matrix a, Matrix b) {
  Matrix ret;
  for (int i = 0; i < 2; ++i)
    for (int k = 0; k < 2; ++k)
      for (int j = 0; j < 2; ++j)
        ret[i][j] = (ret[i][j] + 1ll * a[i][k] * b[k][j]) % P;
  return ret;
}
inline Matrix fpow(Matrix x, long long y) {
  Matrix ret; ret[0][0] = ret[1][1] = 1;
  for ( ; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
inline int fpow(int x, long long y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}

inline int calc1() {
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      cnt += (map[i][j] == '#');
  return fpow(cnt, K);
}

inline int calc2(int o1, int o2) {
  Matrix A, B;
  A[0][0] = 1;
  A[0][1] = 0;
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      cnt += (map[i][j] == '#');
  B[0][0] = cnt;
  if (o1) {
    cnt = 0;
    for (int i = 1; i < n; ++i)
      for (int j = 1; j <= m; ++j)
        cnt += ((map[i][j] == '#') && (map[i + 1][j] == '#'));
    B[1][1] = cnt;
    cnt = 0;
    for (int i = 1; i <= m; ++i)
      cnt += ((map[1][i] == '#') && (map[n][i] == '#'));
    B[0][1] = cnt;
    std::swap(B[1][1], B[0][1]);
  } else {
    cnt = 0;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j < m; ++j)
        cnt += ((map[i][j] == '#') && (map[i][j + 1] == '#'));
    B[1][1] = cnt;
    cnt = 0;
    for (int i = 1; i <= n; ++i)
      cnt += ((map[i][1] == '#') && (map[i][m] == '#'));
    B[0][1] = cnt;
    std::swap(B[1][1], B[0][1]);
  }
  A = A * fpow(B, K);
  int ret = (A[0][0] - A[0][1] + P) % P;
  ret = (ret % P + P) % P;
  return ret;
}

int main() {
  scanf("%d %d %lld", &n, &m, &K);
  for (int i = 1; i <= n; ++i)
    scanf("%s", map[i] + 1);
  if (K == 1)
    return puts("1"), 0;
  --K;
  int a = 0, b = 0;
  for (int i = 1; i <= m; ++i)
    a |= ((map[1][i] == '#') && (map[n][i] == '#'));
  for (int i = 1; i <= n; ++i)
    b |= ((map[i][1] == '#') && (map[i][m] == '#'));
  int ans = 0;
  if (a && b)
    ans = 1;
  else if (!a && !b)
    ans = calc1();
  else
    ans = calc2(a, b);
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 4612
import math
a,b,h,m = map(int,input().split())

radian_m = 6*m

radian_h = 30*h + m/2

#a**2 + b**2 - 2*a*b*cos@ = c**2

f = radian_h - radian_m
c_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(f))
c = math.sqrt(c_2)
print(c)



Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
//const int mx=1e5+7;
//int n,m;
//vector<int> a(mx),b(mx);
// vector<int> g[mx];
// int deg[mx];
//vector<int> adj[mx];
//vector<int> ans;
//---dfs--
// bool visited[mx];
// vector<ll> val(mx,0);

// void dfs(int s,int e,int c1,int c2){
// 	if(a[s]^c1!=b[s]) {ans.push_back(s), c1^=1;}
// 	for(auto u:adj[s]){
// 		if(u!=e){
// 			dfs(u,s,c2,c1);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---
const int N=203;
ll a[N],b[N],c[N];
ll dp[N][N][N];
int n,m,k;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		int n;
		cin>>n;
		vector<ll> l(n);
		for(int i=0;i<n;i++) cin>>l[i];
		ll ans=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				for(int k=j+1;k<n;k++){
					if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
						if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i]) ans++;
					}
				}
			}
		}
		cout<<ans<<"\n";
 	}
}

Measured memory_bytes: 3648
main=print.solve.map read.words=<<getLine
solve[n,m]=div m.minimum.filter(n<=)$f 1 m
f i k
  |i*i>k=[]
  |r==0=i:q:f(i+1)k
  |otherwise=f(i+1)k
  where(q,r)=k`divMod`i

Measured memory_bytes: 4960
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
 
int main(){
    string s,a="",b="";
    char c;
    int q,i;
    int t,f,flag=1;
    s.reserve(1000000);
    cin>>s>>q;
    for(i=0;i<q;i++){
        cin>>t;
        if(t==1){
            flag*=-1;
        }else{
            cin>>f>>c;
            switch(f*flag){
                case 1: 
                    a+=c;
                    break;
                case -1:
                    b+=c;
                    break;
                case 2:
                    b+=c;
                    break;
                case -2:
                    a+=c;
                    break;
            }
        }
    }
    reverse(a.begin(),a.end());
    s=a+s+b;
    if(flag<0) reverse(s.begin(),s.end());
    cout<<s;
 
    return 0;
}


Measured memory_bytes: 1248
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
    while(1){
        int num[100000] = {0};
        int sum = 0;
        int ma = -100000;
        int n,k;
        scanf("%d%d",&n,&k);
        if(n == 0 && k == 0) break;

        for(int i = 0;i < n;i++){
            scanf("%d",&num[i]);
            if(i < k) sum += num[i];
        }
        ma = max(sum,ma);
        for(int i = 0;i < n-k;i++){
            sum += num[k+i] -num[i];
            ma = max(sum,ma);
        }
        printf("%d\n",ma);
    }
    return 0;
}

Measured memory_bytes: 1424
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int a,t,top;
int A[MAX][MAX],B[MAX],C[MAX],color[MAX],S[MAX];

int next(int);
void push(int);
int pop();
void visit(int);
void dfs();


int main()
{
  int i,j,s,t,u;
  
  scanf("%d",&a);

  for(i=0;i<a;i++){
    scanf("%d %d",&t,&s);
    for(j=0;j<s;j++){
      scanf("%d",&u);
      A[t][u]=1;
    }
  }
  
  dfs();
  
  for(i=1;i<=a;i++){
    printf("%d %d %d\n",i,B[i],C[i]);
  }
  
  return 0;
}


int next(int x)
{
  int i;
  
  for(i=1;i<=a;i++){
    if(A[x][i]==1 && color[i]==WHITE){
      return i;
    }
  }
  
  return 0;
}


void push(int x)
{
  S[top++]=x;
}


int pop()
{
  return S[top--];
}


void visit(int r)
{
  int i;
  
  push(r);
  color[r]=GRAY;
  B[r]=++t;

  while(top!=0){
    int a=S[top-1],b;
    b=next(a);
    if(b!=0){
      if(color[b]==WHITE){
	push(b);
	color[b]=GRAY;
	B[b]=++t;
      }
    }
    else {
      pop();
      color[a]=BLACK;
      C[a]=++t;
    }
  }
}


void dfs()
{
  int i;
  
  for(i=1;i<=a;i++){
    if(color[i]==WHITE){
      visit(i);
    }
  }
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;




int main(){
 int n,k; cin>>n>>k;
 int x[n];
ll ans=1e14;
 REP(i,n)cin>>x[i];
 REP(i,n-k+1){
   int l=i; int r=i+k-1;
   int a=0;
   if(x[l]<0&&x[r]>0)a=min(abs(x[l]),abs(x[r]))*2+max(abs(x[l]),abs(x[r]));

   else a=max(abs(x[l]),abs(x[r]));
   if(ans>a)ans=a;
     //cout<<'('<<l<<','<<r<<')'<<a<<endl;

 }
 cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
  int n,m;
  COMinit();
  cin >> n >> m;
  auto vec = prime_factorize(m);
  ll res = 1;
  for(auto pa:vec){
    int num = pa.second;
    ll tmp = COM(num+n-1,n-1);
    res = (res*tmp)%MOD;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(5e3) + 17;

int n, m;
string s;
ll dp[MAXN][MAXN];

bool read() {
    if (!(cin >> n >> s))
        return false;

    return true;
}

void add(ll& a, ll b) {
    a += b;

    if (a >= INF)
        a -= INF;
}

ll binpow(ll a, ll n) {
    ll res = 1ll;

    for (; n > 0; n /= 2, a = a * a % INF)
        if (n & 1)
            res = res * a % INF;

    return res;
}

void solve() {
    int m = sz(s);
    dp[0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int bal = 0; bal <= i; ++bal) {
            add(dp[i + 1][max(0, bal - 1)], dp[i][bal]);
            add(dp[i + 1][bal + 1], 2ll * dp[i][bal] % INF);
        }
    }

    cout << dp[n][m] * binpow(binpow(2ll, m), INF - 2) % INF << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



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

int main(){
  string t;
  cin >> t;
  for(int i=0;i<t.size();i++){
    if(t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
}

Measured memory_bytes: 3752
n = int(input())
s = input()
d ={'R':set(), 'G':set(),'B':set()}

for i,x in enumerate(s):
    d[x].add(i+1)

ans = 1
for k in d:
    ans*=len(d[k])
    
for i in d['R']:
    for j in d['G']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['B']:ans-=1
                
for i in d['R']:
    for j in d['B']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['G']:ans-=1
                
for i in d['B']:
    for j in d['G']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['R']:ans-=1

print(ans)
    

Measured memory_bytes: 74116
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (200005)
#define INF (1LL << 60)
const int MOD = (int)1e9;
typedef pair<int,int> Pii;
typedef pair<double,double> Pdd;

 
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<int> csum(N+1,0);
    for(int i=0; i<N; i++){
        csum[i+1] = csum[i] + A[i];
    }
    //DEBUGVC(csum);

    map<int,int> mp;
    for(int i=0; i<=N; i++) mp[csum[i]]++;

    int ans=0;
    for(auto x: mp) {
        //cout << x.first <<" "<< x.second << endl;
        int n = x.second;
        if(n<=1) continue;
        ans += n*(n-1)/2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 15872
N, Q = map(int, input().split())
S = "Z" + input()
cumsum = [0] * (N + 1)
for i in range(1, N + 1):
  temp = S[i - 1] == "A" and S[i] == "C"
  cumsum[i] = cumsum[i - 1] + temp
#print(cumsum)
for _ in range(Q):
  l, r = map(int, input().split())
  temp = S[l - 1] == "A" and S[l] == "C"
  print(cumsum[r] - cumsum[l - 1] - temp)

Measured memory_bytes: 54616
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int main(){
    IOS;
    int k,n; cin>>k>>n;
    
    vi v(n);
    int mn=INT_MAX;
    for(int i=0;i<n;i++) cin>>v[i];
    int x,y;
    for(int i=0;i<n;i++){
        if(i==0){
            x=v[n-1]-v[0];
            y=k - (v[i+1]-v[i]);
            mn=min({x,y,mn});
        }
        else if(i==n-1){
            x=v[i]-v[0];
            y= k - (v[i]-v[i-1]);
            mn=min({x,y,mn});
        }
        else{
            x=k-(v[i]-v[i-1]);
            y=k-(v[i+1]-v[i]);
            mn=min({x,y,mn});
        }
        
    }
    cout<<mn;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    { 
        static void Main(string[] args)
        {
            //[summary]C - Base -2 Number
            int n = int.Parse(Console.ReadLine());

            string minus2Str = ConvertBaseNumber(n, -2);
            Console.WriteLine(minus2Str);
        }

        static string ConvertBaseNumber(int sourceNum, int n)
        {
            //[summary]10進法の数字をn進法に変換
            //変換方法については、以下リンクの最下部を参照
            //http://manabi.matiralab.com/binary/

            var mods = new List<int>();
            int num = sourceNum;

            //元の数字が"n"で割れなくなるまで繰り返し
            while (num != 0 && num != 1)
            {
                if(num <0 && num % n != 0)
                {
                    mods.Add(1);
                    num = (num - 1) / n;
                }
                else
                {
                    mods.Add(num % n);
                    num /= n;
                }                
            }

            mods.Add(num);

            //記憶した数字の順番を入れ替える
            mods.Reverse();

            //Listの値を結合
            return string.Join("", mods);
        }
    }
}

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

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

  for (int i = 0; i < N; i++) { // iのスコープはforの終わりまで
    char S;
    cin >> S;
    
    if (S == 'Y') {
      cout << "Four" << endl;
      break;
    }
    
    else if (i == N-1) {
      cout << "Three" << endl;
    }
  } 
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1;

int N;

int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  bool ok = false;
  ok |= N % 10 == 9;
  N /= 10;
  ok |= N % 10 == 9;
  puts(ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


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

  int c1=0,c2=0;
  
  cin >> n >> a >> b >> s;

  for(int i=0;i<n;i++){
    if(c1 < a + b){
      if(s[i]=='a'){
        puts("Yes");
        c1++;
      }
      if(s[i]=='b'){
        if(c2 < b){
          puts("Yes");
          c1++;
          c2++;
        }else{
          puts("No");
        }
      }
      if(s[i]=='c'){
        puts("No");
      }
    }else{
      puts("No");
    }
  }
  
  return 0;
}


Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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

  int N;
  cin>>N;

  vpi plus,zero,minus;
  string S;
  pi p;

  Rep(i,N){
  	cin >>S;
  	p=mp(0,0);
  	for(auto&& s:S){
  		if(s==')'){
  			if(p.se) p.se--;
  			else p.fi++;
  		}
  		else p.se++;
  	}
  	if(p.se>p.fi) plus.eb(p);
  	else if(p.se==p.fi) zero.eb(p);
  	else{
  		swap(p.fi,p.se);
  		minus.eb(p);
  	}
  }

  SortA(plus);
  SortD(minus);

  li c=0;

  for(auto pl: plus){
  	if(pl.fi > c){Yes(0);return 0;}
  	else c=c-pl.fi+pl.se;
  }

  for(auto z:zero){
  	if(z.fi>c) {Yes(0);return 0;}
  }

  for(auto m:minus){
  	if(m.se > c){Yes(0);return 0;}
  	else c=c-m.se+m.fi;
  }

  Yes(!c);
 }

Measured memory_bytes: 19004
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int solve( int n, int v[][3]){
	int points[n][3];
	points[0][0] = v[0][0];
	points[0][1] = v[0][1];
	points[0][2] = v[0][2];
	for(int i = 1; i < n; i++){
		points[i][0] = v[i][0] + max(points[i-1][1], points[i-1][2]);
		points[i][1] = v[i][1] + max(points[i-1][0], points[i-1][2]);
		points[i][2] = v[i][2] + max(points[i-1][0], points[i-1][1]);
	}
	return max(points[n-1][0], max(points[n-1][1], points[n-1][2]));
}

int main() {
	int n;
	cin>>n;
	int v[n][3];
	for(int i = 0; i < n; i++){
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}
	cout<<solve(n, v);
}

Measured memory_bytes: 2560
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    n, m = rli()
    la = rli()
    la.sort(reverse=True)
    s = sum(la)
    if la[m-1]*4*m < s:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


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

int main()
{
    long long int a, b ,x;
    cin >> a >> b >> x;
    long long int ans;
    if (a == 0) ans = b/x + 1;
    else ans = b/x + 1 -((a-1)/x + 1);
    cout << ans << endl;
}



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

#define endl '\n'
#define PI acos(-1.0)
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	
	ll a, b, c, k, s = 0;
	cin >> a >> b >> c >> k;
	
	s += min(a, k);
	k -= a;
	if(k <= 0) {
		cout << s  << endl;
		return 0;
	}
	
	
	k -= b;
	if(k <= 0) {
		cout << s << endl;
		return 0;
	}
	
	s -= min(c, k);
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct Edge {
  int to, id;
  Edge(int to, int id): to(to), id(id) {}
};

vector<Edge> g[55];

vector<int> es;
bool dfs(int v, int tv, int p = -1) {
  if (v == tv) return true;
  for (Edge e : g[v]) {
    if (e.to == p) continue;
    if (dfs(e.to, tv, v)) {
      es.push_back(e.id);
      return true;
    }
  }
  return false;
}

int main() {
  int N, M;
  cin >> N;
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }
  
  cin >> M;
  vector<ll> eset(M);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    es = vector<int>();
    dfs(a, b);
    for (int e : es) {
      eset[i] |= 1ll<<e;
    }
  }

  ll ans = 0;
  rep(i, 1<<M) {
    ll mask = 0;
    rep(j, M) {
      if (i>>j&1) mask |= eset[j];
    }
    int white = __builtin_popcountll(mask);
    ll now = 1ll<<(N - 1 - white);
    if(__builtin_popcountll(i) % 2 == 0) {
      ans += now;
    } else {
      ans -= now;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  int h,w;
  cin >> h >> w;
  int count = 0;
  for(int i = 1; i <= h*w; i++) {
    char c;
    cin >> c;
    if(c == '#') {
      count++;
    }
  }
  bool flag = false;
  if(count == h+w-1) {
    flag = true;
  }
  if(flag) {
    cout << "Possible" << endl;
  }else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 19.06.2020 15:01:26
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

using namespace std;

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

    int n, b, f, r, v;
    cin >> n;

    vector<vector<int> > vec(15, vector<int>(10, 0));

    REP(i, n)
    {
        cin >> b >> f >> r >> v;

        vec[b * 4 - 4 + f - 1][r - 1] += v;
    }

    REP(i, 15)
    {
        REP(j, 20)
        {
            if (i % 4 == 3)
            {
                cout << '#';
            }
            else if (j % 2 == 0)
            {
                cout << ' ';
            }
            else
            {
                cout << vec[i][j/2];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int n,a;
    cin >> n >> a;
    pr(n*n - a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,d,mx=0,c=0;
    cin>>n;

    vector<int>v;

    for(int i=0;i<n;i++)
    {
        cin>>d;
        v.push_back(d);
    }
    for(int i=0;i<n-1;i++)
    {
        if(v[i]>=v[i+1])
        {
            c++;
            if(c>mx)
            {
              mx=max(c,mx);

            }
        }
        else
        {


            c=0;
        }
    }
    cout<<mx;
}


Measured memory_bytes: 892
#include<cstdio>
#include<set>
const int mod=1000000007;
int bf(int A,int B){
	int ans=0;
	for(int S=0;S<1<<A+B;S++){
		bool fl=0;
		int rt=0;
		for(int i=0;i<A+B;i++)
			if(S>>i&1)rt++;
		if(rt!=A)continue;
		int s=0,p=A+B-1,t=0;
		while(!(S>>s&1))s++;
		while(S>>s&1)s++;
		while(S>>p&1)p--;
		while(p--)if(S>>p&1)t++;
		int r=A,b=B,i=0;
		for(;i<A+B;i++){
			if(S>>A+B-i-1&1)r--;
			else if(0>=r&&0<r+b||s>=r&&s<r+b||t>=r&&t<r+b)b--;
			else break;
		}
		if(i==A+B)fl=1;
		if(fl)ans++;
	}
	return ans;
}
int C[2010][2010],f[2010][2010];
int calc(int A,int B){
	for(int i=0;i<=A||i<=B;i++)
		for(int j=*C[i]=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	int s=0;
	for(int x=0;x<=A;x++)
		for(int y=0;x+y<=A;y++)
			f[x][y]=x&&y?(f[x-1][y]+C[y-1][x])%mod:1;
	for(int x=0;x<=A;x++){
		for(int y=0;x+y<=A;y++){
			if(x&&y)(f[x][y]+=f[x-1][y])%=mod;
			s=(s+1ll*f[x][y]*C[B-1][y])%mod; //(x,y)->(x+y,B-1)
		}
	}
	return s;
}
int main(){
	int A,B;scanf("%d%d",&A,&B);
	printf("%d\n",calc(A,B));
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  int N;
  cin >> N;
  vector<ll> B(N);
  for(int i = 0; i < N; i++) cin >> B[i];

  vector<ll> back(N);
  for(int i = 0; i < N; i++){
    back[B[i]-1]++;
  }

  vector<ll> A;
  for(int i = 0; i < N; i++){
    if(back[i] > 0){
      A.push_back(back[i]);
    }
  }

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

  int M = A.size();

  vector<ll> sumA(M+1);
  sumA[0] = 0;
  for(int i = 0; i < M; i++){
    sumA[i+1] = sumA[i] + A[i];
  }

  vector<ll> ans(N+1);
  for(int i = 0; i < N+1; i++) ans[i] = 0LL;

  for(int k = 1; k <= N; k++){

    if(k > M) continue;

    int left = 0;
    int right = k;


    while(right - left > 1){

      int l = left + (right - left) / 2;

      ll amount = sumA[M-l];
      ll cnt = amount / (k - l);

      if(A[M-l] >= cnt){ //残せる
        left = l;
      }else{
        right = l;
      }
    }

    // leftがギリギリ

    ll amount = sumA[M-left];
    ll T = M - left;
    ans[k] = amount / (k - left);

  }

  for(int k = 1; k <= N; k++){
    cout << ans[k] << endl;
  }


  return 0;
}


Measured memory_bytes: 12268
import collections
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c =  collections.Counter(prime_factorize(n))
a = c.values()
# print(a)
count =0
for i in a:
    k=1
    for j in range(n):
        if (i==1):
            count+=1
            break
        i-=k
        k +=1
        # print(i,k-1)
        count +=1
        if (i<=k-1):
            break
    
print(count)

Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    string s;
    cin>>s;
    int n = s.length();
    string rev=s;
    reverse(all(rev));
    string s1 = s.substr(0,(n-1)/2);
    string s2 = s.substr((n+3)/2-1);
    string s1r = s1;
    string s2r = s2;
    reverse(all(s1r));
    reverse(all(s2r));
    if(rev==s && s1==s1r && s2==s2r){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int a, b, sum = 0, sa = 0, i;
  cin >> a >> b;
  sa = b - a;
  for(i = 1; i <= sa; i++){
    sum += i;
  }
  sa = sum - b;
  cout << sa << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
f = []
for i in range(n):
    fi = list(map(int,input().split()))
    f.append(fi)
p = []
for i in range(n):
    t = list(map(int,input().split()))
    p.append(t)
ma = -1 * 10 ** 12
for bit in range(1024):
    count = 0
    countc = 0
    for i in range(n):
        countb = 0
        for j in range(10):
            if bit >> j & 1 and f[i][j] == 1:
                countb+=1
                countc+=1
        count+= p[i][countb]
    if countc == 0:
        continue
    ma = max(ma,count)
print(ma)

Measured memory_bytes: 3064
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct dictionary_t *dictionary_t;

#define NIL ((uint64_t)0xFFFFFFFFFFFFFFFF)

struct dictionary_t {
  uint64_t *data;
  size_t size;
};

dictionary_t dictionary_create(size_t size)
{
  dictionary_t dict = (dictionary_t)malloc(sizeof(struct dictionary_t));
  dict->data = (uint64_t *)malloc(sizeof(int64_t) * size);
  uint32_t i;
  for (i = 0; i < size; i++) {
    dict->data[i] = NIL;
  }

  dict->size = size;

  return dict;
}

void dictionary_destroy(dictionary_t dict)
{
  free(dict->data);
  free(dict);
  return;
}

static uint32_t calc_hash(uint64_t key, size_t size, uint32_t i)
{
  uint32_t h1 = key % size;
  uint32_t h2 = 1 + key % (size - 1);

  return (h1 + (i * h2)) % size;
}

bool dictionary_insert(dictionary_t dict, uint64_t data)
{
  uint32_t hash;
  uint32_t index = 0;

  do {
    hash = calc_hash(data, dict->size, index);
    index++;
  } while ((dict->data[hash] != NIL) && (index < dict->size));

  if (index < dict->size) {
    dict->data[hash] = data;
  } else {
    return false;
  }

  return true;
}

bool dictionary_search(dictionary_t dict, uint64_t data)
{
  uint32_t index = 0;

  while (index < dict->size) {
    uint32_t hash = calc_hash(data, dict->size, index);
    if (dict->data[hash] == data) {
      return true;
    } 
    if (dict->data[hash] == NIL){
      return false;
    }
    index++;
  }

  return false;
}

#if !defined(TEST)
static uint64_t calc_key(char data[])
{
  uint64_t ret = 0;

  size_t len = strlen(data);
  int32_t i = 0;
  for (i = 0; i < len; i++) {
    switch (data[i]) {
    case 'A':
      ret |= 1;
      break;
    case 'C':
      ret |= 2;
      break;
    case 'G':
      ret |= 3;
      break;
    case 'T':
      ret |= 4;
      break;
    }
    ret <<= 3;
  }

  return ret;
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  dictionary_t d = dictionary_create(1046527);

  int32_t i;
  for (i = 0; i < num; i++) {
    char command[20];
    char data[20];
    scanf("%s %s", command, data);
    if (command[0] == 'i') {
      uint64_t k = calc_key(data);
      dictionary_insert(d, k);
    } else {
      bool ret = dictionary_search(d, calc_key(data));
      if (ret) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  dictionary_destroy(d);

  return 0;
}
#endif

Measured memory_bytes: 8604
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    int cnt[n]={};
    rep(i,m){
        cin>>a[i]>>b[i];
        cnt[a[i]-1]++;
        cnt[b[i]-1]++;
    }
    rep(i,n){
        if(cnt[i]%2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1408
a,b,c,x,y=map(int,input().split())
cost=[a*x+b*y,2*max(x,y)*c]
if x>y:
  cost.append(2*y*c+(x-y)*a)
else:
  cost.append(2*x*c+(y-x)*b)
print(min(cost))

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,s[1000];

void push(int x){
  s[++top]=x;
}

int pop(){
  top--;
  return s[top+1];
}
int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
typedef long long ll;
typedef long double ld;
using namespace std;

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

  int n;
  cin >> n;
  cout << n * n * n << endl;

  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  b[0] = n - 1;
  for (int i = 1; i < n; ++i) b[i] = b[i - 1] - 2;
  for (int i = n / 2 + (n % 2); i < n; ++i) b[i] = b[i] * (-1);
  sort(a, a + n);
  sort(b, b + n);
  bool check = true;
  for (int i = 0; i < n; ++i) if (a[i] != b[i]) {
    check = false;
    break;
  }
  int ans = 1, mod = (int) 1e9 + 7;
  if (check) for (int i = 0; i < n / 2; ++i) ans = (ans * 2) % mod;
  else ans = 0;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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;
const long long INF = 1LL << 60;

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
    typedef ModInt<1000000007> mint;

mint fact(mint n){
    if(n==1) return 1;
    return n * fact(n-1);
}

int main(){
   ll n,m; cin >> n >> m;
   if(abs(n-m) > 1) cout << 0 << endl;
   else cout << fact(n) * fact(m) * (abs(n-m)==1 ? 1 : 2) << endl;
}

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

map<int,int> div(int N){
	map<int,int> ans;
	int a=2;
	while(N>=a*a){
		if(N%a==0){
			ans[a]++;
			N/=a;
		}else{
			a++;
		}
	}
	ans[N]++;
	return ans;
}

signed main(){
    int N; cin>>N;
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    map<int,int> ma=div(N);
    int ans=0;
    for(auto p: ma){
        int tmp=0;
        while((tmp*(tmp+1))/2<=p.second)tmp++;
        ans+=(tmp-1);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3600